Commit 40bdb6c4 authored by Bhushan Shah's avatar Bhushan Shah 📱 Committed by Bhushan Shah

mobile: bind the power off key to "Turn Off Screen"

PowerOff key is currently bound to "PowerOff" action which then have 3
possible actions,

- Turn Off screen
- Show logout dialog
- Suspend session

This is super complicated and complicates the code elsewhere when on
mobile you want to allow turning screen off but not shutting down
action.

So simply on mobile, bind the Power key to Turn Screen Off action
instead of the PowerOff action
parent 68457117
......@@ -47,6 +47,7 @@ HandleButtonEvents::HandleButtonEvents(QObject *parent)
: Action(parent)
, m_screenConfiguration(nullptr)
{
const bool mobile = !qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_MOBILE");
new HandleButtonEventsAdaptor(this);
// We enforce no policies here - after all, we just call other actions - which have their policies.
setRequiredPolicies(PowerDevil::PolicyAgent::None);
......@@ -70,7 +71,9 @@ HandleButtonEvents::HandleButtonEvents(QObject *parent)
globalAction = actionCollection->addAction("PowerOff");
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Power Off"));
accel->setGlobalShortcut(globalAction, Qt::Key_PowerOff);
if (!mobile) {
accel->setGlobalShortcut(globalAction, Qt::Key_PowerOff);
}
connect(globalAction, SIGNAL(triggered(bool)), SLOT(powerOffButtonTriggered()));
globalAction = actionCollection->addAction("PowerDown");
......
......@@ -82,7 +82,12 @@ PowerDevilDPMSAction::PowerDevilDPMSAction(QObject* parent, const QVariantList &
QAction *globalAction = actionCollection->addAction(QLatin1String("Turn Off Screen"));
globalAction->setText(i18nc("@action:inmenu Global shortcut", "Turn Off Screen"));
accel->setGlobalShortcut(globalAction, QList<QKeySequence>());
const bool mobile = !qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_MOBILE");
if (!mobile) {
accel->setGlobalShortcut(globalAction, QList<QKeySequence>());
} else {
accel->setGlobalShortcut(globalAction, Qt::Key_PowerOff);
}
connect(globalAction, &QAction::triggered, this, [this] {
if (m_helper) {
if (m_lockBeforeTurnOff) {
......
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