From 2f42ad94f671d50568afa2a1d0ef82e921cc73a0 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 28 May 2009 09:09:07 +0200 Subject: Optimize font DPI calculation by using cached value. The default DPI is stored in the S60 structure, so that can simply be used here instead of re-calculating it each time. Task-number: 247279 --- src/gui/text/qfont.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 4d316f6..930e8af 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -173,8 +173,7 @@ Q_GUI_EXPORT int qt_defaultDpiX() screen = subScreens.at(0); dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4))); #elif defined(Q_WS_S60) - const TReal inchWidth = (TReal)S60->screenWidthInTwips / KTwipsPerInch; - dpi = S60->screenWidthInPixels / inchWidth; + dpi = S60->defaultDpiX; #endif // Q_WS_X11 return dpi; @@ -202,8 +201,7 @@ Q_GUI_EXPORT int qt_defaultDpiY() screen = subScreens.at(0); dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4))); #elif defined(Q_WS_S60) - const TReal inchHeight = (TReal)S60->screenHeightInTwips / KTwipsPerInch; - dpi = S60->screenHeightInPixels / inchHeight; + dpi = S60->defaultDpiY; #endif // Q_WS_X11 return dpi; -- cgit v0.12 From ec081e992b1c8588bd08fef677fe090f6fe5c693 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Thu, 28 May 2009 09:24:58 +0200 Subject: No need for this IP address. --- tests/auto/qhostinfo/tst_qhostinfo.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index c3aca7a..0395ca0 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -92,7 +92,6 @@ //TESTED_CLASS= //TESTED_FILES= -const char * const lupinellaIp = "10.3.4.6"; class tst_QHostInfo : public QObject { -- cgit v0.12 From 349dd6ef5cbba0c45d8089a3cf65f587c2662c4d Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 28 May 2009 13:59:31 +0300 Subject: Fixed Qt/Symbian compilation with -stl configure option. The STL enabled config does not have implicit include for e32base.h. --- src/plugins/s60/src/qdesktopservices_3_2.cpp | 4 +++- src/plugins/s60/src/qlocale_3_2.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/s60/src/qdesktopservices_3_2.cpp b/src/plugins/s60/src/qdesktopservices_3_2.cpp index e563c14..679b370 100644 --- a/src/plugins/s60/src/qdesktopservices_3_2.cpp +++ b/src/plugins/s60/src/qdesktopservices_3_2.cpp @@ -10,10 +10,12 @@ ****************************************************************************/ #include -#include // CDirectoryLocalizer #include #include +#include // CBase -> Required by cdirectorylocalizer.h +#include // CDirectoryLocalizer + EXPORT_C QString localizedDirectoryName(QString& rawPath) { QString ret; diff --git a/src/plugins/s60/src/qlocale_3_2.cpp b/src/plugins/s60/src/qlocale_3_2.cpp index 027eefc..fe1d642 100644 --- a/src/plugins/s60/src/qlocale_3_2.cpp +++ b/src/plugins/s60/src/qlocale_3_2.cpp @@ -10,6 +10,7 @@ ****************************************************************************/ #include +#include EXPORT_C TPtrC defaultGetLongDateFormatSpec(TExtendedLocale& locale) { -- cgit v0.12 From f4d9a9458451ad4b3bd63bfafa34a57e3ba91c4a Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 28 May 2009 14:03:24 +0300 Subject: Enabled STL support by default in configure.exe for Symbian. This change should be quite safe, since all Qt <-> STL type conversions are implemented in inline methods. The only major difference is that new operator is now used from STL instead of one from e32base.h Of course, this change also requires that you have STLport installed to your SDK. This should be the case if you have installed the latest Open C/C++ plug-in from forum nokia. --- configure.exe | Bin 535040 -> 1183744 bytes tools/configure/configureapp.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.exe b/configure.exe index 30383d8..b3e68c2 100755 Binary files a/configure.exe and b/configure.exe differ diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index a879e5d..40caff0 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1405,7 +1405,7 @@ void Configure::applySpecSpecifics() dictionary[ "QT3SUPPORT" ] = "no"; dictionary[ "OPENGL" ] = "no"; dictionary[ "OPENSSL" ] = "no"; - dictionary[ "STL" ] = "no"; + dictionary[ "STL" ] = "yes"; dictionary[ "EXCEPTIONS" ] = "no"; dictionary[ "RTTI" ] = "no"; dictionary[ "ARCHITECTURE" ] = "symbian"; -- cgit v0.12 From 131d8f90aa2991866884a896fdebcc05a020a905 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 28 May 2009 13:24:10 +0200 Subject: Recompiled configure.exe with MSVC6. --- configure.exe | Bin 1183744 -> 868352 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index b3e68c2..65db048 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 1ee484031d2a240bd7019753e83bb473ea9891de Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 28 May 2009 13:49:08 +0200 Subject: Enabled QtS60Style background filling also for _simulated, by moving some code to qs60style.cpp. De-duplicated some code in qt_s60_fill_background. The unused QT_S60STYLE_LAYOUTDATA_SIMULATED had to go, too. --- src/gui/kernel/qwidget.cpp | 23 +++++++------- src/gui/styles/qs60style.cpp | 55 ++++++++++++++++++++++++---------- src/gui/styles/qs60style_p.h | 2 -- src/gui/styles/qs60style_simulated.cpp | 23 +++++--------- src/gui/styles/qs60style_symbian.cpp | 52 +++----------------------------- src/gui/styles/styles.pri | 1 - 6 files changed, 65 insertions(+), 91 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index dae4179..4fcedb4 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2046,17 +2046,20 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoin // Defined in qmacstyle_mac.cpp extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush); qt_mac_fill_background(painter, rgn, offset, brush); -#elif defined(Q_WS_S60) - // Defined in qs60style_symbian.cpp - extern void qt_s60_fill_background(QPainter *painter, const QRegion &rgn, - const QPoint &offset, const QBrush &brush); - qt_s60_fill_background(painter, rgn, offset, brush); #else - const QRegion translated = rgn.translated(offset); - const QRect rect(translated.boundingRect()); - painter->setClipRegion(translated); - painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); -#endif +#if !defined(QT_NO_STYLE_S60) + // Defined in qs60style.cpp + extern bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, + const QPoint &offset, const QBrush &brush); + if (!qt_s60_fill_background(painter, rgn, offset, brush)) +#endif // !defined(QT_NO_STYLE_S60) + { + const QRegion translated = rgn.translated(offset); + const QRect rect(translated.boundingRect()); + painter->setClipRegion(translated); + painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); + } +#endif // Q_WS_MAC } else { const QVector &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5f7c083..b066967 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -57,7 +57,6 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl static const QByteArray propertyKeyLayouts = "layouts"; static const QByteArray propertyKeyCurrentlayout = "currentlayout"; -#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** {240,320,1,14,true,QLatin1String("QVGA Landscape Mirrored")}, @@ -93,7 +92,6 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { }; const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; -#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) // theme background texture QPixmap *QS60StylePrivate::m_background = 0; @@ -119,6 +117,11 @@ static const int frameElementsCount = const int KNotFound = -1; +QS60StylePrivate::~QS60StylePrivate() +{ + deleteBackground(); +} + void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, const QRect &rect, SkinElementFlags flags) { @@ -252,10 +255,18 @@ void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part, drawPart(part, painter, rect, flags); } +short QS60StylePrivate::pixelMetric(int metric) +{ + Q_ASSERT(metric < MAX_PIXELMETRICS); + const short returnValue = m_pmPointer[metric]; + if (returnValue==-909) + return -1; + return returnValue; +} + void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) { if (name == propertyKeyCurrentlayout) { -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList(); const QString layout = value.toString(); Q_ASSERT(layouts.contains(layout)); @@ -265,24 +276,17 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) clearCaches(); refreshUI(); return; -#else - qFatal("Cannot set static layout. Dynamic layouts are used!"); -#endif } } QVariant QS60StylePrivate::styleProperty(const char *name) const { if (name == propertyKeyLayouts) { -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) static QStringList layouts; if (layouts.isEmpty()) for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++) layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName); return layouts; -#else - qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!"); -#endif } return QVariant(); } @@ -575,13 +579,10 @@ int QS60StylePrivate::focusRectPenWidth() return pixelMetric(QS60Style::PM_DefaultFrameWidth); } -#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) void QS60StylePrivate::setCurrentLayout(int index) { m_pmPointer = data[index]; } -#endif - void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart, QPainter *painter, const QRect &rect, SkinElementFlags flags) @@ -2185,7 +2186,6 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const metricValue = QCommonStyle::pixelMetric(metric, option, widget); if (metric == PM_SubMenuOverlap && widget){ - const int widgetWidth = widget->width(); const QMenu *menu = qobject_cast(widget); if (menu && menu->activeAction() && menu->activeAction()->menu()) { const int menuWidth = menu->activeAction()->menu()->sizeHint().width(); @@ -2415,11 +2415,12 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple ret = QCommonStyle::subControlRect(control, option, scontrol, widget); switch (scontrol) { case SC_GroupBoxCheckBox: //fallthrough - case SC_GroupBoxLabel: + case SC_GroupBoxLabel: { //slightly indent text and boxes, so that dialog border does not mess with them. const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); ret.adjust(2,horizontalSpacing-3,0,0); + } break; case SC_GroupBoxFrame: { const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget); @@ -2685,6 +2686,7 @@ void QS60Style::polish(QApplication *application) void QS60Style::unpolish(QApplication *application) { + Q_UNUSED(application) QPalette newPalette = qApp->style()->standardPalette(); application->setPalette(newPalette); QApplicationPrivate::setSystemPalette(originalPalette); @@ -2787,6 +2789,29 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); } +extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); + +bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, + const QBrush &brush) +{ + const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); + if (backgroundTexture.cacheKey() != brush.texture().cacheKey()) + return false; + + const QPaintDevice *target = painter->device(); + if (target->devType() == QInternal::Widget) { + const QWidget *widget = static_cast(target); + const QRegion translated = rgn.translated(offset); + const QVector &rects = translated.rects(); + for (int i = 0; i < rects.size(); ++i) { + const QRect rect(rects.at(i)); + painter->drawPixmap(rect.topLeft(), backgroundTexture, + rect.translated(qt_s60_fill_background_offset(widget))); + } + } + return true; +} + QT_END_NAMESPACE #endif // QT_NO_STYLE_S60 || QT_PLUGIN diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index bedff58..22b01f6 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -388,7 +388,6 @@ public: static int focusRectPenWidth(); -#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) static const layoutHeader m_layoutHeaders[]; static const short data[][MAX_PIXELMETRICS]; @@ -398,7 +397,6 @@ public: static short const *m_pmPointer; // number of layouts supported by the style static const int m_numberOfLayouts; -#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED) mutable QHash, QFont> m_mappedFontsCache; mutable QHash m_colorCache; diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 3edc874..b6ad0ac 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -42,19 +42,6 @@ QS60StylePrivate::QS60StylePrivate() setCurrentLayout(0); } -QS60StylePrivate::~QS60StylePrivate() -{ -} - -short QS60StylePrivate::pixelMetric(int metric) -{ - Q_ASSERT(metric < MAX_PIXELMETRICS); - const short returnValue = m_pmPointer[metric]; - if (returnValue==-909) - return -1; - return returnValue; -} - QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, int index, const QStyleOption *option) { @@ -194,7 +181,7 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const QPixmap QS60StylePrivate::backgroundTexture() { if (!m_background) { - const QSize size = QApplication::activeWindow()?QApplication::activeWindow()->size():QSize(100, 100); + const QSize size = QApplication::desktop()->screen()->size(); QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size); m_background = new QPixmap(background); } @@ -216,7 +203,6 @@ bool QS60StylePrivate::isToolBarBackground() return true; } - QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize) { QFont result; @@ -281,6 +267,13 @@ void QS60Style::setS60Theme(const QHash &parts, QS60StyleModeSpecifics::m_partPictures = parts; QS60StyleModeSpecifics::m_colors = colors; d->clearCaches(QS60StylePrivate::CC_ThemeChange); + d->setBackgroundTexture(qApp); +} + +QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) +{ + Q_UNUSED(targetWidget) + return QPoint(); } QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp index f860842..ddee4ba 100644 --- a/src/gui/styles/qs60style_symbian.cpp +++ b/src/gui/styles/qs60style_symbian.cpp @@ -593,30 +593,11 @@ bool QS60StylePrivate::isToolBarBackground() return (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2); } -void qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, - const QBrush &brush) +QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) { - const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture()); - if (backgroundTexture.cacheKey() == brush.texture().cacheKey()) { - const QPaintDevice *target = painter->device(); - if (target->devType() == QInternal::Widget) { - const QWidget *widget = static_cast(target); - CCoeControl *control = widget->effectiveWinId(); - TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0); - const QRegion translated = rgn.translated(offset); - const QVector &rects = translated.rects(); - for (int i = 0; i < rects.size(); ++i) { - const QRect rect(rects.at(i)); - painter->drawPixmap(rect.topLeft(), backgroundTexture, - rect.translated(globalPos.iX, globalPos.iY)); - } - } - } else { - const QRegion translated = rgn.translated(offset); - const QRect rect(translated.boundingRect()); - painter->setClipRegion(translated); - painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); - } + CCoeControl *control = targetWidget->effectiveWinId(); + TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0); + return QPoint(globalPos.iX, globalPos.iY); } QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( @@ -939,7 +920,6 @@ QFont QS60StylePrivate::s60Font_specific( return result; } -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED void QS60StylePrivate::setActiveLayout() { const QSize activeScreenSize(screenSize()); @@ -979,19 +959,11 @@ void QS60StylePrivate::setActiveLayout() m_pmPointer = data[activeLayoutIndex]; } -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED QS60StylePrivate::QS60StylePrivate() { -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED // No need to set active layout, if dynamic metrics API is available setActiveLayout(); -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED -} - -QS60StylePrivate::~QS60StylePrivate() -{ - deleteBackground(); } void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value) @@ -1011,20 +983,6 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const return styleProperty(name); } -short QS60StylePrivate::pixelMetric(int metric) -{ -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED - Q_ASSERT(metric < MAX_PIXELMETRICS); - const short returnValue = m_pmPointer[metric]; - if (returnValue==-909) - return -1; - return returnValue; -#else - //todo - call the pixelmetrics API directly - return 0; -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED -} - QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, int index, const QStyleOption *option) { @@ -1343,9 +1301,7 @@ void QS60Style::handleDynamicLayoutVariantSwitch() { Q_D(QS60Style); d->clearCaches(QS60StylePrivate::CC_LayoutChange); -#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED d->setActiveLayout(); -#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED d->refreshUI(); d->setBackgroundTexture(qApp); foreach (QWidget *widget, QApplication::allWidgets()) diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 9aa170e..b0e9f21 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -160,7 +160,6 @@ contains( styles, s60 ) { styles/qs60style.h \ styles/qs60style_p.h SOURCES += styles/qs60style.cpp - DEFINES += QT_S60STYLE_LAYOUTDATA_SIMULATED symbian { SOURCES += styles/qs60style_symbian.cpp # TODO: fix the following LIBS hack. Line 1 is for armv5, 2 for winscw -- cgit v0.12 From c1246f5b283754ed4f59770ba4690ea391e60483 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 28 May 2009 14:50:17 +0300 Subject: Fixed sis package names in S60 install docs. --- doc/src/installation.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/installation.qdoc b/doc/src/installation.qdoc index 91b7a25..3270dae 100644 --- a/doc/src/installation.qdoc +++ b/doc/src/installation.qdoc @@ -568,8 +568,8 @@ in the \l{Qt for Windows CE Requirements} document. We've included a subset of the Qt demos in this package for you to try out. An excellent starting point is the "fluidlauncher" demo. To run the demo on a real device, you first have to install - the Qt libraries and demos on the device. - Install \c{qt_libs_armv5_urel.sisx} and \c{fluidlauncher_armv5_urel.sisx} + the Qt libraries and the demo on the device. + Install \c{qt_libs.sis} and \c{fluidlauncher.sis} found at Qt installation folder to the device. To run the demos on the emulator, navigate to -- cgit v0.12 From 713833c831fb667fcb6fa4b1aad0dc452d70122f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 28 May 2009 16:53:48 +0300 Subject: S60Style: Adding missing break for clearCaches. --- src/gui/styles/qs60style.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b066967..b0ba30b 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -368,6 +368,7 @@ void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason) m_colorCache.clear(); QPixmapCache::clear(); deleteBackground(); + break; case CC_UndefinedChange: default: m_colorCache.clear(); -- cgit v0.12 From 1e96103c5bbd875d9e8607a322409b3abbfb136b Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 28 May 2009 15:55:45 +0200 Subject: Fixed input methods support on all spinbox types. --- src/gui/widgets/qabstractspinbox.cpp | 13 ++++++++++++- src/gui/widgets/qabstractspinbox.h | 2 ++ src/gui/widgets/qdatetimeedit.cpp | 1 + src/gui/widgets/qspinbox.cpp | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp index 347f89a..2bf1cda 100644 --- a/src/gui/widgets/qabstractspinbox.cpp +++ b/src/gui/widgets/qabstractspinbox.cpp @@ -659,7 +659,6 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit) d->edit->setParent(this); d->edit->setFrame(false); - d->edit->setAttribute(Qt::WA_InputMethodEnabled, false); d->edit->setFocusProxy(this); d->edit->setAcceptDrops(false); @@ -690,6 +689,18 @@ void QAbstractSpinBox::interpretText() d->interpret(EmitIfChanged); } +/* + Reimplemented in 4.6, so be careful. + */ +/*! + \reimp +*/ +QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const +{ + Q_D(const QAbstractSpinBox); + return d->edit->inputMethodQuery(query); +} + /*! \reimp */ diff --git a/src/gui/widgets/qabstractspinbox.h b/src/gui/widgets/qabstractspinbox.h index 4e7fc3f..aa8905f 100644 --- a/src/gui/widgets/qabstractspinbox.h +++ b/src/gui/widgets/qabstractspinbox.h @@ -122,6 +122,8 @@ public: void interpretText(); bool event(QEvent *event); + QVariant inputMethodQuery(Qt::InputMethodQuery) const; + virtual QValidator::State validate(QString &input, int &pos) const; virtual void fixup(QString &input) const; diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index 83bec68..4d34691 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -2390,6 +2390,7 @@ void QDateTimeEditPrivate::init(const QVariant &var) q->setCalendarPopup(true); #endif updateTimeSpec(); + q->setInputMethodHints(Qt::ImhPreferNumbers); setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem); } diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index c691eaf..295bf48 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -77,6 +77,8 @@ public: QChar thousand; inline void init() { + Q_Q(QSpinBox); + q->setInputMethodHints(Qt::ImhDigitsOnly); setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem); } }; @@ -97,6 +99,11 @@ public: // variables int decimals; QChar delimiter, thousand; + + inline void init() { + Q_Q(QDoubleSpinBox); + q->setInputMethodHints(Qt::ImhFormattedNumbersOnly); + } }; @@ -592,6 +599,8 @@ void QSpinBox::fixup(QString &input) const QDoubleSpinBox::QDoubleSpinBox(QWidget *parent) : QAbstractSpinBox(*new QDoubleSpinBoxPrivate(parent), parent) { + Q_D(QDoubleSpinBox); + d->init(); } /*! -- cgit v0.12 From cf6e5bd61cf0fc9fe4f70f87ad6d1dd59d456d97 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 28 May 2009 16:31:28 +0200 Subject: Cleaned up the inputMethodHints enum a bit. Made a clear distinction between Exclusive flags and other flags. --- doc/src/qnamespace.qdoc | 2 ++ src/corelib/global/qnamespace.h | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc index 84b3a01..fc0598f 100644 --- a/doc/src/qnamespace.qdoc +++ b/doc/src/qnamespace.qdoc @@ -2412,6 +2412,8 @@ \value ImhNoPredictiveText Do not use predictive text (i.e. dictionary lookup) while typing. \value ImhDialableCharactersOnly Only characters suitable for phone dialling are allowed. + \value ImhExclusiveInputMask A mask to test for the presence of any flags ending with \c Only. + \note If several flags ending with \c Only are ORed together, the resulting character set will consist of the union of the specified sets. For instance specifying \c ImhNumbersOnly and \c ImhUppercaseOnly would yield a set consisting of numbers and uppercase letters. diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index e0ca27c..75524a0 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1401,16 +1401,19 @@ public: enum InputMethodHint { ImhNone = 0x0, ImhHiddenText = 0x1, - ImhDigitsOnly = 0x2, - ImhFormattedNumbersOnly = 0x4, - ImhUppercaseOnly = 0x8, - ImhLowercaseOnly = 0x10, - ImhNoAutoUppercase = 0x20, - ImhPreferNumbers = 0x40, - ImhPreferUppercase = 0x80, - ImhPreferLowercase = 0x100, - ImhNoPredictiveText = 0x200, - ImhDialableCharactersOnly = 0x400 + ImhNoAutoUppercase = 0x2, + ImhPreferNumbers = 0x4, + ImhPreferUppercase = 0x8, + ImhPreferLowercase = 0x10, + ImhNoPredictiveText = 0x20, + + ImhDigitsOnly = 0x10000, + ImhFormattedNumbersOnly = 0x20000, + ImhUppercaseOnly = 0x40000, + ImhLowercaseOnly = 0x80000, + ImhDialableCharactersOnly = 0x100000, + + ImhExclusiveInputMask = 0xffff0000 }; Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint) -- cgit v0.12