From b807c326bb7e31c12c23c0025516023cbe3c32e6 Mon Sep 17 00:00:00 2001 From: Olli Werwolff Date: Mon, 28 Feb 2011 13:12:09 +0100 Subject: Adapt size of softkey text when changing device Reviewed-by: ckamm --- src/other/applicationmanager.cpp | 2 ++ src/other/applicationmanager.h | 1 + src/other/deviceitem.cpp | 17 +++++++++++++++++ src/other/deviceitem.h | 4 ++++ src/ui/mainwindow.cpp | 1 + 5 files changed, 25 insertions(+) diff --git a/src/other/applicationmanager.cpp b/src/other/applicationmanager.cpp index 674599d..dd3b63e 100644 --- a/src/other/applicationmanager.cpp +++ b/src/other/applicationmanager.cpp @@ -390,6 +390,8 @@ void ApplicationManager::updateDisplayInformation(const QSize &resolution, const foreach (Application *application, mApps) QtSimulatorPrivate::RemoteMetacall::call(application->socket(), QtSimulatorPrivate::NoSync, "updateDisplayInformation"); + double newSoftKeyTextSize = 1.0 * mDisplayInfo.defaultFontSize / mDisplayInfo.hostDpi.width() * mDisplayInfo.dpi.width(); + emit softkeyTextSizeChanged(newSoftKeyTextSize); } void ApplicationManager::updateMobilityVersion(int appId, VersionStruct version) diff --git a/src/other/applicationmanager.h b/src/other/applicationmanager.h index 1f73f6a..7770545 100644 --- a/src/other/applicationmanager.h +++ b/src/other/applicationmanager.h @@ -72,6 +72,7 @@ signals: void applicationTimedOut(int id); void firstAppRegistered(); void lastAppUnregistered(); + void softkeyTextSizeChanged(double newSize); public slots: void handleConnection(); diff --git a/src/other/deviceitem.cpp b/src/other/deviceitem.cpp index 06c1ce2..63d3fbf 100644 --- a/src/other/deviceitem.cpp +++ b/src/other/deviceitem.cpp @@ -313,6 +313,13 @@ void DeviceItem::setSymbianSoftKeyText(int buttonNumber, const QString &text) } } +void DeviceItem::setSymbianSoftKeyTextSize(double size) +{ + foreach (SymbianSoftKeyButton *b, mSymbianSoftKeyButtons) { + b->setTextSize(size); + } +} + void DeviceItem::setMaemoNavigationMode(MaemoNavigationMode mode) { if (mode == maemoClose && mDeviceData.maemoClosePixmap) @@ -525,6 +532,7 @@ SymbianSoftKeyButton::SymbianSoftKeyButton(const SymbianSoftKeyButtonData &butto : QGraphicsObject(parent) , mButton(button) , mMouseOver(false) + , mTextSize(12) { setFlag(QGraphicsItem::ItemIsFocusable); setFocusProxy(parent); @@ -548,6 +556,9 @@ void SymbianSoftKeyButton::paint(QPainter *painter, const QStyleOptionGraphicsIt Q_UNUSED(option); Q_UNUSED(widget); painter->setPen(Qt::white); + QFont f = painter->font(); + f.setPointSizeF(mTextSize); + painter->setFont(f); painter->drawText(boundingRect(), Qt::AlignHCenter | Qt::AlignVCenter, mText); if (mMouseOver) { painter->setPen(Qt::NoPen); @@ -572,6 +583,12 @@ QString SymbianSoftKeyButton::text() const return mText; } +void SymbianSoftKeyButton::setTextSize(double size) +{ + mTextSize = size; + update(); +} + void SymbianSoftKeyButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); diff --git a/src/other/deviceitem.h b/src/other/deviceitem.h index 65788ba..506a09f 100644 --- a/src/other/deviceitem.h +++ b/src/other/deviceitem.h @@ -204,6 +204,8 @@ public: void setText(const QString &text); QString text() const; + void setTextSize(double size); + protected: virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); @@ -216,6 +218,7 @@ signals: private: SymbianSoftKeyButtonData mButton; QString mText; + double mTextSize; bool mMouseOver; }; @@ -241,6 +244,7 @@ public slots: void setInitialRotation(Orientation device, Orientation screen); void changeScaleFactor(qreal newScaleFactor); void setSymbianSoftKeyText(int buttonNumber, const QString &text); + void setSymbianSoftKeyTextSize(double); void setMaemoNavigationMode(MaemoNavigationMode mode); protected: diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 47bc634..bd88f78 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -153,6 +153,7 @@ MainWindow::MainWindow(QWidget *parent) connect(applicationManager, SIGNAL(applicationRegistered(Application*)), this, SLOT(activateWindow())); connect(applicationManager, SIGNAL(applicationUnRegistered(int)), widgetManager, SLOT(onApplicationUnregistered(int))); + connect(applicationManager, SIGNAL(softkeyTextSizeChanged(double)), mDeviceItem, SLOT(setSymbianSoftKeyTextSize(double))); connect(widgetManager, SIGNAL(symbianSoftKeyTextChanged(int,QString)), mDeviceItem, SLOT(setSymbianSoftKeyText(int,QString))); connect(widgetManager, SIGNAL(maemoNavigationChanged(MaemoNavigationMode)), mDeviceItem, SLOT(setMaemoNavigationMode(MaemoNavigationMode))); connect(mDeviceItem, SIGNAL(deviceChanged(QSize,DeviceData)), applicationManager, SLOT(updateDisplayInformation(QSize,DeviceData))); -- cgit v1.2.3