diff --git a/src/core/mac_startup.mm b/src/core/mac_startup.mm index d5730fd83..3d7e3b350 100644 --- a/src/core/mac_startup.mm +++ b/src/core/mac_startup.mm @@ -250,7 +250,8 @@ static BreakpadRef InitBreakpad() { [delegate_ setShortcutHandler:shortcut_handler_]; [self setDelegate:delegate_]; - [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:delegate_]; + [[NSUserNotificationCenter defaultUserNotificationCenter] + setDelegate:delegate_]; } - (void)sendEvent:(NSEvent*)event { @@ -516,10 +517,7 @@ void EnableFullScreen(const QWidget& main_window) { float GetDevicePixelRatio(QWidget* widget) { NSView* view = reinterpret_cast(widget->winId()); - if ([[view window] respondsToSelector:@selector(backingScaleFactor)]) { - return [[view window] backingScaleFactor]; - } - return 1.0f; + return [[view window] backingScaleFactor]; } } // namespace mac diff --git a/src/core/macglobalshortcutbackend.mm b/src/core/macglobalshortcutbackend.mm index 50fe41f1e..38b145793 100644 --- a/src/core/macglobalshortcutbackend.mm +++ b/src/core/macglobalshortcutbackend.mm @@ -139,33 +139,24 @@ void MacGlobalShortcutBackend::ShowAccessibilityDialog() { NSArray* paths = NSSearchPathForDirectoriesInDomains( NSPreferencePanesDirectory, NSSystemDomainMask, YES); if ([paths count] == 1) { - NSURL* prefpane_url = nil; - if (Utilities::GetMacVersion() < 9) { - prefpane_url = - [NSURL fileURLWithPath:[[paths objectAtIndex:0] - stringByAppendingPathComponent: - @"UniversalAccessPref.prefPane"]]; - [[NSWorkspace sharedWorkspace] openURL:prefpane_url]; - } else { - SBSystemPreferencesApplication* system_prefs = [SBApplication - applicationWithBundleIdentifier:@"com.apple.systempreferences"]; - [system_prefs activate]; + SBSystemPreferencesApplication* system_prefs = [SBApplication + applicationWithBundleIdentifier:@"com.apple.systempreferences"]; + [system_prefs activate]; - SBElementArray* panes = [system_prefs panes]; - SBSystemPreferencesPane* security_pane = nil; - for (SBSystemPreferencesPane* pane : panes) { - if ([[pane id] isEqualToString:@"com.apple.preference.security"]) { - security_pane = pane; - break; - } + SBElementArray* panes = [system_prefs panes]; + SBSystemPreferencesPane* security_pane = nil; + for (SBSystemPreferencesPane* pane : panes) { + if ([[pane id] isEqualToString:@"com.apple.preference.security"]) { + security_pane = pane; + break; } - [system_prefs setCurrentPane:security_pane]; + } + [system_prefs setCurrentPane:security_pane]; - SBElementArray* anchors = [security_pane anchors]; - for (SBSystemPreferencesAnchor* anchor : anchors) { - if ([[anchor name] isEqualToString:@"Privacy_Accessibility"]) { - [anchor reveal]; - } + SBElementArray* anchors = [security_pane anchors]; + for (SBSystemPreferencesAnchor* anchor : anchors) { + if ([[anchor name] isEqualToString:@"Privacy_Accessibility"]) { + [anchor reveal]; } } } diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 36c3be1fb..78e24e84c 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -100,7 +100,8 @@ QString PrettyTime(int seconds) { QString ret; if (hours) - ret.sprintf("%d:%02d:%02d", hours, minutes, seconds); // NOLINT(runtime/printf) + ret.sprintf("%d:%02d:%02d", hours, minutes, + seconds); // NOLINT(runtime/printf) else ret.sprintf("%d:%02d", minutes, seconds); // NOLINT(runtime/printf) @@ -161,11 +162,15 @@ QString PrettySize(quint64 bytes) { if (bytes <= 1000) ret = QString::number(bytes) + " bytes"; else if (bytes <= 1000 * 1000) - ret.sprintf("%.1f KB", static_cast(bytes) / 1000); // NOLINT(runtime/printf) + ret.sprintf("%.1f KB", + static_cast(bytes) / 1000); // NOLINT(runtime/printf) else if (bytes <= 1000 * 1000 * 1000) - ret.sprintf("%.1f MB", static_cast(bytes) / (1000 * 1000)); // NOLINT(runtime/printf) + ret.sprintf("%.1f MB", static_cast(bytes) / + (1000 * 1000)); // NOLINT(runtime/printf) else - ret.sprintf("%.1f GB", static_cast(bytes) / (1000 * 1000 * 1000)); // NOLINT(runtime/printf) + ret.sprintf("%.1f GB", + static_cast(bytes) / + (1000 * 1000 * 1000)); // NOLINT(runtime/printf) } return ret; } @@ -375,12 +380,6 @@ QString GetConfigPath(ConfigPath config) { } #ifdef Q_OS_DARWIN -qint32 GetMacVersion() { - SInt32 minor_version; - Gestalt(gestaltSystemVersionMinor, &minor_version); - return minor_version; -} - // Better than openUrl(dirname(path)) - also highlights file at path void RevealFileInFinder(QString const& path) { QProcess::execute("/usr/bin/open", QStringList() << "-R" << path); diff --git a/src/core/utilities.h b/src/core/utilities.h index edb422e21..ccc3b450e 100644 --- a/src/core/utilities.h +++ b/src/core/utilities.h @@ -62,7 +62,11 @@ bool Copy(QIODevice* source, QIODevice* destination); void OpenInFileBrowser(const QList& filenames); -enum HashFunction { Md5_Algo, Sha256_Algo, Sha1_Algo, }; +enum HashFunction { + Md5_Algo, + Sha256_Algo, + Sha1_Algo, +}; QByteArray Hmac(const QByteArray& key, const QByteArray& data, HashFunction algo); QByteArray HmacMd5(const QByteArray& key, const QByteArray& data); @@ -130,9 +134,6 @@ enum ConfigPath { }; QString GetConfigPath(ConfigPath config); -// Returns the minor version of OS X (ie. 6 for Snow Leopard, 7 for Lion). -qint32 GetMacVersion(); - // Borrowed from schedutils enum IoPriority { IOPRIO_CLASS_NONE = 0, @@ -140,7 +141,11 @@ enum IoPriority { IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE, }; -enum { IOPRIO_WHO_PROCESS = 1, IOPRIO_WHO_PGRP, IOPRIO_WHO_USER, }; +enum { + IOPRIO_WHO_PROCESS = 1, + IOPRIO_WHO_PGRP, + IOPRIO_WHO_USER, +}; static const int IOPRIO_CLASS_SHIFT = 13; int SetThreadIOPriority(IoPriority priority); diff --git a/src/ui/globalshortcutssettingspage.cpp b/src/ui/globalshortcutssettingspage.cpp index 8217594a0..37e23f94a 100644 --- a/src/ui/globalshortcutssettingspage.cpp +++ b/src/ui/globalshortcutssettingspage.cpp @@ -57,16 +57,7 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog* dialog) GlobalShortcutsSettingsPage::~GlobalShortcutsSettingsPage() { delete ui_; } -bool GlobalShortcutsSettingsPage::IsEnabled() const { -#ifdef Q_OS_MAC - qLog(Debug) << Utilities::GetMacVersion(); - if (Utilities::GetMacVersion() < 6) { // Leopard and earlier. - return false; - } -#endif - - return true; -} +bool GlobalShortcutsSettingsPage::IsEnabled() const { return true; } void GlobalShortcutsSettingsPage::Load() { GlobalShortcuts* manager = dialog()->global_shortcuts_manager(); @@ -107,11 +98,6 @@ void GlobalShortcutsSettingsPage::Load() { } ui_->mac_container->setVisible(!manager->IsMacAccessibilityEnabled()); -#ifdef Q_OS_DARWIN - qint32 mac_version = Utilities::GetMacVersion(); - ui_->mac_label->setVisible(mac_version < 9); - ui_->mac_label_mavericks->setVisible(mac_version >= 9); -#endif // Q_OS_DARWIN } void GlobalShortcutsSettingsPage::SetShortcut(const QString& id, diff --git a/src/ui/globalshortcutssettingspage.ui b/src/ui/globalshortcutssettingspage.ui index 0d8496526..fda8aedec 100644 --- a/src/ui/globalshortcutssettingspage.ui +++ b/src/ui/globalshortcutssettingspage.ui @@ -58,22 +58,6 @@ - - - 0 - 0 - - - - You need to launch System Preferences and turn on "<span style=" font-style:italic;">Enable access for assistive devices</span>" to use global shortcuts in Clementine. - - - true - - - - - 0 diff --git a/src/ui/macscreensaver.cpp b/src/ui/macscreensaver.cpp index 67b8fd7f6..9bf3d076d 100644 --- a/src/ui/macscreensaver.cpp +++ b/src/ui/macscreensaver.cpp @@ -17,22 +17,17 @@ #include "macscreensaver.h" +#include + #include #include "core/utilities.h" -// kIOPMAssertionTypePreventUserIdleDisplaySleep from Lion. -#define kLionDisplayAssertion CFSTR("PreventUserIdleDisplaySleep") - MacScreensaver::MacScreensaver() : assertion_id_(0) {} void MacScreensaver::Inhibit() { - CFStringRef assertion_type = (Utilities::GetMacVersion() >= 7) - ? kLionDisplayAssertion - : kIOPMAssertionTypeNoDisplaySleep; - IOPMAssertionCreateWithName( - assertion_type, kIOPMAssertionLevelOn, + kIOPMAssertPreventUserIdleDisplaySleep, kIOPMAssertionLevelOn, CFSTR("Showing full-screen Clementine visualisations"), &assertion_id_); }