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+ // 1. Estado local (convención 'edit' y fallbacks oficiales)
12+ property string editOverlayPath: pluginApi? .pluginSettings ? .overlayPath || pluginApi? .manifest ? .metadata ? .defaultSettings ? .overlayPath || " ~/.cache/noctalia/HVE/overlay.conf"
13+ property bool editAutoApply: pluginApi? .pluginSettings ? .autoApply ?? pluginApi? .manifest ? .metadata ? .defaultSettings ? .autoApply ?? true
14+ property string editIcon: pluginApi? .pluginSettings ? .icon || pluginApi? .manifest ? .metadata ? .defaultSettings ? .icon || " adjustments-horizontal"
15+ property string editIconColor: pluginApi? .pluginSettings ? .iconColor || pluginApi? .manifest ? .metadata ? .defaultSettings ? .iconColor || " primary"
1316
14- property string valueOverlayPath: cfg .overlayPath ?? defaults .overlayPath ?? " ~/.cache/noctalia/HVE/overlay.conf"
15- property bool valueAutoApply: cfg .autoApply ?? defaults .autoApply ?? true
17+ spacing: Style .marginM
1618
17- spacing: Style .marginL
19+ // ── Vista previa ──────────────────────────────────────────────────────────
20+ RowLayout {
21+ spacing: Style .marginM
22+ Layout .alignment : Qt .AlignHCenter
23+ Layout .topMargin : Style .marginL
24+ Layout .bottomMargin : Style .marginL
1825
19- Component .onCompleted : {
20- Logger .d (" HVE" , " Settings UI loaded" );
26+ NIcon {
27+ icon: root .editIcon
28+ pointSize: Style .fontSizeXXL * 2
29+ color: {
30+ let res = Color .resolveColorKeyOptional (root .editIconColor );
31+ return res .a > 0 ? res : Color .mOnSurface ;
32+ }
33+ }
34+
35+ NText {
36+ text: pluginApi? .tr (" settings.preview_label" )
37+ font .weight : Font .Bold
38+ }
2139 }
2240
23- ColumnLayout {
24- spacing : Style . marginM
41+ // ── Configuración de Icono ────────────────────────────────────────────────
42+ NButton {
2543 Layout .fillWidth : true
44+ text: pluginApi? .tr (" settings.change_icon_button" )
45+ icon: " search"
46+ onClicked: iconPicker .open ()
47+ }
2648
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
49+ NIconPicker {
50+ id: iconPicker
51+ initialIcon: root .editIcon
52+ onIconSelected : iconName => {
53+ root .editIcon = iconName
3454 }
55+ }
3556
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- }
57+ NColorChoice {
58+ label: pluginApi? .tr (" settings.icon_color_label" )
59+ currentKey: root .editIconColor
60+ onSelected : key => { root .editIconColor = key }
61+ defaultValue: pluginApi? .manifest ? .metadata ? .defaultSettings ? .iconColor || " primary"
4362 }
4463
45- function saveSettings () {
46- if (! pluginApi) {
47- Logger .e (" HVE" , " Cannot save settings: pluginApi is null" );
48- return ;
49- }
64+ NDivider { Layout .fillWidth : true }
65+
66+ // ── Configuración de Archivos y Aplicación (Sección recuperada) ───────────
67+ NTextInput {
68+ Layout .fillWidth : true
69+ label: pluginApi? .tr (" settings.path_label" )
70+ description: pluginApi? .tr (" settings.path_desc" )
71+ text: root .editOverlayPath
72+ onTextChanged: root .editOverlayPath = text
73+ readOnly: true
74+ }
5075
51- pluginApi .pluginSettings .overlayPath = root .valueOverlayPath ;
52- pluginApi .pluginSettings .autoApply = root .valueAutoApply ;
53- pluginApi .saveSettings ();
76+ NToggle {
77+ Layout .fillWidth : true
78+ label: pluginApi? .tr (" settings.autoapply_label" )
79+ description: pluginApi? .tr (" settings.autoapply_description" )
80+ checked: root .editAutoApply
81+ onToggled : checked => { root .editAutoApply = checked }
82+ }
5483
55- Logger .d (" HVE" , " Settings saved successfully" );
84+ // ── Función de Guardado ───────────────────────────────────────────────────
85+ function saveSettings () {
86+ if (! pluginApi) return
87+
88+ pluginApi .pluginSettings .overlayPath = root .editOverlayPath
89+ pluginApi .pluginSettings .autoApply = root .editAutoApply
90+ pluginApi .pluginSettings .icon = root .editIcon
91+ pluginApi .pluginSettings .iconColor = root .editIconColor
92+
93+ pluginApi .saveSettings ()
94+ Logger .i (" HVE" , " Settings saved" )
5695 }
5796}
0 commit comments