From 207943bc0bc7f5fa78b6529ed16964a0829ed3f4 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Sat, 8 Sep 2018 13:40:16 +0300 Subject: [PATCH] Added debug mode --- README.md | 20 ++++++++++++++++++++ slice/Debug.qml | 37 +++++++++++++++++++++++++++++++++++++ slice/Main.qml | 19 +++++++++++++++++-- slice/PagePower.qml | 40 ++++++++++++++++++++-------------------- 4 files changed, 94 insertions(+), 22 deletions(-) create mode 100644 slice/Debug.qml diff --git a/README.md b/README.md index 99894ab..b77a4df 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,26 @@ Create file `theme.conf.user` in theme folder. See `slice/theme.conf` for refere * `bg_mode` - background image fill mode. Can be either `aspect`, `fill`, `tile` or `none`. Defaults to `aspect`. * `parallax_bg_shift` - shifting of parallax background on tab change in pixels. `0` disables parallax motion. Negative values will scroll background in opposite direction. Default is `20`. +### Debug mode options + +Since "Power" screen can't be viewed in greeter because it depends on `sddm.*` properties, there is a debug mode. + +#### Boolean options + +> You can use "0/1", "true/false" and "yes/no" on boolean options. All debug options are disabled by default. + +* `debug` - activates debug mode. +* `debug_can_power_off` - sets `sddm.canPowerOff` (shows "Shutdown"). +* `debug_can_reboot` - sets `sddm.canReboot` (shows "Reboot"). +* `debug_can_suspend` - sets `sddm.canSuspend` (shows "Suspend"). +* `debug_can_hibernate` - sets `sddm.canHibernate` (shows "Hibernate"). +* `debug_can_hybrid_sleep` - sets `sddm.canHybridSleep` (shows "Hybrid Sleep"). + +#### String options + +* `debug_hostname` - sets `sddm.hostName`. + + ### Color scheme There are many color options. In fact, too many. So now they are grouped by layers in [color scheme](https://github.com/RadRussianRus/sddm-slice/wiki/Color-scheme). Most of them are optional, only mandatory options are from [layer 1](https://github.com/RadRussianRus/sddm-slice/wiki/Layer-1): diff --git a/slice/Debug.qml b/slice/Debug.qml new file mode 100644 index 0000000..4344a33 --- /dev/null +++ b/slice/Debug.qml @@ -0,0 +1,37 @@ +import QtQuick 2.7 +import SddmComponents 2.0 + +Item +{ + readonly property bool active: bool(config.debug) + + function debugbool(config_value, real_property) + { + return (active && bool(config_value)) || real_property; + } + + function debugnum(config_value, real_property) + { + if (config_value === null || config_value === undefined) + return real_property; + + return active ? Number(config_value).valueOf() : real_property; + } + + function debugstr(config_value, real_property) + { + if (config_value === null || config_value === undefined) + return real_property; + + return active ? config_value : real_property; + } + + readonly property bool canPowerOff: debugbool(config.debug_can_power_off, sddm.canPowerOff) + readonly property bool canReboot: debugbool(config.debug_can_reboot, sddm.canReboot) + readonly property bool canSuspend: debugbool(config.debug_can_suspend, sddm.canSuspend) + readonly property bool canHibernate: debugbool(config.debug_can_hibernate, sddm.canHibernate) + readonly property bool canHybridSleep: debugbool(config.debug_can_hybrid_sleep, sddm.canHybridSleep) + + readonly property string hostName: debugstr(config.debug_hostname, sddm.hostName) + +} \ No newline at end of file diff --git a/slice/Main.qml b/slice/Main.qml index 1c3c920..f91a8e6 100644 --- a/slice/Main.qml +++ b/slice/Main.qml @@ -56,7 +56,22 @@ Rectangle } ] + function bool(str) { + if (str === null || str === undefined) + return false; + + str = str.toLowerCase(); + + if (str === "false" || str === "no") + return false; + else if (str === "true" || str === "yes") + return true; + + return Boolean(Number(str).valueOf()).valueOf(); + } + TextConstants { id: localeText } + Debug { id: debug } function bgFillMode() { @@ -107,9 +122,9 @@ Rectangle y: 5 hasLeftSlice: false - text: sddm.hostName ? sddm.hostName : "Hostname" + text: debug.hostName ? debug.hostName : "Hostname" - enabled: sddm.canPowerOff || sddm.canReboot || sddm.canSuspend || sddm.canHibernate || sddm.canHybridSleep + enabled: debug.canPowerOff || debug.canReboot || debug.canSuspend || debug.canHibernate || debug.canHybridSleep onClicked: if (enabled) root.state = "statePower" } diff --git a/slice/PagePower.qml b/slice/PagePower.qml index 129942d..d434075 100644 --- a/slice/PagePower.qml +++ b/slice/PagePower.qml @@ -10,11 +10,11 @@ Item property int selectedIndex: { - if (sddm.canPowerOff) return 0 - else if (sddm.canReboot) return 1 - else if (sddm.canSuspend) return 2 - else if (sddm.canHibernate) return 3 - else if (sddm.canHybridSleep) return 4 + if (debug.canPowerOff) return 0 + else if (debug.canReboot) return 1 + else if (debug.canSuspend) return 2 + else if (debug.canHibernate) return 3 + else if (debug.canHybridSleep) return 4 else return 0 } @@ -64,7 +64,7 @@ Item Layout.alignment: Qt.AlignVCenter Layout.minimumHeight: 48 - visible: sddm.canPowerOff + visible: debug.canPowerOff onEntered: selectedIndex = 0 onClicked: { selectedIndex = 0; execute() } } @@ -80,7 +80,7 @@ Item Layout.alignment: Qt.AlignVCenter Layout.minimumHeight: 48 - visible: sddm.canReboot + visible: debug.canReboot onEntered: selectedIndex = 1 onClicked: { selectedIndex = 1; execute() } @@ -98,7 +98,7 @@ Item Layout.alignment: Qt.AlignVCenter Layout.minimumHeight: 48 - visible: sddm.canSuspend + visible: debug.canSuspend onEntered: selectedIndex = 2 onClicked: { selectedIndex = 2; execute() } @@ -115,7 +115,7 @@ Item Layout.alignment: Qt.AlignVCenter Layout.minimumHeight: 48 - visible: sddm.canHibernate + visible: debug.canHibernate onEntered: selectedIndex = 3 onClicked: { selectedIndex = 3; execute() } @@ -133,7 +133,7 @@ Item Layout.alignment: Qt.AlignVCenter Layout.minimumHeight: 48 - visible: sddm.canHybridSleep + visible: debug.canHybridSleep onEntered: selectedIndex = 4 onClicked: { selectedIndex = 4; execute() } @@ -168,23 +168,23 @@ Item switch (result) { case 0: - if (sddm.canPowerOff) actionFound = true + if (debug.canPowerOff) actionFound = true break case 1: - if (sddm.canReboot) actionFound = true + if (debug.canReboot) actionFound = true break case 2: - if (sddm.canSuspend) actionFound = true + if (debug.canSuspend) actionFound = true break case 3: - if (sddm.canHibernate) actionFound = true + if (debug.canHibernate) actionFound = true break case 4: - if (sddm.canHybridSleep) actionFound = true + if (debug.canHybridSleep) actionFound = true break } @@ -211,23 +211,23 @@ Item switch (result) { case 0: - if (sddm.canPowerOff) actionFound = true + if (debug.canPowerOff) actionFound = true break case 1: - if (sddm.canReboot) actionFound = true + if (debug.canReboot) actionFound = true break case 2: - if (sddm.canSuspend) actionFound = true + if (debug.canSuspend) actionFound = true break case 3: - if (sddm.canHibernate) actionFound = true + if (debug.canHibernate) actionFound = true break case 4: - if (sddm.canHybridSleep) actionFound = true + if (debug.canHybridSleep) actionFound = true break }