From 77924b50971f7f78e5c151ce3c716c3cee335aa1 Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Tue, 23 May 2023 22:38:19 +0200 Subject: [PATCH] Add confirmation to power PowerWidget For it to actually do something, we need to click twice within 2s. The clicked button also changes color for visual indication on what was pressed See https://github.com/scorpion-26/gBar/issues/17 --- css/style.css | 4 +++ css/style.scss | 4 +++ src/Bar.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 86 insertions(+), 10 deletions(-) diff --git a/css/style.css b/css/style.css index 46bc34b..3a2bb03 100644 --- a/css/style.css +++ b/css/style.css @@ -46,6 +46,10 @@ margin-right: 6px; } +.system-confirm { + color: #50fa7b; +} + trough { border-radius: 3px; border-width: 1px; diff --git a/css/style.scss b/css/style.scss index d34745a..16ddfd1 100644 --- a/css/style.scss +++ b/css/style.scss @@ -80,6 +80,10 @@ $textsize: 16px; margin-right: 6px; } +.system-confirm { + color: $green; +} + // Common slider settings trough { border-radius: 3px; diff --git a/src/Bar.cpp b/src/Bar.cpp index 71d450d..085db1d 100644 --- a/src/Bar.cpp +++ b/src/Bar.cpp @@ -505,6 +505,34 @@ namespace Bar void WidgetPower(Widget& parent) { + // TODO: Abstract this (Currently not DRY) + static bool activatedExit = false; + static bool activatedLock = false; + static bool activatedSuspend = false; + static bool activatedReboot = false; + static bool activatedShutdown = false; + + auto setActivate = [](Button& button, bool& activeBool, bool activate) + { + if (activate) + { + button.AddClass("system-confirm"); + button.AddTimer