Commit 932bcb70 authored by Michael Abrahams's avatar Michael Abrahams

Fix saving shortcuts

Be more careful setting "defaultShortcuts." KActionCollection compares
shortcut editor settings with defaultShortcuts property and only saves
if they are different.

Maniphest Tasks: T1244

BUG: 362341
parent 91f9ef12
......@@ -265,11 +265,10 @@ void KisActionRegistry::applyShortcutScheme(const KConfigBase *config)
void KisActionRegistry::updateShortcut(const QString &name, QAction *action)
{
const ActionInfoItem info = d->actionInfo(name);
auto newShortcuts = preferredShortcuts(info);
action->setShortcuts(newShortcuts);
const ActionInfoItem &info = d->actionInfo(name);
action->setShortcuts(preferredShortcuts(info));
action->setProperty("defaultShortcuts", qVariantFromValue(newShortcuts));
action->setProperty("defaultShortcuts", qVariantFromValue(info.defaultShortcuts));
}
......
......@@ -121,27 +121,27 @@ void KisShortcutsDialog::allDefault()
void KisShortcutsDialog::importConfiguration(const QString &path)
{
KConfig config(path);
d->m_shortcutsEditor->importConfiguration(static_cast<KConfigBase *>(&config), true);
auto config = KSharedConfig::openConfig(path);
d->m_shortcutsEditor->importConfiguration(config.data(), true);
}
void KisShortcutsDialog::exportConfiguration(const QString &path) const
{
KConfig config(path);
d->m_shortcutsEditor->exportConfiguration(static_cast<KConfigBase *>(&config));
auto config = KSharedConfig::openConfig(path);
d->m_shortcutsEditor->exportConfiguration(config.data());
}
void KisShortcutsDialog::saveCustomShortcuts(const QString &path) const
{
KConfig config(path);
KConfigGroup cg(&config, QStringLiteral("Shortcuts"));
d->m_shortcutsEditor->saveShortcuts(&cg);
auto cg = KSharedConfig::openConfig(path)->group(QStringLiteral("Shortcuts"));
d->m_shortcutsEditor->saveShortcuts(&cg);
d->m_shortcutsEditor->commit();
}
void KisShortcutsDialog::loadCustomShortcuts(const QString &path)
{
KConfig config(path);
d->m_shortcutsEditor->importConfiguration(static_cast<KConfigBase *>(&config), false);
auto config = KSharedConfig::openConfig(path);
d->m_shortcutsEditor->importConfiguration(config.data(), false);
}
#include "moc_KisShortcutsDialog.cpp"
......@@ -222,8 +222,7 @@ void KisShortcutsEditor::exportConfiguration(KConfigBase *config) const
}
if (d->actionTypes) {
QString groupName(QStringLiteral("Shortcuts"));
KConfigGroup group(config, groupName);
KConfigGroup group(config,QStringLiteral("Shortcuts"));
foreach (KActionCollection *collection, d->actionCollections) {
collection->writeSettings(&group, true);
}
......
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