1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

show a power profile OSD

This commit is contained in:
bbedward
2025-11-13 10:23:14 -05:00
parent 76a60df88b
commit cf75c1aad0
4 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
pragma Singleton
import Quickshell
import QtQuick
Singleton {
id: osdManager
property var currentOSDsByScreen: ({})
function showOSD(osd) {
if (!osd || !osd.screen)
return
const screenName = osd.screen.name
const currentOSD = currentOSDsByScreen[screenName]
if (currentOSD && currentOSD !== osd) {
currentOSD.hide()
}
currentOSDsByScreen[screenName] = osd
}
}

View File

@@ -578,6 +578,14 @@ Item {
}
}
Variants {
model: SettingsData.getFilteredScreens("osd")
delegate: PowerProfileOSD {
modelData: item
}
}
LazyLoader {
id: hyprlandOverviewLoader
active: CompositorService.isHyprland

View File

@@ -0,0 +1,40 @@
import QtQuick
import Quickshell.Services.UPower
import qs.Common
import qs.Services
import qs.Widgets
DankOSD {
id: root
osdWidth: Theme.iconSize + Theme.spacingS * 2
osdHeight: Theme.iconSize + Theme.spacingS * 2
autoHideInterval: 2000
enableMouseInteraction: false
property int lastProfile: -1
Connections {
target: typeof PowerProfiles !== "undefined" ? PowerProfiles : null
function onProfileChanged() {
if (lastProfile !== -1 && lastProfile !== PowerProfiles.profile) {
root.show()
}
lastProfile = PowerProfiles.profile
}
}
Component.onCompleted: {
if (typeof PowerProfiles !== "undefined") {
lastProfile = PowerProfiles.profile
}
}
content: DankIcon {
anchors.centerIn: parent
name: typeof PowerProfiles !== "undefined" ? Theme.getPowerProfileIcon(PowerProfiles.profile) : "settings"
size: Theme.iconSize
color: Theme.primary
}
}

View File

@@ -27,6 +27,7 @@ PanelWindow {
signal osdHidden
function show() {
OSDManager.showOSD(root)
closeTimer.stop()
shouldBeVisible = true
visible = true