From 0d1f923b5e28961d8a81f7aad8013c696d37517c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Fri, 29 Nov 2024 11:49:24 +0100 Subject: [PATCH] [shutdowndialog]: hide logout option config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds a config entry in plasmamobilerc which allows to hide the logout button in the shutdown dialog. As mobile systems are often effectively single user, this makes sense to offer in Plasma Mobile. Signed-off-by: Sebastian Kügler --- components/shellsettingsplugin/mobileshellsettings.cpp | 7 +++++++ components/shellsettingsplugin/mobileshellsettings.h | 9 +++++++++ lookandfeel/contents/logout/Logout.qml | 2 ++ 3 files changed, 18 insertions(+) diff --git a/components/shellsettingsplugin/mobileshellsettings.cpp b/components/shellsettingsplugin/mobileshellsettings.cpp index f90ff7e2..b9e3fc8d 100644 --- a/components/shellsettingsplugin/mobileshellsettings.cpp +++ b/components/shellsettingsplugin/mobileshellsettings.cpp @@ -39,6 +39,7 @@ MobileShellSettings::MobileShellSettings(QObject *parent) Q_EMIT actionDrawerTopLeftModeChanged(); Q_EMIT actionDrawerTopRightModeChanged(); Q_EMIT convergenceModeEnabledChanged(); + Q_EMIT allowLogoutChanged(); } }); } @@ -217,3 +218,9 @@ void MobileShellSettings::updateNavigationBarsInPlasma(bool navigationPanelEnabl // TODO check for error response QDBusConnection::sessionBus().asyncCall(message); } + +bool MobileShellSettings::allowLogout() const +{ + auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; + return group.readEntry("allowLogout", true); +} diff --git a/components/shellsettingsplugin/mobileshellsettings.h b/components/shellsettingsplugin/mobileshellsettings.h index d1c599e0..86194ece 100644 --- a/components/shellsettingsplugin/mobileshellsettings.h +++ b/components/shellsettingsplugin/mobileshellsettings.h @@ -45,6 +45,9 @@ class MobileShellSettings : public QObject // convergence mode Q_PROPERTY(bool convergenceModeEnabled READ convergenceModeEnabled WRITE setConvergenceModeEnabled NOTIFY convergenceModeEnabledChanged) + // logout dialog + Q_PROPERTY(bool allowLogout READ allowLogout READ allowLogout NOTIFY allowLogoutChanged) + public: MobileShellSettings(QObject *parent = nullptr); @@ -190,6 +193,11 @@ public: */ void setConvergenceModeEnabled(bool enabled); + /** + * Whether logout button is shown in the logout/shutdown dialog. + */ + bool allowLogout() const; + Q_SIGNALS: void vibrationsEnabledChanged(); void vibrationDurationChanged(); @@ -203,6 +211,7 @@ Q_SIGNALS: void actionDrawerTopLeftModeChanged(); void actionDrawerTopRightModeChanged(); void convergenceModeEnabledChanged(); + void allowLogoutChanged(); private: void updateNavigationBarsInPlasma(bool navigationPanelEnabled); diff --git a/lookandfeel/contents/logout/Logout.qml b/lookandfeel/contents/logout/Logout.qml index 6d269f3c..1bc0e7da 100644 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -15,6 +15,7 @@ import org.kde.kirigami 2.20 as Kirigami import org.kde.coreaddons 1.0 as KCoreAddons import org.kde.plasma.private.sessions 2.0 +import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings Item { id: root @@ -156,6 +157,7 @@ Item { ActionButton { iconSource: "system-log-out" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log Out") + visible: ShellSettings.Settings.allowLogout onClicked: { closeAnim.closeToBlack = true; closeAnim.execute(root.logoutRequested);