From 36bfbe10ab9f6bdcf10d50a5733edf2df0e2130b Mon Sep 17 00:00:00 2001 From: JPratama7 Date: Sun, 31 Aug 2025 00:20:01 +0700 Subject: [PATCH 1/6] feat: taskbar --- Modules/Bar/Widgets/Taskbar.qml | 118 ++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Modules/Bar/Widgets/Taskbar.qml diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml new file mode 100644 index 0000000..a1c4eb5 --- /dev/null +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -0,0 +1,118 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import QtQuick.Controls +import Quickshell.Widgets +import Quickshell.Wayland +import qs.Commons +import qs.Services + +Rectangle { + id: root + property var screen + readonly property real scaling: screen ? ScalingService.scale(screen) : 1 + readonly property real itemSize: 32 * scaling + + // Always visible when there are toplevels + implicitWidth: taskbarRow.width + Style.marginM * scaling * 2 + implicitHeight: Math.round(Style.capsuleHeight * scaling) + radius: Math.round(Style.radiusM * scaling) + color: Color.mSurfaceVariant + + Component.onCompleted: { + Logger.log("Taskbar", "Taskbar loaded") + } + + Row { + id: taskbarRow + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + spacing: Style.marginXS * root.scaling + + Repeater { + model: ToplevelManager && ToplevelManager.toplevels ? ToplevelManager.toplevels : [] + delegate: Item { + id: taskbarItem + required property Toplevel modelData + property Toplevel toplevel: modelData + property bool isActive: ToplevelManager.activeToplevel === modelData + onIsActiveChanged: { + if (modelData) { + Logger.log("Taskbar", `Item ${modelData.appId} active: ${isActive}`) + } + } + + width: root.itemSize + height: root.itemSize + + Rectangle { + id: iconBackground + anchors.centerIn: parent + width: root.itemSize * 0.75 + height: root.itemSize * 0.75 + color: { + if (taskbarItem.isActive) { + return Color.mPrimary + } + return root.color + } + border.width: 0 + border.color: "transparent" + z: -1 + + IconImage { + id: appIcon + anchors.centerIn: parent + width: Style.marginL * root.scaling + height: Style.marginL * root.scaling + source: Icons.iconForAppId(taskbarItem.modelData.appId) + smooth: true + } + } + + MouseArea { + id: appMouseArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onPressed: function(mouse) { + if (!taskbarItem.modelData) return + + if (mouse.button === Qt.LeftButton) { + try { + taskbarItem.modelData.activate() + } catch (error) { + Logger.log("Taskbar", "Failed to activate toplevel: " + error) + } + } else if (mouse.button === Qt.RightButton) { + try { + taskbarItem.modelData.close() + } catch (error) { + Logger.log("Taskbar", "Failed to close toplevel: " + error) + } + } + } + + ToolTip { + parent: appIcon + visible: appMouseArea.containsMouse + delay: 500 + text: taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown App" + background: Rectangle { + color: Color.mSurface + border.color: Color.mOutline + radius: Style.radiusS * root.scaling + } + contentItem: Label { + color: Color.mOnSurface + font.pixelSize: Style.fontSizeS * root.scaling + text: taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown App" + } + } + } + } + } + } +} From d5a8a0d72f13445898855108594cb91823fc6859 Mon Sep 17 00:00:00 2001 From: JPratama7 Date: Sun, 31 Aug 2025 00:20:13 +0700 Subject: [PATCH 2/6] refactor: add to registry --- Services/BarWidgetRegistry.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index 5ff44fd..4ea47bd 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -23,6 +23,7 @@ Singleton { "ScreenRecorderIndicator": screenRecorderIndicatorComponent, "SidePanelToggle": sidePanelToggleComponent, "SystemMonitor": systemMonitorComponent, + "Taskbar": taskbarComponent, "Tray": trayComponent, "Volume": volumeComponent, "WiFi": wiFiComponent, @@ -84,6 +85,9 @@ Singleton { property Component workspaceComponent: Component { Workspace {} } + property Component taskbarComponent: Component { + Taskbar {} + } // ------------------------------ // Helper function to get widget component by name From 9264306a36dce3fb233cac6051b486c11c7f21d8 Mon Sep 17 00:00:00 2001 From: JPratama7 Date: Sun, 31 Aug 2025 00:21:58 +0700 Subject: [PATCH 3/6] refactor: remove debug --- Modules/Bar/Widgets/Taskbar.qml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index a1c4eb5..86c9b95 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -36,12 +36,6 @@ Rectangle { required property Toplevel modelData property Toplevel toplevel: modelData property bool isActive: ToplevelManager.activeToplevel === modelData - onIsActiveChanged: { - if (modelData) { - Logger.log("Taskbar", `Item ${modelData.appId} active: ${isActive}`) - } - } - width: root.itemSize height: root.itemSize From 65601cb855f3cbcf78116bb6c67104fb624757b7 Mon Sep 17 00:00:00 2001 From: JPratama7 Date: Sun, 31 Aug 2025 09:44:20 +0700 Subject: [PATCH 4/6] refactor: adjust codestyle --- Modules/Bar/Widgets/Taskbar.qml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index 86c9b95..d1fc6b4 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -2,15 +2,17 @@ pragma ComponentBehavior: Bound import QtQuick import QtQuick.Controls +import Quickshell import Quickshell.Widgets import Quickshell.Wayland import qs.Commons import qs.Services +import qs.Widgets Rectangle { id: root - property var screen - readonly property real scaling: screen ? ScalingService.scale(screen) : 1 + property ShellScreen modelData + readonly property real scaling: modelData ? ScalingService.scale(modelData) : 1 readonly property real itemSize: 32 * scaling // Always visible when there are toplevels @@ -44,12 +46,7 @@ Rectangle { anchors.centerIn: parent width: root.itemSize * 0.75 height: root.itemSize * 0.75 - color: { - if (taskbarItem.isActive) { - return Color.mPrimary - } - return root.color - } + color: taskbarItem.isActive ? Color.mPrimary : root.color border.width: 0 border.color: "transparent" z: -1 @@ -78,13 +75,13 @@ Rectangle { try { taskbarItem.modelData.activate() } catch (error) { - Logger.log("Taskbar", "Failed to activate toplevel: " + error) + Logger.error("Taskbar", "Failed to activate toplevel: " + error) } } else if (mouse.button === Qt.RightButton) { try { taskbarItem.modelData.close() } catch (error) { - Logger.log("Taskbar", "Failed to close toplevel: " + error) + Logger.error("Taskbar", "Failed to close toplevel: " + error) } } } From 9bb5241e49b9ff8a7b58493e05395b060585f848 Mon Sep 17 00:00:00 2001 From: JPratama7 Date: Sun, 31 Aug 2025 10:54:13 +0700 Subject: [PATCH 5/6] refactor: adjust tooltip --- Modules/Bar/Widgets/Taskbar.qml | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index d1fc6b4..19c77cb 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -21,10 +21,6 @@ Rectangle { radius: Math.round(Style.radiusM * scaling) color: Color.mSurfaceVariant - Component.onCompleted: { - Logger.log("Taskbar", "Taskbar loaded") - } - Row { id: taskbarRow anchors.verticalCenter: parent.verticalCenter @@ -62,7 +58,6 @@ Rectangle { } MouseArea { - id: appMouseArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor @@ -85,23 +80,15 @@ Rectangle { } } } + onEntered: taskbarTooltip.show() + onExited: taskbarTooltip.hide() + } - ToolTip { - parent: appIcon - visible: appMouseArea.containsMouse - delay: 500 - text: taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown App" - background: Rectangle { - color: Color.mSurface - border.color: Color.mOutline - radius: Style.radiusS * root.scaling - } - contentItem: Label { - color: Color.mOnSurface - font.pixelSize: Style.fontSizeS * root.scaling - text: taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown App" - } - } + NTooltip { + id: taskbarTooltip + text: taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown App" + target: taskbarItem + positionAbove: Settings.data.bar.position === "bottom" } } } From d8830969718624dda7e5a6177eee139a14b2575a Mon Sep 17 00:00:00 2001 From: JPratama7 Date: Sun, 31 Aug 2025 11:35:24 +0700 Subject: [PATCH 6/6] feat: add little radius --- Modules/Bar/Widgets/Taskbar.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index 19c77cb..4308a36 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -44,6 +44,7 @@ Rectangle { height: root.itemSize * 0.75 color: taskbarItem.isActive ? Color.mPrimary : root.color border.width: 0 + radius: Math.round(Style.radiusXS * root.scaling) border.color: "transparent" z: -1