Commit 6354f61f authored by David Redondo's avatar David Redondo 🏎
Browse files

Only allow multi key shortcuts for standard shortcuts

KGlobalAccel can only handle key sequences with one key combination.

(cherry picked from commit 1800d327)
parent 834f7db9
......@@ -166,6 +166,8 @@ QVariant BaseModel::data(const QModelIndex &index, int role) const
auto shortcuts = action.activeShortcuts;
return QVariant::fromValue(shortcuts.subtract(action.defaultShortcuts));
}
case SupportsMultipleKeysRole:
return true;
}
return QVariant();
}
......@@ -223,6 +225,7 @@ QHash<int, QByteArray> BaseModel::roleNames() const
{DefaultShortcutsRole, QByteArrayLiteral("defaultShortcuts")},
{CustomShortcutsRole, QByteArrayLiteral("customShortcuts")},
{CheckedRole, QByteArrayLiteral("checked")},
{PendingDeletionRole, QByteArrayLiteral("pendingDeletion")}
{PendingDeletionRole, QByteArrayLiteral("pendingDeletion")},
{SupportsMultipleKeysRole, QByteArrayLiteral("supportsMultipleKeys")}
};
}
......@@ -59,7 +59,8 @@ public:
DefaultShortcutsRole,
CustomShortcutsRole,
CheckedRole,
PendingDeletionRole
PendingDeletionRole,
SupportsMultipleKeysRole
};
Q_ENUM(Roles)
......
......@@ -50,6 +50,14 @@ GlobalAccelModel::GlobalAccelModel(KGlobalAccelInterface *interface, QObject *pa
{
}
QVariant GlobalAccelModel::data(const QModelIndex &index, int role) const
{
if (role == SupportsMultipleKeysRole) {
return false;
}
return BaseModel::data(index, role);
}
void GlobalAccelModel::load()
{
if (!m_globalAccelInterface->isValid()) {
......
......@@ -42,6 +42,8 @@ public:
GlobalAccelModel(KGlobalAccelInterface *interface, QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role) const override;
void addApplication(const QString &desktopFileName, const QString &displayName);
void exportToConfig(const KConfigBase &config) override;
......
......@@ -123,6 +123,7 @@ Kirigami.AbstractListItem {
KeySequenceItem {
keySequence: modelData
showClearButton: false
multiKeyShortcutsAllowed: supportsMultipleKeys
checkForConflictsAgainst: ShortcutType.None
onCaptureFinished: {
kcm.requestKeySequence(this, originalIndex, keySequence, modelData)
......@@ -161,6 +162,7 @@ Kirigami.AbstractListItem {
signal finished
KeySequenceItem {
showClearButton: false
multiKeyShortcutsAllowed: model.supportsMultipleKeys
checkForConflictsAgainst: ShortcutType.None
onCaptureFinished: {
kcm.requestKeySequence(this, originalIndex, keySequence)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment