Commit 55bbe231 authored by Michael Abrahams's avatar Michael Abrahams

Fix saving empty custom shortcuts

Ensure that defaultShortcut for an action with no default shortcut is an
empty list, not a list containing a single item, QKeySequence("")

Maniphest Tasks: T1244
BUG: 361911
parent 54064e5a
......@@ -83,7 +83,10 @@ KisAction *makeKisAction(QString name, QObject *parent)
void KisAction::setDefaultShortcut(const QKeySequence &shortcut)
{
QList<QKeySequence> listifiedShortcut;
listifiedShortcut.append(shortcut);
// Use the empty list to represent no shortcut
if (shortcut != QKeySequence("")) {
listifiedShortcut.append(shortcut);
}
setProperty("defaultShortcuts", qVariantFromValue(listifiedShortcut));
}
......
......@@ -260,8 +260,13 @@ void KisActionRegistry::updateShortcut(const QString &name, QAction *action)
{
const ActionInfoItem info = d->actionInfo(name);
action->setShortcut(preferredShortcut(info));
auto propertizedShortcut = qVariantFromValue(QList<QKeySequence>() << info.defaultShortcut);
action->setProperty("defaultShortcuts", propertizedShortcut);
auto defaultShortcutsList = QList<QKeySequence>();
if (info.defaultShortcut != QKeySequence("")) {
// Use the empty list to represent no shortcut
defaultShortcutsList << info.defaultShortcut;
}
action->setProperty("defaultShortcuts", qVariantFromValue(defaultShortcutsList));
}
......
......@@ -587,16 +587,9 @@ void KActionCollection::writeSettings(KConfigGroup *config,
// not set to its default value. Write it
QString s = QKeySequence::listToString(action->shortcuts());
if (s.isEmpty()) {
if (writeScheme) {
// A scheme file should explicitly set "none" for the shortcut
s = QStringLiteral("none");
config->writeEntry(actionName, s, flags);
} else {
config->deleteEntry(actionName, flags);
}
} else {
config->writeEntry(actionName, s, flags);
s = QStringLiteral("none");
}
config->writeEntry(actionName, s, flags);
} else if (bConfigHasAction) {
// This key is the same as default but exists in config file.
// Remove it.
......
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