From 66438ab6e427fd93331bc0b8002fc6d21d132c60 Mon Sep 17 00:00:00 2001 From: <> Date: Wed, 4 Aug 2010 14:48:22 +0200 Subject: [PATCH] Background color on the Mac --- src/SearchView.cpp | 26 ++++++++++++++++++++++++++ src/SearchView.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/SearchView.cpp b/src/SearchView.cpp index 99efdb6..98e2c74 100644 --- a/src/SearchView.cpp +++ b/src/SearchView.cpp @@ -14,6 +14,19 @@ SearchView::SearchView(QWidget *parent) : QWidget(parent) { QFont biggerFont = FontUtils::big(); QFont smallerFont = FontUtils::smallBold(); + /* + QPalette palette = QPalette(); + palette.setColor(QPalette::Active, QPalette::Window, QColor(0xdd, 0xe4, 0xeb)); + setPalette(palette); + setAutoFillBackground(true); + */ + +#ifdef Q_WS_MAC + // speedup painting since we'll paint the whole background + // by ourselves anyway in paintEvent() + setAttribute(Qt::WA_OpaquePaintEvent); +#endif + QBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setMargin(PADDING); mainLayout->setSpacing(0); @@ -194,3 +207,16 @@ void SearchView::gotNewVersion(QString version) { message->show(); if (updateChecker) delete updateChecker; } + +void SearchView::paintEvent(QPaintEvent * /*event*/) { +#ifdef APP_MAC + QBrush brush; + if (window()->isActiveWindow()) { + brush = QBrush(QColor(0xdd, 0xe4, 0xeb)); + } else { + brush = palette().window(); + } + QPainter painter(this); + painter.fillRect(0, 0, width(), height(), brush); +#endif +} diff --git a/src/SearchView.h b/src/SearchView.h index 6ad912d..c32db4b 100644 --- a/src/SearchView.h +++ b/src/SearchView.h @@ -37,6 +37,9 @@ public slots: signals: void search(QString query); +protected: + void paintEvent(QPaintEvent *); + private slots: void watch(); void textChanged(const QString &text); -- 2.39.5