Skip to content

Commit

Permalink
Theme 'dark': Use accent color on macOS
Browse files Browse the repository at this point in the history
Fixes: QTCREATORBUG-28374
Change-Id: Ifb7fa83c8afc1be0a919c775f7d04e229f146438
Reviewed-by: Orgad Shaneh <[email protected]>
Reviewed-by: <[email protected]>
Reviewed-by: Christian Stenger <[email protected]>
  • Loading branch information
e4z9 committed Nov 11, 2022
1 parent 1a1d478 commit 33a3361
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions share/qtcreator/themes/dark.creatortheme
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ThemeName=Dark
PreferredStyles=
DefaultTextEditorColorScheme=dark.xml
EnforceAccentColorOnMacOS=selectedBackground

[Palette]
shadowBackground=ff232323
Expand All @@ -10,7 +11,6 @@ textDisabled=7fffffff
textHighlighted=ffe7e7e7
hoverBackground=18ffffff
selectedBackground=aa1f75cc
selectedBackgroundText=aa1f75cc
normalBackground=ff333333
alternateBackground=ff515151
error=ffd84044
Expand Down Expand Up @@ -358,7 +358,7 @@ PaletteText=text
PaletteButtonText=text
PaletteButtonTextDisabled=textDisabled
PaletteToolTipBase=66000000
PaletteHighlight=selectedBackgroundText
PaletteHighlight=selectedBackground
PaletteDark=shadowBackground
PaletteHighlightedText=textHighlighted
PaletteToolTipText=text
Expand Down
5 changes: 5 additions & 0 deletions src/libs/utils/theme/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ bool Theme::flag(Theme::Flag f) const

QColor Theme::color(Theme::Color role) const
{
const auto color = d->colors[role];
if (HostOsInfo::isMacHost() && !d->enforceAccentColorOnMacOS.isEmpty()
&& color.second == d->enforceAccentColorOnMacOS)
return initialPalette().color(QPalette::Highlight);
return d->colors[role].first;
}

Expand Down Expand Up @@ -171,6 +175,7 @@ void Theme::readSettings(QSettings &settings)
d->preferredStyles.removeAll(QString());
d->defaultTextEditorColorScheme =
settings.value(QLatin1String("DefaultTextEditorColorScheme")).toString();
d->enforceAccentColorOnMacOS = settings.value("EnforceAccentColorOnMacOS").toString();
}
{
settings.beginGroup(QLatin1String("Palette"));
Expand Down
1 change: 1 addition & 0 deletions src/libs/utils/theme/theme_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class QTCREATOR_UTILS_EXPORT ThemePrivate
QString displayName;
QStringList preferredStyles;
QString defaultTextEditorColorScheme;
QString enforceAccentColorOnMacOS;
QVector<QPair<QColor, QString> > colors;
QVector<QString> imageFiles;
QVector<bool> flags;
Expand Down

0 comments on commit 33a3361

Please sign in to comment.