summaryrefslogtreecommitdiffstats
path: root/src/ui/systeminfostorageui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/systeminfostorageui.cpp')
-rw-r--r--src/ui/systeminfostorageui.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/ui/systeminfostorageui.cpp b/src/ui/systeminfostorageui.cpp
index d896930..e0f7961 100644
--- a/src/ui/systeminfostorageui.cpp
+++ b/src/ui/systeminfostorageui.cpp
@@ -48,8 +48,8 @@ void StorageSystemInfoUi::initializeStorage()
tags << tr("drives") << tr("memory") << tr("storage");
systemInfoDrives = new QComboBox();
- QPushButton *systemInfoChangeDriveName = new QPushButton(tr("Change Name"));
- QPushButton *systemInfoRemoveDrive = new QPushButton(tr("Remove"));
+ systemInfoChangeDriveName = new QPushButton(tr("Change Name"));
+ systemInfoRemoveDrive = new QPushButton(tr("Remove"));
QPushButton *systemInfoAddDrive = new QPushButton(tr("Add"));
QHBoxLayout *hLayout = new QHBoxLayout();
hLayout->addWidget(systemInfoChangeDriveName);
@@ -149,9 +149,12 @@ void StorageSystemInfoUi::emitStorageDataChange()
void StorageSystemInfoUi::showDriveInfo()
{
bool editingEnabled = systemInfoDrives->count() != 0;
- systemInfoDriveType->setEnabled(editingEnabled);
- systemInfoDriveAvailableSpace->setEnabled(editingEnabled);
- systemInfoDriveTotalSpace->setEnabled(editingEnabled);
+
+ // workaround for calling this from another thread (scripts):
+ // always perform the setEnabled calls in the gui thread -
+ // setEnabled calls sendEvent!
+ QMetaObject::invokeMethod(this, "enableDriveControls", Qt::QueuedConnection,
+ Q_ARG(bool, editingEnabled));
if (!editingEnabled)
return;
@@ -389,3 +392,12 @@ bool StorageSystemInfoScriptInterface::setAvailableSpace(const QString &name, qi
}
return true;
}
+
+void StorageSystemInfoUi::enableDriveControls(bool enabled)
+{
+ systemInfoDriveType->setEnabled(enabled);
+ systemInfoDriveAvailableSpace->setEnabled(enabled);
+ systemInfoDriveTotalSpace->setEnabled(enabled);
+ systemInfoRemoveDrive->setEnabled(enabled);
+ systemInfoChangeDriveName->setEnabled(enabled);
+}