feat(bar-scroll-actions): refactor mouse wheel action setting to use a combobox

This commit is contained in:
tibssy
2026-02-18 16:17:29 +00:00
parent 8032978b2d
commit 41c383d89b
5 changed files with 43 additions and 8 deletions
+2 -2
View File
@@ -827,8 +827,8 @@
"appearance-use-separate-opacity-label": "Use separate bar opacity",
"appearance-widget-spacing-description": "Adjust the spacing between each widget in the bar.",
"appearance-widget-spacing-label": "Widget spacing",
"behavior-workspace-scroll-description": "Use the mouse wheel on empty areas of the bar to switch between workspaces or columns.",
"behavior-workspace-scroll-label": "Scroll to switch workspaces",
"behavior-workspace-scroll-description": "Choose what the mouse wheel does on empty areas of the bar.",
"behavior-workspace-scroll-label": "Bar mouse wheel action",
"monitor-configure-widgets": "Configure widgets",
"monitor-override-settings": "Override global settings",
"monitor-override-settings-description": "Use custom settings for this monitor.",
+1
View File
@@ -69,6 +69,7 @@
]
},
"enableWorkspaceScroll": false,
"mouseWheelAction": "none",
"screenOverrides": []
},
"general": {
+1
View File
@@ -253,6 +253,7 @@ Singleton {
]
}
property bool enableWorkspaceScroll: false
property string mouseWheelAction: "none"
// Per-screen overrides for position and widgets
// Format: [{ "name": "HDMI-1", "position": "left" }, { "name": "DP-1", "position": "bottom", "widgets": {...} }]
property list<var> screenOverrides: []
+6 -1
View File
@@ -184,6 +184,11 @@ Item {
// Wheel scroll handling (empty bar area)
property int barWheelAccumulatedDelta: 0
property bool barWheelCooldown: false
readonly property string barWheelAction: {
if (Settings.data.bar.mouseWheelAction !== undefined && Settings.data.bar.mouseWheelAction !== "")
return Settings.data.bar.mouseWheelAction;
return Settings.data.bar.enableWorkspaceScroll ? "workspace" : "none";
}
// Position and size the bar content based on orientation
x: (root.barPosition === "right") ? (parent.width - root.barHeight) : 0
@@ -362,7 +367,7 @@ Item {
id: barWheelHandler
target: bar
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
enabled: Settings.data.bar.enableWorkspaceScroll
enabled: bar.barWheelAction === "workspace"
onWheel: function (event) {
if (bar.barWheelCooldown)
@@ -10,12 +10,40 @@ ColumnLayout {
spacing: Style.marginL
Layout.fillWidth: true
NToggle {
readonly property string effectiveWheelAction: {
if (Settings.data.bar.mouseWheelAction !== undefined && Settings.data.bar.mouseWheelAction !== "")
return Settings.data.bar.mouseWheelAction;
return Settings.data.bar.enableWorkspaceScroll ? "workspace" : "none";
}
NComboBox {
Layout.fillWidth: true
label: I18n.tr("panels.bar.behavior-workspace-scroll-label")
description: I18n.tr("panels.bar.behavior-workspace-scroll-description")
checked: Settings.data.bar.enableWorkspaceScroll
defaultValue: Settings.getDefaultValue("bar.enableWorkspaceScroll")
onToggled: checked => Settings.data.bar.enableWorkspaceScroll = checked
model: {
var items = [
{
"key": "none",
"name": "Nothing"
},
{
"key": "workspace",
"name": "Workspace"
}
];
if (CompositorService.isNiri) {
items.push({
"key": "content",
"name": "Content"
});
}
return items;
}
currentKey: root.effectiveWheelAction
defaultValue: Settings.getDefaultValue("bar.mouseWheelAction")
onSelected: key => {
Settings.data.bar.mouseWheelAction = key;
Settings.data.bar.enableWorkspaceScroll = (key === "workspace");
}
}
}
}