From 21383b03c5f28cb7dfb55d9913f7e3e937aeb8de Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Wed, 3 Sep 2025 22:22:22 -0400 Subject: [PATCH] Custom Buttons: working left/right/middle click --- Modules/Bar/Widgets/CustomButton.qml | 7 +-- .../Extras/BarWidgetSettingsDialog.qml | 44 ++++++++++++------- Widgets/NTextInput.qml | 2 +- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Modules/Bar/Widgets/CustomButton.qml b/Modules/Bar/Widgets/CustomButton.qml index 973e628..8e8252b 100644 --- a/Modules/Bar/Widgets/CustomButton.qml +++ b/Modules/Bar/Widgets/CustomButton.qml @@ -46,14 +46,15 @@ NIconButton { } else { var lines = [] if (userLeftClickExec !== "") { - lines.push(`Left click: ${userLeftClickExec}\n`) + lines.push(`Left click: ${userLeftClickExec}`) } if (userRightClickExec !== "") { - lines.push(`Right click: ${userRightClickExec}\n`) + lines.push(`Right click: ${userRightClickExec}`) } if (userLeftClickExec !== "") { - lines.push(`Middle click: ${userMiddleClickExec}\n`) + lines.push(`Middle click: ${userMiddleClickExec}`) } + return lines.join("
") } } opacity: hasExec ? Style.opacityFull : Style.opacityMedium diff --git a/Modules/SettingsPanel/Extras/BarWidgetSettingsDialog.qml b/Modules/SettingsPanel/Extras/BarWidgetSettingsDialog.qml index 922f0a2..c17f98a 100644 --- a/Modules/SettingsPanel/Extras/BarWidgetSettingsDialog.qml +++ b/Modules/SettingsPanel/Extras/BarWidgetSettingsDialog.qml @@ -18,9 +18,9 @@ Popup { x: (parent.width - width) * 0.5 y: (parent.height - height) * 0.5 - width: 400 * scaling + width: 420 * scaling height: content.implicitHeight + padding * 2 - padding: Style.marginL * scaling + padding: Style.marginXL * scaling modal: true background: Rectangle { @@ -50,10 +50,6 @@ Popup { NIconButton { icon: "close" - colorBg: Color.transparent - colorFg: Color.mOnSurface - colorBgHover: Color.applyOpacity(Color.mError, "20") - colorFgHover: Color.mError onClicked: settingsPopup.close() } } @@ -96,7 +92,6 @@ Popup { NButton { text: "Save" onClicked: { - if (settingsLoader.item && settingsLoader.item.saveSettings) { var newSettings = settingsLoader.item.saveSettings() root.updateWidgetSettings(sectionId, settingsPopup.widgetIndex, newSettings) @@ -114,13 +109,12 @@ Popup { ColumnLayout { spacing: Style.marginM * scaling - property alias iconField: iconInput - property alias executeField: executeInput - function saveSettings() { var settings = Object.assign({}, settingsPopup.widgetData) settings.icon = iconInput.text - settings.execute = executeInput.text + settings.leftClickExec = leftClickExecInput.text + settings.rightClickExec = rightClickExecInput.text + settings.middleClickExec = middleClickExecInput.text return settings } @@ -128,21 +122,41 @@ Popup { NTextInput { id: iconInput Layout.fillWidth: true + Layout.bottomMargin: Style.marginXL * scaling label: "Icon Name" description: "Use Material Icon names from the icon set." text: settingsPopup.widgetData.icon || "" placeholderText: "Enter icon name (e.g., favorite, home, settings)" } - // Execute command setting + + NTextInput { - id: executeInput + id: leftClickExecInput Layout.fillWidth: true - label: "Execute Command" - description: "Command or application to run when clicked." + label: "Left Click Command" + description: "Command or application to run when left clicked." text: settingsPopup.widgetData.leftClickExec || "" placeholderText: "Enter command to execute (app or custom script)" } + + NTextInput { + id: rightClickExecInput + Layout.fillWidth: true + label: "Right Click Command" + description: "Command or application to run when right clicked." + text: settingsPopup.widgetData.rightClickExec || "" + placeholderText: "Enter command to execute (app or custom script)" + } + + NTextInput { + id: middleClickExecInput + Layout.fillWidth: true + label: "Middle Click Command" + description: "Command or application to run when middle clicked." + text: settingsPopup.widgetData.middleClickExec || "" + placeholderText: "Enter command to execute (app or custom script)" + } } } } diff --git a/Widgets/NTextInput.qml b/Widgets/NTextInput.qml index 1e54a51..1cb7141 100644 --- a/Widgets/NTextInput.qml +++ b/Widgets/NTextInput.qml @@ -79,7 +79,7 @@ ColumnLayout { readOnly: root.readOnly enabled: root.enabled color: Color.mOnSurface - placeholderTextColor: Color.mOnSurfaceVariant + placeholderTextColor: Qt.alpha(Color.mOnSurfaceVariant, 0.6) background: null font.family: fontFamily font.pointSize: fontSize