Add hover show applications in workspace bar

This commit is contained in:
Amaro Lopes
2025-09-22 02:37:28 -03:00
parent 2445e21f0b
commit 65497edde2
8 changed files with 205 additions and 56 deletions

View File

@@ -6,8 +6,10 @@ import Quickshell.Hyprland
import Quickshell.Wayland
import Quickshell.Widgets
import qs.Common
import qs.Services
WrapperMouseArea {
id: workspacesRoot
property var monitor: "black"
onWheel: (wheel) => {
@@ -31,70 +33,88 @@ WrapperMouseArea {
model: 5
delegate: Rectangle {
id: workspacesRectangle
required property var modelData
property var index: modelData // Get the workspace data from the model
property var workspace: {
monitor === "DP-2" ? Hyprland.workspaces.values[index + 5] : Hyprland.workspaces.values[index];
workspacesRoot.monitor === "DP-2" ? Hyprland.workspaces.values[index + 5] : Hyprland.workspaces.values[index];
}
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
implicitHeight: Theme.heightGaps
implicitWidth: workspace.id === Hyprland.focusedWorkspace.id ? root.implicitHeight * 1.5 : root.implicitHeight
implicitWidth: workspace.id === Hyprland.focusedWorkspace.id ? Theme.barSize* 1.5 : Theme.barSize
radius: 25
color: workspace.id === Hyprland.focusedWorkspace.id ? "#4444FF" : "#44475A"
color: {
if (workspace.id === Hyprland.focusedWorkspace.id) {
return Theme.color6
}
if (HyprlandService.topLevelWorkspaces.filter(topLevelworkspace => topLevelworkspace.id === workspace.id).length) {
return Theme.backgroudColorBright
}
return Theme.backgroudColor
}
// PopupWindow {
// id: workspacesPopUp
// anchor.window: root
// anchor.rect.x: barArea.x
// anchor.rect.y: root.implicitHeight
// implicitWidth: 500
// implicitHeight: 500
// Item {
// anchors.fill: parent
// ScreencopyView {
// anchors.fill : parent
// live:true
//// captureSource: Quickshell.screens.filter(screen => screen.name == monitor)[0]
// captureSource: workspace.toplevels
// }
// MouseArea {
// anchors.fill: parent
// hoverEnabled: true
// onExited: {
// workspacesPopUp.visible = false
// }
// }
// }
// }
// Timer {
// id: workspacesTimer
// interval: 1000
// onTriggered: { workspacesPopUp.visible = true }
// }
PopupWindow {
id: workspacesPopUp
anchor.item: workspacesRectangle
anchor.rect.y: workspacesRectangle.implicitHeight+5
anchor.rect.x: -implicitWidth/2 + workspacesRectangle.implicitWidth/2
implicitWidth: wsPopUpRow.implicitWidth*1.6
implicitHeight: 35
color:"transparent"
Rectangle {
Component.onCompleted: console.log("Completed Running!")
anchors.fill: parent
color: Theme.backgroudColor
radius: 25
RowLayout {
anchors{
horizontalCenter:parent.horizontalCenter
verticalCenter:parent.verticalCenter
}
id: wsPopUpRow
Repeater {
model: HyprlandService.sortedDesktopApplications.get(workspacesRectangle.workspace.id)
delegate: IconImage {
required property var modelData
width:30; height:30
source: (modelData && modelData.icon) ? Quickshell.iconPath(modelData.icon, 1) : ""
}
}
}
}
}
Timer {
id: workspacesTimer
interval: 300
onTriggered: { workspacesPopUp.visible = true }
}
Text {
anchors.centerIn: parent
text: monitor === "DP-2" ? workspace.id - 5 : workspace.id
text: workspacesRoot.monitor === "DP-2" ? workspacesRectangle.workspace.id - 5 : workspacesRectangle.workspace.id
font.bold: true
font.pixelSize: 14
font.family: root.fontFamily
color: "#F8F8F2"
font.family: Theme.fontFamily
color: Theme.textColor
}
MouseArea {
// hoverEnabled: true
// onEntered: {
// console.log(JSON.stringify(workspace.toplevels.values[0].lastIpcObject))
// workspacesTimer.start()
// }
// onExited: {
// workspacesTimer.stop()
// workspacesPopUp.visible = false
// }
hoverEnabled: true
onEntered: {
if (HyprlandService.sortedDesktopApplications.get(workspacesRectangle.workspace.id)){
workspacesTimer.start()
}
}
onExited: {
workspacesTimer.stop()
workspacesPopUp.visible = false
}
anchors.fill: parent
onClicked: {
if(workspace.id === Hyprland.focusedWorkspace.id) {return} ;
Hyprland.dispatch("workspace " + workspace.id);
if(workspacesRectangle.workspace.id === Hyprland.focusedWorkspace.id) {return} ;
Hyprland.dispatch("workspace " + workspacesRectangle.workspace.id);
}
}