From 67bc9351bdaa7dfbce3555df2a07919d4e79a544 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 17 Jun 2010 23:11:51 +0000 Subject: [PATCH] Only show mac universal access dialog if user clicks on button in global shortcuts dialog. --- src/core/macglobalshortcutbackend.h | 11 +---- src/core/macglobalshortcutbackend.mm | 60 ++++++---------------------- src/translations/ar.po | 15 ------- src/translations/cs.po | 15 ------- src/translations/da.po | 15 ------- src/translations/de.po | 15 ------- src/translations/el.po | 15 ------- src/translations/en_CA.po | 15 ------- src/translations/en_GB.po | 15 ------- src/translations/es.po | 15 ------- src/translations/fi.po | 15 ------- src/translations/fr.po | 15 ------- src/translations/gl.po | 15 ------- src/translations/it.po | 15 ------- src/translations/kk.po | 15 ------- src/translations/nb.po | 15 ------- src/translations/oc.po | 15 ------- src/translations/pl.po | 15 ------- src/translations/pt.po | 15 ------- src/translations/pt_BR.po | 15 ------- src/translations/ro.po | 15 ------- src/translations/ru.po | 15 ------- src/translations/sk.po | 15 ------- src/translations/sv.po | 15 ------- src/translations/tr.po | 15 ------- src/translations/zh_CN.po | 15 ------- src/translations/zh_TW.po | 15 ------- src/ui/globalshortcutsdialog.cpp | 6 +-- 28 files changed, 17 insertions(+), 435 deletions(-) diff --git a/src/core/macglobalshortcutbackend.h b/src/core/macglobalshortcutbackend.h index 4a1810261..c6be5dcfe 100644 --- a/src/core/macglobalshortcutbackend.h +++ b/src/core/macglobalshortcutbackend.h @@ -34,8 +34,8 @@ public: MacGlobalShortcutBackend(GlobalShortcuts* parent); virtual ~MacGlobalShortcutBackend(); - bool IsAccessibilityEnabled() const { return false; } - void ShowAccessibilityDialog() {} + bool IsAccessibilityEnabled() const; + void ShowAccessibilityDialog(); void MacMediaKeyPressed(int key); @@ -45,16 +45,9 @@ protected: private: void KeyPressed(const QKeySequence& sequence); - bool CheckAccessibilityEnabled(); QMap shortcuts_; - enum AccessibilityStatus { - NOT_CHECKED, - ENABLED, - DISABLED - } accessibility_status_; - friend class MacGlobalShortcutBackendPrivate; boost::scoped_ptr p_; }; diff --git a/src/core/macglobalshortcutbackend.mm b/src/core/macglobalshortcutbackend.mm index 53ef98e6c..8b8292071 100644 --- a/src/core/macglobalshortcutbackend.mm +++ b/src/core/macglobalshortcutbackend.mm @@ -62,43 +62,6 @@ class MacGlobalShortcutBackendPrivate : boost::noncopyable { [NSEvent removeMonitor:local_monitor_]; } - // See UIElementInspector example. - bool CheckAccessibilityEnabled() { - if (AXAPIEnabled()) { - return true; - } - - QMessageBox box( - QMessageBox::Question, - QObject::tr("Accessibility API required for global shortcuts"), - QObject::tr("Would you like to launch System Preferences so that you can turn on" - " \"Enable access for assistive devices\"?\n" - "This is required to use global shortcuts in Clementine.")); - QPushButton* default_button = - box.addButton(QObject::tr("Open System Preferences"), QMessageBox::AcceptRole); - QPushButton* continue_button = - box.addButton(QObject::tr("Continue anyway"), QMessageBox::RejectRole); - box.setDefaultButton(default_button); - - box.exec(); - QPushButton* clicked_button = static_cast(box.clickedButton()); - if (clicked_button == default_button) { - NSArray* paths = NSSearchPathForDirectoriesInDomains( - NSPreferencePanesDirectory, NSSystemDomainMask, YES); - if ([paths count] == 1) { - NSURL* prefpane_url = [NSURL fileURLWithPath: - [[paths objectAtIndex:0] stringByAppendingPathComponent:@"UniversalAccessPref.prefPane"]]; - [[NSWorkspace sharedWorkspace] openURL:prefpane_url]; - } - // We assume the user actually clicks the button in the preference pane here... - return true; - } else if (clicked_button == continue_button) { - return false; - } - - return false; - } - private: static QKeySequence GetSequence(NSEvent* event) { NSString* str = [event charactersIgnoringModifiers]; @@ -212,7 +175,6 @@ class MacGlobalShortcutBackendPrivate : boost::noncopyable { MacGlobalShortcutBackend::MacGlobalShortcutBackend(GlobalShortcuts* parent) : GlobalShortcutBackend(parent), - accessibility_status_(NOT_CHECKED), p_(new MacGlobalShortcutBackendPrivate(this)) { } @@ -223,13 +185,7 @@ bool MacGlobalShortcutBackend::DoRegister() { // Always enable media keys. mac::SetShortcutHandler(this); - // Check whether universal access is enabled so that global shortcuts will work. - // This may pop up a modal dialog so only ask once per session. - if (accessibility_status_ == NOT_CHECKED) { - accessibility_status_ = CheckAccessibilityEnabled() ? ENABLED : DISABLED; - } - - if (accessibility_status_ == ENABLED && AXAPIEnabled()) { + if (AXAPIEnabled()) { foreach (const GlobalShortcuts::Shortcut& shortcut, manager_->shortcuts().values()) { shortcuts_[shortcut.action->shortcut()] = shortcut.action; } @@ -265,6 +221,16 @@ void MacGlobalShortcutBackend::KeyPressed(const QKeySequence& sequence) { } } -bool MacGlobalShortcutBackend::CheckAccessibilityEnabled() { - return p_->CheckAccessibilityEnabled(); +bool MacGlobalShortcutBackend::IsAccessibilityEnabled() const { + return AXAPIEnabled(); +} + +void MacGlobalShortcutBackend::ShowAccessibilityDialog() { + NSArray* paths = NSSearchPathForDirectoriesInDomains( + NSPreferencePanesDirectory, NSSystemDomainMask, YES); + if ([paths count] == 1) { + NSURL* prefpane_url = [NSURL fileURLWithPath: + [[paths objectAtIndex:0] stringByAppendingPathComponent:@"UniversalAccessPref.prefPane"]]; + [[NSWorkspace sharedWorkspace] openURL:prefpane_url]; + } } diff --git a/src/translations/ar.po b/src/translations/ar.po index e4f86f50e..b5e43973d 100644 --- a/src/translations/ar.po +++ b/src/translations/ar.po @@ -879,21 +879,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/cs.po b/src/translations/cs.po index 8c4e3a0cf..b34717379 100644 --- a/src/translations/cs.po +++ b/src/translations/cs.po @@ -881,21 +881,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Pokročilé řazení knihoven" diff --git a/src/translations/da.po b/src/translations/da.po index c2ac78b7b..ef9d19af4 100644 --- a/src/translations/da.po +++ b/src/translations/da.po @@ -884,21 +884,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Avanceret bibliotektsgruppering" diff --git a/src/translations/de.po b/src/translations/de.po index f3afa9f48..55224f986 100644 --- a/src/translations/de.po +++ b/src/translations/de.po @@ -883,21 +883,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Benutzerdefiniertes Gruppieren" diff --git a/src/translations/el.po b/src/translations/el.po index 09e67ff42..64c18355d 100644 --- a/src/translations/el.po +++ b/src/translations/el.po @@ -886,21 +886,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Προχωρημένη ομαδοποίηση βιβλιοθήκης" diff --git a/src/translations/en_CA.po b/src/translations/en_CA.po index dcccd7192..d02456a99 100644 --- a/src/translations/en_CA.po +++ b/src/translations/en_CA.po @@ -883,21 +883,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Library advanced grouping" diff --git a/src/translations/en_GB.po b/src/translations/en_GB.po index 1d2ad01f4..2bc95ad2f 100644 --- a/src/translations/en_GB.po +++ b/src/translations/en_GB.po @@ -880,21 +880,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Library advanced grouping" diff --git a/src/translations/es.po b/src/translations/es.po index 822b389ca..699db8492 100644 --- a/src/translations/es.po +++ b/src/translations/es.po @@ -886,21 +886,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Agrupamiento avanzado de la colección" diff --git a/src/translations/fi.po b/src/translations/fi.po index d2d0792bb..26fb76a2e 100644 --- a/src/translations/fi.po +++ b/src/translations/fi.po @@ -879,21 +879,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/fr.po b/src/translations/fr.po index 7db791643..3b949524b 100644 --- a/src/translations/fr.po +++ b/src/translations/fr.po @@ -883,21 +883,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Groupement avancé de la bibliothèque" diff --git a/src/translations/gl.po b/src/translations/gl.po index cbefaf312..e2b02c746 100644 --- a/src/translations/gl.po +++ b/src/translations/gl.po @@ -881,21 +881,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/it.po b/src/translations/it.po index 5c535190d..a212b2a65 100644 --- a/src/translations/it.po +++ b/src/translations/it.po @@ -886,21 +886,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Raggruppamento avanzato della raccolta" diff --git a/src/translations/kk.po b/src/translations/kk.po index 2fe546aaf..48ed83d5a 100644 --- a/src/translations/kk.po +++ b/src/translations/kk.po @@ -881,21 +881,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/nb.po b/src/translations/nb.po index 3ea70ab10..559e65eda 100644 --- a/src/translations/nb.po +++ b/src/translations/nb.po @@ -881,21 +881,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Avansert biblioteksgruppering" diff --git a/src/translations/oc.po b/src/translations/oc.po index ba94e6e7e..650bdf041 100644 --- a/src/translations/oc.po +++ b/src/translations/oc.po @@ -879,21 +879,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/pl.po b/src/translations/pl.po index aa7b676cd..929428198 100644 --- a/src/translations/pl.po +++ b/src/translations/pl.po @@ -881,21 +881,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Zaawansowanie grupowanie Biblioteki" diff --git a/src/translations/pt.po b/src/translations/pt.po index 1a8409b5e..4d7798e2e 100644 --- a/src/translations/pt.po +++ b/src/translations/pt.po @@ -884,21 +884,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Agrupamento avançado da biblioteca" diff --git a/src/translations/pt_BR.po b/src/translations/pt_BR.po index 92dea87cd..35343b27c 100644 --- a/src/translations/pt_BR.po +++ b/src/translations/pt_BR.po @@ -886,21 +886,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Organização avançada de biblioteca" diff --git a/src/translations/ro.po b/src/translations/ro.po index ec8e6c9d8..996583ace 100644 --- a/src/translations/ro.po +++ b/src/translations/ro.po @@ -880,21 +880,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/ru.po b/src/translations/ru.po index bebf3d11e..c027c2b4d 100644 --- a/src/translations/ru.po +++ b/src/translations/ru.po @@ -884,21 +884,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Расширенная сортировка коллекции" diff --git a/src/translations/sk.po b/src/translations/sk.po index 170a5e5d0..fc0fc8799 100644 --- a/src/translations/sk.po +++ b/src/translations/sk.po @@ -884,21 +884,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Pokročilé zoraďovanie zbierky" diff --git a/src/translations/sv.po b/src/translations/sv.po index 6cc2c8f34..9856424e0 100644 --- a/src/translations/sv.po +++ b/src/translations/sv.po @@ -882,21 +882,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "Bibliotek avancerad gruppering" diff --git a/src/translations/tr.po b/src/translations/tr.po index c460f31a4..da2236dce 100644 --- a/src/translations/tr.po +++ b/src/translations/tr.po @@ -879,21 +879,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/zh_CN.po b/src/translations/zh_CN.po index 0250c68e3..7393c3d68 100644 --- a/src/translations/zh_CN.po +++ b/src/translations/zh_CN.po @@ -879,21 +879,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/translations/zh_TW.po b/src/translations/zh_TW.po index 3e0e0915c..a977bdd08 100644 --- a/src/translations/zh_TW.po +++ b/src/translations/zh_TW.po @@ -879,21 +879,6 @@ msgstr "" msgid "Select None" msgstr "" -msgid "Accessibility API required for global shortcuts" -msgstr "" - -msgid "" -"Would you like to launch System Preferences so that you can turn on \"Enable " -"access for assistive devices\"?\n" -"This is required to use global shortcuts in Clementine." -msgstr "" - -msgid "Open System Preferences" -msgstr "" - -msgid "Continue anyway" -msgstr "" - msgid "Library advanced grouping" msgstr "" diff --git a/src/ui/globalshortcutsdialog.cpp b/src/ui/globalshortcutsdialog.cpp index 184f8486d..da1d1602f 100644 --- a/src/ui/globalshortcutsdialog.cpp +++ b/src/ui/globalshortcutsdialog.cpp @@ -41,10 +41,6 @@ GlobalShortcutsDialog::GlobalShortcutsDialog(GlobalShortcuts* manager, ui_->gnome_container->hide(); } - if (manager->IsMacAccessibilityEnabled()) { - ui_->mac_container->hide(); - } - settings_.beginGroup(GlobalShortcuts::kSettingsGroup); foreach (const GlobalShortcuts::Shortcut& s, manager_->shortcuts().values()) { @@ -85,6 +81,8 @@ void GlobalShortcutsDialog::showEvent(QShowEvent*) { if (ui_->gnome_container->isVisible()) { ui_->gnome_checkbox->setChecked(use_gnome); } + + ui_->mac_container->setVisible(!manager_->IsMacAccessibilityEnabled()); } void GlobalShortcutsDialog::ResetAll() {