mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
239 lines
8 KiB
QML
239 lines
8 KiB
QML
import "root:/"
|
|
import "root:/services"
|
|
import "root:/modules/common"
|
|
import "root:/modules/common/widgets"
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import Quickshell.Wayland
|
|
import Quickshell.Hyprland
|
|
|
|
Scope {
|
|
id: overviewScope
|
|
property bool dontAutoCancelSearch: false
|
|
Variants {
|
|
id: overviewVariants
|
|
model: Quickshell.screens
|
|
PanelWindow {
|
|
id: root
|
|
required property var modelData
|
|
property string searchingText: ""
|
|
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(root.screen)
|
|
property bool monitorIsFocused: (Hyprland.focusedMonitor?.id == monitor.id)
|
|
screen: modelData
|
|
visible: GlobalStates.overviewOpen
|
|
|
|
WlrLayershell.namespace: "quickshell:overview"
|
|
WlrLayershell.layer: WlrLayer.Overlay
|
|
// WlrLayershell.keyboardFocus: GlobalStates.overviewOpen ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
|
color: "transparent"
|
|
|
|
mask: Region {
|
|
item: GlobalStates.overviewOpen ? columnLayout : null
|
|
}
|
|
// HyprlandWindow.visibleMask: Region { // Buggy with scaled monitors
|
|
// item: GlobalStates.overviewOpen ? columnLayout : null
|
|
// }
|
|
|
|
|
|
anchors {
|
|
top: true
|
|
left: true
|
|
right: true
|
|
bottom: true
|
|
}
|
|
|
|
HyprlandFocusGrab {
|
|
id: grab
|
|
windows: [ root ]
|
|
property bool canBeActive: root.monitorIsFocused
|
|
active: false
|
|
onCleared: () => {
|
|
if (!active) GlobalStates.overviewOpen = false
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: GlobalStates
|
|
function onOverviewOpenChanged() {
|
|
if (!GlobalStates.overviewOpen) {
|
|
searchWidget.disableExpandAnimation()
|
|
overviewScope.dontAutoCancelSearch = false;
|
|
} else {
|
|
if (!overviewScope.dontAutoCancelSearch) {
|
|
searchWidget.cancelSearch()
|
|
}
|
|
delayedGrabTimer.start()
|
|
}
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: delayedGrabTimer
|
|
interval: Config.options.hacks.arbitraryRaceConditionDelay
|
|
repeat: false
|
|
onTriggered: {
|
|
if (!grab.canBeActive) return
|
|
grab.active = GlobalStates.overviewOpen
|
|
}
|
|
}
|
|
|
|
implicitWidth: columnLayout.implicitWidth
|
|
implicitHeight: columnLayout.implicitHeight
|
|
|
|
function setSearchingText(text) {
|
|
searchWidget.setSearchingText(text);
|
|
}
|
|
|
|
ColumnLayout {
|
|
id: columnLayout
|
|
visible: GlobalStates.overviewOpen
|
|
anchors {
|
|
horizontalCenter: parent.horizontalCenter
|
|
top: parent.top
|
|
}
|
|
|
|
Keys.onPressed: (event) => {
|
|
if (event.key === Qt.Key_Escape) {
|
|
GlobalStates.overviewOpen = false;
|
|
} else if (event.key === Qt.Key_Left) {
|
|
if (!root.searchingText) Hyprland.dispatch("workspace r-1");
|
|
} else if (event.key === Qt.Key_Right) {
|
|
if (!root.searchingText) Hyprland.dispatch("workspace r+1");
|
|
}
|
|
}
|
|
|
|
Item {
|
|
height: 1 // Prevent Wayland protocol error
|
|
width: 1 // Prevent Wayland protocol error
|
|
}
|
|
|
|
SearchWidget {
|
|
id: searchWidget
|
|
Layout.alignment: Qt.AlignHCenter
|
|
onSearchingTextChanged: (text) => {
|
|
root.searchingText = searchingText
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: overviewLoader
|
|
active: GlobalStates.overviewOpen
|
|
sourceComponent: OverviewWidget {
|
|
panelWindow: root
|
|
visible: (root.searchingText == "")
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
IpcHandler {
|
|
target: "overview"
|
|
|
|
function toggle() {
|
|
GlobalStates.overviewOpen = !GlobalStates.overviewOpen
|
|
}
|
|
function close() {
|
|
GlobalStates.overviewOpen = false
|
|
}
|
|
function open() {
|
|
GlobalStates.overviewOpen = true
|
|
}
|
|
function toggleReleaseInterrupt() {
|
|
GlobalStates.superReleaseMightTrigger = false
|
|
}
|
|
}
|
|
|
|
GlobalShortcut {
|
|
name: "overviewToggle"
|
|
description: Translation.tr("Toggles overview on press")
|
|
|
|
onPressed: {
|
|
GlobalStates.overviewOpen = !GlobalStates.overviewOpen
|
|
}
|
|
}
|
|
GlobalShortcut {
|
|
name: "overviewClose"
|
|
description: Translation.tr("Closes overview")
|
|
|
|
onPressed: {
|
|
GlobalStates.overviewOpen = false
|
|
}
|
|
}
|
|
GlobalShortcut {
|
|
name: "overviewToggleRelease"
|
|
description: Translation.tr("Toggles overview on release")
|
|
|
|
onPressed: {
|
|
GlobalStates.superReleaseMightTrigger = true
|
|
}
|
|
|
|
onReleased: {
|
|
if (!GlobalStates.superReleaseMightTrigger) {
|
|
GlobalStates.superReleaseMightTrigger = true
|
|
return
|
|
}
|
|
GlobalStates.overviewOpen = !GlobalStates.overviewOpen
|
|
}
|
|
}
|
|
GlobalShortcut {
|
|
name: "overviewToggleReleaseInterrupt"
|
|
description: Translation.tr("Interrupts possibility of overview being toggled on release. ") +
|
|
Translation.tr("This is necessary because GlobalShortcut.onReleased in quickshell triggers whether or not you press something else while holding the key. ") +
|
|
Translation.tr("To make sure this works consistently, use binditn = MODKEYS, catchall in an automatically triggered submap that includes everything.")
|
|
|
|
onPressed: {
|
|
GlobalStates.superReleaseMightTrigger = false
|
|
}
|
|
}
|
|
GlobalShortcut {
|
|
name: "overviewClipboardToggle"
|
|
description: Translation.tr("Toggle clipboard query on overview widget")
|
|
|
|
onPressed: {
|
|
if (GlobalStates.overviewOpen && overviewScope.dontAutoCancelSearch) {
|
|
GlobalStates.overviewOpen = false;
|
|
return;
|
|
}
|
|
for (let i = 0; i < overviewVariants.instances.length; i++) {
|
|
let panelWindow = overviewVariants.instances[i];
|
|
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
overviewScope.dontAutoCancelSearch = true;
|
|
panelWindow.setSearchingText(
|
|
Config.options.search.prefix.clipboard
|
|
);
|
|
GlobalStates.overviewOpen = true;
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
GlobalShortcut {
|
|
name: "overviewEmojiToggle"
|
|
description: Translation.tr("Toggle emoji query on overview widget")
|
|
|
|
onPressed: {
|
|
if (GlobalStates.overviewOpen && overviewScope.dontAutoCancelSearch) {
|
|
GlobalStates.overviewOpen = false;
|
|
return;
|
|
}
|
|
for (let i = 0; i < overviewVariants.instances.length; i++) {
|
|
let panelWindow = overviewVariants.instances[i];
|
|
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
|
overviewScope.dontAutoCancelSearch = true;
|
|
panelWindow.setSearchingText(
|
|
Config.options.search.prefix.emojis
|
|
);
|
|
GlobalStates.overviewOpen = true;
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|