From b22b06debf9d7e964244a0a613354be0ea9e07b7 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Fri, 22 Jan 2010 11:08:08 +0200 Subject: Fix for symbian dialog background transparency. If Avkon components support transparency then dialog background is transparent enabling rounded corners. Reviewed-by: Sami Merila --- mkspecs/common/symbian/symbian.conf | 2 +- src/gui/dialogs/qdialog.cpp | 16 ++++++++++++++++ src/gui/kernel/qt_s60_p.h | 31 +++++++++++++++++++++++++++++++ src/gui/kernel/qwidget.cpp | 8 ++++++++ src/gui/styles/qs60style.cpp | 12 +++++++----- src/gui/styles/qs60style_s60.cpp | 1 - 6 files changed, 63 insertions(+), 7 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 0f06b92..a2933e9 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -65,7 +65,7 @@ QMAKE_LINK_OBJECT_SCRIPT= QMAKE_LIBS = -llibc -llibm -leuser -llibdl QMAKE_LIBS_CORE = $$QMAKE_LIBS -llibpthread -lefsrv -QMAKE_LIBS_GUI = $$QMAKE_LIBS_CORE -lfbscli -lbitgdi -lhal -lgdi -lws32 -lapgrfx -lcone -leikcore -lmediaclientaudio -leikcoctl -leiksrv -lapparc +QMAKE_LIBS_GUI = $$QMAKE_LIBS_CORE -lfbscli -lbitgdi -lhal -lgdi -lws32 -lapgrfx -lcone -leikcore -lmediaclientaudio -leikcoctl -leiksrv -lapparc -lcentralrepository QMAKE_LIBS_NETWORK = QMAKE_LIBS_EGL = -llibEGL QMAKE_LIBS_OPENGL = diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index 3650051..9e11ebf 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -265,6 +265,14 @@ QDialog::QDialog(QWidget *parent, Qt::WindowFlags f) if (!qt_wince_is_smartphone()) setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint)); #endif + +#ifdef Q_WS_S60 + if (S60->avkonComponentsSupportTransparency()) { + bool noSystemBackground = testAttribute(Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_TranslucentBackground); // also sets WA_NoSystemBackground + setAttribute(Qt::WA_NoSystemBackground, noSystemBackground); // restore system background attribute + } +#endif } #ifdef QT3_SUPPORT @@ -294,6 +302,14 @@ QDialog::QDialog(QDialogPrivate &dd, QWidget *parent, Qt::WindowFlags f) if (!qt_wince_is_smartphone()) setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint)); #endif + +#ifdef Q_WS_S60 + if (S60->avkonComponentsSupportTransparency()) { + bool noSystemBackground = testAttribute(Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_TranslucentBackground); // also sets WA_NoSystemBackground + setAttribute(Qt::WA_NoSystemBackground, noSystemBackground); // restore system background attribute + } +#endif } /*! diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index b417065..2c733b9 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -74,6 +74,7 @@ #include // CAknContextPane #include // CEikStatusPane #include // MAknFadedComponent and TAknPopupFader +#include #endif QT_BEGIN_NAMESPACE @@ -133,8 +134,14 @@ public: static inline CAknTitlePane* titlePane(); static inline CAknContextPane* contextPane(); static inline CEikButtonGroupContainer* buttonGroupContainer(); + static inline bool avkonComponentsSupportTransparency(); TTrapHandler *s60InstalledTrapHandler; + +private: + + bool transparencyChecked; + bool transparencyEnabled; #endif }; @@ -305,6 +312,30 @@ inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer() { return CEikonEnv::Static()->AppUiFactory()->Cba(); } + +inline bool QS60Data::avkonComponentsSupportTransparency() +{ + if(!S60->transparencyChecked) { + S60->transparencyChecked = true; + S60->transparencyEnabled = false; + + TUid KCRUidAvkon = { 0x101F876E }; + TUint32 KAknAvkonTransparencyEnabled = 0x0000000D; + + CRepository* repository = 0; + TRAPD(err, repository = CRepository::NewL(KCRUidAvkon)); + + if(err == KErrNone) { + TInt value = 0; + err = repository->Get(KAknAvkonTransparencyEnabled, value); + if(err == KErrNone) { + S60->transparencyEnabled = (value==1) ? true : false; + } + } + } + + return S60->transparencyEnabled; +} #endif // Q_WS_S60 static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 81a9a80..542da5e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2026,6 +2026,14 @@ void QWidgetPrivate::updateIsOpaque() } #endif +#ifdef Q_WS_S60 + if (q->windowType() == Qt::Dialog && q->testAttribute(Qt::WA_TranslucentBackground) + && S60->avkonComponentsSupportTransparency()) { + setOpaque(false); + return; + } +#endif + if (q->testAttribute(Qt::WA_OpaquePaintEvent) || q->testAttribute(Qt::WA_PaintOnScreen)) { setOpaque(true); return; diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index ca0b8c7..100303e 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -3056,11 +3056,13 @@ bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush const QPaintDevice *target = painter->device(); if (target->devType() == QInternal::Widget) { const QWidget *widget = static_cast(target); - const QVector &rects = rgn.rects(); - for (int i = 0; i < rects.size(); ++i) { - const QRect rect(rects.at(i)); - painter->drawPixmap(rect.topLeft(), backgroundTexture, - rect.translated(qt_s60_fill_background_offset(widget))); + if (!widget->testAttribute(Qt::WA_TranslucentBackground)) { + const QVector &rects = rgn.rects(); + for (int i = 0; i < rects.size(); ++i) { + const QRect rect(rects.at(i)); + painter->drawPixmap(rect.topLeft(), backgroundTexture, + rect.translated(qt_s60_fill_background_offset(widget))); + } } } return true; diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index be61073..d03574f 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -731,7 +731,6 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(QS60StylePrivate::SkinFr MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); QPixmap result; -// QS60WindowSurface::unlockBitmapHeap(); static const TDisplayMode displayMode = S60->supportsPremultipliedAlpha ? Q_SYMBIAN_ECOLOR16MAP : EColor16MA; static const TInt drawParam = S60->supportsPremultipliedAlpha ? KAknsDrawParamDefault : KAknsDrawParamNoClearUnderImage|KAknsDrawParamRGBOnly; -- cgit v0.12