Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
fix(shortcuts_migration): don't override the existing shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
gikari committed Apr 11, 2022
1 parent ca5a5e2 commit d2d3cfd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/kconf_update/legacy_shortcuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <KConfigGroup>
#include <KGlobalAccel>
#include <KSharedConfig>
#include <qdebug.h>

namespace Bismuth
{
Expand All @@ -30,13 +29,22 @@ void KConfUpdate::moveOldKWinShortcutsToNewBismuthComponent()
auto action = QAction();
action.setObjectName(oldEntryName);
action.setProperty("componentName", QStringLiteral("kwin"));

globAccel->setShortcut(&action, {});
globAccel->removeAllShortcuts(&action);

auto newAction = QAction();
action.setObjectName(newEntryName);
action.setProperty("componentName", QStringLiteral("bismuth"));
globAccel->setShortcut(&action, oldKeysequence, KGlobalAccel::NoAutoloading);

auto existingKeysequence = globAccel->globalShortcut(QStringLiteral("bismuth"), newEntryName);

// Only override the shortcut if it's empty
// For some reason KGlobalAccel leaves the empty entries sometimes
// Therefore we cannot rely on Autoloading
if (existingKeysequence.empty()) {
globAccel->setShortcut(&action, oldKeysequence, KGlobalAccel::NoAutoloading);
}
};

auto shortcutsrc = KSharedConfig::openConfig("kglobalshortcutsrc");
Expand Down

0 comments on commit d2d3cfd

Please sign in to comment.