diff --git a/Modules/Settings/WidgetsTab.qml b/Modules/Settings/WidgetsTab.qml index c2ae5137..1a389248 100644 --- a/Modules/Settings/WidgetsTab.qml +++ b/Modules/Settings/WidgetsTab.qml @@ -374,16 +374,14 @@ Item { } Component.onCompleted: { - if (!SettingsData.topBarLeftWidgets - || SettingsData.topBarLeftWidgets.length === 0) + // Only set defaults if widgets have never been configured (null/undefined, not empty array) + if (!SettingsData.topBarLeftWidgets) SettingsData.setTopBarLeftWidgets(defaultLeftWidgets) - if (!SettingsData.topBarCenterWidgets - || SettingsData.topBarCenterWidgets.length === 0) + if (!SettingsData.topBarCenterWidgets) SettingsData.setTopBarCenterWidgets(defaultCenterWidgets) - if (!SettingsData.topBarRightWidgets - || SettingsData.topBarRightWidgets.length === 0) + if (!SettingsData.topBarRightWidgets) SettingsData.setTopBarRightWidgets(defaultRightWidgets) ["left", "center", "right"].forEach(sectionId => { diff --git a/Modules/TopBar/LauncherButton.qml b/Modules/TopBar/LauncherButton.qml index 0d12fa84..ac9e6a84 100644 --- a/Modules/TopBar/LauncherButton.qml +++ b/Modules/TopBar/LauncherButton.qml @@ -3,50 +3,28 @@ import qs.Common import qs.Services import qs.Widgets -Rectangle { +Item { id: root property bool isActive: false - property string section: "left" // Which section this button is in - property var popupTarget: null // Reference to the popup to position - property var parentScreen: null // The screen this button is on + property string section: "left" + property var popupTarget: null + property var parentScreen: null signal clicked width: 40 height: 30 - radius: Theme.cornerRadius - color: { - const baseColor = launcherArea.containsMouse - || isActive ? Theme.surfaceTextPressed : Theme.surfaceTextHover - return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, - baseColor.a * Theme.widgetTransparency) - } - - SystemLogo { - visible: SettingsData.useOSLogo - anchors.centerIn: parent - width: Theme.iconSize - 3 - height: Theme.iconSize - 3 - colorOverride: SettingsData.osLogoColorOverride - brightnessOverride: SettingsData.osLogoBrightness - contrastOverride: SettingsData.osLogoContrast - } - - DankIcon { - visible: !SettingsData.useOSLogo - anchors.centerIn: parent - name: "apps" - size: Theme.iconSize - 6 - color: Theme.surfaceText - } MouseArea { id: launcherArea - anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor + z: 1000 + preventStealing: true + propagateComposedEvents: false + onClicked: { if (popupTarget && popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0) @@ -61,10 +39,39 @@ Rectangle { } } - Behavior on color { - ColorAnimation { - duration: Theme.shortDuration - easing.type: Theme.standardEasing + Rectangle { + anchors.fill: parent + radius: Theme.cornerRadius + color: { + const baseColor = launcherArea.containsMouse + || isActive ? Theme.surfaceTextPressed : Theme.surfaceTextHover + return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, + baseColor.a * Theme.widgetTransparency) + } + + SystemLogo { + visible: SettingsData.useOSLogo + anchors.centerIn: parent + width: Theme.iconSize - 3 + height: Theme.iconSize - 3 + colorOverride: SettingsData.osLogoColorOverride + brightnessOverride: SettingsData.osLogoBrightness + contrastOverride: SettingsData.osLogoContrast + } + + DankIcon { + visible: !SettingsData.useOSLogo + anchors.centerIn: parent + name: "apps" + size: Theme.iconSize - 6 + color: Theme.surfaceText + } + + Behavior on color { + ColorAnimation { + duration: Theme.shortDuration + easing.type: Theme.standardEasing + } } } -} +} \ No newline at end of file diff --git a/Modules/TopBar/Media.qml b/Modules/TopBar/Media.qml index b9c8381b..bb37155c 100644 --- a/Modules/TopBar/Media.qml +++ b/Modules/TopBar/Media.qml @@ -184,8 +184,9 @@ Rectangle { MouseArea { anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor + enabled: root.playerAvailable && root.opacity > 0 && root.width > 0 && textContainer.visible + hoverEnabled: enabled + cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor onClicked: { if (root.popupTarget && root.popupTarget.setTriggerPosition) { var globalPos = mapToGlobal(0, 0) @@ -226,8 +227,9 @@ Rectangle { id: prevArea anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor + enabled: root.playerAvailable && root.width > 0 + hoverEnabled: enabled + cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor onClicked: { if (activePlayer) activePlayer.previous() @@ -256,8 +258,9 @@ Rectangle { MouseArea { anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor + enabled: root.playerAvailable && root.width > 0 + hoverEnabled: enabled + cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor onClicked: { if (activePlayer) activePlayer.togglePlaying() @@ -285,8 +288,9 @@ Rectangle { id: nextArea anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor + enabled: root.playerAvailable && root.width > 0 + hoverEnabled: enabled + cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor onClicked: { if (activePlayer) activePlayer.next() diff --git a/Modules/TopBar/TopBar.qml b/Modules/TopBar/TopBar.qml index 4b3f90fd..dd1a8f9a 100644 --- a/Modules/TopBar/TopBar.qml +++ b/Modules/TopBar/TopBar.qml @@ -82,6 +82,19 @@ PanelWindow { root.updateGpuTempConfig() } + function onWidgetDataChanged() { + Qt.callLater(() => { + leftSection.visible = false + centerSection.visible = false + rightSection.visible = false + Qt.callLater(() => { + leftSection.visible = true + centerSection.visible = true + rightSection.visible = true + }) + }) + } + target: SettingsData } diff --git a/Services/FocusedWindowService.qml b/Services/FocusedWindowService.qml index f71c4408..bfabc140 100644 --- a/Services/FocusedWindowService.qml +++ b/Services/FocusedWindowService.qml @@ -29,7 +29,7 @@ Singleton { root.focusedAppName = getDisplayName(focusedWindow.app_id || "") root.focusedWindowId = parseInt(focusedWindow.id) || -1 } else { - clearFocusedWindow() + setWorkspaceFallback() } } @@ -37,9 +37,29 @@ Singleton { root.focusedAppId = "" root.focusedAppName = "" root.focusedWindowTitle = "" + root.focusedWindowId = -1 + } + + function setWorkspaceFallback() { + if (NiriService.focusedWorkspaceIndex >= 0 && NiriService.allWorkspaces.length > 0) { + const workspace = NiriService.allWorkspaces[NiriService.focusedWorkspaceIndex] + if (workspace) { + root.focusedAppId = "niri" + root.focusedAppName = "niri" + if (workspace.name && workspace.name.length > 0) { + root.focusedWindowTitle = workspace.name + } else { + root.focusedWindowTitle = "Workspace " + (workspace.idx + 1) + } + root.focusedWindowId = -1 + } else { + clearFocusedWindow() + } + } else { + clearFocusedWindow() + } } - // Convert app_id to a more user-friendly display name function getDisplayName(appId) { if (!appId) return "" @@ -62,7 +82,7 @@ Singleton { function onFocusedWindowIdChanged() { const focusedWindowId = NiriService.focusedWindowId if (!focusedWindowId) { - clearFocusedWindow() + setWorkspaceFallback() return } @@ -74,7 +94,7 @@ Singleton { root.focusedAppName = getDisplayName(focusedWindow.app_id || "") root.focusedWindowId = parseInt(focusedWindow.id) || -1 } else { - clearFocusedWindow() + setWorkspaceFallback() } }