mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
cleanup applet shortcuts on startup
--when Latte crashes the global shortcuts from applets remain untouched in kglobalshortcutsrc file. That fact based on the Latte architecture that can alter applet ids during layout loading can break the global shortcuts experience by creating multiple global shortcuts records for the same applet and by disabling some shortcuts because these shortcuts are already enabled for ghost applets of the crashed layout. This patch fixes this by removing all applet global shortcuts during startup. Applet global shortcuts are already saved in the layout file based on the current plasma architecture, that fact simplifies things a lot. BUG: 401184
This commit is contained in:
parent
788e7ad4d9
commit
d0f1a7ffe6
@ -24,9 +24,13 @@
|
||||
#include "sortedactivitiesmodel.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QAction>
|
||||
|
||||
#include <KGlobalAccel>
|
||||
#include <KActivities/Consumer>
|
||||
|
||||
#define GLOBALSHORTCUTSCONFIG "kglobalshortcutsrc"
|
||||
|
||||
namespace Latte {
|
||||
|
||||
UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)
|
||||
@ -34,6 +38,9 @@ UniversalSettings::UniversalSettings(KSharedConfig::Ptr config, QObject *parent)
|
||||
m_config(config),
|
||||
m_universalGroup(KConfigGroup(config, QStringLiteral("UniversalSettings")))
|
||||
{
|
||||
const QString globalShortcutsFilePath = QDir::homePath() + "/.config/" + GLOBALSHORTCUTSCONFIG;
|
||||
m_shortcutsConfigPtr = KSharedConfig::openConfig(globalShortcutsFilePath);
|
||||
|
||||
connect(this, &UniversalSettings::canDisableBordersChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::currentLayoutNameChanged, this, &UniversalSettings::saveConfig);
|
||||
connect(this, &UniversalSettings::downloadWindowSizeChanged, this, &UniversalSettings::saveConfig);
|
||||
@ -59,6 +66,25 @@ UniversalSettings::~UniversalSettings()
|
||||
}
|
||||
}
|
||||
|
||||
void UniversalSettings::clearAllAppletShortcuts()
|
||||
{
|
||||
KConfigGroup latteGroup = KConfigGroup(m_shortcutsConfigPtr, "lattedock");
|
||||
|
||||
foreach(auto key, latteGroup.keyList()) {
|
||||
if (key.startsWith("activate widget ")) {
|
||||
QAction *appletAction = new QAction(this);
|
||||
|
||||
appletAction->setText(QString("Activate ") + key);
|
||||
appletAction->setObjectName(key);
|
||||
appletAction->setShortcut(QKeySequence());
|
||||
KGlobalAccel::setGlobalShortcut(appletAction, QKeySequence());
|
||||
KGlobalAccel::self()->removeAllShortcuts(appletAction);
|
||||
|
||||
appletAction->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UniversalSettings::load()
|
||||
{
|
||||
//! check if user has set the autostart option
|
||||
@ -70,6 +96,8 @@ void UniversalSettings::load()
|
||||
|
||||
//! load configuration
|
||||
loadConfig();
|
||||
|
||||
clearAllAppletShortcuts();
|
||||
}
|
||||
|
||||
bool UniversalSettings::showInfoWindow() const
|
||||
|
@ -103,6 +103,8 @@ public:
|
||||
void enableActivitiesModel();
|
||||
void disableActivitiesModel();
|
||||
|
||||
void clearAllAppletShortcuts();
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE QString splitterIconPath();
|
||||
Q_INVOKABLE QString trademarkIconPath();
|
||||
@ -161,6 +163,7 @@ private:
|
||||
|
||||
KConfigGroup m_universalGroup;
|
||||
KSharedConfig::Ptr m_config;
|
||||
KSharedConfig::Ptr m_shortcutsConfigPtr;
|
||||
|
||||
SortedActivitiesModel *m_runningActivitiesModel{nullptr};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user