diff --git a/components/shellsettingsplugin/CMakeLists.txt b/components/shellsettingsplugin/CMakeLists.txt index 2f68a927..1074bf51 100644 --- a/components/shellsettingsplugin/CMakeLists.txt +++ b/components/shellsettingsplugin/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later ecm_add_qml_module(shellsettingsplugin URI org.kde.plasma.private.mobileshell.shellsettingsplugin GENERATE_PLUGIN_SOURCE) -target_sources(shellsettingsplugin PRIVATE mobileshellsettings.cpp) +target_sources(shellsettingsplugin PRIVATE kwinsettings.cpp mobileshellsettings.cpp) target_link_libraries(shellsettingsplugin PRIVATE Qt::Qml diff --git a/components/shellsettingsplugin/kwinsettings.cpp b/components/shellsettingsplugin/kwinsettings.cpp new file mode 100644 index 00000000..e6c2aa40 --- /dev/null +++ b/components/shellsettingsplugin/kwinsettings.cpp @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2025 Florian RICHER + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "kwinsettings.h" + +const QString CONFIG_FILE = QStringLiteral("kwinrc"); +const QString WAYLAND_CONFIG_GROUP = QStringLiteral("Wayland"); + +KWinSettings::KWinSettings(QObject *parent) + : QObject{parent} + , m_config{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)} +{ + m_configWatcher = KConfigWatcher::create(m_config); + connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) -> void { + Q_UNUSED(names) + if (group.name() == WAYLAND_CONFIG_GROUP) { + Q_EMIT doubleTapWakeupChanged(); + } + }); +} + +bool KWinSettings::doubleTapWakeup() const +{ + auto group = KConfigGroup{m_config, WAYLAND_CONFIG_GROUP}; + return group.readEntry("DoubleTapWakeup", true); +} + +void KWinSettings::setDoubleTapWakeup(bool enabled) +{ + auto group = KConfigGroup{m_config, WAYLAND_CONFIG_GROUP}; + group.writeEntry("DoubleTapWakeup", enabled, KConfigGroup::Notify); + m_config->sync(); +} diff --git a/components/shellsettingsplugin/kwinsettings.h b/components/shellsettingsplugin/kwinsettings.h new file mode 100644 index 00000000..99bd6682 --- /dev/null +++ b/components/shellsettingsplugin/kwinsettings.h @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2025 Florian RICHER + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#pragma once + +#include +#include +#include +#include +#include + +class KWinSettings : public QObject +{ + Q_OBJECT + QML_NAMED_ELEMENT(KWinSettings) + QML_SINGLETON + + Q_PROPERTY(bool doubleTapWakeup READ doubleTapWakeup WRITE setDoubleTapWakeup NOTIFY doubleTapWakeupChanged) + +public: + KWinSettings(QObject *parent = nullptr); + + /** + * Whether Double Tap to Wakeup is enabled. + */ + bool doubleTapWakeup() const; + + /** + * Set whether Double Tap to Wakeup is enabled. + * + * @param enabled + */ + void setDoubleTapWakeup(bool enabled); + +Q_SIGNALS: + void doubleTapWakeupChanged(); + +private: + KConfigWatcher::Ptr m_configWatcher; + KSharedConfig::Ptr m_config; +}; diff --git a/kcms/mobileshell/ui/main.qml b/kcms/mobileshell/ui/main.qml index 771ddc18..e6becfd7 100644 --- a/kcms/mobileshell/ui/main.qml +++ b/kcms/mobileshell/ui/main.qml @@ -61,6 +61,20 @@ KCM.SimpleKCM { } } } + + FormCard.FormDelegateSeparator { above: autoHidePanels; below: doubleTapWakeup } + + FormCard.FormSwitchDelegate { + id: doubleTapWakeup + text: i18n("Double Tap to Wakeup") + description: i18n("When active, it allow to wakeup the device just with double tap when the screen is off.") + checked: ShellSettings.KWinSettings.doubleTapWakeup + onCheckedChanged: { + if (checked != ShellSettings.KWinSettings.doubleTapWakeup) { + ShellSettings.KWinSettings.doubleTapWakeup = checked; + } + } + } } FormCard.FormHeader { diff --git a/shell/contents/lockscreen/LockScreen.qml b/shell/contents/lockscreen/LockScreen.qml index e9bf43e6..06bf7dfb 100644 --- a/shell/contents/lockscreen/LockScreen.qml +++ b/shell/contents/lockscreen/LockScreen.qml @@ -11,6 +11,7 @@ import org.kde.notificationmanager as Notifications import org.kde.plasma.private.mobileshell as MobileShell import org.kde.plasma.private.mobileshell.dpmsplugin as DPMS import org.kde.plasma.components 3.0 as PC3 +import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings import org.kde.kirigami 2.12 as Kirigami @@ -207,6 +208,23 @@ Item { color: Qt.rgba(0, 0, 0, 0.5) } + MouseArea { + // Disable "double tap to lock" to avoid accidental locking + // when the keypad is open, and the user is typing their password. + enabled: flickable.openFactor < 0.1 + anchors.fill: parent + + onDoubleClicked: (mouse) => { + if (ShellSettings.KWinSettings.doubleTapWakeup) { + deviceLock.triggerLock(); + } + } + + MobileShell.DeviceLock { + id: deviceLock + } + } + Keypad { id: keypad visible: !root.lockScreenState.canBeUnlocked // don't show for passwordless login