1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

power profile: put OSD in a lazyloader

This commit is contained in:
bbedward
2025-11-23 16:55:22 -05:00
parent 2a37028b6a
commit 5ce1cb87ea

View File

@@ -1,6 +1,5 @@
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Common
import qs.Modals
import qs.Modals.Clipboard
@@ -19,11 +18,9 @@ import qs.Widgets
import qs.Modules.Notifications.Popup
import qs.Modules.OSD
import qs.Modules.ProcessList
import qs.Modules.Settings
import qs.Modules.DankBar
import qs.Modules.DankBar.Popouts
import qs.Modules.WorkspaceOverlays
import qs.Modules.Plugins
import qs.Services
Item {
@@ -41,12 +38,12 @@ Item {
onLoaded: {
if (item) {
item.pluginService = PluginService
item.pluginService = PluginService;
if (item.popoutService !== undefined) {
item.popoutService = PopoutService
item.popoutService = PopoutService;
}
item.pluginId = pluginId
console.info("Daemon plugin loaded:", pluginId)
item.pluginId = pluginId;
console.info("Daemon plugin loaded:", pluginId);
}
}
}
@@ -85,9 +82,9 @@ Item {
onColorPickerRequested: {
if (colorPickerModal.shouldBeVisible) {
colorPickerModal.close()
colorPickerModal.close();
} else {
colorPickerModal.show()
colorPickerModal.show();
}
}
}
@@ -108,21 +105,20 @@ Item {
onLoaded: {
if (item) {
dockContextMenuLoader.active = true
dockContextMenuLoader.active = true;
}
}
Component.onCompleted: {
initialized = true
initialized = true;
}
onCurrentPositionChanged: {
if (!initialized)
return
const comp = sourceComponent
sourceComponent = null
sourceComponent = comp
return;
const comp = sourceComponent;
sourceComponent = null;
sourceComponent = comp;
}
}
@@ -137,7 +133,7 @@ Item {
id: dankDashPopout
Component.onCompleted: {
PopoutService.dankDashPopout = dankDashPopout
PopoutService.dankDashPopout = dankDashPopout;
}
}
}
@@ -162,7 +158,7 @@ Item {
id: notificationCenter
Component.onCompleted: {
PopoutService.notificationCenterPopout = notificationCenter
PopoutService.notificationCenterPopout = notificationCenter;
}
}
}
@@ -189,11 +185,11 @@ Item {
powerMenuModalLoader: controlCenterLoader.powerModalLoaderRef
onLockRequested: {
lock.activate()
lock.activate();
}
Component.onCompleted: {
PopoutService.controlCenterPopout = controlCenterPopout
PopoutService.controlCenterPopout = controlCenterPopout;
}
}
}
@@ -202,7 +198,7 @@ Item {
id: wifiPasswordModal
Component.onCompleted: {
PopoutService.wifiPasswordModal = wifiPasswordModal
PopoutService.wifiPasswordModal = wifiPasswordModal;
}
}
@@ -214,7 +210,7 @@ Item {
id: bluetoothPairingModal
Component.onCompleted: {
PopoutService.bluetoothPairingModal = bluetoothPairingModal
PopoutService.bluetoothPairingModal = bluetoothPairingModal;
}
}
@@ -225,20 +221,20 @@ Item {
target: NetworkService
function onCredentialsNeeded(token, ssid, setting, fields, hints, reason, connType, connName, vpnService) {
const now = Date.now()
const timeSinceLastPrompt = now - lastCredentialsTime
const now = Date.now();
const timeSinceLastPrompt = now - lastCredentialsTime;
if (wifiPasswordModal.shouldBeVisible && timeSinceLastPrompt < 1000) {
NetworkService.cancelCredentials(lastCredentialsToken)
lastCredentialsToken = token
lastCredentialsTime = now
wifiPasswordModal.showFromPrompt(token, ssid, setting, fields, hints, reason, connType, connName, vpnService)
return
NetworkService.cancelCredentials(lastCredentialsToken);
lastCredentialsToken = token;
lastCredentialsTime = now;
wifiPasswordModal.showFromPrompt(token, ssid, setting, fields, hints, reason, connType, connName, vpnService);
return;
}
lastCredentialsToken = token
lastCredentialsTime = now
wifiPasswordModal.showFromPrompt(token, ssid, setting, fields, hints, reason, connType, connName, vpnService)
lastCredentialsToken = token;
lastCredentialsTime = now;
wifiPasswordModal.showFromPrompt(token, ssid, setting, fields, hints, reason, connType, connName, vpnService);
}
}
@@ -251,7 +247,7 @@ Item {
id: networkInfoModal
Component.onCompleted: {
PopoutService.networkInfoModal = networkInfoModal
PopoutService.networkInfoModal = networkInfoModal;
}
}
}
@@ -265,7 +261,7 @@ Item {
id: batteryPopout
Component.onCompleted: {
PopoutService.batteryPopout = batteryPopout
PopoutService.batteryPopout = batteryPopout;
}
}
}
@@ -279,7 +275,7 @@ Item {
id: layoutPopout
Component.onCompleted: {
PopoutService.layoutPopout = layoutPopout
PopoutService.layoutPopout = layoutPopout;
}
}
}
@@ -293,7 +289,7 @@ Item {
id: vpnPopout
Component.onCompleted: {
PopoutService.vpnPopout = vpnPopout
PopoutService.vpnPopout = vpnPopout;
}
}
}
@@ -317,7 +313,7 @@ Item {
id: processListPopout
Component.onCompleted: {
PopoutService.processListPopout = processListPopout
PopoutService.processListPopout = processListPopout;
}
}
}
@@ -326,7 +322,7 @@ Item {
id: settingsModal
Component.onCompleted: {
PopoutService.settingsModal = settingsModal
PopoutService.settingsModal = settingsModal;
}
}
@@ -339,7 +335,7 @@ Item {
id: appDrawerPopout
Component.onCompleted: {
PopoutService.appDrawerPopout = appDrawerPopout
PopoutService.appDrawerPopout = appDrawerPopout;
}
}
}
@@ -348,7 +344,7 @@ Item {
id: spotlightModal
Component.onCompleted: {
PopoutService.spotlightModal = spotlightModal
PopoutService.spotlightModal = spotlightModal;
}
}
@@ -356,7 +352,7 @@ Item {
id: clipboardHistoryModalPopup
Component.onCompleted: {
PopoutService.clipboardHistoryModal = clipboardHistoryModalPopup
PopoutService.clipboardHistoryModal = clipboardHistoryModalPopup;
}
}
@@ -364,7 +360,7 @@ Item {
id: notificationModal
Component.onCompleted: {
PopoutService.notificationModal = notificationModal
PopoutService.notificationModal = notificationModal;
}
}
@@ -372,7 +368,7 @@ Item {
id: colorPickerModal
Component.onCompleted: {
PopoutService.colorPickerModal = colorPickerModal
PopoutService.colorPickerModal = colorPickerModal;
}
}
@@ -385,7 +381,7 @@ Item {
id: processListModal
Component.onCompleted: {
PopoutService.processListModal = processListModal
PopoutService.processListModal = processListModal;
}
}
}
@@ -399,7 +395,7 @@ Item {
id: systemUpdatePopout
Component.onCompleted: {
PopoutService.systemUpdatePopout = systemUpdatePopout
PopoutService.systemUpdatePopout = systemUpdatePopout;
}
}
}
@@ -420,16 +416,16 @@ Item {
content: Component {
Notepad {
onHideRequested: {
notepadSlideout.hide()
notepadSlideout.hide();
}
}
}
function toggle() {
if (isVisible) {
hide()
hide();
} else {
show()
show();
}
}
}
@@ -445,42 +441,42 @@ Item {
onPowerActionRequested: (action, title, message) => {
if (SettingsData.powerActionConfirm) {
powerConfirmModalLoader.active = true
powerConfirmModalLoader.active = true;
if (powerConfirmModalLoader.item) {
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary
powerConfirmModalLoader.item.show(title, message, () => actionApply(action), function () {})
powerConfirmModalLoader.item.confirmButtonColor = action === "poweroff" ? Theme.error : action === "reboot" ? Theme.warning : Theme.primary;
powerConfirmModalLoader.item.show(title, message, () => actionApply(action), function () {});
}
} else {
actionApply(action)
actionApply(action);
}
}
onLockRequested: {
lock.activate()
lock.activate();
}
function actionApply(action) {
switch (action) {
case "logout":
SessionService.logout()
break
SessionService.logout();
break;
case "suspend":
SessionService.suspend()
break
SessionService.suspend();
break;
case "hibernate":
SessionService.hibernate()
break
SessionService.hibernate();
break;
case "reboot":
SessionService.reboot()
break
SessionService.reboot();
break;
case "poweroff":
SessionService.poweroff()
break
SessionService.poweroff();
break;
}
}
Component.onCompleted: {
PopoutService.powerMenuModal = powerMenuModal
PopoutService.powerMenuModal = powerMenuModal;
}
}
}
@@ -494,7 +490,7 @@ Item {
id: keybindsModal
Component.onCompleted: {
PopoutService.hyprKeybindsModal = keybindsModal
PopoutService.hyprKeybindsModal = keybindsModal;
}
}
}
@@ -560,6 +556,10 @@ Item {
}
}
LazyLoader {
id: powerProfileOSDLoader
active: SettingsData.osdPowerProfileEnabled
Variants {
model: SettingsData.getFilteredScreens("osd")
@@ -567,6 +567,7 @@ Item {
modelData: item
}
}
}
Variants {
model: SettingsData.getFilteredScreens("osd")