Remove some more obsolete os x version checks.
This commit is contained in:
parent
484db9d92b
commit
fb2b91c874
@ -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<NSView*>(widget->winId());
|
||||
if ([[view window] respondsToSelector:@selector(backingScaleFactor)]) {
|
||||
return [[view window] backingScaleFactor];
|
||||
}
|
||||
return 1.0f;
|
||||
return [[view window] backingScaleFactor];
|
||||
}
|
||||
|
||||
} // namespace mac
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<float>(bytes) / 1000); // NOLINT(runtime/printf)
|
||||
ret.sprintf("%.1f KB",
|
||||
static_cast<float>(bytes) / 1000); // NOLINT(runtime/printf)
|
||||
else if (bytes <= 1000 * 1000 * 1000)
|
||||
ret.sprintf("%.1f MB", static_cast<float>(bytes) / (1000 * 1000)); // NOLINT(runtime/printf)
|
||||
ret.sprintf("%.1f MB", static_cast<float>(bytes) /
|
||||
(1000 * 1000)); // NOLINT(runtime/printf)
|
||||
else
|
||||
ret.sprintf("%.1f GB", static_cast<float>(bytes) / (1000 * 1000 * 1000)); // NOLINT(runtime/printf)
|
||||
ret.sprintf("%.1f GB",
|
||||
static_cast<float>(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);
|
||||
|
@ -62,7 +62,11 @@ bool Copy(QIODevice* source, QIODevice* destination);
|
||||
|
||||
void OpenInFileBrowser(const QList<QUrl>& 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);
|
||||
|
@ -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,
|
||||
|
@ -58,22 +58,6 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="mac_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mac_label_mavericks">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -17,22 +17,17 @@
|
||||
|
||||
#include "macscreensaver.h"
|
||||
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#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_);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user