// Return this educated guess if something goes wrong.
// As of macOS 12.4 this will always return 22, even on notched Macbooks.
qCWarning(lcMacSystray) << "Got nil for main menu. Going with reasonable menu bar height guess.";
- return [[NSStatusBar systemStatusBar] thickness];
+ return NSStatusBar.systemStatusBar.thickness;
}
return mainMenu.menuBarHeight;
// TODO: Get this to actually check for permissions
bool canOsXSendUserNotification()
{
- UNUserNotificationCenter * const center = [UNUserNotificationCenter currentNotificationCenter];
+ UNUserNotificationCenter * const center = UNUserNotificationCenter.currentNotificationCenter;
return center != nil;
}
intentIdentifiers:@[]
options:UNNotificationCategoryOptionNone];
- [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:generalCategory, updateCategory, talkReplyCategory, nil]];
+ [UNUserNotificationCenter.currentNotificationCenter setNotificationCategories:[NSSet setWithObjects:generalCategory, updateCategory, talkReplyCategory, nil]];
}
void checkNotificationAuth(MacNotificationAuthorizationOptions additionalAuthOption)
{
- UNUserNotificationCenter * const center = [UNUserNotificationCenter currentNotificationCenter];
+ UNUserNotificationCenter * const center = UNUserNotificationCenter.currentNotificationCenter;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert + UNAuthorizationOptionSound;
if(additionalAuthOption == MacNotificationAuthorizationOptions::Provisional) {
void setUserNotificationCenterDelegate()
{
- UNUserNotificationCenter * const center = [UNUserNotificationCenter currentNotificationCenter];
+ UNUserNotificationCenter * const center = UNUserNotificationCenter.currentNotificationCenter;
static dispatch_once_t once;
dispatch_once(&once, ^{
void sendOsXUserNotification(const QString &title, const QString &message)
{
- UNUserNotificationCenter * const center = [UNUserNotificationCenter currentNotificationCenter];
+ UNUserNotificationCenter * const center = UNUserNotificationCenter.currentNotificationCenter;
checkNotificationAuth();
UNMutableNotificationContent * const content = basicNotificationContent(title, message);
content.categoryIdentifier = @"GENERAL";
- UNTimeIntervalNotificationTrigger * const trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats: NO];
+ UNTimeIntervalNotificationTrigger * const trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:NO];
UNNotificationRequest * const request = [UNNotificationRequest requestWithIdentifier:@"NCUserNotification" content:content trigger:trigger];
[center addNotificationRequest:request withCompletionHandler:nil];
void sendOsXUpdateNotification(const QString &title, const QString &message, const QUrl &webUrl)
{
- UNUserNotificationCenter * const center = [UNUserNotificationCenter currentNotificationCenter];
+ UNUserNotificationCenter * const center = UNUserNotificationCenter.currentNotificationCenter;
checkNotificationAuth();
UNMutableNotificationContent * const content = basicNotificationContent(title, message);
content.categoryIdentifier = @"UPDATE";
content.userInfo = [NSDictionary dictionaryWithObject:[webUrl.toNSURL() absoluteString] forKey:@"webUrl"];
- UNTimeIntervalNotificationTrigger * const trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats: NO];
+ UNTimeIntervalNotificationTrigger * const trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:NO];
UNNotificationRequest * const request = [UNNotificationRequest requestWithIdentifier:@"NCUpdateNotification" content:content trigger:trigger];
[center addNotificationRequest:request withCompletionHandler:nil];
void sendOsXTalkNotification(const QString &title, const QString &message, const QString &token, const QString &replyTo, const AccountStatePtr accountState)
{
- UNUserNotificationCenter * const center = [UNUserNotificationCenter currentNotificationCenter];
+ UNUserNotificationCenter * const center = UNUserNotificationCenter.currentNotificationCenter;
checkNotificationAuth();
if (!accountState || !accountState->account()) {
void setTrayWindowLevelAndVisibleOnAllSpaces(QWindow *window)
{
NSView * const nativeView = (NSView *)window->winId();
- NSWindow * const nativeWindow = (NSWindow *)[nativeView window];
+ NSWindow * const nativeWindow = (NSWindow *)(nativeView.window);
[nativeWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorIgnoresCycle |
NSWindowCollectionBehaviorTransient];
[nativeWindow setLevel:NSMainMenuWindowLevel];
bool osXInDarkMode()
{
- NSString * const osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
+ NSString * const osxMode = [NSUserDefaults.standardUserDefaults stringForKey:@"AppleInterfaceStyle"];
return [osxMode containsString:@"Dark"];
}