From 983d185de62d1236e7bb87def6c13aebecd7a611 Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 25 Sep 2025 23:12:28 -0400 Subject: [PATCH] Explicitly load all modals --- IPC.qml | 373 +++++++++++++++++++++ Modals/Clipboard/ClipboardHistoryModal.qml | 18 - Modals/NotificationModal.qml | 18 - Modals/Settings/SettingsModal.qml | 32 -- Modals/Spotlight/SpotlightModal.qml | 18 - Modules/TopBar/TopBar.qml | 6 +- shell.qml | 277 ++++----------- 7 files changed, 434 insertions(+), 308 deletions(-) create mode 100644 IPC.qml diff --git a/IPC.qml b/IPC.qml new file mode 100644 index 00000000..7ce24c48 --- /dev/null +++ b/IPC.qml @@ -0,0 +1,373 @@ +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Hyprland +import qs.Common +import qs.Services + +Item { + id: root + + property var powermenu: null + property var processlist: null + property var controlCenter: null + property var dash: null + property var notepadVariants: null + property var spotlight: null + property var clipboard: null + property var notifications: null + property var settings: null + + function getFocusedScreenName() { + if (CompositorService.isHyprland && Hyprland.focusedWorkspace && Hyprland.focusedWorkspace.monitor) { + return Hyprland.focusedWorkspace.monitor.name + } + if (CompositorService.isNiri && NiriService.currentOutput) { + return NiriService.currentOutput + } + return "" + } + + function getActiveNotepadInstance() { + if (!notepadVariants || notepadVariants.instances.length === 0) { + return null + } + + if (notepadVariants.instances.length === 1) { + return notepadVariants.instances[0] + } + + var focusedScreen = getFocusedScreenName() + if (focusedScreen && notepadVariants.instances.length > 0) { + for (var i = 0; i < notepadVariants.instances.length; i++) { + var slideout = notepadVariants.instances[i] + if (slideout.modelData && slideout.modelData.name === focusedScreen) { + return slideout + } + } + } + + for (var i = 0; i < notepadVariants.instances.length; i++) { + var slideout = notepadVariants.instances[i] + if (slideout.isVisible) { + return slideout + } + } + + return notepadVariants.instances[0] + } + + IpcHandler { + function open() { + powermenu.active = true + if (powermenu.item) + powermenu.item.open() + return "POWERMENU_OPEN_SUCCESS" + } + + function close() { + if (powermenu.item) { + powermenu.item.close() + powermenu.active = false + } + return "POWERMENU_CLOSE_SUCCESS" + } + + function toggle() { + powermenu.active = true + if (powermenu.item) + powermenu.item.toggle() + return "POWERMENU_TOGGLE_SUCCESS" + } + + target: "powermenu" + } + + IpcHandler { + function open(): string { + processlist.active = true + if (processlist.item) + processlist.item.show() + return "PROCESSLIST_OPEN_SUCCESS" + } + + function close(): string { + if (processlist.item) { + processlist.item.hide() + processlist.active = false + } + return "PROCESSLIST_CLOSE_SUCCESS" + } + + function toggle(): string { + processlist.active = true + if (processlist.item) + processlist.item.toggle() + return "PROCESSLIST_TOGGLE_SUCCESS" + } + + target: "processlist" + } + + IpcHandler { + function open(): string { + controlCenter.active = true + if (controlCenter.item) { + controlCenter.item.open() + return "CONTROL_CENTER_OPEN_SUCCESS" + } + return "CONTROL_CENTER_OPEN_FAILED" + } + + function close(): string { + if (controlCenter.item) { + controlCenter.item.close() + controlCenter.active = false + return "CONTROL_CENTER_CLOSE_SUCCESS" + } + return "CONTROL_CENTER_CLOSE_FAILED" + } + + function toggle(): string { + controlCenter.active = true + if (controlCenter.item) { + controlCenter.item.toggle() + return "CONTROL_CENTER_TOGGLE_SUCCESS" + } + return "CONTROL_CENTER_TOGGLE_FAILED" + } + + target: "control-center" + } + + IpcHandler { + function open(tab: string): string { + dash.active = true + if (dash.item) { + switch (tab.toLowerCase()) { + case "media": + dash.item.currentTabIndex = 1 + break + case "weather": + dash.item.currentTabIndex = SettingsData.weatherEnabled ? 2 : 0 + break + default: + dash.item.currentTabIndex = 0 + break + } + dash.item.setTriggerPosition(Screen.width / 2, Theme.barHeight + Theme.spacingS, 100, "center", Screen) + dash.item.dashVisible = true + return "DASH_OPEN_SUCCESS" + } + return "DASH_OPEN_FAILED" + } + + function close(): string { + if (dash.item) { + dash.item.dashVisible = false + dash.active = false + return "DASH_CLOSE_SUCCESS" + } + return "DASH_CLOSE_FAILED" + } + + function toggle(tab: string): string { + dash.active = true + if (dash.item) { + if (dash.item.dashVisible) { + dash.item.dashVisible = false + } else { + switch (tab.toLowerCase()) { + case "media": + dash.item.currentTabIndex = 1 + break + case "weather": + dash.item.currentTabIndex = SettingsData.weatherEnabled ? 2 : 0 + break + default: + dash.item.currentTabIndex = 0 + break + } + dash.item.setTriggerPosition(Screen.width / 2, Theme.barHeight + Theme.spacingS, 100, "center", Screen) + dash.item.dashVisible = true + } + return "DASH_TOGGLE_SUCCESS" + } + return "DASH_TOGGLE_FAILED" + } + + target: "dash" + } + + IpcHandler { + function open(): string { + var instance = getActiveNotepadInstance() + if (instance) { + instance.show() + return "NOTEPAD_OPEN_SUCCESS" + } + return "NOTEPAD_OPEN_FAILED" + } + + function close(): string { + var instance = getActiveNotepadInstance() + if (instance) { + instance.hide() + return "NOTEPAD_CLOSE_SUCCESS" + } + return "NOTEPAD_CLOSE_FAILED" + } + + function toggle(): string { + var instance = getActiveNotepadInstance() + if (instance) { + instance.toggle() + return "NOTEPAD_TOGGLE_SUCCESS" + } + return "NOTEPAD_TOGGLE_FAILED" + } + + target: "notepad" + } + + IpcHandler { + function open(): string { + spotlight.active = true + if (spotlight.item) { + spotlight.item.show() + return "SPOTLIGHT_OPEN_SUCCESS" + } + return "SPOTLIGHT_OPEN_FAILED" + } + + function close(): string { + if (spotlight.item) { + spotlight.item.hide() + spotlight.active = false + return "SPOTLIGHT_CLOSE_SUCCESS" + } + return "SPOTLIGHT_CLOSE_FAILED" + } + + function toggle(): string { + spotlight.active = true + if (spotlight.item) { + spotlight.item.toggle() + return "SPOTLIGHT_TOGGLE_SUCCESS" + } + return "SPOTLIGHT_TOGGLE_FAILED" + } + + target: "spotlight" + } + + IpcHandler { + function open(): string { + clipboard.active = true + if (clipboard.item) { + clipboard.item.show() + return "CLIPBOARD_OPEN_SUCCESS" + } + return "CLIPBOARD_OPEN_FAILED" + } + + function close(): string { + if (clipboard.item) { + clipboard.item.hide() + clipboard.active = false + return "CLIPBOARD_CLOSE_SUCCESS" + } + return "CLIPBOARD_CLOSE_FAILED" + } + + function toggle(): string { + clipboard.active = true + if (clipboard.item) { + clipboard.item.toggle() + return "CLIPBOARD_TOGGLE_SUCCESS" + } + return "CLIPBOARD_TOGGLE_FAILED" + } + + target: "clipboard" + } + + IpcHandler { + function open(): string { + notifications.active = true + if (notifications.item) { + notifications.item.show() + return "NOTIFICATION_MODAL_OPEN_SUCCESS" + } + return "NOTIFICATION_MODAL_OPEN_FAILED" + } + + function close(): string { + if (notifications.item) { + notifications.item.hide() + notifications.active = false + return "NOTIFICATION_MODAL_CLOSE_SUCCESS" + } + return "NOTIFICATION_MODAL_CLOSE_FAILED" + } + + function toggle(): string { + notifications.active = true + if (notifications.item) { + notifications.item.toggle() + return "NOTIFICATION_MODAL_TOGGLE_SUCCESS" + } + return "NOTIFICATION_MODAL_TOGGLE_FAILED" + } + + target: "notifications" + } + + IpcHandler { + function open(): string { + settings.active = true + if (settings.item) { + settings.item.show() + return "SETTINGS_OPEN_SUCCESS" + } + return "SETTINGS_OPEN_FAILED" + } + + function close(): string { + if (settings.item) { + settings.item.hide() + settings.active = false + return "SETTINGS_CLOSE_SUCCESS" + } + return "SETTINGS_CLOSE_FAILED" + } + + function toggle(): string { + settings.active = true + if (settings.item) { + settings.item.toggle() + return "SETTINGS_TOGGLE_SUCCESS" + } + return "SETTINGS_TOGGLE_FAILED" + } + + target: "settings" + } + + IpcHandler { + function browse(type: string) { + settings.active = true + if (settings.item) { + if (type === "wallpaper") { + settings.item.wallpaperBrowser.allowStacking = false + settings.item.wallpaperBrowser.open() + } else if (type === "profile") { + settings.item.profileBrowser.allowStacking = false + settings.item.profileBrowser.open() + } + } + } + + target: "file" + } +} \ No newline at end of file diff --git a/Modals/Clipboard/ClipboardHistoryModal.qml b/Modals/Clipboard/ClipboardHistoryModal.qml index d6477ea7..022f4436 100644 --- a/Modals/Clipboard/ClipboardHistoryModal.qml +++ b/Modals/Clipboard/ClipboardHistoryModal.qml @@ -187,24 +187,6 @@ DankModal { filteredClipboardModel: filteredClipboardModel } - IpcHandler { - function open(): string { - clipboardHistoryModal.show() - return "CLIPBOARD_OPEN_SUCCESS" - } - - function close(): string { - clipboardHistoryModal.hide() - return "CLIPBOARD_CLOSE_SUCCESS" - } - - function toggle(): string { - clipboardHistoryModal.toggle() - return "CLIPBOARD_TOGGLE_SUCCESS" - } - - target: "clipboard" - } clipboardContent: Component { ClipboardContent { diff --git a/Modals/NotificationModal.qml b/Modals/NotificationModal.qml index 3924016e..57ee95bd 100644 --- a/Modals/NotificationModal.qml +++ b/Modals/NotificationModal.qml @@ -71,24 +71,6 @@ DankModal { onClose: () => notificationModal.hide() } - IpcHandler { - function open(): string { - notificationModal.show(); - return "NOTIFICATION_MODAL_OPEN_SUCCESS"; - } - - function close(): string { - notificationModal.hide(); - return "NOTIFICATION_MODAL_CLOSE_SUCCESS"; - } - - function toggle(): string { - notificationModal.toggle(); - return "NOTIFICATION_MODAL_TOGGLE_SUCCESS"; - } - - target: "notifications" - } content: Component { Item { diff --git a/Modals/Settings/SettingsModal.qml b/Modals/Settings/SettingsModal.qml index 2cd9766e..8824d35c 100644 --- a/Modals/Settings/SettingsModal.qml +++ b/Modals/Settings/SettingsModal.qml @@ -41,38 +41,6 @@ DankModal { } content: settingsContent - IpcHandler { - function open(): string { - settingsModal.show(); - return "SETTINGS_OPEN_SUCCESS"; - } - - function close(): string { - settingsModal.hide(); - return "SETTINGS_CLOSE_SUCCESS"; - } - - function toggle(): string { - settingsModal.toggle(); - return "SETTINGS_TOGGLE_SUCCESS"; - } - - target: "settings" - } - - IpcHandler { - function browse(type: string) { - if (type === "wallpaper") { - wallpaperBrowser.allowStacking = false; - wallpaperBrowser.open(); - } else if (type === "profile") { - profileBrowser.allowStacking = false; - profileBrowser.open(); - } - } - - target: "file" - } FileBrowserModal { id: profileBrowser diff --git a/Modals/Spotlight/SpotlightModal.qml b/Modals/Spotlight/SpotlightModal.qml index 764a7717..5130f726 100644 --- a/Modals/Spotlight/SpotlightModal.qml +++ b/Modals/Spotlight/SpotlightModal.qml @@ -82,24 +82,6 @@ DankModal { target: ModalManager } - IpcHandler { - function open(): string { - spotlightModal.show() - return "SPOTLIGHT_OPEN_SUCCESS" - } - - function close(): string { - spotlightModal.hide() - return "SPOTLIGHT_CLOSE_SUCCESS" - } - - function toggle(): string { - spotlightModal.toggle() - return "SPOTLIGHT_TOGGLE_SUCCESS" - } - - target: "spotlight" - } spotlightContent: Component { SpotlightContent { diff --git a/Modules/TopBar/TopBar.qml b/Modules/TopBar/TopBar.qml index a643946d..4af42cfc 100644 --- a/Modules/TopBar/TopBar.qml +++ b/Modules/TopBar/TopBar.qml @@ -208,7 +208,7 @@ PanelWindow { "loader": controlCenterLoader, "prop": "shouldBeVisible" }, { - "loader": clipboardHistoryModalPopup, + "loader": clipboardHistoryModalLoader.item, "prop": "visible" }, { "loader": systemUpdateLoader, @@ -823,7 +823,9 @@ PanelWindow { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - clipboardHistoryModalPopup.toggle() + clipboardHistoryModalLoader.active = true + if (clipboardHistoryModalLoader.item) + clipboardHistoryModalLoader.item.toggle() } } diff --git a/shell.qml b/shell.qml index 02646ed8..a5ea4988 100644 --- a/shell.qml +++ b/shell.qml @@ -52,7 +52,11 @@ ShellRoot { delegate: TopBar { modelData: item notepadVariants: notepadSlideoutVariants - onColorPickerRequested: colorPickerModal.show() + onColorPickerRequested: { + colorPickerModalLoader.active = true + if (colorPickerModalLoader.item) + colorPickerModalLoader.item.show() + } } } @@ -244,8 +248,14 @@ ShellRoot { } } - SettingsModal { - id: settingsModal + LazyLoader { + id: settingsModalLoader + + active: false + + SettingsModal { + id: settingsModal + } } LazyLoader { @@ -258,19 +268,44 @@ ShellRoot { } } - SpotlightModal { - id: spotlightModal + LazyLoader { + id: spotlightModalLoader + + active: false + + SpotlightModal { + id: spotlightModal + } } - ClipboardHistoryModal { - id: clipboardHistoryModalPopup + LazyLoader { + id: clipboardHistoryModalLoader + + active: false + + ClipboardHistoryModal { + id: clipboardHistoryModalPopup + } } - NotificationModal { - id: notificationModal + LazyLoader { + id: notificationModalLoader + + active: false + + NotificationModal { + id: notificationModal + } } - ColorPickerModal { - id: colorPickerModal + + LazyLoader { + id: colorPickerModalLoader + + active: false + + ColorPickerModal { + id: colorPickerModal + } } LazyLoader { @@ -360,216 +395,18 @@ ShellRoot { } } - IpcHandler { - function open() { - powerMenuModalLoader.active = true - if (powerMenuModalLoader.item) - powerMenuModalLoader.item.open() + IPC { + id: ipcHandlers - return "POWERMENU_OPEN_SUCCESS" - } - - function close() { - if (powerMenuModalLoader.item) - powerMenuModalLoader.item.close() - - return "POWERMENU_CLOSE_SUCCESS" - } - - function toggle() { - powerMenuModalLoader.active = true - if (powerMenuModalLoader.item) - powerMenuModalLoader.item.toggle() - - return "POWERMENU_TOGGLE_SUCCESS" - } - - target: "powermenu" - } - - IpcHandler { - function open(): string { - processListModalLoader.active = true - if (processListModalLoader.item) - processListModalLoader.item.show() - - return "PROCESSLIST_OPEN_SUCCESS" - } - - function close(): string { - if (processListModalLoader.item) - processListModalLoader.item.hide() - - return "PROCESSLIST_CLOSE_SUCCESS" - } - - function toggle(): string { - processListModalLoader.active = true - if (processListModalLoader.item) - processListModalLoader.item.toggle() - - return "PROCESSLIST_TOGGLE_SUCCESS" - } - - target: "processlist" - } - - IpcHandler { - function open(): string { - controlCenterLoader.active = true - if (controlCenterLoader.item) { - controlCenterLoader.item.open() - return "CONTROL_CENTER_OPEN_SUCCESS" - } - return "CONTROL_CENTER_OPEN_FAILED" - } - - function close(): string { - if (controlCenterLoader.item) { - controlCenterLoader.item.close() - return "CONTROL_CENTER_CLOSE_SUCCESS" - } - return "CONTROL_CENTER_CLOSE_FAILED" - } - - function toggle(): string { - controlCenterLoader.active = true - if (controlCenterLoader.item) { - controlCenterLoader.item.toggle() - return "CONTROL_CENTER_TOGGLE_SUCCESS" - } - return "CONTROL_CENTER_TOGGLE_FAILED" - } - - target: "control-center" - } - - IpcHandler { - function open(tab: string): string { - dankDashPopoutLoader.active = true - if (dankDashPopoutLoader.item) { - switch (tab.toLowerCase()) { - case "media": - dankDashPopoutLoader.item.currentTabIndex = 1 - break - case "weather": - dankDashPopoutLoader.item.currentTabIndex = SettingsData.weatherEnabled ? 2 : 0 - break - default: - dankDashPopoutLoader.item.currentTabIndex = 0 - break - } - dankDashPopoutLoader.item.setTriggerPosition(Screen.width / 2, Theme.barHeight + Theme.spacingS, 100, "center", Screen) - dankDashPopoutLoader.item.dashVisible = true - return "DASH_OPEN_SUCCESS" - } - return "DASH_OPEN_FAILED" - } - - function close(): string { - if (dankDashPopoutLoader.item) { - dankDashPopoutLoader.item.dashVisible = false - return "DASH_CLOSE_SUCCESS" - } - return "DASH_CLOSE_FAILED" - } - - function toggle(tab: string): string { - dankDashPopoutLoader.active = true - if (dankDashPopoutLoader.item) { - if (dankDashPopoutLoader.item.dashVisible) { - dankDashPopoutLoader.item.dashVisible = false - } else { - switch (tab.toLowerCase()) { - case "media": - dankDashPopoutLoader.item.currentTabIndex = 1 - break - case "weather": - dankDashPopoutLoader.item.currentTabIndex = SettingsData.weatherEnabled ? 2 : 0 - break - default: - dankDashPopoutLoader.item.currentTabIndex = 0 - break - } - dankDashPopoutLoader.item.setTriggerPosition(Screen.width / 2, Theme.barHeight + Theme.spacingS, 100, "center", Screen) - dankDashPopoutLoader.item.dashVisible = true - } - return "DASH_TOGGLE_SUCCESS" - } - return "DASH_TOGGLE_FAILED" - } - - target: "dash" - } - - IpcHandler { - function getFocusedScreenName() { - if (CompositorService.isHyprland && Hyprland.focusedWorkspace && Hyprland.focusedWorkspace.monitor) { - return Hyprland.focusedWorkspace.monitor.name - } - if (CompositorService.isNiri && NiriService.currentOutput) { - return NiriService.currentOutput - } - return "" - } - - function getActiveNotepadInstance() { - if (notepadSlideoutVariants.instances.length === 0) { - return null - } - - if (notepadSlideoutVariants.instances.length === 1) { - return notepadSlideoutVariants.instances[0] - } - - var focusedScreen = getFocusedScreenName() - if (focusedScreen && notepadSlideoutVariants.instances.length > 0) { - for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) { - var slideout = notepadSlideoutVariants.instances[i] - if (slideout.modelData && slideout.modelData.name === focusedScreen) { - return slideout - } - } - } - - for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) { - var slideout = notepadSlideoutVariants.instances[i] - if (slideout.isVisible) { - return slideout - } - } - - return notepadSlideoutVariants.instances[0] - } - - function open(): string { - var instance = getActiveNotepadInstance() - if (instance) { - instance.show() - return "NOTEPAD_OPEN_SUCCESS" - } - return "NOTEPAD_OPEN_FAILED" - } - - function close(): string { - var instance = getActiveNotepadInstance() - if (instance) { - instance.hide() - return "NOTEPAD_CLOSE_SUCCESS" - } - return "NOTEPAD_CLOSE_FAILED" - } - - function toggle(): string { - var instance = getActiveNotepadInstance() - if (instance) { - instance.toggle() - return "NOTEPAD_TOGGLE_SUCCESS" - } - return "NOTEPAD_TOGGLE_FAILED" - } - - target: "notepad" + powermenu: powerMenuModalLoader + processlist: processListModalLoader + controlCenter: controlCenterLoader + dash: dankDashPopoutLoader + notepadVariants: notepadSlideoutVariants + spotlight: spotlightModalLoader + clipboard: clipboardHistoryModalLoader + notifications: notificationModalLoader + settings: settingsModalLoader } Variants {