diff options
author | Sami Merilä <sami.merila@nokia.com> | 2009-05-20 10:52:21 (GMT) |
---|---|---|
committer | Sami Merilä <sami.merila@nokia.com> | 2009-05-20 10:52:21 (GMT) |
commit | 335cdc13bd19ea2bef3b2ecdf0015f452b576a53 (patch) | |
tree | 9d31990a335a12285499d6fb9ee10de5debec256 /src/gui/styles | |
parent | 3c988e8cdf2fff3782ac13ead72341dd0f6383a7 (diff) | |
download | Qt-335cdc13bd19ea2bef3b2ecdf0015f452b576a53.zip Qt-335cdc13bd19ea2bef3b2ecdf0015f452b576a53.tar.gz Qt-335cdc13bd19ea2bef3b2ecdf0015f452b576a53.tar.bz2 |
S60Style: Set theme palette to widgets once theme changes.
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qs60style.cpp | 93 | ||||
-rw-r--r-- | src/gui/styles/qs60style_p.h | 1 | ||||
-rw-r--r-- | src/gui/styles/qs60style_symbian.cpp | 1 |
3 files changed, 53 insertions, 42 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index bf73494..f3a5d97 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -541,46 +541,10 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const app->setPalette(widgetPalette); } -void QS60StylePrivate::setBackgroundTexture(QApplication *app) const -{ - if (!app) - return; - QPalette applicationPalette = app->palette(); - applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); - app->setPalette(applicationPalette); -} - -void QS60Style::polish(QApplication *application) +void QS60StylePrivate::setThemePalette(QWidget *widget) const { - Q_D(const QS60Style); - originalPalette = application->palette(); - d->setThemePalette(application); -} - -void QS60Style::polish(QWidget *widget) -{ - Q_D(const QS60Style); - QCommonStyle::polish(widget); - - if (!widget) + if(!widget) return; - - if (QS60StylePrivate::isSkinnableDialog(widget)) { - widget->setAttribute(Qt::WA_StyledBackground); - } else if (false -#ifndef QT_NO_MENU - || qobject_cast<const QMenu *> (widget) -#endif // QT_NO_MENU - ) { - widget->setAttribute(Qt::WA_StyledBackground); - } else if (false -#ifndef QT_NO_COMBOBOX - || qobject_cast<const QComboBoxListView *>(widget) -#endif //QT_NO_COMBOBOX - ) { - widget->setAttribute(Qt::WA_StyledBackground); - } - QPalette widgetPalette = widget->palette(); // widget specific colors and fonts @@ -589,16 +553,19 @@ void QS60Style::polish(QWidget *widget) QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); QApplication::setPalette(widgetPalette, "QSlider"); } else if (qobject_cast<QPushButton *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Primary, widget->font().pointSizeF()); widget->setFont(suggestedFont); 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)); + const QStyleOption opt; + widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText, + QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt)); QApplication::setPalette(widgetPalette, "QPushButton"); } else if (qobject_cast<QToolButton *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Primary, widget->font().pointSizeF()); widget->setFont(suggestedFont); widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, @@ -607,7 +574,7 @@ void QS60Style::polish(QWidget *widget) QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); QApplication::setPalette(widgetPalette, "QToolButton"); } else if (qobject_cast<QHeaderView *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Secondary, widget->font().pointSizeF()); widget->setFont(suggestedFont); widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, @@ -630,7 +597,7 @@ void QS60Style::polish(QWidget *widget) QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); QApplication::setPalette(widgetPalette, "QTableView"); } else if (qobject_cast<QGroupBox *>(widget)){ - const QFont suggestedFont = d->s60Font( + const QFont suggestedFont = s60Font( QS60StyleEnums::FC_Title, widget->font().pointSizeF()); widget->setFont(suggestedFont); } else if (qobject_cast<QLineEdit *>(widget)) { @@ -647,6 +614,48 @@ void QS60Style::polish(QWidget *widget) } } +void QS60StylePrivate::setBackgroundTexture(QApplication *app) const +{ + if (!app) + return; + QPalette applicationPalette = app->palette(); + applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); + app->setPalette(applicationPalette); +} + +void QS60Style::polish(QApplication *application) +{ + Q_D(const QS60Style); + originalPalette = application->palette(); + d->setThemePalette(application); +} + +void QS60Style::polish(QWidget *widget) +{ + Q_D(const QS60Style); + QCommonStyle::polish(widget); + + if (!widget) + return; + + if (QS60StylePrivate::isSkinnableDialog(widget)) { + widget->setAttribute(Qt::WA_StyledBackground); + } else if (false +#ifndef QT_NO_MENU + || qobject_cast<const QMenu *> (widget) +#endif // QT_NO_MENU + ) { + widget->setAttribute(Qt::WA_StyledBackground); + } else if (false +#ifndef QT_NO_COMBOBOX + || qobject_cast<const QComboBoxListView *>(widget) +#endif //QT_NO_COMBOBOX + ) { + widget->setAttribute(Qt::WA_StyledBackground); + } + d->setThemePalette(widget); +} + void QS60Style::unpolish(QApplication *application) { application->setPalette(originalPalette); diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index da34efb..fc6bcd6 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -360,6 +360,7 @@ public: // calculates average color based on button skin graphics (minus borders). QColor colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const; void setThemePalette(QApplication *application) const; + void setThemePalette(QWidget *application) const; void setBackgroundTexture(QApplication *application) const; static int focusRectPenWidth(); diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp index 781fe56..0b5e2d9 100644 --- a/src/gui/styles/qs60style_symbian.cpp +++ b/src/gui/styles/qs60style_symbian.cpp @@ -1291,6 +1291,7 @@ void QS60Style::handleSkinChange() foreach (QWidget *topLevelWidget, QApplication::allWidgets()){ QEvent e(QEvent::StyleChange); QApplication::sendEvent(topLevelWidget, &e); + d->setThemePalette(topLevelWidget); topLevelWidget->ensurePolished(); } } |