Don't grab global shortcuts while the global shortcut grabber is open. Fixes issue #462
This commit is contained in:
parent
384ff16f2b
commit
d8cc037446
|
@ -33,7 +33,8 @@ const char* GlobalShortcuts::kSettingsGroup = "Shortcuts";
|
|||
GlobalShortcuts::GlobalShortcuts(QObject *parent)
|
||||
: QObject(parent),
|
||||
gnome_backend_(NULL),
|
||||
system_backend_(NULL)
|
||||
system_backend_(NULL),
|
||||
use_gnome_(false)
|
||||
{
|
||||
settings_.beginGroup(kSettingsGroup);
|
||||
|
||||
|
@ -91,14 +92,21 @@ bool GlobalShortcuts::IsGsdAvailable() const {
|
|||
void GlobalShortcuts::ReloadSettings() {
|
||||
// The actual shortcuts have been set in our actions for us by the config
|
||||
// dialog already - we just need to reread the gnome settings.
|
||||
bool use_gnome = settings_.value("use_gnome", true).toBool();
|
||||
use_gnome_ = settings_.value("use_gnome", true).toBool();
|
||||
|
||||
Unregister();
|
||||
Register();
|
||||
}
|
||||
|
||||
void GlobalShortcuts::Unregister() {
|
||||
if (gnome_backend_ && gnome_backend_->is_active())
|
||||
gnome_backend_->Unregister();
|
||||
if (system_backend_ && system_backend_->is_active())
|
||||
system_backend_->Unregister();
|
||||
}
|
||||
|
||||
if (gnome_backend_ && use_gnome)
|
||||
void GlobalShortcuts::Register() {
|
||||
if (gnome_backend_ && use_gnome_)
|
||||
gnome_backend_->Register();
|
||||
else if (system_backend_)
|
||||
system_backend_->Register();
|
||||
|
|
|
@ -48,6 +48,9 @@ public slots:
|
|||
void ReloadSettings();
|
||||
void ShowMacAccessibilityDialog();
|
||||
|
||||
void Unregister();
|
||||
void Register();
|
||||
|
||||
signals:
|
||||
void Play();
|
||||
void Pause();
|
||||
|
@ -72,6 +75,8 @@ private:
|
|||
|
||||
QMap<QString, Shortcut> shortcuts_;
|
||||
QSettings settings_;
|
||||
|
||||
bool use_gnome_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -130,10 +130,19 @@ void GlobalShortcutsConfig::DefaultClicked() {
|
|||
}
|
||||
|
||||
void GlobalShortcutsConfig::ChangeClicked() {
|
||||
manager_->Unregister();
|
||||
QKeySequence key = grabber_->GetKey(shortcuts_[current_id_].s.action->text());
|
||||
manager_->Register();
|
||||
|
||||
if (key.isEmpty())
|
||||
return;
|
||||
|
||||
// Check if this key sequence is used by any other actions
|
||||
foreach (const QString& id, shortcuts_.keys()) {
|
||||
if (shortcuts_[id].key == key)
|
||||
SetShortcut(id, QKeySequence());
|
||||
}
|
||||
|
||||
ui_->radio_custom->setChecked(true);
|
||||
SetShortcut(current_id_, key);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue