summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlli Werwolff <qt-info@nokia.com>2011-03-08 11:39:21 +0100
committerOlli Werwolff <qt-info@nokia.com>2011-03-10 13:46:58 +0100
commit72585e354e8b74226a3b8f27747f431d5d982892 (patch)
tree95b1e16717abe100bb0cdad8d83243391f16390f
parenta2d3de38660d478f8643f9caf159d28d510d3a46 (diff)
Added support for locking orientation
Reviewed-by: ckamm
-rw-r--r--models/maemoFremantle/maemoFremantle.config2
-rw-r--r--models/symbian3/symbian3.config2
-rw-r--r--models/symbianNonTouch/symbianNonTouch.config2
-rw-r--r--models/symbianTouch/symbianTouch.config2
-rw-r--r--src/main.cpp2
-rw-r--r--src/other/configurationreader.cpp11
-rw-r--r--src/other/deviceitem.cpp22
-rw-r--r--src/other/deviceitem.h7
-rw-r--r--src/other/widget.cpp1
-rw-r--r--src/other/widget.h3
-rw-r--r--src/other/widgetmanager.cpp32
-rw-r--r--src/other/widgetmanager.h3
-rw-r--r--src/ui/configurationwidget.cpp16
-rw-r--r--src/ui/configurationwidget.h2
-rw-r--r--src/ui/mainwindow.cpp4
15 files changed, 103 insertions, 8 deletions
diff --git a/models/maemoFremantle/maemoFremantle.config b/models/maemoFremantle/maemoFremantle.config
index f2457ac..a13ce35 100644
--- a/models/maemoFremantle/maemoFremantle.config
+++ b/models/maemoFremantle/maemoFremantle.config
@@ -9,8 +9,10 @@ defaultFontSize:18
forceDpi:96
menuImage:leftUp,fremantle_leftup.png
availableGeometry:leftUp,0,56,480,744
+portraitOrientation:leftUp
menuImage:topUp,fremantle_topup.png
availableGeometry:topUp,0,57,800,423
+landscapeOrientation:topUp
maemoNavigationButtonLandscape:691,0
maemoNavigationButtonPortrait:371,0
maemoNavigationButtonClose:fremantle_close.png
diff --git a/models/symbian3/symbian3.config b/models/symbian3/symbian3.config
index d4f9dd7..b0cc5bc 100644
--- a/models/symbian3/symbian3.config
+++ b/models/symbian3/symbian3.config
@@ -9,8 +9,10 @@ defaultFontSize:7
style:s60,nseriesblack
menuImage:topUp,N8_portrait.png
availableGeometry:topUp,0,92,360,487
+portraitOrientation:topUp
menuImage:rightUp,N8_landscape.png
availableGeometry:rightUp,0,45,640,270
+landscapeOrientation:rightUp
symbianSoftKeyButton:topUp,0,0,580,180,60
symbianSoftKeyButton:topUp,1,180,580,180,60
symbianSoftKeyButton:rightUp,0,0,316,212,44
diff --git a/models/symbianNonTouch/symbianNonTouch.config b/models/symbianNonTouch/symbianNonTouch.config
index f50bdeb..faa3abb 100644
--- a/models/symbianNonTouch/symbianNonTouch.config
+++ b/models/symbianNonTouch/symbianNonTouch.config
@@ -36,6 +36,8 @@ menuImage:rightUp,n95rightup.png
menuImage:topUp,n95topup.png
availableGeometry:rightUp,0,21,320,198
availableGeometry:topUp,0,58,240,235
+portraitOrientation:topUp
+landscapeOrientation:rightUp
symbianSoftKeyButton:topUp,0,0,293,120,27
symbianSoftKeyButton:topUp,1,120,293,120,27
symbianSoftKeyButton:rightUp,1,220,0,100,21
diff --git a/models/symbianTouch/symbianTouch.config b/models/symbianTouch/symbianTouch.config
index aa51559..e9b3a56 100644
--- a/models/symbianTouch/symbianTouch.config
+++ b/models/symbianTouch/symbianTouch.config
@@ -12,8 +12,10 @@ button:Key_Call,,165,864,42,66
button:Key_Hangup,,255,858,43,78
menuImage:topUp,menu_topup.png
availableGeometry:topUp,0,92,360,487
+portraitOrientation:topUp
menuImage:rightUp,menu_rightup.png
availableGeometry:rightUp,0,73,502,288
+landscapeOrientation:rightUp
symbianSoftKeyButton:topUp,0,0,579,180,61
symbianSoftKeyButton:topUp,1,180,579,180,61
symbianSoftKeyButton:rightUp,1,503,0,137,72
diff --git a/src/main.cpp b/src/main.cpp
index 1cbe79f..540fce7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -77,7 +77,7 @@ static void registerSimulator(const QString &location)
settings->beginGroup(SIMULATOR_APP_QT_VERSIONS_KEY);
QList<QString> supportedQtVersion;
- supportedQtVersion << "4.7.1.0" << "4.7.2.0";
+ supportedQtVersion << "4.7.2.1";
foreach(const QString &version, supportedQtVersion) {
QList<QString> simulators;
QVariant value = settings->value(version);
diff --git a/src/other/configurationreader.cpp b/src/other/configurationreader.cpp
index 7f621d9..e532580 100644
--- a/src/other/configurationreader.cpp
+++ b/src/other/configurationreader.cpp
@@ -232,6 +232,17 @@ bool ConfigurationReader::processLine(const QByteArray &line, DeviceData *device
}
deviceData->menus[orientation].pixmapPath = mCurrentDir->filePath(values[1]);
deviceData->supportedOrientations |= orientation;
+ } else if (parameter == "landscapeOrientation" || parameter == "portraitOrientation"){
+ bool orientationOk = false;
+ Orientation orientation = stringToOrientation(value, &orientationOk);
+ if (!orientationOk) {
+ errorMsg = tr("ConfigurationReader: unknown orientation: %1").arg(QString(value));
+ return false;
+ }
+ if (parameter == "landscapeOrientation")
+ deviceData->landscapeOrientation = orientation;
+ else
+ deviceData->portraitOrientation = orientation;
} else
return false;
return true;
diff --git a/src/other/deviceitem.cpp b/src/other/deviceitem.cpp
index 63d3fbf..fefd6e8 100644
--- a/src/other/deviceitem.cpp
+++ b/src/other/deviceitem.cpp
@@ -47,6 +47,7 @@ DeviceItem::DeviceItem(QGraphicsItem *parent)
: QGraphicsObject(parent)
, mDeviceOrientation(topUp)
, mScreenOrientation(topUp)
+ , mFixedOrientation(Qt::WA_AutoOrientation)
, mDisplay(0)
, mMockup(0)
, mMaemoNavigationButton(0)
@@ -187,7 +188,7 @@ void DeviceItem::changeOrientation(Orientation newOrientation, bool rotateScreen
{
bool animatedRotate = needsAnimation(mDeviceOrientation, newOrientation);
mDeviceOrientation = newOrientation;
- if (rotateScreen) {
+ if (mFixedOrientation == Qt::WA_AutoOrientation && rotateScreen) {
mScreenOrientation = newOrientation;
if (!animatedRotate)
updateScreenOrientation();
@@ -233,9 +234,15 @@ void DeviceItem::updateScreenOrientation()
{
QSize newResolution = mDeviceData.resolution;
- // switch to a valid screen orientation if invalid
- if (!(mScreenOrientation & mDeviceData.supportedOrientations) && !mDeviceData.menus.isEmpty())
- mScreenOrientation = mDeviceData.menus.begin().key();
+ if (mFixedOrientation == Qt::WA_AutoOrientation) {
+ // switch to a valid screen orientation if invalid
+ if (!(mScreenOrientation & mDeviceData.supportedOrientations) && !mDeviceData.menus.isEmpty())
+ mScreenOrientation = mDeviceData.menus.begin().key();
+ } else if (mFixedOrientation == Qt::WA_LockLandscapeOrientation) {
+ mScreenOrientation = mDeviceData.landscapeOrientation;
+ } else if (mFixedOrientation == Qt::WA_LockPortraitOrientation) {
+ mScreenOrientation = mDeviceData.portraitOrientation;
+ }
switch (mScreenOrientation) {
case topUp:
@@ -613,3 +620,10 @@ void SymbianSoftKeyButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Q_UNUSED(event);
emit clicked(mButton.buttonNumber);
}
+
+void DeviceItem::updateOrientation(Qt::WidgetAttribute orientation)
+{
+ mFixedOrientation = orientation;
+ updateScreenOrientation();
+ emit orientationLocked(orientation != Qt::WA_AutoOrientation);
+}
diff --git a/src/other/deviceitem.h b/src/other/deviceitem.h
index 506a09f..e5d98da 100644
--- a/src/other/deviceitem.h
+++ b/src/other/deviceitem.h
@@ -83,6 +83,8 @@ struct DeviceData
: diagonalInInch(0.)
, defaultFontSize(12)
, forceDpi(-1)
+ , landscapeOrientation(topUp)
+ , portraitOrientation(topUp)
{}
QString name;
@@ -106,6 +108,8 @@ struct DeviceData
SupportedOrientations supportedOrientations;
QHash<Orientation, MenuData> menus;
QList<SymbianSoftKeyButtonData> symbianSoftKeys;
+ Orientation landscapeOrientation;
+ Orientation portraitOrientation;
};
class DisplayWidget;
@@ -241,6 +245,7 @@ public:
public slots:
void changeDevice(const DeviceData &data);
void changeOrientation(Orientation newOrientation, bool rotateScreen);
+ void updateOrientation(Qt::WidgetAttribute orientation);
void setInitialRotation(Orientation device, Orientation screen);
void changeScaleFactor(qreal newScaleFactor);
void setSymbianSoftKeyText(int buttonNumber, const QString &text);
@@ -260,6 +265,7 @@ private:
Orientation mDeviceOrientation;
Orientation mScreenOrientation;
+ Qt::WidgetAttribute mFixedOrientation;
DeviceData mDeviceData;
@@ -297,6 +303,7 @@ signals:
void symbianSoftKeyClicked(int buttonNr);
void orientationChanged(Orientation to);
+ void orientationLocked(bool locked);
friend class InputScriptInterface;
};
diff --git a/src/other/widget.cpp b/src/other/widget.cpp
index 40510f3..e573252 100644
--- a/src/other/widget.cpp
+++ b/src/other/widget.cpp
@@ -76,6 +76,7 @@ Widget::Widget(QRect geometry, QImage::Format f, const QString &t, Application*
, wantsUpdate(false)
, memoryFilled(false)
, mMaemo5Stacked(false)
+ , mOrientation(Qt::WA_AutoOrientation)
, mSharedMemoryName(sharedMemoryName)
{
//Commented out, in order to be
diff --git a/src/other/widget.h b/src/other/widget.h
index e4b727e..9633bbe 100644
--- a/src/other/widget.h
+++ b/src/other/widget.h
@@ -75,6 +75,8 @@ public:
void setMenuBar(QMenuBar* menuBar) { mMenuBar = menuBar; }
bool maemo5Stacked() { return mMaemo5Stacked; }
void setMaemo5Stacked(bool stacked) { mMaemo5Stacked = stacked; }
+ Qt::WidgetAttribute orientation() { return mOrientation; }
+ void setOrientation(Qt::WidgetAttribute orientation) { mOrientation = orientation; }
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent* ev);
@@ -100,6 +102,7 @@ private:
bool wantsUpdate;
bool memoryFilled;
bool mMaemo5Stacked;
+ Qt::WidgetAttribute mOrientation;
// can't use QGraphicsItem::isVisible because we need to support visible children of
// invisible parents
bool mWidgetVisible;
diff --git a/src/other/widgetmanager.cpp b/src/other/widgetmanager.cpp
index 28c9cb2..01d50ac 100644
--- a/src/other/widgetmanager.cpp
+++ b/src/other/widgetmanager.cpp
@@ -85,6 +85,7 @@ WidgetManager::WidgetManager(DisplayWidget *dw, QObject *parent)
connect(this, SIGNAL(topWidgetChanged(Widget*)), this, SLOT(updateSymbianSoftKeys()));
connect(this, SIGNAL(topWidgetChanged(Widget*)), this, SLOT(maybeFullscreen(Widget *)));
connect(this, SIGNAL(topWidgetChanged(Widget*)), this, SLOT(updateMaemoNavigate(Widget*)));
+ connect(this, SIGNAL(topWidgetChanged(Widget*)), this, SLOT(handleTopOrientation(Widget*)));
}
WidgetManager::~WidgetManager()
@@ -659,3 +660,34 @@ QString WidgetManager::freeSharedMemoryName()
qFatal("Could not find a free shared memory area");
return QString();
}
+
+void WidgetManager::setOrientationAttribute(int id, int orientation, bool on)
+{
+ Qt::WidgetAttribute realOrientation = static_cast<Qt::WidgetAttribute>(orientation);
+ switch (realOrientation) {
+ case Qt::WA_LockLandscapeOrientation:
+ case Qt::WA_LockPortraitOrientation:
+ case Qt::WA_AutoOrientation:
+ break;
+ default:
+ return;
+ }
+
+ Widget* w = widgetForId(id);
+ if (!w)
+ return;
+ if (w->orientation() == realOrientation && !on)
+ realOrientation = Qt::WA_AutoOrientation;
+ w->setOrientation(realOrientation);
+ if (topWidget() == w) {
+ emit topOrientationChanged(realOrientation);
+ }
+}
+
+void WidgetManager::handleTopOrientation(Widget *topWidget)
+{
+ if (!topWidget)
+ emit topOrientationChanged(Qt::WA_AutoOrientation);
+ else
+ emit topOrientationChanged(topWidget->orientation());
+}
diff --git a/src/other/widgetmanager.h b/src/other/widgetmanager.h
index d5c8ac2..fad056c 100644
--- a/src/other/widgetmanager.h
+++ b/src/other/widgetmanager.h
@@ -87,6 +87,7 @@ public slots:
void setWidgetOpacity(int id, double opacity);
void setWidgetParent(int id, int newParentId);
void setMaemo5StackedWindowFlag(int id, bool stacked);
+ void setOrientationAttribute(int id, int orientation, bool on);
void onApplicationUnregistered(int appId);
@@ -103,9 +104,11 @@ private slots:
void handleUpdateRequests();
void updateMaemoNavigate(Widget *topWidget);
void maybeFullscreen(Widget *topWidget);
+ void handleTopOrientation(Widget *topWidget);
signals:
void topWidgetChanged(Widget *);
+ void topOrientationChanged(Qt::WidgetAttribute orientation);
void symbianSoftKeyTextChanged(int buttonNr, QString text);
void maemoNavigationChanged(MaemoNavigationMode mode);
diff --git a/src/ui/configurationwidget.cpp b/src/ui/configurationwidget.cpp
index 667a79a..6eac856 100644
--- a/src/ui/configurationwidget.cpp
+++ b/src/ui/configurationwidget.cpp
@@ -61,6 +61,7 @@ ConfigurationWidget::ConfigurationWidget(const DeviceItem *deviceItem, QWidget *
, mCorrectionFactor(1)
, mViewConfiguration(0)
, mDeviceItem(deviceItem)
+ , mOrientationLocked(false)
{
qRegisterMetaType<Orientation>();
@@ -198,7 +199,7 @@ void ConfigurationWidget::updateOrientationButtons(const DeviceData &data)
{
const bool rotateScreen = ui_inspector->rotateScreen->isChecked();
- if (!rotateScreen) {
+ if (!rotateScreen || mOrientationLocked) {
ui_inspector->topUp->setEnabled(true);
ui_inspector->leftUp->setEnabled(true);
ui_inspector->rightUp->setEnabled(true);
@@ -210,7 +211,7 @@ void ConfigurationWidget::updateOrientationButtons(const DeviceData &data)
ui_inspector->topDown->setEnabled(data.supportedOrientations & topDown);
}
- if (!mOrientationButtons->checkedButton()->isEnabled() && !data.menus.isEmpty()) {
+ if (!mOrientationButtons->checkedButton()->isEnabled() && !data.menus.isEmpty() && !mOrientationLocked) {
Orientation fallback = data.menus.begin().key();
if (data.supportedOrientations & fallback)
mOrientationButtons->button(fallback)->click();
@@ -544,3 +545,14 @@ QStringList SimulatorScriptInterface::supportedScreenOrientations() const
return ret;
}
+
+void ConfigurationWidget::setOrientationLocked(bool locked)
+{
+ mOrientationLocked = locked;
+ ui_inspector->rotateScreen->setDisabled(locked);
+ updateOrientationButtons(deviceList.at(currentDeviceIndex()));
+ if (!locked) {
+ emit orientationChangeRequested(static_cast<Orientation>(mOrientationButtons->checkedId()),
+ ui_inspector->rotateScreen->isChecked());
+ }
+}
diff --git a/src/ui/configurationwidget.h b/src/ui/configurationwidget.h
index 040dcf8..c65b9b0 100644
--- a/src/ui/configurationwidget.h
+++ b/src/ui/configurationwidget.h
@@ -82,6 +82,7 @@ public slots:
void updateMenuBarWidget(Widget *menuBarWidget);
void updateOrientationButtonsState(Orientation orientation);
void updateOrientationsButtonsIcons(bool standardOrientationPortrait);
+ void setOrientationLocked(bool locked);
signals:
void deviceSelectionChanged(const DeviceData &data);
@@ -126,6 +127,7 @@ private:
QPointer<QMenuBar> mMenuBar;
const DeviceItem *mDeviceItem;
+ bool mOrientationLocked;
SimulatorScriptInterface *mScriptInterface;
friend class SimulatorScriptInterface;
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index bd88f78..93d23c2 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -84,7 +84,7 @@
#endif
// VERSION UPDATE
-const VersionStruct simulatorVersion(1, 1, 0, 0);
+const VersionStruct simulatorVersion(1, 1, 0, 1);
// Increment this value if the scripts that come bundled with the Simulator
// have changed and the user should be asked whehter he wants to copy them
@@ -190,6 +190,8 @@ MainWindow::MainWindow(QWidget *parent)
return;
}
connect(widgetManager, SIGNAL(topWidgetChanged(Widget *)), config, SLOT(updateMenuBarWidget(Widget *)));
+ connect(widgetManager, SIGNAL(topOrientationChanged(Qt::WidgetAttribute)), mDeviceItem, SLOT(updateOrientation(Qt::WidgetAttribute)));
+ connect(mDeviceItem, SIGNAL(orientationLocked(bool)), config, SLOT(setOrientationLocked(bool)));
connect(config, SIGNAL(deviceSelectionChanged(const DeviceData &)), mDeviceItem, SLOT(changeDevice(const DeviceData &)));
connect(mDeviceItem, SIGNAL(sizeChanged(const QSize &)), this, SLOT(setSizeToDevice(const QSize &)));
connect(mDeviceItem, SIGNAL(orientationChanged(Orientation)), config, SLOT(updateOrientationButtonsState(Orientation)));