mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
Keep the modal, but relatively positioned
This commit is contained in:
@@ -9,6 +9,7 @@ DankModal {
|
||||
|
||||
property int selectedIndex: 0
|
||||
property int optionCount: SessionService.hibernateSupported ? 5 : 4
|
||||
property rect parentBounds: Qt.rect(0, 0, 0, 0)
|
||||
|
||||
signal powerActionRequested(string action, string title, string message)
|
||||
|
||||
@@ -47,6 +48,15 @@ DankModal {
|
||||
width: 320
|
||||
height: contentLoader.item ? contentLoader.item.implicitHeight : 300
|
||||
enableShadow: true
|
||||
positioning: parentBounds.width > 0 ? "custom" : "center"
|
||||
customPosition: {
|
||||
if (parentBounds.width > 0) {
|
||||
const centerX = parentBounds.x + (parentBounds.width - width) / 2
|
||||
const centerY = parentBounds.y + (parentBounds.height - height) / 2
|
||||
return Qt.point(centerX, centerY)
|
||||
}
|
||||
return Qt.point(0, 0)
|
||||
}
|
||||
onBackgroundClicked: () => {
|
||||
return close();
|
||||
}
|
||||
|
||||
@@ -126,6 +126,8 @@ DankPopout {
|
||||
if (powerMenuModalLoader) {
|
||||
powerMenuModalLoader.active = true
|
||||
if (powerMenuModalLoader.item) {
|
||||
const globalPos = controlContent.mapToGlobal(0, 0)
|
||||
powerMenuModalLoader.item.parentBounds = Qt.rect(globalPos.x, globalPos.y, controlContent.width, controlContent.height)
|
||||
powerMenuModalLoader.item.open()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user