ui fixes
This commit is contained in:
parent
d0a24eb225
commit
9553163c76
15 changed files with 52 additions and 2 deletions
37
client/publib/macos_functions.mm
Normal file
37
client/publib/macos_functions.mm
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "macos_functions.h"
|
||||
#include <QDebug>
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
MacOSFunctions &MacOSFunctions::instance()
|
||||
{
|
||||
static MacOSFunctions s;
|
||||
return s;
|
||||
}
|
||||
|
||||
MacOSFunctions::MacOSFunctions()
|
||||
{
|
||||
registerThemeNotification();
|
||||
}
|
||||
|
||||
bool MacOSFunctions::isMenuBarUseDarkTheme() const
|
||||
{
|
||||
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
|
||||
id style = [dict objectForKey:@"AppleInterfaceStyle"];
|
||||
BOOL darkModeOn = ( style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"] );
|
||||
|
||||
return darkModeOn;
|
||||
}
|
||||
|
||||
|
||||
void MacOSFunctions::registerThemeNotification()
|
||||
{
|
||||
// [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(darkModeChanged:) name:@"AppleInterfaceThemeChangedNotification" object:nil];
|
||||
}
|
||||
|
||||
|
||||
void darkModeChanged(NSNotification*notif)
|
||||
{
|
||||
Q_UNUSED(notif);
|
||||
qDebug() << "Dark mode changed" << MacOSFunctions::instance().isMenuBarUseDarkTheme();
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue