From 49b6219dd12815d5155aa28bd8d1dbf26cf0b1d7 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 3 Jun 2009 17:13:29 +0200 Subject: Fixed a small input method bug in QLineEdit. We need to check for replacementLength as well. Otherwise there will be no undo information if text is deleted using input methods. --- src/gui/widgets/qlineedit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index d9e39d3..a95d2f2 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -2275,7 +2275,8 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) #endif int priorState = 0; - bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty(); + bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty() + || e->replacementLength() > 0; bool cursorPositionChanged = false; if (isGettingInput) { -- cgit v0.12 From 34c1e57a003cea4f359c05f07b6f255132e97b5f Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 3 Jun 2009 17:15:55 +0200 Subject: Added inputMethodQuery fallback to QWidget. --- src/gui/kernel/qwidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 4fcedb4..955ac8b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -8500,6 +8500,9 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const return QRect(width()/2, 0, 1, height()); case Qt::ImFont: return font(); + case Qt::ImAnchorPosition: + // Fallback. + return inputMethodQuery(Qt::ImCursorPosition); default: return QVariant(); } -- cgit v0.12 From ad0f42aa8f07b453e9ccfb960f24f40f4f00280d Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 3 Jun 2009 17:16:50 +0200 Subject: Gave QTextControl support for ImAnchorPosition and Selection. RevBy: Trust me The fix is almost identical to the one made for QLineEdit. --- src/gui/text/qtextcontrol.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index f6092bb..482d50b 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1813,13 +1813,18 @@ bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &po void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) { + Q_Q(QTextControl); if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) { e->ignore(); return; } - cursor.beginEditBlock(); + bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty() + || e->replacementLength() > 0; - cursor.removeSelectedText(); + if (isGettingInput) { + cursor.beginEditBlock(); + cursor.removeSelectedText(); + } // insert commit string if (!e->commitString().isEmpty() || e->replacementLength()) { @@ -1829,6 +1834,17 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) c.insertText(e->commitString()); } + for (int i = 0; i < e->attributes().size(); ++i) { + const QInputMethodEvent::Attribute &a = e->attributes().at(i); + if (a.type == QInputMethodEvent::Selection) { + QTextCursor oldCursor = cursor; + cursor.setPosition(a.start, QTextCursor::MoveAnchor); + cursor.setPosition(a.start + a.length, QTextCursor::KeepAnchor); + q->ensureCursorVisible(); + repaintOldAndNewSelection(oldCursor); + } + } + QTextBlock block = cursor.block(); QTextLayout *layout = block.layout(); layout->setPreeditArea(cursor.position() - block.position(), e->preeditString()); @@ -1852,7 +1868,9 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) } } layout->setAdditionalFormats(overrides); - cursor.endEditBlock(); + + if (isGettingInput) + cursor.endEditBlock(); } QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const @@ -1872,6 +1890,8 @@ QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const return QVariant(d->cursor.selectedText()); case Qt::ImMaximumTextLength: return QVariant(); // No limit. + case Qt::ImAnchorPosition: + return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length())); default: return QVariant(); } -- cgit v0.12 From 3893a10158e3ef5bec79c55ad89666cdc4ad14f5 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 3 Jun 2009 17:19:02 +0200 Subject: Fixed an update bug in QTextControl. Previously, the input context would not get updated on every selection update. --- src/gui/text/qtextcontrol.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 482d50b..6647558 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1611,6 +1611,9 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF if (cursor.position() != oldCursorPos) emit q->cursorPositionChanged(); _q_updateCurrentCharFormatAndSelection(); + if (QInputContext *ic = inputContext()) { + ic->update(); + } } else { //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1))); if (cursor.position() != oldCursorPos) -- cgit v0.12 From cfbe3355b36d629f0ba40ddcf421d807e624a1d3 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 3 Jun 2009 20:42:47 +0200 Subject: Added loadS60ThemeFromBlob and saveS60ThemeToBlob. The simulated style will by default try to load the 'Default.blob' --- src/gui/styles/qs60style.cpp | 8 --- src/gui/styles/qs60style.h | 2 + src/gui/styles/qs60style_s60.cpp | 8 +++ src/gui/styles/qs60style_simulated.cpp | 125 +++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 8 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index f7a1700..b30cc0d 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -870,14 +870,6 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag \sa QMacStyle, QWindowsStyle, QWindowsXPStyle, QWindowsVistaStyle, QPlastiqueStyle, QCleanlooksStyle, QMotifStyle */ -/*! - Constructs a QS60Style object. -*/ -QS60Style::QS60Style() - : QCommonStyle(*new QS60StylePrivate) -{ -} - QS60Style::~QS60Style() { } diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index bf8f22e..21cdd1c 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -85,6 +85,8 @@ public: static QStringList colorListKeys(); void setS60Theme(const QHash &parts, const QHash, QColor> &colors); + bool loadS60ThemeFromBlob(const QString &blobFile); + bool saveS60ThemeToBlob(const QString &blobFile) const; #endif // !Q_WS_S60 #ifdef Q_WS_S60 diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index d6f7109..55e80b9 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1326,6 +1326,14 @@ void QS60StyleModeSpecifics::colorGroupAndIndex( } } +/*! + Constructs a QS60Style object. +*/ +QS60Style::QS60Style() + : QCommonStyle(*new QS60StylePrivate) +{ +} + void QS60Style::handleDynamicLayoutVariantSwitch() { Q_D(QS60Style); diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 089a252..a94d73e 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -51,11 +51,109 @@ #include "qlayout.h" #include "qpixmapcache.h" #include "qmetaobject.h" +#include "qdebug.h" +#include "qbuffer.h" #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) QT_BEGIN_NAMESPACE +static const quint32 blobVersion = 1; +static const int pictureSize = 256; + +bool saveThemeToBlob(const QString &themeBlob, + const QHash &partPictures, + const QHash, QColor> &colors) +{ + QFile blob(themeBlob); + if (!blob.open(QIODevice::WriteOnly)) { + qWarning() << __FUNCTION__": Could not create blob: " << themeBlob; + return false; + } + + QByteArray data; + QBuffer dataBuffer(&data); + dataBuffer.open(QIODevice::WriteOnly); + QDataStream dataOut(&dataBuffer); + + const int colorsCount = colors.count(); + dataOut << colorsCount; + const QList > colorKeys = colors.keys(); + for (int i = 0; i < colorsCount; ++i) { + const QPair &key = colorKeys.at(i); + dataOut << key; + const QColor color = colors.value(key); + dataOut << color; + } + + const int picturesCount = partPictures.count(); + dataOut << picturesCount; + foreach (const QString &key, partPictures.keys()) { + const QPicture picture = partPictures.value(key); + dataOut << key; + dataOut << picture; + } + + QDataStream blobOut(&blob); + blobOut << blobVersion; + blobOut << qCompress(data); + return blobOut.status() == QDataStream::Ok; +} + +bool loadThemeFromBlob(const QString &themeBlob, + QHash &partPictures, + QHash, QColor> &colors) +{ + QFile blob(themeBlob); + if (!blob.open(QIODevice::ReadOnly)) { + qWarning() << __FUNCTION__": Could not read blob: " << themeBlob; + return false; + } + QDataStream blobIn(&blob); + + quint32 version; + blobIn >> version; + + if (version != blobVersion) { + qWarning() << __FUNCTION__": Invalid blob version: " << version << " ...expected: " << blobVersion; + return false; + } + + QByteArray data; + blobIn >> data; + data = qUncompress(data); + QBuffer dataBuffer(&data); + dataBuffer.open(QIODevice::ReadOnly); + QDataStream dataIn(&dataBuffer); + + int colorsCount; + dataIn >> colorsCount; + for (int i = 0; i < colorsCount; ++i) { + QPair key; + dataIn >> key; + QColor value; + dataIn >> value; + colors.insert(key, value); + } + + int picturesCount; + dataIn >> picturesCount; + for (int i = 0; i < picturesCount; ++i) { + QString key; + dataIn >> key; + QPicture value; + dataIn >> value; + value.setBoundingRect(QRect(0, 0, pictureSize, pictureSize)); // Bug? The forced bounding rect was not deserialized. + partPictures.insert(key, value); + } + + if (dataIn.status() != QDataStream::Ok) { + qWarning() << __FUNCTION__": Invalid data blob: " << themeBlob; + return false; + } + return true; +} + class QS60StyleModeSpecifics { public: @@ -254,6 +352,16 @@ QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCate return result; } +/*! + Constructs a QS60Style object. +*/ +QS60Style::QS60Style() + : QCommonStyle(*new QS60StylePrivate) +{ + // Assume, that the resource system has a ':/s60Stylethemes/Default.blob' + loadS60ThemeFromBlob(QString::fromLatin1(":/s60Stylethemes/Default.blob")); +} + Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, enumPartKeys, { const int enumIndex = QS60StyleEnums::staticMetaObject.indexOfEnumerator("SkinParts"); Q_ASSERT(enumIndex >= 0); @@ -303,6 +411,23 @@ void QS60Style::setS60Theme(const QHash &parts, d->setThemePalette(qApp); } +bool QS60Style::loadS60ThemeFromBlob(const QString &blobFile) +{ + QHash partPictures; + QHash, QColor> colors; + + if (!loadThemeFromBlob(blobFile, partPictures, colors)) + return false; + setS60Theme(partPictures, colors); + return true; +} + +bool QS60Style::saveS60ThemeToBlob(const QString &blobFile) const +{ + return saveThemeToBlob(blobFile, + QS60StyleModeSpecifics::m_partPictures, QS60StyleModeSpecifics::m_colors); +} + QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) { Q_UNUSED(targetWidget) -- cgit v0.12 From 58d05bc0ddbbae72128849676d12493058272cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 4 Jun 2009 09:29:46 +0300 Subject: S60Style: Draw all dialog with popup menu theme background. --- src/gui/styles/qs60style.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index f7a1700..9fbad41 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -50,7 +50,6 @@ #include "qcalendarwidget.h" #include "qdial.h" #include "qdialog.h" -#include "qerrormessage.h" #include "qgroupbox.h" #include "qheaderview.h" #include "qlist.h" @@ -58,7 +57,6 @@ #include "qlistview.h" #include "qmenu.h" #include "qmenubar.h" -#include "qmessagebox.h" #include "qpushbutton.h" #include "qscrollarea.h" #include "qscrollbar.h" @@ -116,8 +114,6 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { {7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1}, {7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,5,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}, {7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1} - - // *** End of generated data *** }; @@ -126,6 +122,7 @@ const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; // theme background texture QPixmap *QS60StylePrivate::m_background = 0; +// theme palette QPalette *QS60StylePrivate::m_themePalette = 0; const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { @@ -144,6 +141,7 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, }; + static const int frameElementsCount = int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); @@ -360,8 +358,7 @@ QColor QS60StylePrivate::lighterColor(const QColor &baseColor) bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget) { - return (qobject_cast (widget) || - qobject_cast (widget)); + return qobject_cast (widget); } QFont QS60StylePrivate::s60Font( @@ -413,8 +410,8 @@ void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason) } // Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use -// for QPalette::Button and QPalette::ToolTipBase. Therefore we need to guesstimate -// this by calculating average rgb values for button pixels. +// for QPalette::Button and QPalette::ToolTipBase. Therefore S60Style needs to guesstimate +// palette colors by calculating average rgb values for button pixels. // Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const { @@ -615,9 +612,7 @@ QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size void QS60StylePrivate::refreshUI() { - QList widgets = QApplication::allWidgets(); - - // The following is similar to updateWidgets in qstylesheetstyle.cpp. + QList widgets = QApplication::allWidgets(); for (int i = 0; i < widgets.size(); ++i) { QWidget *widget = widgets.at(i); @@ -662,7 +657,7 @@ void QS60StylePrivate::setThemePalette(QWidget *widget) const QPalette widgetPalette = widget->palette(); //header view and its viewport need to be set 100% transparent button color, since drawing code will - //draw transparent theme graphics there. + //draw transparent theme graphics to table column and row headers. if (qobject_cast(widget)){ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); -- cgit v0.12 From efcc087e7da35f6db0e544f48493626f4fa2d56a Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Wed, 3 Jun 2009 10:29:24 +0200 Subject: In QGraphicsView the viewport itself has to be enabled for InputMethods. When events are comming, exactly that widget will be aske for InputContext. --- src/gui/graphicsview/qgraphicsview.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index a795fb4..8137f8e 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -1195,6 +1195,11 @@ QGraphicsView::QGraphicsView(QWidget *parent) // using a simple reference count. The same goes for acceptDrops and mouse // tracking. setAttribute(Qt::WA_InputMethodEnabled); + + // viewport part of the graphics view has to be enabled + // as well, because when events come this widget is asked + // for input context and so on + viewport()->setAttribute(Qt::WA_InputMethodEnabled); } /*! @@ -1209,6 +1214,11 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent) setAcceptDrops(true); setBackgroundRole(QPalette::Base); setAttribute(Qt::WA_InputMethodEnabled); + + // viewport part of the graphics view has to be enabled + // as well, because when events come this widget is asked + // for input context and so on + viewport()->setAttribute(Qt::WA_InputMethodEnabled); } /*! @@ -1221,6 +1231,11 @@ QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent) setAcceptDrops(true); setBackgroundRole(QPalette::Base); setAttribute(Qt::WA_InputMethodEnabled); + + // viewport part of the graphics view has to be enabled + // as well, because when events come this widget is asked + // for input context and so on + viewport()->setAttribute(Qt::WA_InputMethodEnabled); } /*! -- cgit v0.12 From 08d020409ecf08c81f31faf33f1da329177cc207 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 4 Jun 2009 11:59:07 +0300 Subject: Added proper picture for Drilldown example in fluidlauncher --- demos/embedded/fluidlauncher/screenshots/drilldown.png | Bin 0 -> 102922 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 demos/embedded/fluidlauncher/screenshots/drilldown.png diff --git a/demos/embedded/fluidlauncher/screenshots/drilldown.png b/demos/embedded/fluidlauncher/screenshots/drilldown.png new file mode 100644 index 0000000..413d713 Binary files /dev/null and b/demos/embedded/fluidlauncher/screenshots/drilldown.png differ -- cgit v0.12 From fc96ef8bf45482483d795fe3d979fb842869a315 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 4 Jun 2009 12:15:05 +0300 Subject: Added proper UID for phonon.pro, and did some symbian scope cleanup, too. --- src/phonon/phonon.pro | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/phonon/phonon.pro b/src/phonon/phonon.pro index 679a1b0..b38adb8 100644 --- a/src/phonon/phonon.pro +++ b/src/phonon/phonon.pro @@ -13,13 +13,6 @@ PHONON_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/phonon unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork -# Phonon depends on numeric_limits. Enabling STL support in Qt -# would bring in link dependencies, and we don't need that for -# numeric_limits, hence we here merely ensure we bring in the necessary -# header. -symbian:INCLUDEPATH += $${EPOCROOT}epoc32/include/stdapis/stlport \ - $$OS_LAYER_STDCPP_SYSTEMINCLUDE - # Input HEADERS += $$PHONON_DIR/abstractaudiooutput.h \ $$PHONON_DIR/abstractaudiooutput_p.h \ @@ -122,7 +115,16 @@ contains(QT_CONFIG, dbus) { contains(QT_CONFIG, reduce_exports): CONFIG += hide_symbols symbian: { + # Phonon depends on numeric_limits. Enabling STL support in Qt + # would bring in link dependencies, and we don't need that for + # numeric_limits, hence we here merely ensure we bring in the necessary + # header. + INCLUDEPATH *= $${EPOCROOT}epoc32/include/stdapis/stlport \ + $$OS_LAYER_STDCPP_SYSTEMINCLUDE + # Without this setting, code using numeric_limits will fail # for winscw, although armv5 works fine no matter what. - MMP_RULES += "option cw -wchar_t on" + QMAKE_CXXFLAGS.CW *= $$STLLIB_USAGE_CW_FLAGS + + TARGET.UID3 = 0x2001E624 } -- cgit v0.12 From c244010c866cf1a80f1de7382a3b78e2eb0cb56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 4 Jun 2009 12:17:39 +0300 Subject: S60Style: Cleanup code before Tower release. --- src/gui/styles/qs60style.cpp | 413 ++++++++++++++++++++------------------- src/gui/styles/qs60style_s60.cpp | 49 ++--- 2 files changed, 229 insertions(+), 233 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index c8582eb..7db0992 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -145,7 +145,7 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme static const int frameElementsCount = int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); -const int KNotFound = -1; +const int KNotFound = -909; QS60StylePrivate::~QS60StylePrivate() { @@ -290,8 +290,6 @@ short QS60StylePrivate::pixelMetric(int metric) { Q_ASSERT(metric < MAX_PIXELMETRICS); const short returnValue = m_pmPointer[metric]; - if (returnValue==-909) - return -1; return returnValue; } @@ -306,7 +304,6 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value) QApplication::setLayoutDirection(m_layoutHeaders[layoutIndex].mirroring ? Qt::RightToLeft : Qt::LeftToRight); clearCaches(); refreshUI(); - return; } } @@ -559,11 +556,11 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start, QRect endRect; if (orientation == Qt::Horizontal) { - startRect.setWidth(qMin(rect.width() / 2 - 1, startRect.width())); + startRect.setWidth(qMin(rect.width() >>1 - 1, startRect.width())); endRect = startRect.translated(rect.width() - startRect.width(), 0); middleRect.adjust(startRect.width(), 0, -startRect.width(), 0); } else { - startRect.setHeight(qMin(rect.height() / 2 - 1, startRect.height())); + startRect.setHeight(qMin(rect.height() >>1 - 1, startRect.height())); endRect = startRect.translated(0, rect.height() - startRect.height()); middleRect.adjust(0, startRect.height(), 0, -startRect.height()); } @@ -691,20 +688,21 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); palette->setColor(QPalette::Highlight, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); + // set background image as a texture brush + palette->setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); // set these as transparent so that styled full screen theme background is visible palette->setColor(QPalette::AlternateBase, Qt::transparent); - palette->setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); - palette->setColor(QPalette::Base, Qt::transparent); + palette->setBrush(QPalette::Base, Qt::transparent); // set button and tooltipbase based on pixel colors const QColor buttonColor = this->colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal); palette->setColor(QPalette::Button, buttonColor ); + const QColor toolTipColor = this->colorFromFrameGraphics(QS60StylePrivate::SF_ToolTip); + palette->setColor(QPalette::ToolTipBase, toolTipColor ); palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); palette->setColor(QPalette::Shadow, Qt::black); - QColor toolTipColor = this->colorFromFrameGraphics(QS60StylePrivate::SF_ToolTip); - palette->setColor(QPalette::ToolTipBase, toolTipColor ); setThemePaletteHash(palette); QS60StylePrivate::storeThemePalette(palette); @@ -728,6 +726,8 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const //store the original palette QPalette widgetPalette = *palette; + const QColor mainAreaTextColor = + QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); widgetPalette.setColor(QPalette::All, QPalette::WindowText, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); @@ -735,20 +735,16 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const // return to original palette after each widget widgetPalette = *palette; - widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); - widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor); + widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor); const QStyleOption opt; widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt)); QApplication::setPalette(widgetPalette, "QPushButton"); widgetPalette = *palette; - widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); - widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor); + widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor); QApplication::setPalette(widgetPalette, "QToolButton"); widgetPalette = *palette; @@ -777,11 +773,10 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const QApplication::setPalette(widgetPalette, "QLineEdit"); widgetPalette = *palette; - const QColor color(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); - widgetPalette.setColor(QPalette::WindowText, color); + widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); - widgetPalette.setColor(QPalette::Dark, color.darker()); - widgetPalette.setColor(QPalette::Light, color.lighter()); + widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker()); + widgetPalette.setColor(QPalette::Light, mainAreaTextColor.lighter()); QApplication::setPalette(widgetPalette, "QDial"); widgetPalette = *palette; @@ -890,7 +885,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); - QStyle::SubControls subControls = optionSlider->subControls; + const QStyle::SubControls subControls = optionSlider->subControls; // select correct slider (horizontal/vertical/pressed) const bool sliderPressed = ((optionSlider->state & QStyle::State_Sunken) && (subControls & SC_ScrollBarSlider)); @@ -942,7 +937,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom if (const QStyleOptionComboBox *cmb = qstyleoption_cast(option)) { const QRect cmbxEditField = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget); const QRect cmbxFrame = subControlRect(CC_ComboBox, option, SC_ComboBoxFrame, widget); - const bool direction = cmb->direction == Qt::LeftToRight; // Button frame @@ -960,8 +954,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit; QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); + // Draw the combobox arrow if (sub & SC_ComboBoxArrow) { - // Draw the little arrow + // Make rect slightly smaller buttonOption.rect.adjust(1, 1, -1, -1); painter->save(); painter->setPen(option->palette.buttonText().color()); @@ -1102,14 +1097,13 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom if (spinBox->subControls & SC_SpinBoxUp) { copy.subControls = SC_SpinBoxUp; - QPalette pal2 = spinBox->palette; + QPalette spinBoxPal = spinBox->palette; if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { - pal2.setCurrentColorGroup(QPalette::Disabled); + spinBoxPal.setCurrentColorGroup(QPalette::Disabled); copy.state &= ~State_Enabled; + copy.palette = spinBoxPal; } - copy.palette = pal2; - if (spinBox->activeSubControls == SC_SpinBoxUp && (spinBox->state & State_Sunken)) { copy.state |= State_On; copy.state |= State_Sunken; @@ -1117,8 +1111,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom copy.state |= State_Raised; copy.state &= ~State_Sunken; } - pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus - : PE_IndicatorSpinUp); + pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ? + PE_IndicatorSpinPlus : + PE_IndicatorSpinUp; copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxUp, widget); drawPrimitive(PE_PanelButtonBevel, ©, painter, widget); @@ -1129,12 +1124,12 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom if (spinBox->subControls & SC_SpinBoxDown) { copy.subControls = SC_SpinBoxDown; copy.state = spinBox->state; - QPalette pal2 = spinBox->palette; + QPalette spinBoxPal = spinBox->palette; if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { - pal2.setCurrentColorGroup(QPalette::Disabled); + spinBoxPal.setCurrentColorGroup(QPalette::Disabled); copy.state &= ~State_Enabled; + copy.palette = spinBoxPal; } - copy.palette = pal2; if (spinBox->activeSubControls == SC_SpinBoxDown && (spinBox->state & State_Sunken)) { copy.state |= State_On; @@ -1143,8 +1138,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom copy.state |= State_Raised; copy.state &= ~State_Sunken; } - pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus - : PE_IndicatorSpinDown); + pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ? + PE_IndicatorSpinMinus : + PE_IndicatorSpinDown; copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxDown, widget); drawPrimitive(PE_PanelButtonBevel, ©, painter, widget); @@ -1352,13 +1348,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, // draw themed background for table unless background brush has been defined. if (vopt->backgroundBrush == Qt::NoBrush) { - // draw the background const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast(option); const QTableView *table = qobject_cast(widget); if (table && tableOption) { const QModelIndex index = tableOption->index; //todo: Draw cell background only once - for the first cell. - QStyleOptionViewItemV4 voptAdj2 = voptAdj2; + QStyleOptionViewItemV4 voptAdj2 = voptAdj; const QModelIndex indexFirst = table->model()->index(0,0); const QModelIndex indexLast = table->model()->index( table->model()->rowCount()-1,table->model()->columnCount()-1); @@ -1384,7 +1379,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, listView && (listView->selectionMode() == QAbstractItemView::SingleSelection || listView->selectionMode() == QAbstractItemView::NoSelection); - QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); + const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget); if (voptAdj.state & QStyle::State_Selected && !singleSelection) { QStyleOptionViewItemV4 option(voptAdj); option.rect = selectionRect; @@ -1421,9 +1416,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast(option); if (isSelected) { if (qobject_cast(widget) && tableOption) - voptAdj.palette.setColor(QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); + voptAdj.palette.setColor( + QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0)); else - voptAdj.palette.setColor(QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); + voptAdj.palette.setColor( + QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); } painter->setPen(voptAdj.palette.text().color()); d->viewItemDrawText(painter, &voptAdj, textRect); @@ -1521,7 +1518,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } painter->save(); QFont f = painter->font(); - f.setPointSizeF(f.pointSizeF() * 0.72); + f.setPointSizeF(f.pointSizeF() * KTabFontMul); painter->setFont(f); if (option->state & QStyle::State_Selected){ @@ -1529,27 +1526,27 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option)); } - bool verticalTabs = optionTab.shape == QTabBar::RoundedEast + const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::RoundedWest || optionTab.shape == QTabBar::TriangularEast || optionTab.shape == QTabBar::TriangularWest; - bool selected = optionTab.state & State_Selected; + const bool selected = optionTab.state & State_Selected; if (verticalTabs) { painter->save(); - int newX, newY, newRot; + int newX, newY, newRotation; if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) { newX = tr.width(); newY = tr.y(); - newRot = 90; + newRotation = 90; } else { newX = 0; newY = tr.y() + tr.height(); - newRot = -90; + newRotation = -90; } tr.setRect(0, 0, tr.height(), tr.width()); QTransform m; m.translate(newX, newY); - m.rotate(newRot); + m.rotate(newRotation); painter->setTransform(m, true); } tr.adjust(0, 0, pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget), @@ -1571,9 +1568,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QPixmap tabIcon = optionTab.icon.pixmap(iconSize, (optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); if (tab->text.isEmpty()) - painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1), tr.center().y() - (tabIcon.height() >>1), tabIcon); + painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1), + tr.center().y() - (tabIcon.height() >>1), + tabIcon); else - painter->drawPixmap(tr.left() + tabOverlap, tr.center().y() - (tabIcon.height() >>1), tabIcon); + painter->drawPixmap(tr.left() + tabOverlap, + tr.center().y() - (tabIcon.height() >>1), + tabIcon); tr.setLeft(tr.left() + iconSize.width() + 4); } @@ -1583,13 +1584,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (optionTab.state & State_HasFocus) { const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth); - const int x1 = optionTab.rect.left(); - const int x2 = optionTab.rect.right() - 1; + const int leftBorder = optionTab.rect.left(); + const int rightBorder = optionTab.rect.right() - 1; QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*tab); - fropt.rect.setRect(x1 + 1 + OFFSET, optionTab.rect.y() + OFFSET, - x2 - x1 - 2*OFFSET, optionTab.rect.height() - 2*OFFSET); + fropt.rect.setRect(leftBorder + 1 + OFFSET, optionTab.rect.y() + OFFSET, + rightBorder - leftBorder - 2*OFFSET, optionTab.rect.height() - 2*OFFSET); drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); } @@ -1639,25 +1640,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } break; #endif // QT_NO_PROGRESSBAR -#ifndef QT_NO_MENUBAR -#endif //QT_NO_MENUBAR #ifndef QT_NO_MENU case CE_MenuItem: if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { QStyleOptionMenuItem optionMenuItem = *menuItem; - const bool enabled = optionMenuItem.state & State_Enabled; - const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable; - - uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip - | Qt::TextSingleLine | Qt::AlignVCenter; - if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) - text_flags |= Qt::TextHideMnemonic; - - QRect iconRect = - subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); - QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); + bool drawSubMenuIndicator = false; - switch(menuItem->menuItemType) { case QStyleOptionMenuItem::Scroller: case QStyleOptionMenuItem::Separator: @@ -1668,20 +1656,29 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, default: break; } + const bool enabled = optionMenuItem.state & State_Enabled; + const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable; + + uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip + | Qt::TextSingleLine | Qt::AlignVCenter; + if (!styleHint(SH_UnderlineShortcut, menuItem, widget)) + text_flags |= Qt::TextHideMnemonic; + + QRect iconRect = + subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget); + QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); if ((option->state & State_Selected) && (option->state & State_Enabled)) QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); //todo: move the vertical spacing stuff into subElementRect const int vSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); - QStyleOptionMenuItem optionCheckBox; if (checkable){ - QRect checkBoxRect = optionMenuItem.rect; - checkBoxRect.setWidth(pixelMetric(PM_IndicatorWidth)); - checkBoxRect.setHeight(pixelMetric(PM_IndicatorHeight)); + QStyleOptionMenuItem optionCheckBox; optionCheckBox.QStyleOption::operator=(*menuItem); - optionCheckBox.rect = checkBoxRect; - const int moveByX = checkBoxRect.width()+vSpacing; + optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); + optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); + const int moveByX = optionCheckBox.rect.width()+vSpacing; if (optionMenuItem.direction == Qt::LeftToRight) { textRect.translate(moveByX,0); iconRect.translate(moveByX, 0); @@ -1732,20 +1729,18 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text))); painter->save(); painter->setOpacity(0.5); - QCommonStyle::drawItemText(painter, textRect, text_flags, + } + QCommonStyle::drawItemText(painter, textRect, text_flags, optionMenuItem.palette, enabled, optionMenuItem.text, QPalette::Text); + if (!enabled) painter->restore(); - } else { - QCommonStyle::drawItemText(painter, textRect, text_flags, - optionMenuItem.palette, enabled, - optionMenuItem.text, QPalette::Text); - } } break; + case CE_MenuEmptyArea: + break; #endif //QT_NO_MENU - case CE_MenuEmptyArea: #ifndef QT_NO_MENUBAR case CE_MenuBarEmptyArea: break; @@ -1775,19 +1770,19 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, case CE_HeaderEmptyArea: { QS60StylePrivate::SkinElementFlags adjFlags = flags; - QRect mtyRect = option->rect; + QRect emptyAreaRect = option->rect; if (option->state & QStyle::State_Horizontal) { - mtyRect.adjust(-2,-2,2,-2); + emptyAreaRect.adjust(-2,-2,2,-2); } else { if ( option->direction == Qt::LeftToRight ) { - mtyRect.adjust(-2,-2,0,2); + emptyAreaRect.adjust(-2,-2,0,2); adjFlags |= QS60StylePrivate::SF_PointWest; } else { - mtyRect.adjust(2,2,0,-2); + emptyAreaRect.adjust(2,2,0,-2); adjFlags |= QS60StylePrivate::SF_PointEast; } } - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, mtyRect, adjFlags); + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, emptyAreaRect, adjFlags); } break; case CE_Header: @@ -1807,7 +1802,19 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } } QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, mtyRect, adjFlags); - QCommonStyle::drawControl(element, header, painter, widget); + + QRegion clipRegion = painter->clipRegion(); + painter->setClipRect(option->rect); + drawControl(CE_HeaderSection, header, painter, widget); + QStyleOptionHeader subopt = *header; + subopt.rect = subElementRect(SE_HeaderLabel, header, widget); + if (subopt.rect.isValid()) + drawControl(CE_HeaderLabel, &subopt, painter, widget); + if (header->sortIndicator != QStyleOptionHeader::None) { + subopt.rect = subElementRect(SE_HeaderArrow, option, widget); + drawPrimitive(PE_IndicatorHeaderArrow, &subopt, painter, widget); + } + painter->setClipRegion(clipRegion); } break; #ifndef QT_NO_TOOLBAR @@ -1815,6 +1822,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (const QStyleOptionToolBar *toolBar = qstyleoption_cast(option)) { const QToolBar *tbWidget = qobject_cast(widget); + //toolbar within a toolbar, skip if (!tbWidget || (widget && qobject_cast(widget->parentWidget()))) break; @@ -1890,6 +1898,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti } break; case PE_IndicatorViewItemCheck: +#ifndef QT_NO_ITEMVIEWS if (const QListView *listItem = (qobject_cast(widget))) { if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast(option)) { const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator; @@ -1910,9 +1919,9 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti } } } +#endif //QT_NO_ITEMVIEWS break; - case PE_IndicatorRadioButton: - { + case PE_IndicatorRadioButton: { QRect buttonRect = option->rect; //there is empty (a. 33%) space in svg graphics for radiobutton const qreal reduceWidth = (qreal)buttonRect.width()/3.0; @@ -1935,8 +1944,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_PanelButtonCommand: case PE_PanelButtonTool: case PE_PanelButtonBevel: - case PE_FrameButtonBevel: - { + case PE_FrameButtonBevel: { const bool isPressed = option->state & QStyle::State_Sunken; const QS60StylePrivate::SkinElements skinElement = isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; @@ -1947,8 +1955,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_IndicatorArrowDown: case PE_IndicatorArrowLeft: case PE_IndicatorArrowRight: - case PE_IndicatorArrowUp: - { + case PE_IndicatorArrowUp: { QS60StyleEnums::SkinParts skinPart; if (element==PE_IndicatorArrowDown) skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowDown; @@ -2003,6 +2010,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti break; #endif //QT_NO_SPINBOX case PE_FrameFocusRect: +// Calendar widget and combox both do not use styled itemDelegate +#if not defined (QT_NO_CALENDARWIDGET) && not defined (QT_NO_COMBOBOX) if (!(widget && qobject_cast(widget->parent())) || qobject_cast(widget)) { // no focus selection for touch @@ -2031,13 +2040,19 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti painter->restore(); } } +#endif //!QT_NO_CALENDARWIDGET && !QT_NO_COMBOBOX break; case PE_Widget: - if (QS60StylePrivate::drawsOwnThemeBackground(widget) || - qobject_cast(widget) || - qobject_cast (widget)) { - QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu; - QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); + if (QS60StylePrivate::drawsOwnThemeBackground(widget) +#ifndef QT_NO_COMBOBOX + || qobject_cast(widget) +#endif //QT_NO_COMBOBOX +#ifndef QT_NO_MENU + || qobject_cast (widget) +#endif //QT_NO_MENU + ) { + QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu; + QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); } break; case PE_FrameWindow: @@ -2103,8 +2118,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti break; //disable frame in menu case PE_IndicatorBranch: - { #if defined(Q_WS_S60) + // 3.1 AVKON UI does not have tree view component, use common style for drawing there if (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1) { #else if (true) { @@ -2146,7 +2161,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); } } - } break; // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases @@ -2179,9 +2193,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti } } -/*! - \reimp -*/ +/*! \reimp */ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { int metricValue = QS60StylePrivate::pixelMetric(metric); @@ -2197,6 +2209,7 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const } return metricValue; } + /*! \reimp */ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const @@ -2219,22 +2232,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, } return sz; } + /*! \reimp */ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *hret) const { int retValue = -1; switch (sh) { - case SH_Table_GridLineColor: { - QColor lineColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0); - retValue = lineColor.rgb(); - } - break; - case SH_GroupBox_TextLabelColor: { - QColor groupBoxTxtColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0); - retValue = groupBoxTxtColor.rgb(); - } - break; + case SH_Table_GridLineColor: + retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgb(); + break; + case SH_GroupBox_TextLabelColor: + retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgb(); + break; case SH_ScrollBar_ScrollWhenPointerLeavesControl: retValue = true; break; @@ -2260,10 +2270,7 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w return retValue; } - -/*! - \reimp -*/ +/*! \reimp */ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget) const { QRect ret; @@ -2298,35 +2305,33 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple scrollbarOption->upsideDown); switch (scontrol) { - case SC_ScrollBarSubLine: // top/left button - case SC_ScrollBarAddLine: // bottom/right button - break; - case SC_ScrollBarSubPage: // between top/left button and slider - if (isHorizontal) - ret.setRect(0, 0, sliderstart, scrollBarRect.height()); - else - ret.setRect(0, 0, scrollBarRect.width(), sliderstart); - break; - case SC_ScrollBarAddPage: // between bottom/right button and slider - { + case SC_ScrollBarSubPage: // between top/left button and slider + if (isHorizontal) + ret.setRect(0, 0, sliderstart, scrollBarRect.height()); + else + ret.setRect(0, 0, scrollBarRect.width(), sliderstart); + break; + case SC_ScrollBarAddPage: { // between bottom/right button and slider const int addPageLength = sliderstart + sliderlen; if (isHorizontal) ret = scrollBarRect.adjusted(addPageLength, 0, 0, 0); else ret = scrollBarRect.adjusted(0, addPageLength, 0, 0); - } - break; - case SC_ScrollBarGroove: - ret = scrollBarRect; - break; - case SC_ScrollBarSlider: - if (scrollbarOption->orientation == Qt::Horizontal) - ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height()); - else - ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen); - break; - default: - break; + } + break; + case SC_ScrollBarGroove: + ret = scrollBarRect; + break; + case SC_ScrollBarSlider: + if (scrollbarOption->orientation == Qt::Horizontal) + ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height()); + else + ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen); + break; + case SC_ScrollBarSubLine: // top/left button + case SC_ScrollBarAddLine: // bottom/right button + default: + break; } ret = visualRect(scrollbarOption->direction, scrollBarRect, ret); } @@ -2344,37 +2349,37 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple const int y = frameThickness + spinbox->rect.y(); const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2*buttonSize.width(); - + switch (scontrol) { - case SC_SpinBoxUp: - if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) - return QRect(); - ret = QRect(x, y, buttonWidth, buttonSize.height()); - break; - case SC_SpinBoxDown: - if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) - return QRect(); - ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height()); - break; - case SC_SpinBoxEditField: - if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) - ret = QRect( - frameThickness, - frameThickness, - spinbox->rect.width() - 2*frameThickness, - spinbox->rect.height() - 2*frameThickness); - else - ret = QRect( - frameThickness, - frameThickness, - x - frameThickness, - spinbox->rect.height() - 2*frameThickness); - break; - case SC_SpinBoxFrame: - ret = spinbox->rect; - break; - default: - break; + case SC_SpinBoxUp: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + return QRect(); + ret = QRect(x, y, buttonWidth, buttonSize.height()); + break; + case SC_SpinBoxDown: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + return QRect(); + ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height()); + break; + case SC_SpinBoxEditField: + if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) + ret = QRect( + frameThickness, + frameThickness, + spinbox->rect.width() - 2*frameThickness, + spinbox->rect.height() - 2*frameThickness); + else + ret = QRect( + frameThickness, + frameThickness, + x - frameThickness, + spinbox->rect.height() - 2*frameThickness); + break; + case SC_SpinBoxFrame: + ret = spinbox->rect; + break; + default: + break; } ret = visualRect(spinbox->direction, spinbox->rect, ret); } @@ -2388,7 +2393,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple // lets use spinbox frame here as well, as no combobox specific value available. const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize); - int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth; + const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth; const int ypos = cmb->rect.y(); QSize buttonSize; @@ -2417,26 +2422,26 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) { ret = QCommonStyle::subControlRect(control, option, scontrol, widget); switch (scontrol) { - case SC_GroupBoxCheckBox: //fallthrough - 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); - const int tbHeight = textBox.height(); - ret.translate(0, -ret.y()); - // include title to within the groupBox frame - ret.setHeight(ret.height()+tbHeight); - if (widget && ret.bottom() > widget->rect().bottom()) - ret.setBottom(widget->rect().bottom()); - } - break; - default: - break; + case SC_GroupBoxCheckBox: //fallthrough + 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); + const int tbHeight = textBox.height(); + ret.translate(0, -ret.y()); + // include title to within the groupBox frame + ret.setHeight(ret.height()+tbHeight); + if (widget && ret.bottom() > widget->rect().bottom()) + ret.setBottom(widget->rect().bottom()); + } + break; + default: + break; } } break; @@ -2454,7 +2459,7 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con // in S60 the input text box doesn't start from line Edit's TL, but // a bit indented. QRect lineEditRect = opt->rect; - int adjustment = opt->rect.height()>>2; + const int adjustment = opt->rect.height()>>2; lineEditRect.adjust(adjustment,0,0,0); ret = lineEditRect; } @@ -2526,7 +2531,7 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } } else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(opt)) { const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; - int indicatorWidth = checkable ? + const int indicatorWidth = checkable ? pixelMetric(PM_ListViewIconSize, opt, widget) : pixelMetric(PM_SmallIconSize, opt, widget); ret = menuItem->rect; @@ -2546,11 +2551,10 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con // Make room for submenu indicator if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){ // submenu indicator is very small, so lets halve the rect - indicatorWidth = indicatorWidth >> 1; if (menuItem->direction == Qt::LeftToRight) - ret.adjust(0,0,-indicatorWidth,0); + ret.adjust(0,0,-(indicatorWidth >> 1),0); else - ret.adjust(indicatorWidth,0,0,0); + ret.adjust((indicatorWidth >> 1),0,0,0); } } } @@ -2579,7 +2583,9 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con // Move rect and make it slightly smaller, so that // a) highlight border does not cross the rect // b) in s60 list checkbox is smaller than normal checkbox - ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset, indicatorWidth-3, indicatorHeight-3); + //todo; magic three + ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset, + indicatorWidth-3, indicatorHeight-3); } else { ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset, indicatorWidth, indicatorHeight); @@ -2654,9 +2660,8 @@ void QS60Style::unpolish(QWidget *widget) #ifndef QT_NO_SCROLLBAR || qobject_cast(widget) #endif - ) { + ) widget->setAttribute(Qt::WA_OpaquePaintEvent); - } if (QS60StylePrivate::drawsOwnThemeBackground(widget)) { widget->setAttribute(Qt::WA_StyledBackground, false); @@ -2674,9 +2679,8 @@ void QS60Style::unpolish(QWidget *widget) widget->setAttribute(Qt::WA_StyledBackground, false); } - if (widget) { + if (widget) widget->setPalette(QPalette()); - } QCommonStyle::unpolish(widget); } @@ -2690,7 +2694,6 @@ void QS60Style::polish(QApplication *application) void QS60Style::unpolish(QApplication *application) { - Q_UNUSED(application) Q_D(QS60Style); const QPalette newPalette = QApplication::style()->standardPalette(); application->setPalette(newPalette); @@ -2717,7 +2720,9 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, QS60StyleEnums::SkinParts part; QS60StylePrivate::SkinElementFlags adjustedFlags; if (option) - adjustedFlags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; + adjustedFlags = (option->state & State_Enabled) ? + QS60StylePrivate::SF_StateEnabled : + QS60StylePrivate::SF_StateDisabled; switch(standardIcon) { case QStyle::SP_MessageBoxWarning: diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 55e80b9..dbb98c5 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -77,8 +77,10 @@ enum TSupportRelease { ES60_3_1 = 0x0001, ES60_3_2 = 0x0002, ES60_5_0 = 0x0004, + ES60_5_1 = 0x0008, + ES60_5_2 = 0x0010, // Add all new releases here - ES60_AllReleases = ES60_3_1 | ES60_3_2 | ES60_5_0 + ES60_AllReleases = ES60_3_1 | ES60_3_2 | ES60_5_0 | ES60_5_1 | ES60_5_2 }; typedef struct { @@ -89,17 +91,6 @@ typedef struct { int newMinorSkinId; } partMapEntry; -enum TFallbackMbmFile { - EAvkonMbm = 0, - ELastMbm -}; - -typedef struct { - const QS60StyleEnums::SkinParts partID; - TFallbackMbmFile fallbackFileID; //to avoid putting large char strings to table, lets only have a mapping value - int fallbackGraphicID; -} fallbackMapEntry; - class QS60StyleModeSpecifics { public: @@ -644,7 +635,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( Q_ASSERT(drawType != ENoDraw); const bool rotatedBy90or270 = (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)); - TSize targetSize = + const TSize targetSize = rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size); MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); @@ -719,7 +710,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFra const bool rotatedBy90or270 = (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)); - TSize targetSize = + const TSize targetSize = rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size); MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); @@ -901,7 +892,7 @@ void QS60StyleModeSpecifics::checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBit QFont QS60StylePrivate::s60Font_specific( QS60StyleEnums::FontCategories fontCategory, int pointSize) { - enum TAknFontCategory aknFontCategory = EAknFontCategoryUndefined; + TAknFontCategory aknFontCategory = EAknFontCategoryUndefined; switch (fontCategory) { case QS60StyleEnums::FC_Primary: aknFontCategory = EAknFontCategoryPrimary; @@ -1176,8 +1167,8 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap if (displayMode != aTrgBitmap->DisplayMode()) User::Leave(KErrArgument); - TSize trgSize = aTrgBitmap->SizeInPixels(); - TSize srcSize = aSrcBitmap->SizeInPixels(); + const TSize trgSize = aTrgBitmap->SizeInPixels(); + const TSize srcSize = aSrcBitmap->SizeInPixels(); // calculate the valid drawing area TRect drawRect = aTrgRect; @@ -1213,14 +1204,14 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap const TInt drawWidth = drawRect.Width(); const TInt drawHeight = drawRect.Height(); - TRect offsetRect(aTrgRect.iTl, drawRect.iTl); + const TRect offsetRect(aTrgRect.iTl, drawRect.iTl); const TInt yPosOffset = ySkip * offsetRect.Height(); const TInt xPosOffset = xSkip * offsetRect.Width(); if ((displayMode == EGray256) || (displayMode == EColor256)) { - TInt srcScanLen8 = CFbsBitmap::ScanLineLength(srcSize.iWidth, + const TInt srcScanLen8 = CFbsBitmap::ScanLineLength(srcSize.iWidth, displayMode); - TInt trgScanLen8 = CFbsBitmap::ScanLineLength(trgSize.iWidth, + const TInt trgScanLen8 = CFbsBitmap::ScanLineLength(trgSize.iWidth, displayMode); TUint8* trgAddress8 = reinterpret_cast (trgAddress); @@ -1230,7 +1221,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap trgAddress8 += trgScanLen8 * drawRect.iTl.iY + drawRect.iTl.iX; for (TInt y = 0; y < drawHeight; y++) { - TUint8* srcAddress8 = reinterpret_cast (srcAddress) + const TUint8* srcAddress8 = reinterpret_cast (srcAddress) + (srcScanLen8 * (yPos >> 8)); TInt xPos = xPosOffset; @@ -1244,9 +1235,9 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap trgAddress8 += trgScanLen8 - drawWidth; } } else if (displayMode == EColor4K || displayMode == EColor64K) { - TInt srcScanLen16 = CFbsBitmap::ScanLineLength(srcSize.iWidth, + const TInt srcScanLen16 = CFbsBitmap::ScanLineLength(srcSize.iWidth, displayMode) >>1; - TInt trgScanLen16 = CFbsBitmap::ScanLineLength(trgSize.iWidth, + const TInt trgScanLen16 = CFbsBitmap::ScanLineLength(trgSize.iWidth, displayMode) >>1; TUint16* trgAddress16 = reinterpret_cast (trgAddress); @@ -1256,7 +1247,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap trgAddress16 += trgScanLen16 * drawRect.iTl.iY + drawRect.iTl.iX; for (TInt y = 0; y < drawHeight; y++) { - TUint16* srcAddress16 = reinterpret_cast (srcAddress) + const TUint16* srcAddress16 = reinterpret_cast (srcAddress) + (srcScanLen16 * (yPos >> 8)); TInt xPos = xPosOffset; @@ -1270,9 +1261,9 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap trgAddress16 += trgScanLen16 - drawWidth; } } else if (displayMode == EColor16MU || displayMode == EColor16MA) { - TInt srcScanLen32 = CFbsBitmap::ScanLineLength(srcSize.iWidth, + const TInt srcScanLen32 = CFbsBitmap::ScanLineLength(srcSize.iWidth, displayMode) >>2; - TInt trgScanLen32 = CFbsBitmap::ScanLineLength(trgSize.iWidth, + const TInt trgScanLen32 = CFbsBitmap::ScanLineLength(trgSize.iWidth, displayMode) >>2; TUint32* trgAddress32 = reinterpret_cast (trgAddress); @@ -1282,7 +1273,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap trgAddress32 += trgScanLen32 * drawRect.iTl.iY + drawRect.iTl.iX; for (TInt y = 0; y < drawHeight; y++) { - TUint32* srcAddress32 = reinterpret_cast (srcAddress) + const TUint32* srcAddress32 = reinterpret_cast (srcAddress) + (srcScanLen32 * (yPos >> 8)); TInt xPos = xPosOffset; @@ -1302,8 +1293,8 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap QSize QS60StylePrivate::screenSize() { - TSize mySize = QS60Data::screenDevice()->SizeInPixels(); - return QSize(mySize.iWidth, mySize.iHeight); + const TSize screenSize = QS60Data::screenDevice()->SizeInPixels(); + return QSize(screenSize.iWidth, screenSize.iHeight); } void QS60StyleModeSpecifics::colorGroupAndIndex( -- cgit v0.12 From d53a3282598b7bfa5c48627ffa0b04763cccfdf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 4 Jun 2009 12:19:03 +0300 Subject: S60Style: Missing constant --- 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 7db0992..e7ba1bb 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -146,6 +146,7 @@ static const int frameElementsCount = int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); const int KNotFound = -909; +const double KTabFontMul = 0.72; QS60StylePrivate::~QS60StylePrivate() { -- cgit v0.12 From 422905e301394dfd23b59a09ac9a725803ddf4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 4 Jun 2009 14:41:07 +0300 Subject: S60Style: Buildbreak fix. Remove problematic #ifdef line. --- src/gui/styles/qs60style.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index e7ba1bb..83f5a6b 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2012,7 +2012,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif //QT_NO_SPINBOX case PE_FrameFocusRect: // Calendar widget and combox both do not use styled itemDelegate -#if not defined (QT_NO_CALENDARWIDGET) && not defined (QT_NO_COMBOBOX) if (!(widget && qobject_cast(widget->parent())) || qobject_cast(widget)) { // no focus selection for touch @@ -2041,7 +2040,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti painter->restore(); } } -#endif //!QT_NO_CALENDARWIDGET && !QT_NO_COMBOBOX break; case PE_Widget: if (QS60StylePrivate::drawsOwnThemeBackground(widget) -- cgit v0.12 From da7b5677262254aada234ac2c71d54d8fee3c711 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 4 Jun 2009 15:49:06 +0200 Subject: Implement a dummy QColorMap for Symbian. It seems that this class has been completely forgotten until now, but this never causes any problems because apparently no one uses it. Provide a quick little implementation to get things linking. Implementation brought to you courtesy of Qt/Mac. --- src/gui/painting/painting.pri | 3 +- src/gui/painting/qcolormap_s60.cpp | 112 +++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 src/gui/painting/qcolormap_s60.cpp diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 33d53e4..693e506 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -190,7 +190,8 @@ embedded { symbian { SOURCES += \ painting/qpaintdevice_s60.cpp \ - painting/qregion_s60.cpp + painting/qregion_s60.cpp \ + painting/qcolormap_s60.cpp } x11|embedded { diff --git a/src/gui/painting/qcolormap_s60.cpp b/src/gui/painting/qcolormap_s60.cpp new file mode 100644 index 0000000..c21eba9 --- /dev/null +++ b/src/gui/painting/qcolormap_s60.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcolormap.h" +#include "qcolor.h" + +QT_BEGIN_NAMESPACE + +class QColormapPrivate +{ +public: + inline QColormapPrivate() + : ref(1) + { } + + QAtomicInt ref; +}; +static QColormap *qt_symbian_color_map = 0; + +void QColormap::initialize() +{ + qt_symbian_color_map = new QColormap; +} + +void QColormap::cleanup() +{ + delete qt_symbian_color_map; + qt_symbian_color_map = 0; +} + +QColormap QColormap::instance(int) +{ + return *qt_symbian_color_map; +} + +QColormap::QColormap() : d(new QColormapPrivate) +{} + +QColormap::QColormap(const QColormap &colormap) :d (colormap.d) +{ d->ref.ref(); } + +QColormap::~QColormap() +{ + if (!d->ref.deref()) + delete d; +} + +QColormap::Mode QColormap::mode() const +{ return QColormap::Direct; } + +int QColormap::depth() const +{ + return 32; +} + +int QColormap::size() const +{ + return -1; +} + +uint QColormap::pixel(const QColor &color) const +{ return color.rgba(); } + +const QColor QColormap::colorAt(uint pixel) const +{ return QColor(pixel); } + +const QVector QColormap::colormap() const +{ return QVector(); } + +QColormap &QColormap::operator=(const QColormap &colormap) +{ qAtomicAssign(d, colormap.d); return *this; } + +QT_END_NAMESPACE + -- cgit v0.12 From 2b6dda723b168b3379684bc89b128ea1e792eddf Mon Sep 17 00:00:00 2001 From: Iain Date: Thu, 4 Jun 2009 17:18:59 +0200 Subject: Correctly scope local variables in switch statement (for GCC 4.3) --- src/corelib/tools/qlocale_symbian.cpp | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index b58a5d5..c11a7b9 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -272,11 +272,14 @@ static QString s60ToQtFormat(const QString &sys_fmt) switch (c.unicode()) { case 'F': + { // locale indep mode on locale_indep_ordering = true; break; + } case '/': + { // date sep 0-3 ++i; if (i >= sys_fmt.size()) @@ -291,8 +294,10 @@ static QString s60ToQtFormat(const QString &sys_fmt) result += QChar(val); } break; + } case 'D': + { if (!locale_indep_ordering) break; @@ -302,8 +307,10 @@ static QString s60ToQtFormat(const QString &sys_fmt) result += QLatin1Char('d'); break; + } case 'M': + { if (!locale_indep_ordering) break; @@ -320,8 +327,10 @@ static QString s60ToQtFormat(const QString &sys_fmt) } break; + } case 'N': + { n_mode = true; if (!locale_indep_ordering) @@ -333,8 +342,10 @@ static QString s60ToQtFormat(const QString &sys_fmt) result += QLatin1String("MMM"); break; + } case 'Y': + { if (!locale_indep_ordering) break; @@ -344,16 +355,20 @@ static QString s60ToQtFormat(const QString &sys_fmt) result += QLatin1String("yy"); break; + } case 'E': + { if (!abbrev_next) result += QLatin1String("dddd"); else result += QLatin1String("ddd"); break; + } case ':': + { // timesep 0-3 ++i; if (i >= sys_fmt.size()) @@ -369,47 +384,60 @@ static QString s60ToQtFormat(const QString &sys_fmt) } break; + } case 'J': + { if (tf == ETime24 && !abbrev_next) result += QLatin1String("hh"); else result += QLatin1Char('h'); break; + } case 'H': + { if (!abbrev_next) result += QLatin1String("hh"); else result += QLatin1Char('h'); break; + } case 'I': + { result += QLatin1Char('h'); break; + } case 'T': + { if (!abbrev_next) result += QLatin1String("mm"); else result += QLatin1Char('m'); break; + } case 'S': + { if (!abbrev_next) result += QLatin1String("ss"); else result += QLatin1Char('s'); break; + } case 'B': + { // only done for 12h clock if (tf == ETime24) break; + } // fallthru to A case 'A': { @@ -445,6 +473,7 @@ static QString s60ToQtFormat(const QString &sys_fmt) break; case 'C': + { // six digits in s60, three digits in qt if (!abbrev_next) { result += QLatin1String("zzz"); @@ -468,6 +497,7 @@ static QString s60ToQtFormat(const QString &sys_fmt) } } break; + } // these cases fallthru case '1': @@ -475,6 +505,7 @@ static QString s60ToQtFormat(const QString &sys_fmt) case '3': case '4': case '5': + { // shouldn't parse these with %F if (locale_indep_ordering) @@ -503,17 +534,24 @@ static QString s60ToQtFormat(const QString &sys_fmt) result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]); break; + } case '%': // fallthru percent + { // any junk gets copied as is + } default: + { result += c; break; + } case 'Z': // Qt doesn't support these :( case 'X': case 'W': + { break; + } } } else { // double any single quotes, don't begin escape -- cgit v0.12 From 7b9b55e3a0deb69a6ff04ee9b76840a5f8d11545 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 4 Jun 2009 18:31:49 +0200 Subject: Fix up the display mode conversion function. Few things here: - Add support for EGray2 and EGray256 - Change the define to disable EColor16MAP for old SDKs - Make the default case return Invalid instead of a fatal error - Fix indentation, tabs -> spaces --- src/gui/kernel/qt_s60_p.h | 65 +++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index aed8241..d2fa5da 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -242,37 +242,40 @@ static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec) static inline QImage::Format qt_TDisplayMode2Format(TDisplayMode mode) { - QImage::Format format; - switch(mode) { - case EColor256: - // TODO: is the correct? - format = QImage::Format_Indexed8; - break; - case EColor4K: - format = QImage::Format_RGB444; - break; - case EColor64K: - format = QImage::Format_RGB16; - break; - case EColor16M: - format = QImage::Format_RGB666; - break; - case EColor16MU: - format = QImage::Format_RGB32; - break; - case EColor16MA: - format = QImage::Format_ARGB32; - break; -#ifdef __S60_50__ - case EColor16MAP: - format = QImage::Format_ARGB32_Premultiplied; - break; -#endif - default: - qFatal("Screen format not supported"); - break; - } - return format; + QImage::Format format; + switch(mode) { + case EGray2: + format = QImage::Format_MonoLSB; + break; + case EColor256: + case EGray256: + format = QImage::Format_Indexed8; + break; + case EColor4K: + format = QImage::Format_RGB444; + break; + case EColor64K: + format = QImage::Format_RGB16; + break; + case EColor16M: + format = QImage::Format_RGB666; + break; + case EColor16MU: + format = QImage::Format_RGB32; + break; + case EColor16MA: + format = QImage::Format_ARGB32; + break; +#if !defined(__SERIES60_31__) && !defined(__S60_32__) + case EColor16MAP: + format = QImage::Format_ARGB32_Premultiplied; + break; +#endif + default: + format = QImage::Format_Invalid; + break; + } + return format; } -- cgit v0.12 From 9196781f93fd60e869fededc83e32168868632cb Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 4 Jun 2009 23:26:40 +0200 Subject: Loading fonts from other /resource/fonts folders than the one on Z: Order is 'soft to hard' W:, X: ... A:, Z: Duplicated font file names are ignored. That should imitate the font loading behaviour in the fbSrv. --- src/gui/text/qfontdatabase_s60.cpp | 44 ++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index ab9291f..416c3d1 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -55,6 +55,39 @@ QT_BEGIN_NAMESPACE +QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters, + QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort, + bool uniqueFileNames = true) +{ + QFileInfoList result; + + // Prepare a 'soft to hard' drive list: W:, X: ... A:, Z: + QStringList driveStrings; + foreach (const QFileInfo &drive, QDir::drives()) + driveStrings.append(drive.absolutePath()); + driveStrings.sort(); + const QString zDriveString("Z:/"); + driveStrings.removeAll(zDriveString); + driveStrings.prepend(zDriveString); + + QStringList uniqueFileNameList; + for (int i = driveStrings.count() - 1; i >= 0; --i) { + const QDir dirOnDrive(driveStrings.at(i) + path); + const QFileInfoList entriesOnDrive = dirOnDrive.entryInfoList(nameFilters, filters, sort); + if (uniqueFileNames) { + foreach(const QFileInfo &entry, entriesOnDrive) { + if (!uniqueFileNameList.contains(entry.fileName())) { + uniqueFileNameList.append(entry.fileName()); + result.append(entry); + } + } + } else { + result.append(entriesOnDrive); + } + } + return result; +} + #if defined(QT_NO_FREETYPE) class QFontDatabaseS60StoreImplementation : public QFontDatabaseS60Store { @@ -77,10 +110,13 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation() m_store = CFontStore::NewL(m_heap); m_rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E)); m_store->InstallRasterizerL(m_rasterizer); - QDir dir(QDesktopServices::storageLocation(QDesktopServices::FontsLocation)); - dir.setNameFilters(QStringList() << QLatin1String("*.ttf") << QLatin1String("*.ccc")); - for (int i = 0; i < int(dir.count()); ++i) { - const QString fontFile = QDir::toNativeSeparators(dir.absoluteFilePath(dir[i])); + + QStringList filters; + filters.append(QString::fromLatin1("*.ttf")); + filters.append(QString::fromLatin1("*.ccc")); + const QFileInfoList fontFiles = alternativeFilePaths(QString::fromLatin1("resource\\Fonts"), filters); + foreach (const QFileInfo &fontFileInfo, fontFiles) { + const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath()); m_store->AddFileL(qt_QString2TPtrC(fontFile)); } } -- cgit v0.12 From 958b66dd60aac48909a5ba32282e088e68d9a9c7 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 5 Jun 2009 11:05:01 +1000 Subject: Set UID for QtScriptTools --- src/scripttools/scripttools.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scripttools/scripttools.pro b/src/scripttools/scripttools.pro index faf0936a..5878db2 100644 --- a/src/scripttools/scripttools.pro +++ b/src/scripttools/scripttools.pro @@ -10,3 +10,5 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtScript include(../qbase.pri) include(debugging/debugging.pri) + +symbian:TARGET.UID3=0x2001E625 -- cgit v0.12 From 04b4e2254e59fcb8776044d5d627e7f0d8daeacf Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 5 Jun 2009 10:14:12 +0200 Subject: Turned off input methods on X11 when using certain hints. If any of those hints are present, complex input is not possible, so input methods should be turned off on X11. --- src/gui/inputmethod/qximinputcontext_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp index c320fb4..60ea15b 100644 --- a/src/gui/inputmethod/qximinputcontext_x11.cpp +++ b/src/gui/inputmethod/qximinputcontext_x11.cpp @@ -610,7 +610,7 @@ void QXIMInputContext::setFocusWidget(QWidget *w) QInputContext::setFocusWidget(w); - if (!w) + if (!w || w->inputMethodHints() & Qt::ImhExclusiveInputMask) return; ICData *data = ximData.value(w->effectiveWinId()); -- cgit v0.12 From fd6e80b7cc36ebc111d062301ba8bfca5e6e6f50 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 4 Jun 2009 18:41:47 +0200 Subject: Introduce Symbian CFbsBitmap <-> QPixmap conversion functions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce functions for converting to and from a CFbsBitmap on Symbian. Currently these functions unfortunately have to copy the data to the internal QImage stored in the raster pixmap data backend :( Hopefully we can improve this with a native Symbian pixmap backend in the future. The autotest generates both small and large CFbsBitmaps of different formats and then verifies that the color makes it into the QPixmap. Currently the indexed image formats don't seem to work, but this is most likely because we don't set a palette for them. The semi-trans bitmaps seem to work fine (verified visually), but the current QCOMPARE doesn't consider the fact that the color was alpha blended. Reviewed-by: Sami Merilä --- src/gui/image/qpixmap.h | 9 +++ src/gui/image/qpixmap_s60.cpp | 140 +++++++++++++++++++++++++++++++++++-- tests/auto/qpixmap/qpixmap.pro | 19 ++--- tests/auto/qpixmap/tst_qpixmap.cpp | 101 ++++++++++++++++++++++++++ 4 files changed, 251 insertions(+), 18 deletions(-) diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 1863273..9ef5347 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -62,6 +62,10 @@ class QX11Info; class QPixmapData; +#if defined(Q_OS_SYMBIAN) +class CFbsBitmap; +#endif + class Q_GUI_EXPORT QPixmap : public QPaintDevice { public: @@ -152,6 +156,11 @@ public: static QPixmap fromMacCGImageRef(CGImageRef image); #endif +#if defined(Q_OS_SYMBIAN) + CFbsBitmap *toSymbianCFbsBitmap() const; + static QPixmap fromSymbianCFbsBitmap(CFbsBitmap *bitmap); +#endif + inline QPixmap copy(int x, int y, int width, int height) const; QPixmap copy(const QRect &rect = QRect()) const; diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 52e2fe7..879c980 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -91,14 +91,142 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h ) return QPixmap(); } - QImage::Format format = qt_TDisplayMode2Format( displayMode ); - int bytesPerLine = CFbsBitmap::ScanLineLength(temporary->SizeInPixels().iWidth,displayMode); - temporary->LockHeap(); - QImage image = QImage((uchar*)temporary->DataAddress(), srcRect.Width(), srcRect.Height(), bytesPerLine, format); - QPixmap pixmap = QPixmap::fromImage(image.copy()); - temporary->UnlockHeap(); + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(temporary); CBase::Delete(temporary); return pixmap; +} + +/*! +\since 4.6 + +Returns a \c CFbsBitmap that is equivalent to the QPixmap by copying the data. + +It is the caller's responsibility to delete the \c CFbsBitmap after use. + +\warning This function is only available on Symbian OS. + +\sa fromSymbianCFbsBitmap() +*/ + +CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const +{ + if (isNull()) + return 0; + + TDisplayMode mode; + const QImage img = toImage(); + QImage::Format destFormat = img.format(); + switch (img.format()) { + case QImage::Format_Mono: + destFormat = QImage::Format_MonoLSB; + // Fall through intended + case QImage::Format_MonoLSB: + mode = EGray2; + break; + case QImage::Format_Indexed8: + if (img.isGrayscale()) + mode = EGray256; + else + mode = EColor256; + break; + case QImage::Format_RGB32: + mode = EColor16MU; + break; + case QImage::Format_ARGB6666_Premultiplied: + case QImage::Format_ARGB8565_Premultiplied: + case QImage::Format_ARGB8555_Premultiplied: + destFormat = QImage::Format_ARGB32_Premultiplied; + // Fall through intended + case QImage::Format_ARGB32_Premultiplied: +#if !defined(__SERIES60_31__) && !defined(__S60_32__) + // ### TODO: Add runtime detection as well? + mode = EColor16MAP: + break; +#endif + destFormat = QImage::Format_ARGB32; + // Fall through intended + case QImage::Format_ARGB32: + mode = EColor16MA; + break; + case QImage::Format_RGB555: + destFormat = QImage::Format_RGB16; + // Fall through intended + case QImage::Format_RGB16: + mode = EColor64K; + break; + case QImage::Format_RGB666: + destFormat = QImage::Format_RGB888; + // Fall through intended + case QImage::Format_RGB888: + mode = EColor16M; + break; + case QImage::Format_RGB444: + mode = EColor4K; + break; + case QImage::Format_Invalid: + return 0; + default: + qWarning("Image format not supported: %d", img.format()); + return 0; + } + + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); + TSize size(width(), height()); + if (bitmap->Create(size, mode) != KErrNone) { + CBase::Delete(bitmap); + return 0; + } + + const QImage converted = img.convertToFormat(destFormat); + bitmap->LockHeap(); + const uchar *sptr = converted.bits(); + uchar *dptr = (uchar*)bitmap->DataAddress(); + Mem::Copy(dptr, sptr, converted.numBytes()); + bitmap->UnlockHeap(); + return bitmap; } + +/*! +\since 4.6 + +Returns a QPixmap that is equivalent to the \c CFbsBitmap by copying the data. +If the CFbsBitmap is not valid or is compressed in memory, this function will +return a null QPixmap. + +\warning This function is only available on Symbian OS. + +\sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} +*/ + +QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) +{ + int width = bitmap->SizeInPixels().iWidth; + int height = bitmap->SizeInPixels().iHeight; + + if (!bitmap || width <= 0 || height <= 0 || bitmap->IsCompressedInRAM()) + return QPixmap(); + + TDisplayMode displayMode = bitmap->DisplayMode(); + QImage::Format format = qt_TDisplayMode2Format(displayMode); + int bytesPerLine = CFbsBitmap::ScanLineLength(width, displayMode); + bitmap->LockHeap(); + QImage image = QImage((const uchar*)bitmap->DataAddress(), width, height, bytesPerLine, format); + if (displayMode == EGray2) { + image.setNumColors(2); + image.setColor(0, QColor(Qt::color0).rgba()); + image.setColor(1, QColor(Qt::color1).rgba()); + } else if (displayMode == EGray256) { + for (int i=0; i < 256; ++i) + image.setColor(i, qRgb(i, i, i)); + }else if (displayMode == EColor256) { + const TColor256Util *palette = TColor256Util::Default(); + for (int i=0; i < 256; ++i) + image.setColor(i, (QRgb)(palette->Color256(i).Value())); + } + QPixmap pixmap = QPixmap::fromImage(image.copy()); + bitmap->UnlockHeap(); + return pixmap; +} + QT_END_NAMESPACE diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro index aa767aa..c992f6e 100644 --- a/tests/auto/qpixmap/qpixmap.pro +++ b/tests/auto/qpixmap/qpixmap.pro @@ -1,26 +1,21 @@ load(qttest_p4) SOURCES += tst_qpixmap.cpp contains(QT_CONFIG, qt3support): QT += qt3support -wince*: { +wince*|symbian*: { task31722_0.sources = convertFromImage/task31722_0/* task31722_0.path = convertFromImage/task31722_0 task31722_1.sources = convertFromImage/task31722_1/* task31722_1.path = convertFromImage/task31722_1 DEPLOYMENT += task31722_0 task31722_1 - DEFINES += SRCDIR=\\\".\\\" } -symbian*:{ - task31722_0.sources = convertFromImage/task31722_0/* - task31722_0.path = convertFromImage/task31722_0 - task31722_1.sources = convertFromImage/task31722_1/* - task31722_1.path = convertFromImage/task31722_1 - DEPLOYMENT += task31722_0 task31722_1 + +wince*: { + DEFINES += SRCDIR=\\\".\\\" +} symbian*: { DEPLOYMENT_PLUGIN += qmng -} -else { + LIBS += -lfbscli.lib -lbitgdi.lib -lgdi.lib +} else { DEFINES += SRCDIR=\\\"$$PWD\\\" win32:LIBS += -lgdi32 -luser32 } - - diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 493333b..9f73e34 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -58,6 +58,14 @@ #include #endif +#ifdef Q_OS_SYMBIAN +#include +#include +#include +#include +#endif + + //TESTED_CLASS= //TESTED_FILES= #if defined(Q_OS_SYMBIAN) @@ -120,6 +128,11 @@ private slots: void fromWinHBITMAP(); #endif +#if defined(Q_WS_S60) + void fromSymbianCFbsBitmap_data(); + void fromSymbianCFbsBitmap(); +#endif + void onlyNullPixmapsOutsideGuiThread(); void refUnref(); @@ -798,6 +811,94 @@ void tst_QPixmap::fromWinHBITMAP() #endif +#if defined(Q_WS_S60) +Q_DECLARE_METATYPE(TDisplayMode) + +void tst_QPixmap::fromSymbianCFbsBitmap_data() +{ + QTest::addColumn("format"); + QTest::addColumn("width"); + QTest::addColumn("height"); + QTest::addColumn("color"); + + const int smallWidth = 20; + const int smallHeight = 20; + const int largeWidth = 240; + const int largeHeight = 320; + + // Indexed Color Formats - Disabled since images seem to be blank -> no palette? +// QTest::newRow("EGray2 small") << EGray2 << smallWidth << smallHeight << QColor(Qt::black); +// QTest::newRow("EGray2 big") << EGray2 << largeWidth << largeHeight << QColor(Qt::black); +// QTest::newRow("EGray256 small") << EGray256 << smallWidth << smallHeight << QColor(Qt::blue); +// QTest::newRow("EGray256 big") << EGray256 << largeWidth << largeHeight << QColor(Qt::blue); +// QTest::newRow("EColor256 small") << EColor256 << smallWidth << smallHeight << QColor(Qt::red); +// QTest::newRow("EColor256 big") << EColor256 << largeWidth << largeHeight << QColor(Qt::red); + + // Direct Color Formats + QTest::newRow("EColor4K small") << EColor4K << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor4K big") << EColor4K << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor64K small") << EColor64K << smallWidth << smallHeight << QColor(Qt::green); + QTest::newRow("EColor64K big") << EColor64K << largeWidth << largeHeight << QColor(Qt::green); + QTest::newRow("EColor16MU small") << EColor16MU << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor16MU big") << EColor16MU << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor16MA small opaque") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0); + QTest::newRow("EColor16MA big opaque") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0); + + // Semi-transparent Colors - Disabled for now, since the QCOMPARE fails, but visually confirmed to work +// QTest::newRow("EColor16MA small semi") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 127); +// QTest::newRow("EColor16MA big semi") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 127); +// QTest::newRow("EColor16MA small trans") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 0); +// QTest::newRow("EColor16MA big trans") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 0); + +#if !defined(__SERIES60_31__) && !defined(__S60_32__) + QTest::newRow("EColor16MAP small") << EColor16MAP << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor16MAP big") << EColor16MAP << largeWidth << largeHeight << QColor(Qt::red); +#endif +} + +void tst_QPixmap::fromSymbianCFbsBitmap() +{ + QFETCH(TDisplayMode, format); + QFETCH(int, width); + QFETCH(int, height); + QFETCH(QColor, color); + int expectedDepth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(format); + + CFbsBitmap *nativeBitmap = 0; + CFbsBitmapDevice *bitmapDevice = 0; + CBitmapContext *bitmapContext = 0; + + nativeBitmap = new (ELeave) CFbsBitmap(); + TInt err = nativeBitmap->Create(TSize(width, height), format); + CleanupStack::PushL(nativeBitmap); + QVERIFY(err == KErrNone); + bitmapDevice = CFbsBitmapDevice::NewL(nativeBitmap); + CleanupStack::PushL(bitmapDevice); + + err = bitmapDevice->CreateBitmapContext(bitmapContext); + CleanupStack::PushL(bitmapContext); + QVERIFY(err == KErrNone); + TRgb symbianColor = TRgb(color.red(), color.green(), color.blue(), color.alpha()); + bitmapContext->SetBrushColor(symbianColor); + bitmapContext->Clear(); + + __UHEAP_MARK; + { // Test the normal case + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(nativeBitmap); +// QCOMPARE(pixmap.depth(), expectedDepth); // Depth is not preserved now + QCOMPARE(pixmap.width(), width); + QCOMPARE(pixmap.height(), height); + QImage image = pixmap.toImage(); + + QColor actualColor(image.pixel(1, 1)); + QCOMPARE(actualColor, color); + } + __UHEAP_MARKEND; + + CleanupStack::PopAndDestroy(3); +} +#endif + void tst_QPixmap::onlyNullPixmapsOutsideGuiThread() { #if !defined(Q_WS_WIN) -- cgit v0.12 From ec4fd914b3b34ae14b996fd525f3f6f9b68ddd9e Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 5 Jun 2009 10:30:46 +0200 Subject: Make QColormap::instance() not crash. This doesn't really need a static instance lying around and this current implementation crashes since we never call the constructor. Just recreate it on the fly when instance() is called which apparently is never. --- src/gui/painting/qcolormap_s60.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/gui/painting/qcolormap_s60.cpp b/src/gui/painting/qcolormap_s60.cpp index c21eba9..1b58598 100644 --- a/src/gui/painting/qcolormap_s60.cpp +++ b/src/gui/painting/qcolormap_s60.cpp @@ -53,22 +53,18 @@ public: QAtomicInt ref; }; -static QColormap *qt_symbian_color_map = 0; void QColormap::initialize() { - qt_symbian_color_map = new QColormap; } void QColormap::cleanup() { - delete qt_symbian_color_map; - qt_symbian_color_map = 0; } QColormap QColormap::instance(int) { - return *qt_symbian_color_map; + return QColormap(); } QColormap::QColormap() : d(new QColormapPrivate) -- cgit v0.12 From 800b7e087f90e6253e4c496e816721c63b366e02 Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Fri, 5 Jun 2009 11:12:04 +0200 Subject: Enabling QGraphicsTextItem to handle input method events. On S60 one should get virtual keyboard. --- src/gui/graphicsview/qgraphicsitem.cpp | 129 ++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index e8ace65..ed1891c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -515,6 +515,7 @@ #include #include #include +#include #include #include @@ -7609,7 +7610,7 @@ class QGraphicsTextItemPrivate { public: QGraphicsTextItemPrivate() - : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false) + : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0) { } mutable QTextControl *control; @@ -7630,6 +7631,8 @@ public: bool useDefaultImpl; bool tabChangesFocus; + uint clickCausedFocus : 1; + QGraphicsTextItem *qq; }; @@ -7956,7 +7959,13 @@ void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) dd->useDefaultImpl = false; return; } + dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -7968,7 +7977,13 @@ void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QGraphicsItem::mouseMoveEvent(event); return; } + dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -7988,7 +8003,23 @@ void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } return; } + + if (event->button() == Qt::LeftButton && qApp->autoSipEnabled() + && (!dd->clickCausedFocus || qApp->autoSipOnMouseFocus())) { + QEvent _event(QEvent::RequestSoftwareInputPanel); + QApplication::sendEvent(event->widget(), &_event); + } else { + QGraphicsItem::mouseReleaseEvent(event); + } + dd->clickCausedFocus = 0; + dd->sendControlEvent(event); + + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8007,6 +8038,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) } dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8015,6 +8051,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8023,6 +8064,18 @@ void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void QGraphicsTextItem::keyPressEvent(QKeyEvent *event) { dd->sendControlEvent(event); + QList views = scene()->views(); + for (int i = 0; i < views.size(); ++i) { + QGraphicsView *view = views.at(i); + Q_ASSERT(view->viewport()); + if(view->viewport()->hasFocus()) { + QInputContext *qic = view->viewport()->inputContext(); + if(qic){ + qic->update(); + } + break; + } + } } /*! @@ -8031,6 +8084,18 @@ void QGraphicsTextItem::keyPressEvent(QKeyEvent *event) void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event) { dd->sendControlEvent(event); + QList views = scene()->views(); + for (int i = 0; i < views.size(); ++i) { + QGraphicsView *view = views.at(i); + Q_ASSERT(view->viewport()); + if(view->viewport()->hasFocus()) { + QInputContext *qic = view->viewport()->inputContext(); + if(qic){ + qic->update(); + } + break; + } + } } /*! @@ -8039,7 +8104,22 @@ void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event) void QGraphicsTextItem::focusInEvent(QFocusEvent *event) { dd->sendControlEvent(event); + if (event->reason() == Qt::MouseFocusReason) { + dd->clickCausedFocus = 1; + } update(); + QList views = scene()->views(); + for (int i = 0; i < views.size(); ++i) { + QGraphicsView *view = views.at(i); + Q_ASSERT(view->viewport()); + if(view->viewport()->hasFocus()) { + QInputContext *qic = view->viewport()->inputContext(); + if(qic){ + qic->reset(); + } + break; + } + } } /*! @@ -8049,6 +8129,18 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event) { dd->sendControlEvent(event); update(); + QList views = scene()->views(); + for (int i = 0; i < views.size(); ++i) { + QGraphicsView *view = views.at(i); + Q_ASSERT(view->viewport()); + if(view->viewport()->hasFocus()) { + QInputContext *qic = view->viewport()->inputContext(); + if(qic){ + qic->reset(); + } + break; + } + } } /*! @@ -8057,6 +8149,11 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event) void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8065,6 +8162,11 @@ void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8073,6 +8175,11 @@ void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8081,6 +8188,11 @@ void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8097,6 +8209,11 @@ void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event) void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8105,6 +8222,11 @@ void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! @@ -8113,6 +8235,11 @@ void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { dd->sendControlEvent(event); + Q_ASSERT(event->widget()); + QInputContext *qic = event->widget()->inputContext(); + if(qic) { + qic->update(); + } } /*! -- cgit v0.12