Commit 041a4eba authored by David Edmundson's avatar David Edmundson

Migrate powerdevil keyboard shortcuts

Summary:
Powerdevil "faked" that it's name was "kded5" presumably as a way to
keep user's keyboard shortcuts without having to write a kconf_update
script.

It then tried setting the component name to "power management".
This fails because immediately after it does so, kscreen (which has the component name kded5
because it is in kded5) automatically changes the name back to "KDE Daemon".

This means two things:
- the shortcuts don't end up under their own "power management" section
in system settings properly.
- kglobalaccel5 on every startup thinks that the locale is changed (as
a component has changed name) and does some complex heavy writing which we don't want.

This patch moves everything to their own component, and provides a
kconf_update script to move shortcuts.

Test Plan:
Confirmed shortcuts moved
Confirmed we have our own "Power Management" section in systemsettings global shortcuts
No more writing on starting kglobalaccel5

I'd be grateful if someone else could confirm that migration works correctly. Migration is hard to re-test.

Reviewers: #plasma, apol

Reviewed By: apol

Subscribers: apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9053
parent d492dc57
......@@ -75,6 +75,8 @@ add_definitions(-DQT_NO_KEYWORDS)
add_subdirectory(daemon)
add_subdirectory(kcmodule)
add_subdirectory(doc)
add_subdirectory(kconf_update)
install( FILES powerdevil.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR} )
......
......@@ -38,8 +38,6 @@
namespace PowerDevil {
namespace BundledActions {
static const QString s_globalAccelComponent = QStringLiteral("kded5");
BrightnessControl::BrightnessControl(QObject* parent)
: Action(parent)
{
......@@ -55,13 +53,11 @@ BrightnessControl::BrightnessControl(QObject* parent)
QAction* globalAction = actionCollection->addAction(QLatin1String("Increase Screen Brightness"));
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Increase Screen Brightness"));
globalAction->setProperty("componentName", s_globalAccelComponent);
KGlobalAccel::setGlobalShortcut(globalAction, Qt::Key_MonBrightnessUp);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(increaseBrightness()));
globalAction = actionCollection->addAction(QLatin1String("Decrease Screen Brightness"));
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Decrease Screen Brightness"));
globalAction->setProperty("componentName", s_globalAccelComponent);
KGlobalAccel::setGlobalShortcut(globalAction, Qt::Key_MonBrightnessDown);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(decreaseBrightness()));
}
......
......@@ -43,8 +43,6 @@
namespace PowerDevil {
namespace BundledActions {
static const QString s_globalAccelComponent = QStringLiteral("kded5");
HandleButtonEvents::HandleButtonEvents(QObject *parent)
: Action(parent)
, m_screenConfiguration(nullptr)
......@@ -62,19 +60,16 @@ HandleButtonEvents::HandleButtonEvents(QObject *parent)
QAction *globalAction = actionCollection->addAction("Sleep");
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Suspend"));
globalAction->setProperty("componentName", s_globalAccelComponent);
accel->setGlobalShortcut(globalAction, Qt::Key_Sleep);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToRam()));
globalAction = actionCollection->addAction("Hibernate");
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Hibernate"));
globalAction->setProperty("componentName", s_globalAccelComponent);
accel->setGlobalShortcut(globalAction, Qt::Key_Hibernate);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToDisk()));
globalAction = actionCollection->addAction("PowerOff");
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Power Off"));
globalAction->setProperty("componentName", s_globalAccelComponent);
accel->setGlobalShortcut(globalAction, Qt::Key_PowerOff);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(powerOffButtonTriggered()));
......
......@@ -43,8 +43,6 @@
namespace PowerDevil {
namespace BundledActions {
static const QString s_globalAccelComponent = QStringLiteral("kded5");
KeyboardBrightnessControl::KeyboardBrightnessControl(QObject* parent)
: Action(parent)
{
......@@ -61,19 +59,16 @@ KeyboardBrightnessControl::KeyboardBrightnessControl(QObject* parent)
QAction *globalAction = actionCollection->addAction(QLatin1String("Increase Keyboard Brightness"));
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Increase Keyboard Brightness"));
globalAction->setProperty("componentName", s_globalAccelComponent);
accel->setGlobalShortcut(globalAction, Qt::Key_KeyboardBrightnessUp);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(increaseKeyboardBrightness()));
globalAction = actionCollection->addAction(QLatin1String("Decrease Keyboard Brightness"));
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Decrease Keyboard Brightness"));
globalAction->setProperty("componentName", s_globalAccelComponent);
accel->setGlobalShortcut(globalAction, Qt::Key_KeyboardBrightnessDown);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(decreaseKeyboardBrightness()));
globalAction = actionCollection->addAction("Toggle Keyboard Backlight");
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Toggle Keyboard Backlight"));
globalAction->setProperty("componentName", s_globalAccelComponent);
accel->setGlobalShortcut(globalAction, Qt::Key_KeyboardLightOnOff);
connect(globalAction, SIGNAL(triggered(bool)), SLOT(toggleKeyboardBacklight()));
......
install(FILES powerdevil_move_shortcuts.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR})
Version=5
Id=powerdevil_move_shortcuts
File=kglobalshortcutsrc
Group=kded5, org_kde_powerdevil
Key=Hibernate
Key=PowerOff
Key=Sleep
Key=Decrease Keyboard Brightness
Key=Decrease Screen Brightness
Key=Increase Keyboard Brightness
Key=Increase Screen Brightness
Key=Toggle Keyboard Backlight
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