1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 21:45:38 -05:00

replace qmlformat with a better tool

still not perfect, but well - what can ya do
This commit is contained in:
bbedward
2025-08-08 15:55:37 -04:00
parent 8dc6e2805d
commit 4d408c65f2
137 changed files with 30315 additions and 29625 deletions

View File

@@ -8,202 +8,204 @@ import qs.Services
import qs.Widgets
PanelWindow {
id: root
id: root
property var modelData
property bool brightnessPopupVisible: false
property var brightnessDebounceTimer
property var modelData
property bool brightnessPopupVisible: false
property var brightnessDebounceTimer
brightnessDebounceTimer: Timer {
property int pendingValue: 0
brightnessDebounceTimer: Timer {
property int pendingValue: 0
interval: BrightnessService.ddcAvailable ? 500 : 50
repeat: false
onTriggered: {
BrightnessService.setBrightnessInternal(pendingValue);
}
interval: BrightnessService.ddcAvailable ? 500 : 50
repeat: false
onTriggered: {
BrightnessService.setBrightnessInternal(pendingValue)
}
}
function show() {
root.brightnessPopupVisible = true
hideTimer.restart()
}
function resetHideTimer() {
if (root.brightnessPopupVisible)
hideTimer.restart()
}
screen: modelData
visible: brightnessPopupVisible
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
color: "transparent"
anchors {
top: true
left: true
right: true
bottom: true
}
Timer {
id: hideTimer
interval: 3000
repeat: false
onTriggered: {
if (!brightnessPopup.containsMouse)
root.brightnessPopupVisible = false
else
hideTimer.restart()
}
}
Connections {
function onBrightnessChanged() {
root.show()
}
function show() {
root.brightnessPopupVisible = true;
hideTimer.restart();
}
target: BrightnessService
}
function resetHideTimer() {
if (root.brightnessPopupVisible)
hideTimer.restart();
}
Rectangle {
id: brightnessPopup
screen: modelData
visible: brightnessPopupVisible
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
color: "transparent"
property bool containsMouse: popupMouseArea.containsMouse
anchors {
top: true
left: true
right: true
bottom: true
}
width: Math.min(260, Screen.width - Theme.spacingM * 2)
height: brightnessContent.height + Theme.spacingS * 2
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.spacingM
color: Theme.popupBackground()
radius: Theme.cornerRadiusLarge
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
Theme.outline.b, 0.08)
border.width: 1
opacity: root.brightnessPopupVisible ? 1 : 0
scale: root.brightnessPopupVisible ? 1 : 0.9
layer.enabled: true
Timer {
id: hideTimer
Column {
id: brightnessContent
interval: 3000
repeat: false
onTriggered: {
if (!brightnessPopup.containsMouse)
root.brightnessPopupVisible = false;
else
hideTimer.restart();
}
}
anchors.centerIn: parent
width: parent.width - Theme.spacingS * 2
spacing: Theme.spacingXS
Connections {
function onBrightnessChanged() {
root.show();
}
Item {
property int gap: Theme.spacingS
target: BrightnessService
}
width: parent.width
height: 40
Rectangle {
id: brightnessPopup
property bool containsMouse: popupMouseArea.containsMouse
width: Math.min(260, Screen.width - Theme.spacingM * 2)
height: brightnessContent.height + Theme.spacingS * 2
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.spacingM
color: Theme.popupBackground()
radius: Theme.cornerRadiusLarge
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: 1
opacity: root.brightnessPopupVisible ? 1 : 0
scale: root.brightnessPopupVisible ? 1 : 0.9
layer.enabled: true
Column {
id: brightnessContent
Rectangle {
width: Theme.iconSize
height: Theme.iconSize
radius: Theme.iconSize / 2
color: "transparent"
x: parent.gap
anchors.verticalCenter: parent.verticalCenter
DankIcon {
anchors.centerIn: parent
width: parent.width - Theme.spacingS * 2
spacing: Theme.spacingXS
name: BrightnessService.brightnessLevel
< 30 ? "brightness_low" : BrightnessService.brightnessLevel
< 70 ? "brightness_medium" : "brightness_high"
size: Theme.iconSize
color: Theme.primary
}
}
Item {
property int gap: Theme.spacingS
DankSlider {
id: brightnessSlider
width: parent.width
height: 40
Rectangle {
width: Theme.iconSize
height: Theme.iconSize
radius: Theme.iconSize / 2
color: "transparent"
x: parent.gap
anchors.verticalCenter: parent.verticalCenter
DankIcon {
anchors.centerIn: parent
name: BrightnessService.brightnessLevel < 30 ? "brightness_low" :
BrightnessService.brightnessLevel < 70 ? "brightness_medium" : "brightness_high"
size: Theme.iconSize
color: Theme.primary
}
}
DankSlider {
id: brightnessSlider
width: parent.width - Theme.iconSize - parent.gap * 3
height: 40
x: parent.gap * 2 + Theme.iconSize
anchors.verticalCenter: parent.verticalCenter
minimum: 1
maximum: 100
enabled: BrightnessService.brightnessAvailable
showValue: true
unit: "%"
Component.onCompleted: {
if (BrightnessService.brightnessAvailable)
value = BrightnessService.brightnessLevel;
}
onSliderValueChanged: function(newValue) {
if (BrightnessService.brightnessAvailable) {
brightnessDebounceTimer.pendingValue = newValue;
brightnessDebounceTimer.restart();
root.resetHideTimer();
}
}
onSliderDragFinished: function(finalValue) {
if (BrightnessService.brightnessAvailable) {
brightnessDebounceTimer.stop();
BrightnessService.setBrightnessInternal(finalValue);
}
}
Connections {
function onBrightnessChanged() {
brightnessSlider.value = BrightnessService.brightnessLevel;
}
target: BrightnessService
}
}
width: parent.width - Theme.iconSize - parent.gap * 3
height: 40
x: parent.gap * 2 + Theme.iconSize
anchors.verticalCenter: parent.verticalCenter
minimum: 1
maximum: 100
enabled: BrightnessService.brightnessAvailable
showValue: true
unit: "%"
Component.onCompleted: {
if (BrightnessService.brightnessAvailable)
value = BrightnessService.brightnessLevel
}
onSliderValueChanged: function (newValue) {
if (BrightnessService.brightnessAvailable) {
brightnessDebounceTimer.pendingValue = newValue
brightnessDebounceTimer.restart()
root.resetHideTimer()
}
}
MouseArea {
id: popupMouseArea
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
propagateComposedEvents: true
z: -1
}
layer.effect: MultiEffect {
shadowEnabled: true
shadowHorizontalOffset: 0
shadowVerticalOffset: 4
shadowBlur: 0.8
shadowColor: Qt.rgba(0, 0, 0, 0.3)
shadowOpacity: 0.3
}
transform: Translate {
y: root.brightnessPopupVisible ? 0 : 20
}
Behavior on opacity {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
onSliderDragFinished: function (finalValue) {
if (BrightnessService.brightnessAvailable) {
brightnessDebounceTimer.stop()
BrightnessService.setBrightnessInternal(finalValue)
}
}
}
Behavior on scale {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
Connections {
function onBrightnessChanged() {
brightnessSlider.value = BrightnessService.brightnessLevel
}
}
Behavior on transform {
PropertyAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
target: BrightnessService
}
}
}
}
mask: Region {
item: brightnessPopup
MouseArea {
id: popupMouseArea
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
propagateComposedEvents: true
z: -1
}
}
layer.effect: MultiEffect {
shadowEnabled: true
shadowHorizontalOffset: 0
shadowVerticalOffset: 4
shadowBlur: 0.8
shadowColor: Qt.rgba(0, 0, 0, 0.3)
shadowOpacity: 0.3
}
transform: Translate {
y: root.brightnessPopupVisible ? 0 : 20
}
Behavior on opacity {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
Behavior on scale {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
Behavior on transform {
PropertyAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
}
mask: Region {
item: brightnessPopup
}
}