diff --git a/daemon/actions/dpms/CMakeLists.txt b/daemon/actions/dpms/CMakeLists.txt --- a/daemon/actions/dpms/CMakeLists.txt +++ b/daemon/actions/dpms/CMakeLists.txt @@ -18,6 +18,7 @@ XCB::DPMS KF5::CoreAddons KF5::ConfigGui + KF5::I18n KF5::WaylandClient Qt5::Widgets powerdevilcore) diff --git a/daemon/actions/dpms/powerdevildpmsaction.cpp b/daemon/actions/dpms/powerdevildpmsaction.cpp --- a/daemon/actions/dpms/powerdevildpmsaction.cpp +++ b/daemon/actions/dpms/powerdevildpmsaction.cpp @@ -28,11 +28,15 @@ #include #include +#include #include #include #include +#include #include +#include +#include #include #include @@ -67,6 +71,20 @@ // inhibitions persist over kded module unload/load m_inhibitScreen = PowerDevil::PolicyAgent::instance()->unavailablePolicies() & PowerDevil::PolicyAgent::ChangeScreenSettings; + + KGlobalAccel *accel = KGlobalAccel::self(); + + KActionCollection *actionCollection = new KActionCollection( this ); + actionCollection->setComponentDisplayName(i18nc("Name for powerdevil shortcuts category", "Power Management")); + + QAction *globalAction = actionCollection->addAction(QLatin1String("Turn Off Screen")); + globalAction->setText(i18nc("@action:inmenu Global shortcut", "Turn Off Screen")); + accel->setGlobalShortcut(globalAction, QList()); + connect(globalAction, &QAction::triggered, this, [this] { + if (m_helper) { + m_helper->trigger(QStringLiteral("TurnOff")); + } + }); } PowerDevilDPMSAction::~PowerDevilDPMSAction() = default;