1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 07:52:50 -05:00

Fix positioning of power menu

This commit is contained in:
bbedward
2025-10-03 17:21:43 -04:00
parent fedec450cb
commit ddc88fd360
3 changed files with 19 additions and 5 deletions

View File

@@ -372,7 +372,7 @@ ShellRoot {
function open() { function open() {
powerMenuModalLoader.active = true powerMenuModalLoader.active = true
if (powerMenuModalLoader.item) if (powerMenuModalLoader.item)
powerMenuModalLoader.item.open() powerMenuModalLoader.item.openCentered()
return "POWERMENU_OPEN_SUCCESS" return "POWERMENU_OPEN_SUCCESS"
} }
@@ -386,8 +386,13 @@ ShellRoot {
function toggle() { function toggle() {
powerMenuModalLoader.active = true powerMenuModalLoader.active = true
if (powerMenuModalLoader.item) if (powerMenuModalLoader.item) {
powerMenuModalLoader.item.toggle() if (powerMenuModalLoader.item.shouldBeVisible) {
powerMenuModalLoader.item.close()
} else {
powerMenuModalLoader.item.openCentered()
}
}
return "POWERMENU_TOGGLE_SUCCESS" return "POWERMENU_TOGGLE_SUCCESS"
} }

View File

@@ -10,9 +10,16 @@ DankModal {
property int selectedIndex: 0 property int selectedIndex: 0
property int optionCount: SessionService.hibernateSupported ? 5 : 4 property int optionCount: SessionService.hibernateSupported ? 5 : 4
property rect parentBounds: Qt.rect(0, 0, 0, 0) property rect parentBounds: Qt.rect(0, 0, 0, 0)
property var parentScreen: null
signal powerActionRequested(string action, string title, string message) signal powerActionRequested(string action, string title, string message)
function openCentered() {
parentBounds = Qt.rect(0, 0, 0, 0)
parentScreen = null
open()
}
function selectOption(action) { function selectOption(action) {
close(); close();
const actions = { const actions = {
@@ -48,6 +55,7 @@ DankModal {
width: 320 width: 320
height: contentLoader.item ? contentLoader.item.implicitHeight : 300 height: contentLoader.item ? contentLoader.item.implicitHeight : 300
enableShadow: true enableShadow: true
screen: parentScreen
positioning: parentBounds.width > 0 ? "custom" : "center" positioning: parentBounds.width > 0 ? "custom" : "center"
customPosition: { customPosition: {
if (parentBounds.width > 0) { if (parentBounds.width > 0) {

View File

@@ -126,8 +126,9 @@ DankPopout {
if (powerMenuModalLoader) { if (powerMenuModalLoader) {
powerMenuModalLoader.active = true powerMenuModalLoader.active = true
if (powerMenuModalLoader.item) { if (powerMenuModalLoader.item) {
const globalPos = controlContent.mapToGlobal(0, 0) const popoutPos = controlContent.mapToItem(null, 0, 0)
powerMenuModalLoader.item.parentBounds = Qt.rect(globalPos.x, globalPos.y, controlContent.width, controlContent.height) powerMenuModalLoader.item.parentScreen = root.triggerScreen
powerMenuModalLoader.item.parentBounds = Qt.rect(popoutPos.x, popoutPos.y, controlContent.width, controlContent.height)
powerMenuModalLoader.item.open() powerMenuModalLoader.item.open()
} }
} }