mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat(bar): implement middle-click action support for Bar Behavior
This commit is contained in:
@@ -842,10 +842,14 @@
|
||||
"behavior-wheel-wrap-label": "Wrap around",
|
||||
"behavior-workspace-scroll-description": "Choose what the mouse wheel does on empty areas of the bar.",
|
||||
"behavior-workspace-scroll-label": "Bar mouse wheel action",
|
||||
"behavior-middle-click-description": "Choose what middle click does on empty areas of the bar.",
|
||||
"behavior-middle-click-label": "Bar middle click action",
|
||||
"behavior-middle-click-follow-mouse-description": "Open the selected middle-click panel at the cursor position.",
|
||||
"behavior-middle-click-follow-mouse-label": "Middle click follow mouse",
|
||||
"behavior-right-click-description": "Choose what right click does on empty areas of the bar.",
|
||||
"behavior-right-click-label": "Bar right click action",
|
||||
"behavior-right-click-follow-mouse-description": "Open the selected panel at the cursor position.",
|
||||
"behavior-right-click-follow-mouse-label": "Follow mouse position",
|
||||
"behavior-right-click-follow-mouse-description": "Open the selected right-click panel at the cursor position.",
|
||||
"behavior-right-click-follow-mouse-label": "Right click follow mouse",
|
||||
"monitor-configure-widgets": "Configure widgets",
|
||||
"monitor-override-settings": "Override global settings",
|
||||
"monitor-override-settings-description": "Use custom settings for this monitor.",
|
||||
|
||||
@@ -70,6 +70,8 @@
|
||||
]
|
||||
},
|
||||
"mouseWheelAction": "none",
|
||||
"middleClickAction": "none",
|
||||
"middleClickFollowMouse": false,
|
||||
"rightClickAction": "controlCenter",
|
||||
"rightClickFollowMouse": true,
|
||||
"reverseScroll": false,
|
||||
|
||||
@@ -377,6 +377,24 @@
|
||||
"subTab": 2,
|
||||
"subTabLabel": "common.behavior"
|
||||
},
|
||||
{
|
||||
"labelKey": "panels.bar.behavior-middle-click-label",
|
||||
"descriptionKey": "panels.bar.behavior-middle-click-description",
|
||||
"widget": "NComboBox",
|
||||
"tab": 4,
|
||||
"tabLabel": "panels.bar.title",
|
||||
"subTab": 2,
|
||||
"subTabLabel": "common.behavior"
|
||||
},
|
||||
{
|
||||
"labelKey": "panels.bar.behavior-middle-click-follow-mouse-label",
|
||||
"descriptionKey": "panels.bar.behavior-middle-click-follow-mouse-description",
|
||||
"widget": "NToggle",
|
||||
"tab": 4,
|
||||
"tabLabel": "panels.bar.title",
|
||||
"subTab": 2,
|
||||
"subTabLabel": "common.behavior"
|
||||
},
|
||||
{
|
||||
"labelKey": "panels.bar.behavior-right-click-label",
|
||||
"descriptionKey": "panels.bar.behavior-right-click-description",
|
||||
|
||||
@@ -259,6 +259,8 @@ Singleton {
|
||||
property string mouseWheelAction: "none"
|
||||
property bool reverseScroll: false
|
||||
property bool mouseWheelWrap: true
|
||||
property string middleClickAction: "none"
|
||||
property bool middleClickFollowMouse: false
|
||||
property string rightClickAction: "controlCenter"
|
||||
property bool rightClickFollowMouse: true
|
||||
// Per-screen overrides for position and widgets
|
||||
|
||||
+28
-15
@@ -336,29 +336,42 @@ Item {
|
||||
CompositorService.switchToWorkspace(candidates[next]);
|
||||
}
|
||||
|
||||
function handleEmptyBarClick(action, followMouse, mouse) {
|
||||
if (action === "none")
|
||||
return;
|
||||
if (action === "controlCenter") {
|
||||
var controlCenterPanel = PanelService.getPanel("controlCenterPanel", screen);
|
||||
controlCenterPanel?.toggle(null, followMouse ? mapToItem(null, mouse.x, mouse.y) : "ControlCenter");
|
||||
mouse.accepted = true;
|
||||
} else if (action === "settings") {
|
||||
var settingsPanel = PanelService.getPanel("settingsPanel", screen);
|
||||
settingsPanel?.toggle(null, followMouse ? mapToItem(null, mouse.x, mouse.y) : null);
|
||||
mouse.accepted = true;
|
||||
} else if (action === "launcherPanel") {
|
||||
var launcherPanel = PanelService.getPanel("launcherPanel", screen);
|
||||
launcherPanel?.toggle(null, followMouse ? mapToItem(null, mouse.x, mouse.y) : null);
|
||||
mouse.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
enabled: bar.barRightClickAction !== "none"
|
||||
acceptedButtons: Qt.RightButton | Qt.MiddleButton
|
||||
enabled: bar.barRightClickAction !== "none" || Settings.data.bar.middleClickAction !== "none"
|
||||
hoverEnabled: false
|
||||
preventStealing: true
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
if (bar.isPointOverWidget(mouse.x, mouse.y))
|
||||
return;
|
||||
if (bar.barRightClickAction === "controlCenter") {
|
||||
var controlCenterPanel = PanelService.getPanel("controlCenterPanel", screen);
|
||||
controlCenterPanel?.toggle(null, Settings.data.bar.rightClickFollowMouse ? mapToItem(null, mouse.x, mouse.y) : "ControlCenter");
|
||||
mouse.accepted = true;
|
||||
} else if (bar.barRightClickAction === "settings") {
|
||||
var settingsPanel = PanelService.getPanel("settingsPanel", screen);
|
||||
settingsPanel?.toggle(null, Settings.data.bar.rightClickFollowMouse ? mapToItem(null, mouse.x, mouse.y) : null);
|
||||
mouse.accepted = true;
|
||||
} else if (bar.barRightClickAction === "launcherPanel") {
|
||||
var launcherPanel = PanelService.getPanel("launcherPanel", screen);
|
||||
launcherPanel?.toggle(null, Settings.data.bar.rightClickFollowMouse ? mapToItem(null, mouse.x, mouse.y) : null);
|
||||
mouse.accepted = true;
|
||||
}
|
||||
bar.handleEmptyBarClick(bar.barRightClickAction, Settings.data.bar.rightClickFollowMouse, mouse);
|
||||
return;
|
||||
}
|
||||
if (mouse.button === Qt.MiddleButton) {
|
||||
if (bar.isPointOverWidget(mouse.x, mouse.y))
|
||||
return;
|
||||
bar.handleEmptyBarClick(Settings.data.bar.middleClickAction || "none", Settings.data.bar.middleClickFollowMouse, mouse);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
readonly property string effectiveWheelAction: Settings.data.bar.mouseWheelAction || "none"
|
||||
readonly property string effectiveMiddleClickAction: Settings.data.bar.middleClickAction || "none"
|
||||
readonly property string effectiveRightClickAction: Settings.data.bar.rightClickAction || "controlCenter"
|
||||
|
||||
NComboBox {
|
||||
@@ -61,6 +62,43 @@ ColumnLayout {
|
||||
visible: Settings.data.bar.mouseWheelAction === "workspace"
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.bar.behavior-middle-click-label")
|
||||
description: I18n.tr("panels.bar.behavior-middle-click-description")
|
||||
model: [
|
||||
{
|
||||
"key": "none",
|
||||
"name": I18n.tr("common.none")
|
||||
},
|
||||
{
|
||||
"key": "controlCenter",
|
||||
"name": I18n.tr("tooltips.open-control-center")
|
||||
},
|
||||
{
|
||||
"key": "settings",
|
||||
"name": I18n.tr("tooltips.open-settings")
|
||||
},
|
||||
{
|
||||
"key": "launcherPanel",
|
||||
"name": I18n.tr("actions.open-launcher")
|
||||
}
|
||||
]
|
||||
currentKey: root.effectiveMiddleClickAction
|
||||
defaultValue: Settings.getDefaultValue("bar.middleClickAction")
|
||||
onSelected: key => Settings.data.bar.middleClickAction = key
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.bar.behavior-middle-click-follow-mouse-label")
|
||||
description: I18n.tr("panels.bar.behavior-middle-click-follow-mouse-description")
|
||||
checked: Settings.data.bar.middleClickFollowMouse
|
||||
defaultValue: Settings.getDefaultValue("bar.middleClickFollowMouse")
|
||||
onToggled: checked => Settings.data.bar.middleClickFollowMouse = checked
|
||||
visible: Settings.data.bar.middleClickAction !== "none" && !(Settings.data.bar.middleClickAction === "settings" && Settings.data.ui.settingsPanelMode === "window")
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.bar.behavior-right-click-label")
|
||||
|
||||
Reference in New Issue
Block a user