diff options
author | Olli Werwolff <qt-info@nokia.com> | 2010-08-24 14:56:39 +0200 |
---|---|---|
committer | Olli Werwolff <qt-info@nokia.com> | 2010-08-25 11:28:06 +0200 |
commit | 44652d2a34c45aa348f78c2256af4ca3ae1e2054 (patch) | |
tree | 811bbcf51b54f3022111aff7903c5c6426fda67b | |
parent | 8cb4fe6a4de3cf8c1bdaa8e6d8a1a1e13a9bada5 (diff) |
Added NavigationButton for Maemo5 Devices
Task-number: QTSIM-72
Reviewed-by: ckamm
21 files changed, 141 insertions, 27 deletions
diff --git a/models/maemoFremantle/N900.png b/models/maemoFremantle/N900.png Binary files differindex 308053a..27fb3cd 100644 --- a/models/maemoFremantle/N900.png +++ b/models/maemoFremantle/N900.png diff --git a/models/maemoFremantle/fremantle_back.png b/models/maemoFremantle/fremantle_back.png Binary files differnew file mode 100644 index 0000000..e1d3f87 --- /dev/null +++ b/models/maemoFremantle/fremantle_back.png diff --git a/models/maemoFremantle/fremantle_close.png b/models/maemoFremantle/fremantle_close.png Binary files differnew file mode 100644 index 0000000..47d94c2 --- /dev/null +++ b/models/maemoFremantle/fremantle_close.png diff --git a/models/maemoFremantle/fremantle_leftup.png b/models/maemoFremantle/fremantle_leftup.png Binary files differnew file mode 100644 index 0000000..4e2c02b --- /dev/null +++ b/models/maemoFremantle/fremantle_leftup.png diff --git a/models/maemoFremantle/fremantle_portrait.png b/models/maemoFremantle/fremantle_portrait.png Binary files differindex f38a190..4e2c02b 100644 --- a/models/maemoFremantle/fremantle_portrait.png +++ b/models/maemoFremantle/fremantle_portrait.png diff --git a/models/maemoFremantle/fremantle_topup.png b/models/maemoFremantle/fremantle_topup.png Binary files differnew file mode 100644 index 0000000..efb8326 --- /dev/null +++ b/models/maemoFremantle/fremantle_topup.png diff --git a/models/maemoFremantle/maemoFremantle.config b/models/maemoFremantle/maemoFremantle.config index 65f6bbc..8bcf4d5 100644 --- a/models/maemoFremantle/maemoFremantle.config +++ b/models/maemoFremantle/maemoFremantle.config @@ -7,10 +7,11 @@ offsetX:72 offsetY:165 defaultFontSize:18 forceDpi:96 -nativeOrientation:landscape -menuPortrait:fremantle_portrait.png +menuPortrait:fremantle_leftup.png availableGeometryPortrait:0,56,480,744 -menuLandscape:fremantle_landscape.png +menuLandscape:fremantle_topup.png availableGeometryLandscape:0,57,800,423 -closeButtonLandscape:691,0,109,57 -closeButtonPortrait:371,0,109,56 +maemoNavigationButtonLandscape:691,0 +maemoNavigationButtonPortrait:371,0 +maemoNavigationButtonClose:fremantle_close.png +maemoNavigationButtonBack:fremantle_back.png diff --git a/models/symbianNonTouch/n95rightup.png b/models/symbianNonTouch/n95rightup.png Binary files differnew file mode 100644 index 0000000..159a628 --- /dev/null +++ b/models/symbianNonTouch/n95rightup.png diff --git a/models/symbianNonTouch/n95topup.png b/models/symbianNonTouch/n95topup.png Binary files differnew file mode 100644 index 0000000..33021bd --- /dev/null +++ b/models/symbianNonTouch/n95topup.png diff --git a/models/symbianNonTouch/symbianNonTouch.config b/models/symbianNonTouch/symbianNonTouch.config index bae6153..daa40f0 100644 --- a/models/symbianNonTouch/symbianNonTouch.config +++ b/models/symbianNonTouch/symbianNonTouch.config @@ -32,7 +32,6 @@ button:Key_Music,,184,459,59,34 button:Key_Select,,128,461,35,34 button:Key_Spell,,60,493,49,20 button:Key_Backspace,,183,494,48,20 -nativeOrientation:portrait menuLandscape:n95landscape.png menuPortrait:n95portrait.png availableGeometryLandscape:0,21,320,198 diff --git a/models/symbianTouch/menu_rightup.png b/models/symbianTouch/menu_rightup.png Binary files differnew file mode 100644 index 0000000..25d80d5 --- /dev/null +++ b/models/symbianTouch/menu_rightup.png diff --git a/models/symbianTouch/menu_topup.png b/models/symbianTouch/menu_topup.png Binary files differnew file mode 100644 index 0000000..c954310 --- /dev/null +++ b/models/symbianTouch/menu_topup.png diff --git a/models/symbianTouch/symbianTouch.config b/models/symbianTouch/symbianTouch.config index ed9eb25..0f01daa 100644 --- a/models/symbianTouch/symbianTouch.config +++ b/models/symbianTouch/symbianTouch.config @@ -14,7 +14,6 @@ menuPortrait:menu_portrait.png availableGeometryPortrait:0,92,360,487 menuLandscape:menu_landscape.png availableGeometryLandscape:0,73,502,288 -nativeOrientation:portrait symbianSoftKeyButtonPortrait:0,0,579,180,61 symbianSoftKeyButtonPortrait:1,180,579,180,61 symbianSoftKeyButtonLandscape:1,503,0,137,72 diff --git a/src/other/configurationreader.cpp b/src/other/configurationreader.cpp index 17af3bc..8b14fea 100644 --- a/src/other/configurationreader.cpp +++ b/src/other/configurationreader.cpp @@ -146,19 +146,30 @@ bool ConfigurationReader::processLine(const QByteArray &line, DeviceData *device b.area = QRectF(values[2].toFloat(), values[3].toFloat(), values[4].toFloat(), values[5].toFloat()); deviceData->buttons.append(b); - } else if (parameter == "closeButtonPortrait" || parameter == "closeButtonLandscape") { + } else if (parameter == "maemoNavigationButtonPortrait" || parameter == "maemoNavigationButtonLandscape") { QList<QByteArray> values = value.split(','); - if (values.count() != 4) { - errorMsg = tr("ConfigurationReader: closeButton property requires four comma separated values\n" - " closeButton:x,y,width,height"); + if (values.count() != 2) { + errorMsg = tr("ConfigurationReader: maemoNavigationButton property requires two comma separated values\n" + " maemoNavigationButton:x,y"); return false; } - QRectF toSet = QRectF(values[0].toFloat(), values[1].toFloat(), - values[2].toFloat(), values[3].toFloat()); - if (parameter == "closeButtonPortrait") - deviceData->closeButtonPortrait = toSet; + QPointF toSet = QPointF(values[0].toFloat(), values[1].toFloat()); + if (parameter == "maemoNavigationButtonPortrait") + deviceData->maemoNavigationButtonPortrait = toSet; else - deviceData->closeButtonLandscape = toSet; + deviceData->maemoNavigationButtonLandscape = toSet; + } else if (parameter == "maemoNavigationButtonBack") { + deviceData->maemoNavigationBackButton = mCurrentDir->filePath(value); + if (!mCurrentDir->exists(value)) { + errorMsg = tr("Image file %1 does not exist.").arg(deviceData->maemoNavigationBackButton); + return false; + } + } else if (parameter == "maemoNavigationButtonClose") { + deviceData->maemoNavigationCloseButton = mCurrentDir->filePath(value); + if (!mCurrentDir->exists(value)) { + errorMsg = tr("Image file %1 does not exist.").arg(deviceData->maemoNavigationCloseButton); + return false; + } } else if (parameter == "symbianSoftKeyButtonPortrait" || parameter == "symbianSoftKeyButtonLandscape") { QList<QByteArray> values = value.split(','); if (values.count() != 5) { diff --git a/src/other/deviceitem.cpp b/src/other/deviceitem.cpp index 6d41ae7..2961fc1 100644 --- a/src/other/deviceitem.cpp +++ b/src/other/deviceitem.cpp @@ -44,7 +44,7 @@ DeviceItem::DeviceItem(QGraphicsItem *parent) , mLandscape(false) , mDisplay(0) , mMockup(0) - , mCloseButton(0) + , mMaemoNavigationButton(0) , mMenu(0) { qRegisterMetaType<DeviceData>("DeviceData"); @@ -60,8 +60,9 @@ DeviceItem::DeviceItem(QGraphicsItem *parent) mMenu->setFocusProxy(mDisplay); mMenu->setZValue(SIMULATOR_MENU_Z); - mCloseButton = new DeviceButton(mMenu); - connect(mCloseButton, SIGNAL(pressed()), this, SIGNAL(closeWindowPressed())); + mMaemoNavigationButton = new PixmapButton(mMenu); + mMaemoNavigationButton ->setZValue(SIMULATOR_MENU_Z); + connect(mMaemoNavigationButton, SIGNAL(pressed()), this, SIGNAL(closeWindowPressed())); mLandscapeState = new QState; mPortraitState = new QState; @@ -137,6 +138,21 @@ void DeviceItem::changeDevice(const DeviceData &data) qFatal("Could not read landscape menu image %s", qPrintable(data.landscapeMenu.pixmapPath)); } + // maemo navigation button setup + if (!data.maemoNavigationBackButton.isNull() + && !data.maemoNavigationBackButton.isEmpty() + && !data.maemoBackPixmap) { + data.maemoBackPixmap = QSharedPointer<QPixmap>(new QPixmap(data.maemoNavigationBackButton)); + if (!data.maemoBackPixmap || data.maemoBackPixmap ->isNull()) + qFatal("Could not read maemo back button image %s", qPrintable(data.maemoNavigationBackButton)); + } + if (!data.maemoNavigationCloseButton.isNull() + && !data.maemoNavigationCloseButton.isEmpty() + && !data.maemoClosePixmap) { + data.maemoClosePixmap = QSharedPointer<QPixmap>(new QPixmap(data.maemoNavigationCloseButton)); + if (!data.maemoClosePixmap || data.maemoClosePixmap ->isNull()) + qFatal("Could not read maemo close button image %s", qPrintable(data.maemoNavigationCloseButton)); + } Orientation current; if (mLandscape) current = landscapeOrientation; @@ -145,6 +161,7 @@ void DeviceItem::changeDevice(const DeviceData &data) if (data.nativeOrientation != mDeviceData.nativeOrientation) { emit deviceChanged(current, mDeviceData.nativeOrientation, data.nativeOrientation); } + mMaemoNavigationButton->setPixmap(QPixmap()); mDeviceData = data; // self size @@ -273,6 +290,20 @@ void DeviceItem::setSymbianSoftKeyText(int buttonNumber, const QString &text) } } +void DeviceItem::setMaemoNavigationMode(MaemoNavigationMode mode) +{ + switch (mode) { + case maemoBack: + if (mDeviceData.maemoBackPixmap) + mMaemoNavigationButton->setPixmap(*mDeviceData.maemoBackPixmap); + break; + case maemoClose: + if (mDeviceData.maemoClosePixmap) + mMaemoNavigationButton->setPixmap(*mDeviceData.maemoClosePixmap); + break; + } +} + void DeviceItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { mDragOffset = event->scenePos().toPoint(); @@ -325,8 +356,7 @@ void DeviceItem::updateMenuPositionAndSize() mMenu->setPixmap(QPixmap()); mAvailableGeometry = displayRect; } - mCloseButton->setPos(mDeviceData.closeButtonLandscape.topLeft()); - mCloseButton->setSize(mDeviceData.closeButtonLandscape.size()); + mMaemoNavigationButton->setPos(mDeviceData.maemoNavigationButtonLandscape); } else { displayRect.setRect(0, 0, mDeviceData.resolution.width(), mDeviceData.resolution.height()); if (mDeviceData.portraitMenu.pixmap) { @@ -336,8 +366,7 @@ void DeviceItem::updateMenuPositionAndSize() mMenu->setPixmap(QPixmap()); mAvailableGeometry = displayRect; } - mCloseButton->setPos(mDeviceData.closeButtonPortrait.topLeft()); - mCloseButton->setSize(mDeviceData.closeButtonPortrait.size()); + mMaemoNavigationButton->setPos(mDeviceData.maemoNavigationButtonPortrait); } QHash<int, QString> oldSoftKeyTexts; @@ -404,6 +433,18 @@ void DeviceButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) emit released(); } +void PixmapButton::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + Q_UNUSED(event); + emit pressed(); +} + +void PixmapButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + Q_UNUSED(event); + emit released(); +} + KeyButton::KeyButton(const Button &button, QGraphicsItem *parent) : QGraphicsObject(parent) , mButton(button) diff --git a/src/other/deviceitem.h b/src/other/deviceitem.h index ec83f16..52c3cc6 100644 --- a/src/other/deviceitem.h +++ b/src/other/deviceitem.h @@ -65,6 +65,11 @@ struct SymbianSoftKeyButtonData { int buttonNumber; }; +enum MaemoNavigationMode { + maemoBack, + maemoClose, +}; + struct DeviceData { DeviceData() @@ -83,8 +88,12 @@ struct DeviceData QPoint offset; int defaultFontSize; int forceDpi; - QRectF closeButtonPortrait; - QRectF closeButtonLandscape; + QString maemoNavigationBackButton; + mutable QSharedPointer<QPixmap> maemoBackPixmap; + QString maemoNavigationCloseButton; + mutable QSharedPointer<QPixmap> maemoClosePixmap; + QPointF maemoNavigationButtonPortrait; + QPointF maemoNavigationButtonLandscape; QList<Button> buttons; QString style; QString styleTheme; @@ -132,6 +141,23 @@ signals: void released() const; }; +class PixmapButton: public QObject, public QGraphicsPixmapItem +{ + Q_OBJECT +public: + explicit PixmapButton(QGraphicsItem *parent = 0) : QGraphicsPixmapItem(parent) {}; + virtual ~PixmapButton() {}; + +protected: + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + +signals: + void pressed() const; + void released() const; + +}; + class KeyButton: public QGraphicsObject { Q_OBJECT @@ -206,6 +232,7 @@ public slots: void setInitialRotation(bool rotate); void changeScaleFactor(qreal newScaleFactor); void setSymbianSoftKeyText(int buttonNumber, const QString &text); + void setMaemoNavigationMode(MaemoNavigationMode mode); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -233,7 +260,7 @@ private: QPoint mDragOffset; QList<KeyButton*> mButtons; - DeviceButton *mCloseButton; + PixmapButton *mMaemoNavigationButton; QList<SymbianSoftKeyButton *> mSymbianSoftKeyButtons; MenuPixmapItem *mMenu; diff --git a/src/other/widget.cpp b/src/other/widget.cpp index fe51364..d9bd11c 100644 --- a/src/other/widget.cpp +++ b/src/other/widget.cpp @@ -69,6 +69,7 @@ Widget::Widget(QRect geometry, QImage::Format f, const QString &t, Application* , fullscreen(false) , mMenuBar(0) , wantsUpdate(false) + , mMaemo5Stacked(false) { //Commented out, in order to be //able to easily re-enable mouse tracking diff --git a/src/other/widget.h b/src/other/widget.h index cbe82d5..d511afc 100644 --- a/src/other/widget.h +++ b/src/other/widget.h @@ -65,6 +65,8 @@ public: QMenuBar* menuBar() const { return mMenuBar; } void setMenuBar(QMenuBar* menuBar) { mMenuBar = menuBar; } + bool maemo5Stacked() { return mMaemo5Stacked; } + void setMaemo5Stacked(bool stacked) { mMaemo5Stacked = stacked; } protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent* ev); @@ -88,6 +90,7 @@ private: bool fullscreen; QMenuBar* mMenuBar; bool wantsUpdate; + bool mMaemo5Stacked; }; #endif // WIDGET_H diff --git a/src/other/widgetmanager.cpp b/src/other/widgetmanager.cpp index f82ef73..123bf60 100644 --- a/src/other/widgetmanager.cpp +++ b/src/other/widgetmanager.cpp @@ -32,7 +32,6 @@ #include "application.h" #include "displaywidget.h" #include "qsimulatordata_p.h" -#include "deviceitem.h" #include <QtCore/QDebug> #include <QtGui/QWidget> @@ -342,6 +341,7 @@ void WidgetManager::stackWidget(int id, int pos) setZBefore(item, under); } + updateMaemoNavigate(); } void WidgetManager::setWidgetWindowTitle(int id, const QString &title) @@ -384,6 +384,14 @@ void WidgetManager::setWidgetParent(int id, int newParentId) w->setParentItem(newParent); } +void WidgetManager::setMaemo5StackedWindowFlag(int id, bool stacked) +{ + Widget *w = widgetForId(id); + if (!w) + return; + w->setMaemo5Stacked(stacked); +} + void WidgetManager::handleUpdateRequests() { foreach (Widget *w, widgets) { @@ -439,6 +447,23 @@ void WidgetManager::updateWidgetOffset(const QPoint &newOffset) } } +void WidgetManager::updateMaemoNavigate() +{ + Widget *top = topWidget(); + if (!top) + return; + QGraphicsItem *parent = top->parentItem(); + if (top->maemo5Stacked() && parent != displayWidget) { + Widget *parentWidget = static_cast<Widget *>(parent); + if (parentWidget->maemo5Stacked()) + emit maemoNavigationChanged(maemoBack); + else + emit maemoNavigationChanged(maemoClose); + } else { + emit maemoNavigationChanged(maemoClose); + } +} + /*! Adjust the Z order of this and all siblings to make this have the highest value diff --git a/src/other/widgetmanager.h b/src/other/widgetmanager.h index 6111082..6993502 100644 --- a/src/other/widgetmanager.h +++ b/src/other/widgetmanager.h @@ -30,6 +30,8 @@ #ifndef WIDGETMANAGER_H #define WIDGETMANAGER_H +#include "deviceitem.h" + #include <QtGui/QImage> #include <QtCore/QObject> @@ -78,6 +80,7 @@ public slots: void setFocusWidget(int id); void setWidgetOpacity(int id, double opacity); void setWidgetParent(int id, int newParentId); + void setMaemo5StackedWindowFlag(int id, bool stacked); void onApplicationUnregistered(int appId); @@ -96,11 +99,13 @@ private slots: signals: void topWidgetChanged(Widget *); void symbianSoftKeyTextChanged(int buttonNr, QString text); + void maemoNavigationChanged(MaemoNavigationMode mode); private: void updateLogItem(int id); void removeWidgetFromTable(int id); void updateWidgetOffset(const QPoint &newOffset); + void updateMaemoNavigate(); QList<Widget*> widgets; QTableWidget *tableWidget; QWidget *configWidget; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index a478796..fcb7d48 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -129,6 +129,7 @@ MainWindow::MainWindow(QWidget *parent) connect(applicationManager, SIGNAL(applicationUnRegistered(int)), widgetManager, SLOT(onApplicationUnregistered(int))); connect(widgetManager, SIGNAL(symbianSoftKeyTextChanged(int,QString)), deviceItem, SLOT(setSymbianSoftKeyText(int,QString))); + connect(widgetManager, SIGNAL(maemoNavigationChanged(MaemoNavigationMode)), deviceItem, SLOT(setMaemoNavigationMode(MaemoNavigationMode))); connect(deviceItem, SIGNAL(deviceChanged(QSize,DeviceData)), applicationManager, SLOT(updateDisplayInformation(QSize,DeviceData))); connect(deviceItem, SIGNAL(drag(QPoint)), this, SLOT(dragFromView(QPoint))); connect(deviceItem, SIGNAL(viewSizeRequired(QSize)), this, SLOT(setViewSize(QSize))); @@ -387,6 +388,7 @@ void MainWindow::readSettings() if (settings.contains("rotation")) rotated = settings.value("rotation").toBool(); deviceItem->setInitialRotation(rotated); + deviceItem->setMaemoNavigationMode(maemoClose); settings.endGroup(); } |