mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-26 14:32:52 -05:00
refactor all modals and popouts so they retain animations on exit
This commit is contained in:
@@ -125,7 +125,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
@@ -8,13 +8,9 @@ import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
PanelWindow {
|
||||
DankPopout {
|
||||
id: root
|
||||
|
||||
property bool batteryPopupVisible: false
|
||||
property real triggerX: Screen.width - 380 - Theme.spacingL
|
||||
property real triggerY: Theme.barHeight - 4 + SettingsData.topBarSpacing + Theme.spacingS
|
||||
property real triggerWidth: 70
|
||||
property string triggerSection: "right"
|
||||
property var triggerScreen: null
|
||||
|
||||
@@ -43,84 +39,22 @@ PanelWindow {
|
||||
ToastService.showError("Failed to set power profile")
|
||||
}
|
||||
|
||||
visible: batteryPopupVisible
|
||||
popupWidth: 400
|
||||
popupHeight: contentLoader.item ? contentLoader.item.implicitHeight : 400
|
||||
triggerX: Screen.width - 380 - Theme.spacingL
|
||||
triggerY: Theme.barHeight - 4 + SettingsData.topBarSpacing + Theme.spacingS
|
||||
triggerWidth: 70
|
||||
positioning: "center"
|
||||
WlrLayershell.namespace: "quickshell-battery"
|
||||
screen: triggerScreen
|
||||
implicitWidth: 400
|
||||
implicitHeight: 300
|
||||
WlrLayershell.layer: WlrLayershell.Overlay
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: batteryPopupVisible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
color: "transparent"
|
||||
shouldBeVisible: false
|
||||
visible: shouldBeVisible
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: function (mouse) {
|
||||
var localPos = mapToItem(contentLoader, mouse.x, mouse.y)
|
||||
if (localPos.x < 0 || localPos.x > contentLoader.width || localPos.y < 0
|
||||
|| localPos.y > contentLoader.height)
|
||||
batteryPopupVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: contentLoader
|
||||
|
||||
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(
|
||||
380, screenWidth - Theme.spacingL * 2)
|
||||
readonly property real calculatedX: {
|
||||
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
|
||||
}
|
||||
|
||||
asynchronous: true
|
||||
active: batteryPopupVisible
|
||||
width: targetWidth
|
||||
height: item ? item.implicitHeight : 0
|
||||
x: calculatedX
|
||||
y: root.triggerY
|
||||
opacity: batteryPopupVisible ? 1 : 0
|
||||
scale: batteryPopupVisible ? 1 : 0.9
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Anims.durMed
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Anims.emphasized
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on scale {
|
||||
NumberAnimation {
|
||||
duration: Anims.durMed
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Anims.emphasized
|
||||
}
|
||||
}
|
||||
|
||||
sourceComponent: Rectangle {
|
||||
content: Component {
|
||||
Rectangle {
|
||||
id: batteryContent
|
||||
|
||||
implicitHeight: contentColumn.height + Theme.spacingL * 2
|
||||
color: Theme.popupBackground()
|
||||
radius: Theme.cornerRadius
|
||||
@@ -129,22 +63,24 @@ PanelWindow {
|
||||
antialiasing: true
|
||||
smooth: true
|
||||
focus: true
|
||||
|
||||
Component.onCompleted: {
|
||||
if (batteryPopupVisible)
|
||||
if (root.shouldBeVisible)
|
||||
forceActiveFocus()
|
||||
}
|
||||
|
||||
Keys.onPressed: function (event) {
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
batteryPopupVisible = false
|
||||
root.close()
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onBatteryPopupVisibleChanged() {
|
||||
if (batteryPopupVisible)
|
||||
function onShouldBeVisibleChanged() {
|
||||
if (root.shouldBeVisible)
|
||||
Qt.callLater(function () {
|
||||
parent.forceActiveFocus()
|
||||
batteryContent.forceActiveFocus()
|
||||
})
|
||||
}
|
||||
target: root
|
||||
@@ -220,8 +156,8 @@ PanelWindow {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
batteryPopupVisible = false
|
||||
onPressed: {
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,7 +478,7 @@ PanelWindow {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
root.setProfile(modelData)
|
||||
}
|
||||
}
|
||||
@@ -599,4 +535,4 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0);
|
||||
var currentScreen = parentScreen || Screen;
|
||||
|
||||
@@ -132,7 +132,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
@@ -35,7 +35,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
@@ -35,7 +35,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
@@ -74,7 +74,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
@@ -21,11 +21,9 @@ Item {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
z: 1000
|
||||
preventStealing: true
|
||||
propagateComposedEvents: false
|
||||
acceptedButtons: Qt.LeftButton
|
||||
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
@@ -39,15 +37,12 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
const baseColor = launcherArea.containsMouse
|
||||
|| isActive ? Theme.surfaceTextPressed : Theme.surfaceTextHover
|
||||
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b,
|
||||
baseColor.a * Theme.widgetTransparency)
|
||||
}
|
||||
color: Qt.rgba(Theme.surfaceTextHover.r, Theme.surfaceTextHover.g, Theme.surfaceTextHover.b,
|
||||
Theme.surfaceTextHover.a * Theme.widgetTransparency)
|
||||
|
||||
SystemLogo {
|
||||
visible: SettingsData.useOSLogo
|
||||
@@ -67,11 +62,5 @@ Item {
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ Rectangle {
|
||||
enabled: root.playerAvailable && root.opacity > 0 && root.width > 0 && textContainer.visible
|
||||
hoverEnabled: enabled
|
||||
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (root.popupTarget && root.popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = root.parentScreen || Screen
|
||||
|
||||
@@ -49,7 +49,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
@@ -35,7 +35,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
@@ -617,7 +617,7 @@ PanelWindow {
|
||||
id: launcherButtonComponent
|
||||
|
||||
LauncherButton {
|
||||
isActive: appDrawerLoader.item ? appDrawerLoader.item.isVisible : false
|
||||
isActive: false
|
||||
section: {
|
||||
if (parent && parent.parent) {
|
||||
if (parent.parent === leftSection)
|
||||
@@ -921,7 +921,7 @@ PanelWindow {
|
||||
id: batteryComponent
|
||||
|
||||
Battery {
|
||||
batteryPopupVisible: batteryPopoutLoader.item ? batteryPopoutLoader.item.batteryPopupVisible : false
|
||||
batteryPopupVisible: batteryPopoutLoader.item ? batteryPopoutLoader.item.shouldBeVisible : false
|
||||
section: {
|
||||
if (parent && parent.parent === leftSection)
|
||||
return "left"
|
||||
@@ -939,7 +939,7 @@ PanelWindow {
|
||||
onToggleBatteryPopup: {
|
||||
batteryPopoutLoader.active = true
|
||||
if (batteryPopoutLoader.item) {
|
||||
batteryPopoutLoader.item.batteryPopupVisible = !batteryPopoutLoader.item.batteryPopupVisible
|
||||
batteryPopoutLoader.item.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -949,7 +949,7 @@ PanelWindow {
|
||||
id: controlCenterButtonComponent
|
||||
|
||||
ControlCenterButton {
|
||||
isActive: controlCenterLoader.item ? controlCenterLoader.item.controlCenterVisible : false
|
||||
isActive: controlCenterLoader.item ? controlCenterLoader.item.shouldBeVisible : false
|
||||
section: {
|
||||
if (parent && parent.parent === leftSection)
|
||||
return "left"
|
||||
@@ -968,8 +968,8 @@ PanelWindow {
|
||||
controlCenterLoader.active = true
|
||||
if (controlCenterLoader.item) {
|
||||
controlCenterLoader.item.triggerScreen = root.screen
|
||||
controlCenterLoader.item.controlCenterVisible = !controlCenterLoader.item.controlCenterVisible
|
||||
if (controlCenterLoader.item.controlCenterVisible) {
|
||||
controlCenterLoader.item.toggle()
|
||||
if (controlCenterLoader.item.shouldBeVisible) {
|
||||
if (NetworkService.wifiEnabled)
|
||||
NetworkService.scanWifi()
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
onPressed: {
|
||||
if (popupTarget && popupTarget.setTriggerPosition) {
|
||||
var globalPos = mapToGlobal(0, 0)
|
||||
var currentScreen = parentScreen || Screen
|
||||
|
||||
Reference in New Issue
Block a user