mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(cc-cb): add showExecTooltip option and fix tooltip logic
This commit is contained in:
@@ -905,6 +905,7 @@
|
||||
"desc": "Configure the control center panel positioning and behavior.",
|
||||
"position-description": "Choose where the control center panel appears when opened.",
|
||||
"shortcuts-custom-button-command-description": "The command to execute when the button is clicked.",
|
||||
"shortcuts-custom-button-icon-description": "Select an icon from the library.",
|
||||
"shortcuts-custom-button-enable-on-state-logic-description": "Enable a second icon and 'hot' state based on a check command.",
|
||||
"shortcuts-custom-button-enable-on-state-logic-label": "Enable on-state logic",
|
||||
"shortcuts-custom-button-general-tooltip-text-description": "General description for the button's tooltip.",
|
||||
@@ -912,6 +913,9 @@
|
||||
"shortcuts-custom-button-on-clicked-label": "Left click command",
|
||||
"shortcuts-custom-button-on-middle-clicked-label": "Middle click command",
|
||||
"shortcuts-custom-button-on-right-clicked-label": "Right click command",
|
||||
"shortcuts-custom-button-on-clicked-description": "Command to execute when the button is left-clicked.",
|
||||
"shortcuts-custom-button-on-middle-clicked-description": "Command to execute when the button is middle-clicked.",
|
||||
"shortcuts-custom-button-on-right-clicked-description": "Command to execute when the button is right-clicked.",
|
||||
"shortcuts-custom-button-on-state-command-description": "Command to execute to check if the button should be in the 'on' state. Returns 0 for on, non-zero for off.",
|
||||
"shortcuts-custom-button-on-state-command-label": "On-state check command",
|
||||
"shortcuts-custom-button-on-state-icon-description": "The icon for the button when it's in the 'on' state.",
|
||||
@@ -922,6 +926,9 @@
|
||||
"shortcuts-custom-button-state-checks-remove": "Remove",
|
||||
"shortcuts-custom-button-tooltip-description": "The tooltip to show when hovering over the button.",
|
||||
"shortcuts-custom-button-tooltip-label": "Tooltip",
|
||||
"shortcuts-custom-button-show-exec-tooltip-description": "Show tooltips with command details (left/right/middle click).",
|
||||
"shortcuts-custom-button-show-exec-tooltip-label": "Show command tooltips",
|
||||
"shortcuts-custom-button-default-tooltip": "Custom button, configure in settings.",
|
||||
"shortcuts-title": "Shortcuts widgets",
|
||||
"system-monitor-disk-path-description": "Select which disk mount point the system monitor card in the control center should monitor.",
|
||||
"system-monitor-disk-path-label": "System monitor disk path",
|
||||
|
||||
@@ -15,8 +15,10 @@ Item {
|
||||
property string onMiddleClickedCommand: ""
|
||||
property string stateChecksJson: "[]" // Store state checks as JSON string
|
||||
|
||||
property string generalTooltipText: "Custom Button"
|
||||
property string generalTooltipText: ""
|
||||
property bool enableOnStateLogic: false
|
||||
property bool showExecTooltip: true
|
||||
property bool _hasCustomTooltip: false
|
||||
|
||||
property string _currentIcon: "heart" // Default icon
|
||||
property bool _isHot: false
|
||||
@@ -46,8 +48,10 @@ Item {
|
||||
Logger.e("CustomButton", "Failed to parse stateChecksJson:", e.message);
|
||||
_parsedStateChecks = [];
|
||||
}
|
||||
generalTooltipText = widgetSettings.generalTooltipText || "Custom Button";
|
||||
generalTooltipText = widgetSettings.generalTooltipText || "";
|
||||
_hasCustomTooltip = !!(widgetSettings.generalTooltipText && widgetSettings.generalTooltipText.trim() !== "");
|
||||
enableOnStateLogic = widgetSettings.enableOnStateLogic || false;
|
||||
showExecTooltip = widgetSettings.showExecTooltip !== undefined ? widgetSettings.showExecTooltip : true;
|
||||
|
||||
updateState();
|
||||
}
|
||||
@@ -120,15 +124,28 @@ Item {
|
||||
}
|
||||
|
||||
function _buildTooltipText() {
|
||||
let tooltip = generalTooltipText;
|
||||
if (onClickedCommand) {
|
||||
tooltip += `\nLeft click: ${onClickedCommand}`;
|
||||
// Build tooltip based on settings
|
||||
let tooltip = "";
|
||||
|
||||
// If user set custom text, always show it
|
||||
// If no custom text and showExecTooltip is off, show i18n default
|
||||
if (_hasCustomTooltip) {
|
||||
tooltip = generalTooltipText;
|
||||
} else if (!showExecTooltip) {
|
||||
tooltip = I18n.tr("panels.control-center.shortcuts-custom-button-default-tooltip");
|
||||
}
|
||||
if (onRightClickedCommand) {
|
||||
tooltip += `\nRight click: ${onRightClickedCommand}`;
|
||||
}
|
||||
if (onMiddleClickedCommand) {
|
||||
tooltip += `\nMiddle click: ${onMiddleClickedCommand}`;
|
||||
|
||||
// Add command details if enabled
|
||||
if (showExecTooltip) {
|
||||
if (onClickedCommand) {
|
||||
tooltip += tooltip ? `\nLeft click: ${onClickedCommand}` : `Left click: ${onClickedCommand}`;
|
||||
}
|
||||
if (onRightClickedCommand) {
|
||||
tooltip += tooltip ? `\nRight click: ${onRightClickedCommand}` : `Right click: ${onRightClickedCommand}`;
|
||||
}
|
||||
if (onMiddleClickedCommand) {
|
||||
tooltip += tooltip ? `\nMiddle click: ${onMiddleClickedCommand}` : `Middle click: ${onMiddleClickedCommand}`;
|
||||
}
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
|
||||
@@ -26,8 +26,9 @@ ColumnLayout {
|
||||
property string onMiddleClicked: (widgetData && widgetData.onMiddleClicked !== undefined) ? widgetData.onMiddleClicked : (widgetMetadata && widgetMetadata.onMiddleClicked ? widgetMetadata.onMiddleClicked : "")
|
||||
property ListModel _stateChecksListModel: ListModel {}
|
||||
property string stateChecksJson: "[]"
|
||||
property string generalTooltipText: (widgetData && widgetData.generalTooltipText !== undefined) ? widgetData.generalTooltipText : (widgetMetadata && widgetMetadata.generalTooltipText ? widgetMetadata.generalTooltipText : "Custom Button")
|
||||
property string generalTooltipText: (widgetData && widgetData.generalTooltipText !== undefined) ? widgetData.generalTooltipText : (widgetMetadata && widgetMetadata.generalTooltipText ? widgetMetadata.generalTooltipText : "")
|
||||
property bool enableOnStateLogic: (widgetData && widgetData.enableOnStateLogic !== undefined) ? widgetData.enableOnStateLogic : (widgetMetadata && widgetMetadata.enableOnStateLogic !== undefined ? widgetMetadata.enableOnStateLogic : false)
|
||||
property bool showExecTooltip: (widgetData && widgetData.showExecTooltip !== undefined) ? widgetData.showExecTooltip : (widgetMetadata && widgetMetadata.showExecTooltip !== undefined ? widgetMetadata.showExecTooltip : true)
|
||||
|
||||
function populateStateChecks() {
|
||||
try {
|
||||
@@ -71,7 +72,8 @@ ColumnLayout {
|
||||
"onMiddleClicked": _settings.onMiddleClicked,
|
||||
"stateChecksJson": _settings.stateChecksJson,
|
||||
"generalTooltipText": _settings.generalTooltipText,
|
||||
"enableOnStateLogic": _settings.enableOnStateLogic
|
||||
"enableOnStateLogic": _settings.enableOnStateLogic,
|
||||
"showExecTooltip": _settings.showExecTooltip
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -100,7 +102,7 @@ ColumnLayout {
|
||||
|
||||
NLabel {
|
||||
label: I18n.tr("common.icon")
|
||||
description: I18n.tr("bar.custom-button.icon-description")
|
||||
description: I18n.tr("panels.control-center.shortcuts-custom-button-icon-description")
|
||||
}
|
||||
|
||||
NIcon {
|
||||
@@ -137,10 +139,21 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.control-center.shortcuts-custom-button-show-exec-tooltip-label")
|
||||
description: I18n.tr("panels.control-center.shortcuts-custom-button-show-exec-tooltip-description")
|
||||
checked: _settings.showExecTooltip
|
||||
onToggled: checked => {
|
||||
_settings.showExecTooltip = checked;
|
||||
saveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
NTextInput {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.control-center.shortcuts-custom-button-on-clicked-label")
|
||||
description: I18n.tr("bar.custom-button.left-click-description")
|
||||
description: I18n.tr("panels.control-center.shortcuts-custom-button-on-clicked-description")
|
||||
placeholderText: I18n.tr("placeholders.enter-command")
|
||||
text: _settings.onClicked
|
||||
onEditingFinished: {
|
||||
@@ -152,7 +165,7 @@ ColumnLayout {
|
||||
NTextInput {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.control-center.shortcuts-custom-button-on-right-clicked-label")
|
||||
description: I18n.tr("bar.custom-button.right-click-description")
|
||||
description: I18n.tr("panels.control-center.shortcuts-custom-button-on-right-clicked-description")
|
||||
placeholderText: I18n.tr("placeholders.enter-command")
|
||||
text: _settings.onRightClicked
|
||||
onEditingFinished: {
|
||||
@@ -164,7 +177,7 @@ ColumnLayout {
|
||||
NTextInput {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.control-center.shortcuts-custom-button-on-middle-clicked-label")
|
||||
description: I18n.tr("bar.custom-button.middle-click-description")
|
||||
description: I18n.tr("panels.control-center.shortcuts-custom-button-on-middle-clicked-description")
|
||||
placeholderText: I18n.tr("placeholders.enter-command")
|
||||
text: _settings.onMiddleClicked
|
||||
onEditingFinished: {
|
||||
|
||||
@@ -29,9 +29,10 @@ Singleton {
|
||||
"onClicked": "",
|
||||
"onRightClicked": "",
|
||||
"onMiddleClicked": "",
|
||||
"stateChecks": [],
|
||||
"generalTooltipText": "Custom Button",
|
||||
"enableOnStateLogic": false
|
||||
"stateChecksJson": "[]",
|
||||
"generalTooltipText": "",
|
||||
"enableOnStateLogic": false,
|
||||
"showExecTooltip": true
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user