mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-31 00:42:50 -05:00
fix control center positioning
This commit is contained in:
@@ -18,6 +18,18 @@ PanelWindow {
|
|||||||
property string currentTab: "network"
|
property string currentTab: "network"
|
||||||
property bool powerOptionsExpanded: false
|
property bool powerOptionsExpanded: false
|
||||||
property var triggerScreen: null
|
property var triggerScreen: null
|
||||||
|
property real triggerX: Screen.width - 600 - Theme.spacingL
|
||||||
|
property real triggerY: Theme.barHeight + Theme.spacingXS
|
||||||
|
property real triggerWidth: 80
|
||||||
|
property string triggerSection: "right"
|
||||||
|
|
||||||
|
function setTriggerPosition(x, y, width, section, screen) {
|
||||||
|
triggerX = x;
|
||||||
|
triggerY = y;
|
||||||
|
triggerWidth = width;
|
||||||
|
triggerSection = section;
|
||||||
|
triggerScreen = screen;
|
||||||
|
}
|
||||||
|
|
||||||
signal powerActionRequested(string action, string title, string message)
|
signal powerActionRequested(string action, string title, string message)
|
||||||
signal lockRequested()
|
signal lockRequested()
|
||||||
@@ -50,14 +62,32 @@ PanelWindow {
|
|||||||
Loader {
|
Loader {
|
||||||
id: contentLoader
|
id: contentLoader
|
||||||
|
|
||||||
readonly property real targetWidth: Math.min(600, (root.screen ? root.screen.width : Screen.width) - Theme.spacingL * 2)
|
readonly property real screenWidth: root.screen ? root.screen.width : Screen.width
|
||||||
|
readonly property real screenHeight: root.screen ? root.screen.height : Screen.height
|
||||||
|
readonly property real targetWidth: Math.min(600, screenWidth - Theme.spacingL * 2)
|
||||||
|
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
active: controlCenterVisible
|
active: controlCenterVisible
|
||||||
width: targetWidth
|
width: targetWidth
|
||||||
height: root.powerOptionsExpanded ? 570 : 500
|
height: root.powerOptionsExpanded ? 570 : 500
|
||||||
y: Theme.barHeight + Theme.spacingXS
|
y: Theme.barHeight + Theme.spacingXS
|
||||||
x: Math.max(Theme.spacingL, (root.screen ? root.screen.width : Screen.width) - targetWidth - Theme.spacingL)
|
x: {
|
||||||
|
var centerX = root.triggerX + (root.triggerWidth / 2) - (targetWidth / 2);
|
||||||
|
|
||||||
|
if (centerX >= Theme.spacingM && centerX + targetWidth <= screenWidth - Theme.spacingM) {
|
||||||
|
return centerX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (centerX < Theme.spacingM) {
|
||||||
|
return Theme.spacingM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (centerX + targetWidth > screenWidth - Theme.spacingM) {
|
||||||
|
return screenWidth - targetWidth - Theme.spacingM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return centerX;
|
||||||
|
}
|
||||||
opacity: controlCenterVisible ? 1 : 0
|
opacity: controlCenterVisible ? 1 : 0
|
||||||
scale: controlCenterVisible ? 1 : 0.9
|
scale: controlCenterVisible ? 1 : 0.9
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ Rectangle {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool isActive: false
|
property bool isActive: false
|
||||||
|
property string section: "right"
|
||||||
|
property var popupTarget: null
|
||||||
|
property var parentScreen: null
|
||||||
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
|
|
||||||
@@ -118,6 +121,13 @@ Rectangle {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||||
|
var globalPos = mapToGlobal(0, 0);
|
||||||
|
var currentScreen = parentScreen || Screen;
|
||||||
|
var screenX = currentScreen.x || 0;
|
||||||
|
var relativeX = globalPos.x - screenX;
|
||||||
|
popupTarget.setTriggerPosition(relativeX, Theme.barHeight + Theme.spacingXS, width, section, currentScreen);
|
||||||
|
}
|
||||||
root.clicked();
|
root.clicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -678,6 +678,14 @@ PanelWindow {
|
|||||||
|
|
||||||
ControlCenterButton {
|
ControlCenterButton {
|
||||||
isActive: controlCenterPopout.controlCenterVisible
|
isActive: controlCenterPopout.controlCenterVisible
|
||||||
|
section: {
|
||||||
|
if (parent && parent.parent === leftSection) return "left";
|
||||||
|
if (parent && parent.parent === rightSection) return "right";
|
||||||
|
if (parent && parent.parent === centerSection) return "center";
|
||||||
|
return "right";
|
||||||
|
}
|
||||||
|
popupTarget: controlCenterPopout
|
||||||
|
parentScreen: root.screen
|
||||||
onClicked: {
|
onClicked: {
|
||||||
controlCenterPopout.triggerScreen = root.screen;
|
controlCenterPopout.triggerScreen = root.screen;
|
||||||
controlCenterPopout.controlCenterVisible = !controlCenterPopout.controlCenterVisible;
|
controlCenterPopout.controlCenterVisible = !controlCenterPopout.controlCenterVisible;
|
||||||
|
|||||||
Reference in New Issue
Block a user