From 84f031573e107abcb4cc9af6739664a96fef3d68 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 24 Apr 2025 20:26:58 +0200 Subject: [PATCH] overview: middle click to close --- .../quickshell/modules/overview/Overview.qml | 37 ++++++++++++++++++- .../modules/overview/OverviewWidget.qml | 10 ++--- .../modules/overview/OverviewWindow.qml | 12 ++++-- .../modules/sidebarRight/todo/TodoWidget.qml | 1 + 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/.config/quickshell/modules/overview/Overview.qml b/.config/quickshell/modules/overview/Overview.qml index 4ff3d11f7..6bdf17430 100644 --- a/.config/quickshell/modules/overview/Overview.qml +++ b/.config/quickshell/modules/overview/Overview.qml @@ -18,6 +18,7 @@ Scope { PanelWindow { id: root property var modelData + property string searchingText: "" screen: modelData visible: GlobalStates.overviewOpen @@ -70,7 +71,7 @@ Scope { Keys.onPressed: (event) => { if (event.key === Qt.Key_Escape) { - sessionRoot.visible = false; + GlobalStates.overviewOpen = false; } } @@ -79,7 +80,41 @@ Scope { width: 1 // Prevent Wayland protocol error } + TextField { + id: searchInput + + Layout.alignment: Qt.AlignHCenter + padding: 15 + color: activeFocus ? Appearance.m3colors.m3onSurface : Appearance.m3colors.m3onSurfaceVariant + selectedTextColor: Appearance.m3colors.m3onSurface + placeholderText: "Search, calculate or run" + placeholderTextColor: Appearance.m3colors.m3outline + focus: root.visible + + onTextChanged: root.searchingText = text + Connections { + target: root + function onVisibleChanged() { + searchInput.selectAll() + root.searchingText = "" + } + } + + background: Rectangle { + anchors.fill: parent + radius: Appearance.rounding.normal + color: Appearance.colors.colLayer0 + } + + cursorDelegate: Rectangle { + width: 1 + color: searchInput.activeFocus ? Appearance.m3colors.m3primary : "transparent" + radius: 1 + } + } + OverviewWidget { + visible: (root.searchingText == "") bar: root } } diff --git a/.config/quickshell/modules/overview/OverviewWidget.qml b/.config/quickshell/modules/overview/OverviewWidget.qml index 4f5695ae1..829d7d653 100644 --- a/.config/quickshell/modules/overview/OverviewWidget.qml +++ b/.config/quickshell/modules/overview/OverviewWidget.qml @@ -92,12 +92,10 @@ Item { } Repeater { // Window repeater - model: ScriptModel { - values: windowAddresses.filter((address) => { - var win = windowByAddress[address] - return (win?.workspace?.id === workspace.workspaceValue) - }) - } + model: windowAddresses.filter((address) => { + var win = windowByAddress[address] + return (win?.workspace?.id === workspace.workspaceValue) + }) delegate: OverviewWindow { windowData: windowByAddress[modelData] monitorData: root.monitorData diff --git a/.config/quickshell/modules/overview/OverviewWindow.qml b/.config/quickshell/modules/overview/OverviewWindow.qml index ce85e0408..f492ee155 100644 --- a/.config/quickshell/modules/overview/OverviewWindow.qml +++ b/.config/quickshell/modules/overview/OverviewWindow.qml @@ -80,12 +80,16 @@ Rectangle { // Window onExited: root.hovered = false onPressed: root.pressed = true onReleased: root.pressed = false + acceptedButtons: Qt.LeftButton | Qt.MiddleButton onClicked: (event) => { - if (windowData) { + if (!windowData) return; + + if (event.button === Qt.LeftButton) { closeOverview.running = true - Hyprland.dispatch(`keyword cursor:no_warps true`) - Hyprland.dispatch(`focuswindow address:${windowData.address}`) - Hyprland.dispatch(`keyword cursor:no_warps false`) + Hyprland.dispatch(`workspace ${windowData.workspace.id}`) + event.accepted = true + } else if (event.button === Qt.MiddleButton) { + Hyprland.dispatch(`closewindow address:${windowData.address}`) event.accepted = true } } diff --git a/.config/quickshell/modules/sidebarRight/todo/TodoWidget.qml b/.config/quickshell/modules/sidebarRight/todo/TodoWidget.qml index d473eda2d..ab4e54305 100644 --- a/.config/quickshell/modules/sidebarRight/todo/TodoWidget.qml +++ b/.config/quickshell/modules/sidebarRight/todo/TodoWidget.qml @@ -275,6 +275,7 @@ Item { color: activeFocus ? Appearance.m3colors.m3onSurface : Appearance.m3colors.m3onSurfaceVariant selectedTextColor: Appearance.m3colors.m3onSurface placeholderText: "Task description" + placeholderTextColor: Appearance.m3colors.m3outline focus: root.showAddDialog onAccepted: dialog.addTask()