From b03f598df2aa4037815eab9249ba1213236216c5 Mon Sep 17 00:00:00 2001 From: kh Date: Tue, 26 May 2009 15:57:45 +0200 Subject: Workaround the palette issue, set it only when we search is open. --- tools/assistant/tools/assistant/centralwidget.cpp | 35 +++++++++++++++++++++-- tools/assistant/tools/assistant/centralwidget.h | 5 ++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 98245c0..52d48d5 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -87,6 +87,7 @@ namespace { FindWidget::FindWidget(QWidget *parent) : QWidget(parent) + , appPalette(qApp->palette()) { QHBoxLayout *hboxLayout = new QHBoxLayout(this); QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); @@ -148,6 +149,34 @@ FindWidget::~FindWidget() { } +void FindWidget::hideEvent(QHideEvent* event) +{ +#if !defined(QT_NO_WEBKIT) + // TODO: remove this once webkit supports setting the palette + if (!event->spontaneous()) + qApp->setPalette(appPalette); +#else + Q_UNUSED(event); +#endif +} + +void FindWidget::showEvent(QShowEvent* event) +{ +#if !defined(QT_NO_WEBKIT) + // TODO: remove this once webkit supports setting the palette + if (!event->spontaneous()) { + QPalette p = appPalette; + p.setColor(QPalette::Inactive, QPalette::Highlight, + p.color(QPalette::Active, QPalette::Highlight)); + p.setColor(QPalette::Inactive, QPalette::HighlightedText, + p.color(QPalette::Active, QPalette::HighlightedText)); + qApp->setPalette(p); + } +#else + Q_UNUSED(event); +#endif +} + void FindWidget::updateButtons() { if (editFind->text().isEmpty()) { @@ -245,12 +274,14 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) SLOT(showTabBarContextMenu(QPoint))); } - QPalette p = qApp->palette(); +#if defined(QT_NO_WEBKIT) + QPalette p = palette(); p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight)); p.setColor(QPalette::Inactive, QPalette::HighlightedText, p.color(QPalette::Active, QPalette::HighlightedText)); - qApp->setPalette(p); + setPalette(p); +#endif } CentralWidget::~CentralWidget() diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 1342a75..d59dbe5 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -80,6 +80,10 @@ signals: void findNext(); void findPrevious(); +protected: + void hideEvent(QHideEvent* event); + void showEvent(QShowEvent * event); + private slots: void updateButtons(); @@ -95,6 +99,7 @@ private: QToolButton *toolPrevious; QCheckBox *checkWholeWords; + QPalette appPalette; friend class CentralWidget; }; -- cgit v0.12