Only show mac universal access dialog if user clicks on button in global shortcuts dialog.

This commit is contained in:
John Maguire 2010-06-17 23:11:51 +00:00
parent 9f2db477f8
commit 67bc9351bd
28 changed files with 17 additions and 435 deletions

View File

@ -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<QKeySequence, QAction*> shortcuts_;
enum AccessibilityStatus {
NOT_CHECKED,
ENABLED,
DISABLED
} accessibility_status_;
friend class MacGlobalShortcutBackendPrivate;
boost::scoped_ptr<MacGlobalShortcutBackendPrivate> p_;
};

View File

@ -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<QPushButton*>(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];
}
}

View File

@ -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 ""

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 "Προχωρημένη ομαδοποίηση βιβλιοθήκης"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 ""

View File

@ -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"

View File

@ -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 ""

View File

@ -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"

View File

@ -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 ""

View File

@ -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"

View File

@ -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 ""

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 ""

View File

@ -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 "Расширенная сортировка коллекции"

View File

@ -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"

View File

@ -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"

View File

@ -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 ""

View File

@ -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 ""

View File

@ -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 ""

View File

@ -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() {