summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-02-24 14:18:40 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2011-02-24 14:18:40 +0100
commit4220464fd54beb0fd101bdf8e48d5ea9840035b6 (patch)
tree7b523fe8b89ade50cfbedb968cdfbbc71302cbd4
parentacd7b7bff1753fc22d72a2148149057d11a344e0 (diff)
Workaround for setEnabled calls from scripts.1.1beta
Reviewed-by: owolff
-rw-r--r--src/ui/cameraui.cpp6
-rw-r--r--src/ui/cameraui.h2
-rw-r--r--src/ui/configurationwidget.cpp31
-rw-r--r--src/ui/configurationwidget.h1
-rw-r--r--src/ui/systeminfostorageui.cpp22
-rw-r--r--src/ui/systeminfostorageui.h5
6 files changed, 48 insertions, 19 deletions
diff --git a/src/ui/cameraui.cpp b/src/ui/cameraui.cpp
index 82059bb..fe65ee5 100644
--- a/src/ui/cameraui.cpp
+++ b/src/ui/cameraui.cpp
@@ -146,7 +146,11 @@ void CameraUi::emitCameraDataChange() const
void CameraUi::showCameraInfo()
{
bool editingEnabled = mCameras->count() != 0;
- enableCameraControls(editingEnabled);
+ // workaround for calling this from another thread (scripts):
+ // always perform the setEnabled calls in the gui thread -
+ // setEnabled calls sendEvent!
+ QMetaObject::invokeMethod(this, "enableCameraControls", Qt::QueuedConnection,
+ Q_ARG(bool, editingEnabled));
if (!editingEnabled)
return;
diff --git a/src/ui/cameraui.h b/src/ui/cameraui.h
index 385b54e..d2f64bf 100644
--- a/src/ui/cameraui.h
+++ b/src/ui/cameraui.h
@@ -112,7 +112,7 @@ private slots:
void removeCameraClicked();
private:
- void enableCameraControls(bool enabled);
+ Q_INVOKABLE void enableCameraControls(bool enabled);
friend class CameraScriptInterface;
CameraScriptInterface *mScriptInterface;
diff --git a/src/ui/configurationwidget.cpp b/src/ui/configurationwidget.cpp
index ea16db2..15de9f6 100644
--- a/src/ui/configurationwidget.cpp
+++ b/src/ui/configurationwidget.cpp
@@ -194,17 +194,11 @@ void ConfigurationWidget::updateOrientationButtons(const DeviceData &data)
{
const bool rotateScreen = ui_inspector->rotateScreen->isChecked();
- if (!rotateScreen) {
- ui_inspector->topUp->setEnabled(true);
- ui_inspector->leftUp->setEnabled(true);
- ui_inspector->rightUp->setEnabled(true);
- ui_inspector->topDown->setEnabled(true);
- } else {
- ui_inspector->topUp->setEnabled(data.supportedOrientations & topUp);
- ui_inspector->leftUp->setEnabled(data.supportedOrientations & leftUp);
- ui_inspector->rightUp->setEnabled(data.supportedOrientations & rightUp);
- ui_inspector->topDown->setEnabled(data.supportedOrientations & topDown);
- }
+ // workaround for calling this from another thread (scripts):
+ // always perform the setEnabled calls in the gui thread -
+ // setEnabled calls sendEvent!
+ QMetaObject::invokeMethod(this, "enableRotationButtons", Qt::QueuedConnection,
+ Q_ARG(bool, rotateScreen), Q_ARG(int, data.supportedOrientations));
if (!mOrientationButtons->checkedButton()->isEnabled() && !data.menus.isEmpty()) {
Orientation fallback = data.menus.begin().key();
@@ -540,3 +534,18 @@ QStringList SimulatorScriptInterface::supportedScreenOrientations() const
return ret;
}
+
+void ConfigurationWidget::enableRotationButtons(bool rotateScreen, int supportedOrientations)
+{
+ if (!rotateScreen) {
+ ui_inspector->topUp->setEnabled(true);
+ ui_inspector->leftUp->setEnabled(true);
+ ui_inspector->rightUp->setEnabled(true);
+ ui_inspector->topDown->setEnabled(true);
+ } else {
+ ui_inspector->topUp->setEnabled(supportedOrientations & topUp);
+ ui_inspector->leftUp->setEnabled(supportedOrientations & leftUp);
+ ui_inspector->rightUp->setEnabled(supportedOrientations & rightUp);
+ ui_inspector->topDown->setEnabled(supportedOrientations & topDown);
+ }
+}
diff --git a/src/ui/configurationwidget.h b/src/ui/configurationwidget.h
index b528c30..5eadc88 100644
--- a/src/ui/configurationwidget.h
+++ b/src/ui/configurationwidget.h
@@ -101,6 +101,7 @@ private slots:
private:
void initializeViewArea();
void initializeApplicationArea();
+ Q_INVOKABLE void enableRotationButtons(bool rotateScreen, int supportedOrientations);
QList<DeviceData> deviceList;
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);
+}
diff --git a/src/ui/systeminfostorageui.h b/src/ui/systeminfostorageui.h
index aab3741..734a890 100644
--- a/src/ui/systeminfostorageui.h
+++ b/src/ui/systeminfostorageui.h
@@ -37,6 +37,7 @@
class QLineEdit;
class QComboBox;
+class QPushButton;
class StorageSystemInfoUi;
@@ -123,13 +124,15 @@ private slots:
private:
void initializeStorage();
void initializeStorageOptions();
-
+ Q_INVOKABLE void enableDriveControls(bool enabled);
private:
QComboBox *systemInfoDrives;
QComboBox *systemInfoDriveType;
QLineEdit *systemInfoDriveTotalSpace;
QLineEdit *systemInfoDriveAvailableSpace;
+ QPushButton *systemInfoRemoveDrive;
+ QPushButton *systemInfoChangeDriveName;
StorageData mData;