macOS: Fix vanishing controls in Welcome mode with macOS dark mode

The example set selector and the search input field were missing some
palette tweaks that were done by other classes deriving from
WelcomePageFrame.

Fixes: QTCREATORBUG-25405
Change-Id: I43a022aa5464a1167f94d26e945de225a436b768
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2021-03-04 11:57:32 +01:00
parent c43956ea45
commit 28f53a9040
4 changed files with 13 additions and 5 deletions

View File

@@ -58,7 +58,7 @@ IWelcomePage::~IWelcomePage()
g_welcomePages.removeOne(this); g_welcomePages.removeOne(this);
} }
static QPalette buttonPalette(bool isActive, bool isCursorInside, bool forText) QPalette WelcomePageFrame::buttonPalette(bool isActive, bool isCursorInside, bool forText)
{ {
QPalette pal; QPalette pal;
Theme *theme = Utils::creatorTheme(); Theme *theme = Utils::creatorTheme();
@@ -175,8 +175,8 @@ bool WelcomePageButtonPrivate::isActive() const
void WelcomePageButtonPrivate::doUpdate(bool cursorInside) void WelcomePageButtonPrivate::doUpdate(bool cursorInside)
{ {
const bool active = isActive(); const bool active = isActive();
q->setPalette(buttonPalette(active, cursorInside, false)); q->setPalette(WelcomePageFrame::buttonPalette(active, cursorInside, false));
const QPalette lpal = buttonPalette(active, cursorInside, true); const QPalette lpal = WelcomePageFrame::buttonPalette(active, cursorInside, true);
m_label->setPalette(lpal); m_label->setPalette(lpal);
if (m_icon) if (m_icon)
m_icon->setPalette(lpal); m_icon->setPalette(lpal);

View File

@@ -68,6 +68,8 @@ public:
WelcomePageFrame(QWidget *parent); WelcomePageFrame(QWidget *parent);
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
static QPalette buttonPalette(bool isActive, bool isCursorInside, bool forText);
}; };
class CORE_EXPORT WelcomePageButton : public WelcomePageFrame class CORE_EXPORT WelcomePageButton : public WelcomePageFrame

View File

@@ -57,15 +57,17 @@ static QFont sizedFont(int size, const QWidget *widget)
SearchBox::SearchBox(QWidget *parent) SearchBox::SearchBox(QWidget *parent)
: WelcomePageFrame(parent) : WelcomePageFrame(parent)
{ {
QPalette pal; QPalette pal = buttonPalette(false, false, true);
pal.setColor(QPalette::Base, themeColor(Theme::Welcome_BackgroundColor)); pal.setColor(QPalette::Base, themeColor(Theme::Welcome_BackgroundColor));
// for macOS dark mode
pal.setColor(QPalette::Text, themeColor(Theme::Welcome_TextColor));
setPalette(pal);
m_lineEdit = new FancyLineEdit; m_lineEdit = new FancyLineEdit;
m_lineEdit->setFiltering(true); m_lineEdit->setFiltering(true);
m_lineEdit->setFrame(false); m_lineEdit->setFrame(false);
m_lineEdit->setFont(sizedFont(14, this)); m_lineEdit->setFont(sizedFont(14, this));
m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
m_lineEdit->setPalette(pal);
auto box = new QHBoxLayout(this); auto box = new QHBoxLayout(this);
box->setContentsMargins(10, 3, 3, 3); box->setContentsMargins(10, 3, 3, 3);

View File

@@ -287,6 +287,10 @@ public:
m_searcher->setPlaceholderText(ExamplesWelcomePage::tr("Search in Examples...")); m_searcher->setPlaceholderText(ExamplesWelcomePage::tr("Search in Examples..."));
auto exampleSetSelector = new QComboBox(this); auto exampleSetSelector = new QComboBox(this);
QPalette pal = exampleSetSelector->palette();
// for macOS dark mode
pal.setColor(QPalette::Text, Utils::creatorTheme()->color(Theme::Welcome_TextColor));
exampleSetSelector->setPalette(pal);
exampleSetSelector->setMinimumWidth(GridProxyModel::GridItemWidth); exampleSetSelector->setMinimumWidth(GridProxyModel::GridItemWidth);
exampleSetSelector->setMaximumWidth(GridProxyModel::GridItemWidth); exampleSetSelector->setMaximumWidth(GridProxyModel::GridItemWidth);
ExampleSetModel *exampleSetModel = m_examplesModel->exampleSetModel(); ExampleSetModel *exampleSetModel = m_examplesModel->exampleSetModel();