Skip to content

Commit bd30e85

Browse files
committed
feat(hyprland-visual-editor): add i18n, icon/color settings and IPC handler
1 parent ab5e461 commit bd30e85

20 files changed

Lines changed: 1300 additions & 1231 deletions

hyprland-visual-editor/BarWidget.qml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import QtQuick
12
import Quickshell
23
import qs.Commons
34
import qs.Services.UI
@@ -7,7 +8,6 @@ NIconButton {
78
id: root
89

910
property var pluginApi: null
10-
1111
property ShellScreen screen
1212
property string widgetId: ""
1313
property string section: ""
@@ -17,28 +17,48 @@ NIconButton {
1717
property var cfg: pluginApi?.pluginSettings || ({})
1818
property var defaults: pluginApi?.manifest?.metadata?.defaultSettings || ({})
1919

20-
readonly property string iconColorKey: cfg.iconColor ?? defaults.iconColor ?? "onSurface"
21-
22-
icon: "adjustments-horizontal"
20+
readonly property string iconKey: cfg.icon ?? defaults.icon ?? "adjustments-horizontal"
21+
readonly property string iconColorKey: cfg.iconColor ?? defaults.iconColor ?? "primary"
22+
23+
icon: iconKey
2324
tooltipText: pluginApi?.tr("widget.tooltip")
24-
2525
tooltipDirection: BarService.getTooltipDirection(screen?.name)
26-
baseSize: Style.getCapsuleHeightForScreen(screen?.name)
2726

27+
baseSize: Style.getCapsuleHeightForScreen(screen?.name)
2828
customRadius: Style.radiusM
2929

3030
colorBg: Style.capsuleColor
31-
colorFg: Color.resolveColorKey(iconColorKey)
31+
32+
colorFg: {
33+
let resolved = Color.resolveColorKeyOptional(iconColorKey);
34+
if (root.containsMouse) return Color.mOnHover;
35+
return resolved.a > 0 ? resolved : Color.mOnSurface;
36+
}
3237

3338
border.color: Style.capsuleBorderColor
3439
border.width: Style.borderS
3540

41+
Behavior on colorFg {
42+
ColorAnimation {
43+
duration: Style.animationFast
44+
easing.type: Easing.InOutQuad
45+
}
46+
}
47+
3648
onClicked: {
3749
if (pluginApi) {
3850
pluginApi.openPanel(root.screen, this);
3951
}
4052
}
4153

54+
onEntered: {
55+
TooltipService.show(root, pluginApi?.tr("widget.tooltip"), BarService.getTooltipDirection(screen?.name))
56+
}
57+
58+
onExited: {
59+
TooltipService.hide()
60+
}
61+
4262
NPopupContextMenu {
4363
id: contextMenu
4464

hyprland-visual-editor/Main.qml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import QtQuick
2+
import Quickshell
3+
import Quickshell.Io
4+
import qs.Commons
5+
6+
Item {
7+
id: root
8+
property var pluginApi: null
9+
10+
// Shared state accessible from other components via pluginApi.mainInstance
11+
property bool isActive: false
12+
13+
// IPC handler for CLI control (qs ipc call plugin:my-plugin commandName)
14+
IpcHandler {
15+
target: "plugin:hyprland-visual-editor"
16+
17+
function toggle() {
18+
if (pluginApi) {
19+
pluginApi.withCurrentScreen(screen => {
20+
pluginApi.togglePanel(screen);
21+
});
22+
}
23+
}
24+
}
25+
}
Lines changed: 72 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,96 @@
11
import QtQuick
22
import QtQuick.Layouts
3+
import Quickshell
34
import qs.Commons
45
import qs.Widgets
56

67
ColumnLayout {
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
}

hyprland-visual-editor/i18n/de.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,12 @@
239239
}
240240
},
241241
"settings": {
242-
"path": {
243-
"label": "Konfigurationspfad",
244-
"desc": "Absoluter Pfad für die Satelliten-Konfigurationsdatei."
245-
},
246-
"autoapply": {
247-
"label": "Automatisch anwenden",
248-
"desc": "Hyprland automatisch neu laden, wenn sich die Einstellungen ändern."
249-
}
242+
"preview_label": "Vorschau",
243+
"change_icon_button": "Widget-Icon ändern",
244+
"icon_color_label": "Icon-Farbe",
245+
"autoapply_label": "Automatisch anwenden",
246+
"autoapply_description": "Hyprland sofort neu laden beim Speichern",
247+
"path_label": "Konfigurationspfad",
248+
"path_desc": "Absoluter Pfad für die Satelliten-Konfigurationsdatei."
250249
}
251250
}

hyprland-visual-editor/i18n/en.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,12 @@
239239
}
240240
},
241241
"settings": {
242-
"path": {
243-
"label": "Config Path",
244-
"desc": "Absolute path for the satellite configuration file."
245-
},
246-
"autoapply": {
247-
"label": "Auto Apply",
248-
"desc": "Automatically reload Hyprland when settings change."
249-
}
242+
"preview_label": "Preview",
243+
"change_icon_button": "Change Widget Icon",
244+
"icon_color_label": "Icon Color",
245+
"autoapply_label": "Auto Apply",
246+
"autoapply_description": "Instantly reload Hyprland when saving",
247+
"path_label": "Config Path",
248+
"path_desc": "Absolute path for the satellite configuration file."
250249
}
251250
}

hyprland-visual-editor/i18n/es.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,12 @@
239239
}
240240
},
241241
"settings": {
242-
"path": {
243-
"label": "Ruta de Configuración",
244-
"desc": "Ruta absoluta para el archivo de configuración satélite."
245-
},
246-
"autoapply": {
247-
"label": "Aplicación Automática",
248-
"desc": "Recargar Hyprland automáticamente al cambiar los ajustes."
249-
}
242+
"preview_label": "Vista previa",
243+
"change_icon_button": "Cambiar icono del widget",
244+
"icon_color_label": "Color del icono",
245+
"autoapply_label": "Aplicar automáticamente",
246+
"autoapply_description": "Actualiza Hyprland al instante al guardar",
247+
"path_label": "Ruta de Configuración",
248+
"path_desc": "Ruta absoluta para el archivo de configuración satélite."
250249
}
251250
}

hyprland-visual-editor/i18n/fr.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,12 @@
239239
}
240240
},
241241
"settings": {
242-
"path": {
243-
"label": "Chemin de configuration",
244-
"desc": "Chemin absolu pour le fichier de configuration satellite."
245-
},
246-
"autoapply": {
247-
"label": "Application automatique",
248-
"desc": "Recharger automatiquement Hyprland lorsque les paramètres changent."
249-
}
242+
"preview_label": "Aperçu",
243+
"change_icon_button": "Changer l'icône du widget",
244+
"icon_color_label": "Couleur de l'icône",
245+
"autoapply_label": "Application automatique",
246+
"autoapply_description": "Recharger instantanément Hyprland lors de la sauvegarde",
247+
"path_label": "Chemin de configuration",
248+
"path_desc": "Chemin absolu pour le fichier de configuration satellite."
250249
}
251250
}

0 commit comments

Comments
 (0)