diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 29ed9c5c..ac0bee75 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -1000,6 +1000,16 @@ "description": "Use a space to separate each part onto a new line." }, "preview": "Preview" + }, + "taskbar": { + "only-active-workspaces": { + "label": "Only from active workspaces", + "description": "Show only apps from active workspaces." + }, + "only-same-output": { + "label": "Only from same output", + "description": "Show only apps from the output where the bar is located." + } } } }, diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index 253f2a88..8cfd8564 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -12,10 +12,27 @@ Rectangle { id: root property ShellScreen screen property real scaling: 1.0 + + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" + property string section: "" + property int sectionWidgetIndex: -1 + property int sectionWidgetsCount: 0 readonly property bool isVerticalBar: Settings.data.bar.position === "left" || Settings.data.bar.position === "right" readonly property bool compact: (Settings.data.bar.density === "compact") readonly property real itemSize: compact ? Style.capsuleHeight * 0.9 * scaling : Style.capsuleHeight * 0.8 * scaling + + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] + property var widgetSettings: { + if (section && sectionWidgetIndex >= 0) { + var widgets = Settings.data.bar.widgets[section] + if (widgets && sectionWidgetIndex < widgets.length) { + return widgets[sectionWidgetIndex] + } + } + return {} + } // Always visible when there are toplevels implicitWidth: isVerticalBar ? Math.round(Style.capsuleHeight * scaling) : taskbarLayout.implicitWidth + Style.marginM * scaling * 2 @@ -46,8 +63,8 @@ Rectangle { id: taskbarItem required property var modelData - // TODO: Make this configurable - visible: modelData.output == screen.name && CompositorService.getActiveWorkspaces().map(ws => ws.id).includes(modelData.workspaceId) + visible: (!widgetSettings.onlySameOutput || modelData.output == screen.name) + && (!widgetSettings.onlyActiveWorkspaces || CompositorService.getActiveWorkspaces().map(ws => ws.id).includes(modelData.workspaceId)) Layout.preferredWidth: root.itemSize Layout.preferredHeight: root.itemSize diff --git a/Modules/Settings/Bar/BarWidgetSettingsDialog.qml b/Modules/Settings/Bar/BarWidgetSettingsDialog.qml index a198b1e3..4e52bc68 100644 --- a/Modules/Settings/Bar/BarWidgetSettingsDialog.qml +++ b/Modules/Settings/Bar/BarWidgetSettingsDialog.qml @@ -133,7 +133,8 @@ Popup { "Spacer": "WidgetSettings/SpacerSettings.qml", "SystemMonitor": "WidgetSettings/SystemMonitorSettings.qml", "Volume": "WidgetSettings/VolumeSettings.qml", - "Workspace": "WidgetSettings/WorkspaceSettings.qml" + "Workspace": "WidgetSettings/WorkspaceSettings.qml", + "Taskbar": "WidgetSettings/TaskbarSettings.qml" } const source = widgetSettingsMap[widgetId] diff --git a/Modules/Settings/Bar/WidgetSettings/TaskbarSettings.qml b/Modules/Settings/Bar/WidgetSettings/TaskbarSettings.qml new file mode 100644 index 00000000..98df4c3f --- /dev/null +++ b/Modules/Settings/Bar/WidgetSettings/TaskbarSettings.qml @@ -0,0 +1,43 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import qs.Commons +import qs.Widgets +import qs.Services + +ColumnLayout { + id: root + spacing: Style.marginM * scaling + + // Properties to receive data from parent + property var widgetData: null + property var widgetMetadata: null + + // Local state + property bool valueOnlyActiveWorkspaces: widgetData.onlyActiveWorkspaces !== undefined ? widgetData.onlyActiveWorkspaces : widgetMetadata.onlyActiveWorkspaces + property bool valueOnlySameOutput: widgetData.onlySameOutput !== undefined ? widgetData.onlySameOutput : widgetMetadata.onlySameOutput + + function saveSettings() { + var settings = Object.assign({}, widgetData || {}) + settings.onlySameOutput = valueOnlySameOutput + settings.onlyActiveWorkspaces = valueOnlyActiveWorkspaces + console.log(JSON.stringify(settings)) + return settings + } + + NToggle { + Layout.fillWidth: true + label: I18n.tr("bar.widget-settings.taskbar.only-same-output.label") + description: I18n.tr("bar.widget-settings.taskbar.only-same-output.description") + checked: root.valueOnlySameOutput + onToggled: checked => root.valueOnlySameOutput = checked + } + + NToggle { + Layout.fillWidth: true + label: I18n.tr("bar.widget-settings.taskbar.only-active-workspaces.label") + description: I18n.tr("bar.widget-settings.taskbar.only-active-workspaces.description") + checked: root.valueOnlyActiveWorkspaces + onToggled: checked => root.valueOnlyActiveWorkspaces = checked + } +} diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index bab1a4b4..6beda333 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -109,6 +109,11 @@ Singleton { "showNetworkStats": false, "showDiskUsage": false }, + "Taskbar": { + "allowUserSettings": true, + "onlySameOutput": true, + "onlyActiveWorkspaces": true + }, "Workspace": { "allowUserSettings": true, "labelMode": "index",