11import QtQuick
22import QtQuick.Layouts
3+ import Quickshell
34import qs.Commons
45import qs.Widgets
56
67ColumnLayout {
78 id: root
8-
99 property var pluginApi: null
1010
11- property var cfg: pluginApi? .pluginSettings || ({})
12- property var defaults: pluginApi? .manifest ? .metadata ? .defaultSettings || ({})
11+ // Settings and default values (Official Noctalia pattern)
12+ readonly property var cfg: pluginApi? .pluginSettings || ({})
13+ readonly property var defaults: pluginApi? .manifest ? .metadata ? .defaultSettings || ({})
14+
15+ // 1. Local state ('edit' convention to avoid unnecessary disk writes)
16+ property string editOverlayPath: cfg .overlayPath ?? defaults .overlayPath ?? " ~/.cache/noctalia/HVE/overlay.conf"
17+ property bool editAutoApply: cfg .autoApply ?? defaults .autoApply ?? true
18+ property string editIcon: cfg .icon ?? defaults .icon ?? " adjustments-horizontal"
19+ property string editIconColor: cfg .iconColor ?? defaults .iconColor ?? " primary"
1320
14- property string valueOverlayPath: cfg .overlayPath ?? defaults .overlayPath ?? " ~/.cache/noctalia/HVE/overlay.conf"
15- property bool valueAutoApply: cfg .autoApply ?? defaults .autoApply ?? true
21+ spacing: Style .marginM
1622
17- spacing: Style .marginL
23+ // ── Preview ──────────────────────────────────────────────────────────
24+ RowLayout {
25+ spacing: Style .marginM
26+ Layout .alignment : Qt .AlignHCenter
27+ Layout .topMargin : Style .marginL
28+ Layout .bottomMargin : Style .marginL
1829
19- Component .onCompleted : {
20- Logger .d (" HVE" , " Settings UI loaded" );
30+ NIcon {
31+ icon: root .editIcon
32+ pointSize: Style .fontSizeXXL * 2
33+ color: {
34+ let res = Color .resolveColorKeyOptional (root .editIconColor );
35+ return res .a > 0 ? res : Color .mOnSurface ;
36+ }
37+ }
38+
39+ NText {
40+ text: pluginApi? .tr (" settings.preview_label" )
41+ font .weight : Font .Bold
42+ }
2143 }
2244
23- ColumnLayout {
24- spacing : Style . marginM
45+ // ── Icon Configuration ────────────────────────────────────────────────
46+ NButton {
2547 Layout .fillWidth : true
48+ text: pluginApi? .tr (" settings.change_icon_button" )
49+ icon: " search"
50+ onClicked: iconPicker .open ()
51+ }
2652
27- NTextInput {
28- Layout .fillWidth : true
29- label: pluginApi? .tr (" settings.path.label" )
30- description: pluginApi? .tr (" settings.path.desc" )
31- text: root .valueOverlayPath
32- onTextChanged: root .valueOverlayPath = text
33- readOnly: true
53+ NIconPicker {
54+ id: iconPicker
55+ initialIcon: root .editIcon
56+ onIconSelected : iconName => {
57+ root .editIcon = iconName
3458 }
59+ }
3560
36- NToggle {
37- Layout .fillWidth : true
38- label: pluginApi? .tr (" settings.autoapply.label" )
39- description: pluginApi? .tr (" settings.autoapply.desc" )
40- checked: root .valueAutoApply
41- onToggled: root .valueAutoApply = ! root .valueAutoApply
42- }
61+ NColorChoice {
62+ label: pluginApi? .tr (" settings.icon_color_label" )
63+ currentKey: root .editIconColor
64+ onSelected : key => { root .editIconColor = key }
65+ defaultValue: defaults .iconColor || " primary"
4366 }
4467
45- function saveSettings () {
46- if (! pluginApi) {
47- Logger .e (" HVE" , " Cannot save settings: pluginApi is null" );
48- return ;
49- }
68+ NDivider { Layout .fillWidth : true }
69+
70+ // ── Files and Application Configuration ────────────────────────────────
71+ NTextInput {
72+ Layout .fillWidth : true
73+ label: pluginApi? .tr (" settings.path_label" )
74+ description: pluginApi? .tr (" settings.path_desc" )
75+ text: root .editOverlayPath
76+ onTextChanged: root .editOverlayPath = text
77+ readOnly: true
78+ }
5079
51- pluginApi .pluginSettings .overlayPath = root .valueOverlayPath ;
52- pluginApi .pluginSettings .autoApply = root .valueAutoApply ;
53- pluginApi .saveSettings ();
80+ NToggle {
81+ Layout .fillWidth : true
82+ label: pluginApi? .tr (" settings.autoapply_label" )
83+ description: pluginApi? .tr (" settings.autoapply_description" )
84+ checked: root .editAutoApply
85+ onToggled : checked => { root .editAutoApply = checked }
86+ }
5487
55- Logger .d (" HVE" , " Settings saved successfully" );
88+ // ── Save Function (Required by the Shell) ──────────────────────────
89+ function saveSettings () {
90+ if (! pluginApi) return
91+
92+ pluginApi .pluginSettings .overlayPath = root .editOverlayPath
93+ pluginApi .pluginSettings .autoApply = root .editAutoApply
94+ pluginApi .pluginSettings .icon = root .editIcon
95+ pluginApi .pluginSettings .iconColor = root .editIconColor
96+
97+ pluginApi .saveSettings ()
98+ Logger .i (" HVE" , " Settings saved" )
5699 }
57100}
0 commit comments