From dfe55f34af2ed9e50a922c5019f2ca98f05d8a03 Mon Sep 17 00:00:00 2001 From: Amaro Lopes Date: Fri, 10 Oct 2025 11:35:15 -0300 Subject: [PATCH] Add LazyLoader to the hover popup, add env to wal theme folder, fix a bug in popup calendar text --- Common/Theme.qml | 22 +--- Services/PopUpHover.qml | 244 +++++++++++++++++++++------------------- Workspaces.qml | 1 + 3 files changed, 129 insertions(+), 138 deletions(-) diff --git a/Common/Theme.qml b/Common/Theme.qml index 29fd2e1..a79f8d2 100644 --- a/Common/Theme.qml +++ b/Common/Theme.qml @@ -18,7 +18,7 @@ Singleton { // Colors FileView { id: walColors - path: Qt.resolvedUrl("/home/amaro/.cache/wal/colors") + path: Qt.resolvedUrl(Quickshell.env("XDG_CACHE_HOME")+"/wal/colors") blockLoading: true watchChanges: true onFileChanged: this.reload() @@ -44,24 +44,4 @@ Singleton { readonly property color foregroundColorBright: walColorsText[15] readonly property color textColor: foregroundColorBright -// background "#0e1721" -// color2 "#463e44" -// color3 "#7b4834" -// color4 "#735148" -// color5 "#896451" -// color6 "#9d7057" -// color7 "#595563" -// foreground "#91959b" -// "#5d6772" -// "#5E535B" -// "#A56046" -// "#9A6C60" -// "#B7866C" -// "#D29674" -// "#777285" -// "#c2c5c7" - - - - } diff --git a/Services/PopUpHover.qml b/Services/PopUpHover.qml index 1af8b85..33a0e2d 100644 --- a/Services/PopUpHover.qml +++ b/Services/PopUpHover.qml @@ -10,6 +10,9 @@ import qs.Common.Styled import qs.Services Singleton { + id: root + + property bool showWindow: false function start(component, type) { HoverMediator.component = component; @@ -19,122 +22,7 @@ Singleton { function exit() { hoverTimer.stop(); - hoverPopUp.visible = false; - } - - PopupWindow { - id: hoverPopUp - - anchor.item: HoverMediator.component - property bool initialized: false - anchor.rect.y: HoverMediator.y - anchor.rect.x: (HoverMediator.x - this.implicitWidth) / 2 - implicitHeight: wsPopUp.implicitHeight - implicitWidth: wsPopUp.implicitWidth - - color: "transparent" - - Component { - id: stub - StyledText { - text: "stub" - } - } - - Component { - id: systray - StyledText { - text: { - if (!HoverMediator.component?.model) - return ""; - if (HoverMediator.component.model.tooltipTitle) - return HoverMediator.component.model.tooltipTitle; - if (HoverMediator.component.model.title) - return HoverMediator.component.model.title; - else - return ""; - } - } - } - - Component { - id: time - StyledText { - property string calendar: (HoverMediator.component.calendar) ? HoverMediator.component.calendar : "" - - text: calendar - font.family: Theme.fontFamilyMono - } - } - - Component { - id: audio - StyledText { - property string sinkDescription: (HoverMediator.component.sink) ? HoverMediator.component.sink.description : "" - text: sinkDescription - } - } - - Component { - id: workspaceComponent - - RowLayout { - id: wsPopUpRow - - property int workspaceIndexAlign: HoverMediator.component.workspaceIndexAlign || 0 - - Repeater { - - property var modelo: HyprlandService.sortedDesktopApplications.get(parent.workspaceIndexAlign) - - model: modelo - delegate: IconImage { - - required property var modelData - - width: 30 - height: 30 - source: (modelData && modelData.icon) ? Quickshell.iconPath(modelData.icon, 1) : "" - } - } - } - } - - BackgroundRectangle { - id: wsPopUp - - MarginWrapperManager { - leftMargin: (Theme.gaps * 2) - rightMargin: (Theme.gaps * 2) - topMargin: Theme.gaps - bottomMargin: Theme.gaps - } - color: Theme.backgroudColor - radius: 25 - opacity: 1 - Behavior on opacity { - NumberAnimation { - property: "opacity" - duration: Theme.animationDuration - } - } - - Loader { - id: hoverLoader - sourceComponent: { - if (!HoverMediator.type) - return stub; - if (HoverMediator.type === "workspace") - return workspaceComponent; - if (HoverMediator.type === "audio") - return audio; - if (HoverMediator.type === "time") - return time; - if (HoverMediator.type === "systray") - return systray; - } - } - } + root.showWindow = false; } Timer { @@ -143,7 +31,129 @@ Singleton { interval: 300 onTriggered: { // wsPopUp.opacity = 1 - hoverPopUp.visible = true; + root.showWindow = true; } } + + LazyLoader { + active: root.showWindow + component: PopupWindow { + id: hoverPopUp + + anchor.item: HoverMediator.component + property bool initialized: false + anchor.rect.y: HoverMediator.y + anchor.rect.x: (HoverMediator.x - this.implicitWidth) / 2 + implicitHeight: wsPopUp.implicitHeight + implicitWidth: wsPopUp.implicitWidth + visible: true + + color: "transparent" + + Component { + id: stub + StyledText { + text: "stub" + } + } + + Component { + id: systray + StyledText { + text: { + if (!HoverMediator.component?.model) + return ""; + if (HoverMediator.component.model.tooltipTitle) + return HoverMediator.component.model.tooltipTitle; + if (HoverMediator.component.model.title) + return HoverMediator.component.model.title; + else + return ""; + } + } + } + + Component { + id: time + StyledText { + property string calendar: (HoverMediator.component.calendar) ? HoverMediator.component.calendar : "" + + text: calendar + + textFormat: Text.AutoText + font.family: Theme.fontFamilyMono + } + } + + Component { + id: audio + StyledText { + property string sinkDescription: (HoverMediator.component.sink) ? HoverMediator.component.sink.description : "" + text: sinkDescription + } + } + + Component { + id: workspaceComponent + + RowLayout { + id: wsPopUpRow + + property int workspaceIndexAlign: HoverMediator.component.workspaceIndexAlign || 0 + + Repeater { + + property var modelo: HyprlandService.sortedDesktopApplications.get(parent.workspaceIndexAlign) + + model: modelo + delegate: IconImage { + + required property var modelData + + width: 30 + height: 30 + source: (modelData && modelData.icon) ? Quickshell.iconPath(modelData.icon, 1) : "" + } + } + } + } + + BackgroundRectangle { + id: wsPopUp + + MarginWrapperManager { + leftMargin: (Theme.gaps * 2) + rightMargin: (Theme.gaps * 2) + topMargin: Theme.gaps + bottomMargin: Theme.gaps + } + color: Theme.backgroudColor + radius: 25 + opacity: 1 + Behavior on opacity { + NumberAnimation { + property: "opacity" + duration: Theme.animationDuration + } + } + + Loader { + id: hoverLoader + sourceComponent: { + if (!HoverMediator.type) + return stub; + if (HoverMediator.type === "workspace") + return workspaceComponent; + if (HoverMediator.type === "audio") + return audio; + if (HoverMediator.type === "time") + return time; + if (HoverMediator.type === "systray") + return systray; + } + } + } + } + + } } diff --git a/Workspaces.qml b/Workspaces.qml index 5d96e82..e62635a 100644 --- a/Workspaces.qml +++ b/Workspaces.qml @@ -129,6 +129,7 @@ WrapperMouseArea { } ; Hyprland.dispatch("workspace " + workspacesRectangle.workspace.id); + PopUpHover.exit(); } } }