mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
show a power profile OSD
This commit is contained in:
24
quickshell/Common/OSDManager.qml
Normal file
24
quickshell/Common/OSDManager.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -578,6 +578,14 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variants {
|
||||||
|
model: SettingsData.getFilteredScreens("osd")
|
||||||
|
|
||||||
|
delegate: PowerProfileOSD {
|
||||||
|
modelData: item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
id: hyprlandOverviewLoader
|
id: hyprlandOverviewLoader
|
||||||
active: CompositorService.isHyprland
|
active: CompositorService.isHyprland
|
||||||
|
|||||||
40
quickshell/Modules/OSD/PowerProfileOSD.qml
Normal file
40
quickshell/Modules/OSD/PowerProfileOSD.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ PanelWindow {
|
|||||||
signal osdHidden
|
signal osdHidden
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
|
OSDManager.showOSD(root)
|
||||||
closeTimer.stop()
|
closeTimer.stop()
|
||||||
shouldBeVisible = true
|
shouldBeVisible = true
|
||||||
visible = true
|
visible = true
|
||||||
|
|||||||
Reference in New Issue
Block a user