Skip to content

Commit

Permalink
Fix #290946 - Change macOS window title bar color for Dark theme
Browse files Browse the repository at this point in the history
Previously, when you selected MuseScore's Dark theme,
the title bars of the windows on macOS stayed light.
Now, they will also change, along with the MuseScore theme.
  • Loading branch information
cbjeukendrup authored and vpereverzev committed Oct 22, 2020
1 parent f21710b commit a4cfffe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions mscore/macos/cocoabridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CocoaBridge
public:
static void setAllowsAutomaticWindowTabbing(bool flag);
static bool isSystemDarkTheme();
static void setWindowAppearanceIsDark(bool flag);
};

#endif
6 changes: 6 additions & 0 deletions mscore/macos/cocoabridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@
NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
return ([osxMode isEqualToString:@"Dark"]);
}

void CocoaBridge::setWindowAppearanceIsDark(bool flag)
{
if (@available(macOS 10.14, *))
[NSApp setAppearance:[NSAppearance appearanceNamed:flag ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]];
}
5 changes: 5 additions & 0 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7421,6 +7421,11 @@ void MuseScore::updateUiStyleAndTheme()
{
// set UI Theme
QApplication::setStyle(QStyleFactory::create("Fusion"));

#ifdef Q_OS_MAC
// On Mac, update the color of the window title bars
CocoaBridge::setWindowAppearanceIsDark(preferences.isThemeDark());
#endif

#if defined(WIN_PORTABLE)
QString wd = QDir::cleanPath(QString("%1/../../../Data/%2").arg(QCoreApplication::applicationDirPath()).arg(QCoreApplication::applicationName()));
Expand Down

0 comments on commit a4cfffe

Please sign in to comment.