Fix shortcut handling with KDE Frameworks
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 3 Feb 2016 21:50:02 +0000 (22:50 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 3 Feb 2016 21:51:55 +0000 (22:51 +0100)
KDE Frameworks slightly altered the way it handles default shortcuts
for actions; the property name was changed to support lists of
shortcuts. This issue lead to default shortcuts not being active for
Quassel built against KDE Frameworks.

src/uisupport/action.cpp

index c222dc1..216cac8 100644 (file)
@@ -98,11 +98,12 @@ void Action::setShortcutConfigurable(bool b)
 QKeySequence Action::shortcut(ShortcutTypes type) const
 {
     Q_ASSERT(type);
-    if (type == DefaultShortcut)
-        return property("defaultShortcut").value<QKeySequence>();
+    if (type == DefaultShortcut) {
+        auto sequence = property("defaultShortcuts").value<QList<QKeySequence>>();
+        return sequence.isEmpty() ? QKeySequence() : sequence.first();
+    }
 
-    if (shortcuts().count()) return shortcuts().value(0);
-    return QKeySequence();
+    return shortcuts().isEmpty() ? QKeySequence() : shortcuts().first();
 }
 
 
@@ -117,7 +118,7 @@ void Action::setShortcut(const QKeySequence &key, ShortcutTypes type)
     Q_ASSERT(type);
 
     if (type & DefaultShortcut)
-        setProperty("defaultShortcut", key);
+        setProperty("defaultShortcuts", QVariant::fromValue(QList<QKeySequence>() << key));
 
     if (type & ActiveShortcut)
         QAction::setShortcut(key);