From f11aea02a8ed7bc9530e05f74d5f3316b480a09b Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 19 Jan 2025 15:34:58 +1300 Subject: [PATCH] Add help and reset to UI for ppt values --- CHANGELOG.md | 3 +- asusd/src/asus_armoury.rs | 21 +++ rog-control-center/build.rs | 2 +- .../translations/en/rog-control-center.po | 141 +++++++++++++----- rog-control-center/ui/main_window.slint | 24 +-- rog-control-center/ui/pages/system.slint | 102 ++++++++++--- rog-control-center/ui/widgets/common.slint | 140 ++++++++++++++--- 7 files changed, 333 insertions(+), 100 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f45e322..e3360c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ### Changed - Per-AC/DC, per-profile tunings enabled (Battery vs AC power + platform profile) -- Add ability to restore PPT defaults (WIP) +- Add ability to restore PPT defaults +- Add PPT help dialogue to UI ## [v6.1.0-rc4] diff --git a/asusd/src/asus_armoury.rs b/asusd/src/asus_armoury.rs index ae23718d..7ce63804 100644 --- a/asusd/src/asus_armoury.rs +++ b/asusd/src/asus_armoury.rs @@ -181,6 +181,27 @@ impl AsusArmouryAttribute { async fn restore_default(&self) -> fdo::Result<()> { self.attr.restore_default()?; + if self.name().is_ppt() { + let profile: ThrottlePolicy = + ThrottlePolicy::from_str(self.platform.get_platform_profile()?.as_str())?; + let power_plugged = self + .power + .get_online() + .map_err(|e| { + error!("Could not get power status: {e:?}"); + e + }) + .unwrap_or_default(); + + let mut config = self.config.lock().await; + let tunings = config.select_tunings(power_plugged == 1, profile); + if let Some(tune) = tunings.get_mut(&self.name()) { + if let AttrValue::Integer(i) = self.attr.default_value() { + *tune = *i; + } + } + config.write(); + } Ok(()) } diff --git a/rog-control-center/build.rs b/rog-control-center/build.rs index 55fac09e..a4aa1370 100644 --- a/rog-control-center/build.rs +++ b/rog-control-center/build.rs @@ -20,7 +20,7 @@ fn main() { CompilerConfiguration::new() // .embed_resources(EmbedResourcesKind::EmbedFiles) .with_include_paths(vec![include]) - .with_style("fluent-dark".into()) + .with_style("fluent".into()) ) .unwrap(); } diff --git a/rog-control-center/translations/en/rog-control-center.po b/rog-control-center/translations/en/rog-control-center.po index 6093f4f7..66014f1a 100644 --- a/rog-control-center/translations/en/rog-control-center.po +++ b/rog-control-center/translations/en/rog-control-center.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2025-01-18 23:02+0000\n" +"POT-Creation-Date: 2025-01-19 02:34+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -292,142 +292,198 @@ msgctxt "SystemPageData" msgid "Power" msgstr "" -#: rog-control-center/ui/pages/system.slint:138 +#: rog-control-center/ui/pages/system.slint:139 msgctxt "PageSystem" msgid "Power settings" msgstr "" -#: rog-control-center/ui/pages/system.slint:143 +#: rog-control-center/ui/pages/system.slint:144 msgctxt "PageSystem" msgid "Charge limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:155 +#: rog-control-center/ui/pages/system.slint:157 msgctxt "PageSystem" msgid "Throttle Policy" msgstr "" -#: rog-control-center/ui/pages/system.slint:165 +#: rog-control-center/ui/pages/system.slint:167 msgctxt "PageSystem" msgid "Advanced" msgstr "" -#: rog-control-center/ui/pages/system.slint:183 +#: rog-control-center/ui/pages/system.slint:185 msgctxt "PageSystem" msgid "Armoury settings" msgstr "" -#: rog-control-center/ui/pages/system.slint:191 +#: rog-control-center/ui/pages/system.slint:193 msgctxt "PageSystem" msgid "Panel Overdrive" msgstr "" -#: rog-control-center/ui/pages/system.slint:199 +#: rog-control-center/ui/pages/system.slint:201 msgctxt "PageSystem" msgid "MiniLED Mode" msgstr "" -#: rog-control-center/ui/pages/system.slint:207 +#: rog-control-center/ui/pages/system.slint:209 msgctxt "PageSystem" msgid "POST boot sound" msgstr "" -#: rog-control-center/ui/pages/system.slint:218 -msgctxt "PageSystem" +#: rog-control-center/ui/pages/system.slint:223 +msgctxt "no_asus_armoury_driver_2" msgid "The asus-armoury driver is not loaded" msgstr "" -#: rog-control-center/ui/pages/system.slint:223 -msgctxt "PageSystem" +#: rog-control-center/ui/pages/system.slint:229 +msgctxt "no_asus_armoury_driver_2" msgid "For advanced features you will require a kernel with this driver added." msgstr "" -#: rog-control-center/ui/pages/system.slint:234 +#: rog-control-center/ui/pages/system.slint:240 msgctxt "ppt_warning" -msgid "The following settings may not be safe, please take care." +msgid "The following settings may not be safe, please review the help." msgstr "" -#: rog-control-center/ui/pages/system.slint:239 +#: rog-control-center/ui/pages/system.slint:245 rog-control-center/ui/pages/system.slint:246 msgctxt "ppt_pl1_spl" -msgid "PL1, sustained power limit" +msgid "CPU Sustained Power Limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:250 +#: rog-control-center/ui/pages/system.slint:247 +msgctxt "ppt_pl1_spl_help" +msgid "" +"Long-term CPU power limit that affects sustained workload performance. " +"Higher values may increase heat and power consumption." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:262 rog-control-center/ui/pages/system.slint:263 msgctxt "ppt_pl2_sppt" -msgid "PL2, turbo power limit" +msgid "CPU Turbo Power Limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:261 +#: rog-control-center/ui/pages/system.slint:264 +msgctxt "ppt_pl2_sppt_help" +msgid "" +"Short-term CPU power limit for boost periods. Controls maximum power during " +"brief high-performance bursts." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:279 rog-control-center/ui/pages/system.slint:280 msgctxt "ppt_pl3_fppt" -msgid "PL3, Fast Power Limit" +msgid "CPU Fast Burst Power Limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:271 +#: rog-control-center/ui/pages/system.slint:281 +msgctxt "ppt_pl3_fppt_help" +msgid "" +"Ultra-short duration power limit for instantaneous CPU bursts. Affects " +"responsiveness during sudden workload spikes." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:295 rog-control-center/ui/pages/system.slint:296 msgctxt "ppt_fppt" -msgid "FPPT, Fast Power Limit" +msgid "Fast Package Power Limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:282 +#: rog-control-center/ui/pages/system.slint:297 +msgctxt "ppt_fppt_help" +msgid "" +"Ultra-short duration power limit for system package. Controls maximum power " +"during millisecond-scale load spikes." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:312 rog-control-center/ui/pages/system.slint:313 msgctxt "ppt_apu_sppt" -msgid "SPPT, APU slow power limit" +msgid "APU Sustained Power Limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:293 +#: rog-control-center/ui/pages/system.slint:314 +msgctxt "ppt_apu_sppt_help" +msgid "" +"Long-term power limit for integrated graphics and CPU combined. Affects " +"sustained performance of APU-based workloads." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:329 rog-control-center/ui/pages/system.slint:330 msgctxt "ppt_platform_sppt" -msgid "Slow package power tracking limit" +msgid "Platform Sustained Power Limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:304 +#: rog-control-center/ui/pages/system.slint:331 +msgctxt "ppt_platform_sppt_help" +msgid "" +"Overall system power limit for sustained operations. Controls total platform " +"power consumption over extended periods." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:346 rog-control-center/ui/pages/system.slint:347 msgctxt "nv_dynamic_boost" -msgid "dGPU boost overclock" +msgid "GPU Power Boost" msgstr "" -#: rog-control-center/ui/pages/system.slint:315 +#: rog-control-center/ui/pages/system.slint:348 +msgctxt "nv_dynamic_boost_help" +msgid "" +"Additional power allocation for GPU dynamic boost. Higher values increase " +"GPU performance but generate more heat." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:363 rog-control-center/ui/pages/system.slint:364 msgctxt "nv_temp_target" -msgid "dGPU temperature max" +msgid "GPU Temperature Limit" msgstr "" -#: rog-control-center/ui/pages/system.slint:362 +#: rog-control-center/ui/pages/system.slint:365 +msgctxt "nv_temp_target_help" +msgid "" +"Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain " +"temperature below this limit." +msgstr "" + +#: rog-control-center/ui/pages/system.slint:416 msgctxt "PageSystem" msgid "Energy Performance Preference linked to Throttle Policy" msgstr "" -#: rog-control-center/ui/pages/system.slint:366 +#: rog-control-center/ui/pages/system.slint:420 msgctxt "PageSystem" msgid "Change EPP based on Throttle Policy" msgstr "" -#: rog-control-center/ui/pages/system.slint:374 +#: rog-control-center/ui/pages/system.slint:428 msgctxt "PageSystem" msgid "EPP for Balanced Policy" msgstr "" -#: rog-control-center/ui/pages/system.slint:384 +#: rog-control-center/ui/pages/system.slint:438 msgctxt "PageSystem" msgid "EPP for Performance Policy" msgstr "" -#: rog-control-center/ui/pages/system.slint:394 +#: rog-control-center/ui/pages/system.slint:448 msgctxt "PageSystem" msgid "EPP for Quiet Policy" msgstr "" -#: rog-control-center/ui/pages/system.slint:412 +#: rog-control-center/ui/pages/system.slint:466 msgctxt "PageSystem" msgid "Throttle Policy for power state" msgstr "" -#: rog-control-center/ui/pages/system.slint:418 +#: rog-control-center/ui/pages/system.slint:472 msgctxt "PageSystem" msgid "Throttle Policy on Battery" msgstr "" -#: rog-control-center/ui/pages/system.slint:428 rog-control-center/ui/pages/system.slint:449 +#: rog-control-center/ui/pages/system.slint:482 rog-control-center/ui/pages/system.slint:503 msgctxt "PageSystem" msgid "Enabled" msgstr "" -#: rog-control-center/ui/pages/system.slint:439 +#: rog-control-center/ui/pages/system.slint:493 msgctxt "PageSystem" msgid "Throttle Policy on AC" msgstr "" @@ -667,6 +723,11 @@ msgctxt "AuraPowerGroupOld" msgid "Sleep" msgstr "" +#: rog-control-center/ui/widgets/common.slint:133 +msgctxt "confirm_reset" +msgid "Are you sure you want to reset this?" +msgstr "" + #: rog-control-center/ui/main_window.slint:51 msgctxt "MainWindow" msgid "ROG" diff --git a/rog-control-center/ui/main_window.slint b/rog-control-center/ui/main_window.slint index 090f1b30..b535ef38 100644 --- a/rog-control-center/ui/main_window.slint +++ b/rog-control-center/ui/main_window.slint @@ -21,8 +21,8 @@ export component MainWindow inherits Window { title: "ROG Control"; default-font-family: "DejaVu Sans"; in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true]; - private property show-notif; - private property fade-cover; + private property show_notif; + private property fade_cover; private property toast: false; private property toast_text: "I show when something is waiting"; callback show_toast(string); @@ -31,10 +31,10 @@ export component MainWindow inherits Window { toast_text = text; } callback exit-app(); - callback show-notification(bool); - show-notification(yes) => { - show-notif = yes; - fade-cover = yes; + callback show_notification(bool); + show_notification(yes) => { + show_notif = yes; + fade_cover = yes; } callback external_colour_change(); external_colour_change() => { @@ -109,7 +109,7 @@ export component MainWindow inherits Window { } } - if fade-cover: Rectangle { + if fade_cover: Rectangle { x: 0px; y: 0px; width: root.width; @@ -121,10 +121,10 @@ export component MainWindow inherits Window { width: 100%; clicked => { // toolbar-dropdown.close(); - if (show-notif) { - show-notif = false; + if (show_notif) { + show_notif = false; } - fade-cover = false; + fade_cover = false; } } } @@ -156,7 +156,7 @@ export component MainWindow inherits Window { } // // TODO: or use Dialogue - if show-notif: Rectangle { + if show_notif: Rectangle { x: root.width / 8; y: root.height / 8; height: (root.height / 8) * 6; @@ -165,7 +165,7 @@ export component MainWindow inherits Window { height: 100%; width: 100%; clicked => { - show-notif = false; + show_notif = false; exit-app(); } } diff --git a/rog-control-center/ui/pages/system.slint b/rog-control-center/ui/pages/system.slint index 6129551f..7e215a03 100644 --- a/rog-control-center/ui/pages/system.slint +++ b/rog-control-center/ui/pages/system.slint @@ -125,6 +125,7 @@ export component PageSystem inherits Rectangle { VerticalLayout { padding: 10px; spacing: 10px; + alignment: LayoutAlignment.start; Rectangle { background: Palette.alternate-background; border-color: Palette.accent-background; @@ -143,6 +144,7 @@ export component PageSystem inherits Rectangle { text: @tr("Charge limit"); minimum: 20; maximum: 100; + has_reset: false; value <=> SystemPageData.charge_control_end_threshold; released => { SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold)) @@ -213,33 +215,43 @@ export component PageSystem inherits Rectangle { } if !SystemPageData.asus_armoury_loaded: Rectangle { - VerticalBox { - Text { - text: @tr("The asus-armoury driver is not loaded"); - font-size: 16px; - horizontal-alignment: TextHorizontalAlignment.center; + border-width: 3px; + border-color: red; + max-height: 30px; + VerticalBox { + Text { + text: @tr("no_asus_armoury_driver_2" => "The asus-armoury driver is not loaded"); + font-size: 16px; + horizontal-alignment: TextHorizontalAlignment.center; + } + + Text { + text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added."); + font-size: 16px; + horizontal-alignment: TextHorizontalAlignment.center; + } } - Text { - text: @tr("For advanced features you will require a kernel with this driver added."); - font-size: 16px; - horizontal-alignment: TextHorizontalAlignment.center; - } - } } if SystemPageData.ppt_pl1_spl.val != -1: Rectangle { - height: 32px; - Text { - font-size: 16px; - text: @tr("ppt_warning" => "The following settings may not be safe, please take care."); - } + height: 32px; + Text { + font-size: 16px; + text: @tr("ppt_warning" => "The following settings may not be safe, please review the help."); + } } if SystemPageData.ppt_pl1_spl.val != -1: SystemSlider { - text: @tr("ppt_pl1_spl" => "PL1, sustained power limit"); + text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit"); + title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit"); + help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption."); minimum: SystemPageData.ppt_pl1_spl.min; maximum: SystemPageData.ppt_pl1_spl.max; value: SystemPageData.ppt_pl1_spl.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_ppt_pl1_spl(); + } released => { SystemPageData.ppt_pl1_spl.val = self.value; SystemPageData.cb_ppt_pl1_spl(Math.round(self.value)) @@ -247,10 +259,16 @@ export component PageSystem inherits Rectangle { } if SystemPageData.ppt_pl2_sppt.val != -1: SystemSlider { - text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit"); + text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit"); + title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit"); + help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts."); minimum: SystemPageData.ppt_pl2_sppt.min; maximum: SystemPageData.ppt_pl2_sppt.max; value: SystemPageData.ppt_pl2_sppt.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_ppt_pl2_sppt(); + } released => { SystemPageData.ppt_pl2_sppt.val = self.value; SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value)) @@ -258,20 +276,32 @@ export component PageSystem inherits Rectangle { } if SystemPageData.ppt_pl3_fppt.val != -1: SystemSlider { - text: @tr("ppt_pl3_fppt" => "PL3, Fast Power Limit"); + text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit"); + title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit"); + help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes."); minimum: SystemPageData.ppt_pl3_fppt.min; maximum: SystemPageData.ppt_pl3_fppt.max; value: SystemPageData.ppt_pl3_fppt.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_ppt_pl3_fppt(); + } released => { SystemPageData.ppt_pl3_fppt.val = self.value; SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value)) } } if SystemPageData.ppt_fppt.val != -1: SystemSlider { - text: @tr("ppt_fppt" => "FPPT, Fast Power Limit"); + text: @tr("ppt_fppt" => "Fast Package Power Limit"); + title: @tr("ppt_fppt" => "Fast Package Power Limit"); + help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes."); minimum: SystemPageData.ppt_fppt.min; maximum: SystemPageData.ppt_fppt.max; value: SystemPageData.ppt_fppt.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_ppt_fppt(); + } released => { SystemPageData.ppt_fppt.val = self.value; SystemPageData.cb_ppt_fppt(Math.round(self.value)) @@ -279,10 +309,16 @@ export component PageSystem inherits Rectangle { } if SystemPageData.ppt_apu_sppt.val != -1: SystemSlider { - text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit"); + text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit"); + title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit"); + help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads."); minimum: SystemPageData.ppt_apu_sppt.min; maximum: SystemPageData.ppt_apu_sppt.max; value: SystemPageData.ppt_apu_sppt.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_ppt_apu_sppt(); + } released => { SystemPageData.ppt_apu_sppt.val = self.value; SystemPageData.cb_ppt_apu_sppt(Math.round(self.value)) @@ -290,10 +326,16 @@ export component PageSystem inherits Rectangle { } if SystemPageData.ppt_platform_sppt.val != -1: SystemSlider { - text: @tr("ppt_platform_sppt" => "Slow package power tracking limit"); + text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit"); + title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit"); + help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods."); minimum: SystemPageData.ppt_platform_sppt.min; maximum: SystemPageData.ppt_platform_sppt.max; value: SystemPageData.ppt_platform_sppt.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_ppt_platform_sppt(); + } released => { SystemPageData.ppt_platform_sppt.val = self.value; SystemPageData.cb_ppt_platform_sppt(Math.round(self.value)) @@ -301,10 +343,16 @@ export component PageSystem inherits Rectangle { } if SystemPageData.nv_dynamic_boost.val != -1: SystemSlider { - text: @tr("nv_dynamic_boost" => "dGPU boost overclock"); + text: @tr("nv_dynamic_boost" => "GPU Power Boost"); + title: @tr("nv_dynamic_boost" => "GPU Power Boost"); + help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat."); minimum: SystemPageData.nv_dynamic_boost.min; maximum: SystemPageData.nv_dynamic_boost.max; value: SystemPageData.nv_dynamic_boost.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_nv_dynamic_boost(); + } released => { SystemPageData.nv_dynamic_boost.val = self.value; SystemPageData.cb_nv_dynamic_boost(Math.round(self.value)) @@ -312,10 +360,16 @@ export component PageSystem inherits Rectangle { } if SystemPageData.nv_temp_target.val != -1: SystemSlider { - text: @tr("nv_temp_target" => "dGPU temperature max"); + text: @tr("nv_temp_target" => "GPU Temperature Limit"); + title: @tr("nv_temp_target" => "GPU Temperature Limit"); + help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit."); minimum: SystemPageData.nv_temp_target.min; maximum: SystemPageData.nv_temp_target.max; value: SystemPageData.nv_temp_target.val; + has_reset: true; + cb_do_reset => { + SystemPageData.cb_default_nv_temp_target(); + } released => { SystemPageData.nv_temp_target.val = self.value; SystemPageData.cb_nv_temp_target(Math.round(self.value)) diff --git a/rog-control-center/ui/widgets/common.slint b/rog-control-center/ui/widgets/common.slint index c7b54151..5ec70af4 100644 --- a/rog-control-center/ui/widgets/common.slint +++ b/rog-control-center/ui/widgets/common.slint @@ -10,40 +10,46 @@ export component RogItem inherits Rectangle { } export component SystemSlider inherits RogItem { + in property title; in property text; in-out property value; in-out property minimum; in-out property maximum; callback released(int); + in-out property help_text; + in-out property has_reset: false; + callback cb_do_reset(); + HorizontalLayout { HorizontalLayout { - width: 50%; + width: 40%; alignment: LayoutAlignment.stretch; padding-left: 10px; TouchArea { - clicked => { - slider.value += 1; - if slider.value > slider.maximum { - slider.value = slider.minimum; + clicked => { + slider.value += 1; + if slider.value > slider.maximum { + slider.value = slider.minimum; + } } - } - HorizontalLayout { - spacing: 6px; - Text { - font-size: 16px; - vertical-alignment: TextVerticalAlignment.center; - color: Palette.control-foreground; - text <=> root.text; + HorizontalLayout { + spacing: 6px; + Text { + font-size: 16px; + vertical-alignment: TextVerticalAlignment.center; + color: Palette.control-foreground; + text <=> root.text; + } + + Text { + font-size: 16px; + horizontal-alignment: TextHorizontalAlignment.right; + vertical-alignment: TextVerticalAlignment.center; + color: Palette.control-foreground; + text: "\{Math.round(root.value)}"; + } } - Text { - font-size: 16px; - horizontal-alignment: TextHorizontalAlignment.right; - vertical-alignment: TextVerticalAlignment.center; - color: Palette.control-foreground; - text: "\{Math.round(root.value)}"; - } - } } } @@ -59,6 +65,96 @@ export component SystemSlider inherits RogItem { } } } + + help_popup := PopupWindow { + x: help.x - self.width + help.width - 10px; + y: help.y - self.height + help.height - 10px; + Rectangle { + drop-shadow-blur: 10px; + drop-shadow-color: black; + border-radius: 10px; + border-color: Palette.accent-background; + background: Palette.background; + Dialog { + title <=> root.title; + VerticalBox { + Text { + max-width: 420px; + font-size: 18px; + wrap: TextWrap.word-wrap; + horizontal-alignment: TextHorizontalAlignment.center; + text <=> root.title; + } + + Rectangle { + height: 1px; + border-color: black; + border-width: 1px; + } + + Text { + max-width: 420px; + font-size: 16px; + wrap: TextWrap.word-wrap; + text <=> root.help_text; + } + } + + StandardButton { + kind: ok; + } + } + } + } + + help := HorizontalBox { + if (help_text != ""): StandardButton { + kind: StandardButtonKind.help; + clicked => { + help_popup.show(); + } + } + } + + reset_popup := PopupWindow { + x: reset.x - self.width + reset.width; + y: reset.y - self.height + reset.height; + Rectangle { + drop-shadow-blur: 10px; + drop-shadow-color: black; + border-radius: 10px; + border-color: Palette.accent-background; + background: Palette.background; + Dialog { + Text { + max-width: 420px; + font-size: 16px; + wrap: TextWrap.word-wrap; + text: @tr("confirm_reset" => "Are you sure you want to reset this?"); + } + + StandardButton { + kind: ok; + clicked => { + root.cb_do_reset(); + } + } + + StandardButton { + kind: cancel; + } + } + } + } + + reset := HorizontalBox { + if (has_reset): StandardButton { + kind: StandardButtonKind.reset; + clicked => { + reset_popup.show(); + } + } + } } } @@ -114,7 +210,7 @@ export component SystemToggleInt inherits RogItem { alignment: LayoutAlignment.end; padding-right: 20px; Switch { - checked: root.checked_int != 0; + checked: root.checked_int != 0; toggled => { root.checked_int = self.checked ? 1 : 0; root.toggled(root.checked_int);