Custom Buttons: working left/right/middle click
This commit is contained in:
parent
17944211d5
commit
21383b03c5
3 changed files with 34 additions and 19 deletions
|
|
@ -46,14 +46,15 @@ NIconButton {
|
||||||
} else {
|
} else {
|
||||||
var lines = []
|
var lines = []
|
||||||
if (userLeftClickExec !== "") {
|
if (userLeftClickExec !== "") {
|
||||||
lines.push(`Left click: ${userLeftClickExec}\n`)
|
lines.push(`Left click: <i>${userLeftClickExec}</i>`)
|
||||||
}
|
}
|
||||||
if (userRightClickExec !== "") {
|
if (userRightClickExec !== "") {
|
||||||
lines.push(`Right click: ${userRightClickExec}\n`)
|
lines.push(`Right click: <i>${userRightClickExec}</i>`)
|
||||||
}
|
}
|
||||||
if (userLeftClickExec !== "") {
|
if (userLeftClickExec !== "") {
|
||||||
lines.push(`Middle click: ${userMiddleClickExec}\n`)
|
lines.push(`Middle click: <i>${userMiddleClickExec}</i>`)
|
||||||
}
|
}
|
||||||
|
return lines.join("<br/>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
opacity: hasExec ? Style.opacityFull : Style.opacityMedium
|
opacity: hasExec ? Style.opacityFull : Style.opacityMedium
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ Popup {
|
||||||
x: (parent.width - width) * 0.5
|
x: (parent.width - width) * 0.5
|
||||||
y: (parent.height - height) * 0.5
|
y: (parent.height - height) * 0.5
|
||||||
|
|
||||||
width: 400 * scaling
|
width: 420 * scaling
|
||||||
height: content.implicitHeight + padding * 2
|
height: content.implicitHeight + padding * 2
|
||||||
padding: Style.marginL * scaling
|
padding: Style.marginXL * scaling
|
||||||
modal: true
|
modal: true
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
|
@ -50,10 +50,6 @@ Popup {
|
||||||
|
|
||||||
NIconButton {
|
NIconButton {
|
||||||
icon: "close"
|
icon: "close"
|
||||||
colorBg: Color.transparent
|
|
||||||
colorFg: Color.mOnSurface
|
|
||||||
colorBgHover: Color.applyOpacity(Color.mError, "20")
|
|
||||||
colorFgHover: Color.mError
|
|
||||||
onClicked: settingsPopup.close()
|
onClicked: settingsPopup.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +92,6 @@ Popup {
|
||||||
NButton {
|
NButton {
|
||||||
text: "Save"
|
text: "Save"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
||||||
if (settingsLoader.item && settingsLoader.item.saveSettings) {
|
if (settingsLoader.item && settingsLoader.item.saveSettings) {
|
||||||
var newSettings = settingsLoader.item.saveSettings()
|
var newSettings = settingsLoader.item.saveSettings()
|
||||||
root.updateWidgetSettings(sectionId, settingsPopup.widgetIndex, newSettings)
|
root.updateWidgetSettings(sectionId, settingsPopup.widgetIndex, newSettings)
|
||||||
|
|
@ -114,13 +109,12 @@ Popup {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: Style.marginM * scaling
|
spacing: Style.marginM * scaling
|
||||||
|
|
||||||
property alias iconField: iconInput
|
|
||||||
property alias executeField: executeInput
|
|
||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
var settings = Object.assign({}, settingsPopup.widgetData)
|
var settings = Object.assign({}, settingsPopup.widgetData)
|
||||||
settings.icon = iconInput.text
|
settings.icon = iconInput.text
|
||||||
settings.execute = executeInput.text
|
settings.leftClickExec = leftClickExecInput.text
|
||||||
|
settings.rightClickExec = rightClickExecInput.text
|
||||||
|
settings.middleClickExec = middleClickExecInput.text
|
||||||
return settings
|
return settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,21 +122,41 @@ Popup {
|
||||||
NTextInput {
|
NTextInput {
|
||||||
id: iconInput
|
id: iconInput
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.bottomMargin: Style.marginXL * scaling
|
||||||
label: "Icon Name"
|
label: "Icon Name"
|
||||||
description: "Use Material Icon names from the icon set."
|
description: "Use Material Icon names from the icon set."
|
||||||
text: settingsPopup.widgetData.icon || ""
|
text: settingsPopup.widgetData.icon || ""
|
||||||
placeholderText: "Enter icon name (e.g., favorite, home, settings)"
|
placeholderText: "Enter icon name (e.g., favorite, home, settings)"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute command setting
|
|
||||||
|
|
||||||
NTextInput {
|
NTextInput {
|
||||||
id: executeInput
|
id: leftClickExecInput
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
label: "Execute Command"
|
label: "Left Click Command"
|
||||||
description: "Command or application to run when clicked."
|
description: "Command or application to run when left clicked."
|
||||||
text: settingsPopup.widgetData.leftClickExec || ""
|
text: settingsPopup.widgetData.leftClickExec || ""
|
||||||
placeholderText: "Enter command to execute (app or custom script)"
|
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)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ ColumnLayout {
|
||||||
readOnly: root.readOnly
|
readOnly: root.readOnly
|
||||||
enabled: root.enabled
|
enabled: root.enabled
|
||||||
color: Color.mOnSurface
|
color: Color.mOnSurface
|
||||||
placeholderTextColor: Color.mOnSurfaceVariant
|
placeholderTextColor: Qt.alpha(Color.mOnSurfaceVariant, 0.6)
|
||||||
background: null
|
background: null
|
||||||
font.family: fontFamily
|
font.family: fontFamily
|
||||||
font.pointSize: fontSize
|
font.pointSize: fontSize
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue