actiondrawer: hide action drawer while adjusting screen brightness

This change hides the action drawer while adjusting the screen brightness so that one can see the content behind it.
This commit is contained in:
Micah Stanley 2024-11-14 03:34:01 +00:00 committed by Devin Lin
parent e4d57d19bc
commit 7245080b22
7 changed files with 64 additions and 6 deletions

View file

@ -30,6 +30,8 @@ Item {
Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false Kirigami.Theme.inherit: false
readonly property alias brightnessPressedValue: quickSettings.brightnessPressedValue
// Background color // Background color
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
@ -37,8 +39,8 @@ Item {
Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.g,
Kirigami.Theme.backgroundColor.b, Kirigami.Theme.backgroundColor.b,
(root.actionDrawer.mode == ActionDrawer.Portrait || notificationWidget.hasNotifications) ? 0.95 : 0.9) (root.actionDrawer.mode == ActionDrawer.Portrait || notificationWidget.hasNotifications) ? 0.95 : 0.9)
Behavior on color { ColorAnimation { duration: Kirigami.Units.longDuration } } Behavior on color { ColorAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.OutQuad } }
opacity: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset)) opacity: Math.max(0, Math.min(brightnessPressedValue, actionDrawer.offset / root.minimizedQuickSettingsOffset))
} }
// Layout that switches between landscape and portrait mode // Layout that switches between landscape and portrait mode
@ -108,11 +110,15 @@ Item {
// security reasons, system tray also doesn't work on lockscreen // security reasons, system tray also doesn't work on lockscreen
disableSystemTray: root.actionDrawer.restrictedPermissions disableSystemTray: root.actionDrawer.restrictedPermissions
opacity: brightnessPressedValue
} }
property MobileShell.MediaControlsWidget mediaControlsWidget: MobileShell.MediaControlsWidget { property MobileShell.MediaControlsWidget mediaControlsWidget: MobileShell.MediaControlsWidget {
id: mediaWidget id: mediaWidget
inActionDrawer: true inActionDrawer: true
opacity: brightnessPressedValue
} }
property MobileShell.NotificationsWidget notificationsWidget: MobileShell.NotificationsWidget { property MobileShell.NotificationsWidget notificationsWidget: MobileShell.NotificationsWidget {
@ -123,6 +129,8 @@ Item {
actionsRequireUnlock: root.actionDrawer.restrictedPermissions actionsRequireUnlock: root.actionDrawer.restrictedPermissions
onUnlockRequested: root.actionDrawer.permissionsRequested() onUnlockRequested: root.actionDrawer.permissionsRequested()
opacity: brightnessPressedValue
Connections { Connections {
target: root.actionDrawer target: root.actionDrawer

View file

@ -32,6 +32,7 @@ Item {
readonly property bool isOnLargeScreen: width > quickSettingsPanel.width * 2.5 readonly property bool isOnLargeScreen: width > quickSettingsPanel.width * 2.5
readonly property real minWidthHeight: Math.min(root.width, root.height) readonly property real minWidthHeight: Math.min(root.width, root.height)
readonly property real opacityValue: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset)) readonly property real opacityValue: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset))
readonly property double brightnessPressedValue: quickSettings.brightnessPressedValue
Kirigami.Theme.colorSet: Kirigami.Theme.View Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false Kirigami.Theme.inherit: false
@ -81,7 +82,7 @@ Item {
id: clock id: clock
text: Qt.formatTime(timeSource.data.Local.DateTime, MobileShell.ShellUtil.isSystem24HourFormat ? "h:mm" : "h:mm ap") text: Qt.formatTime(timeSource.data.Local.DateTime, MobileShell.ShellUtil.isSystem24HourFormat ? "h:mm" : "h:mm ap")
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
opacity: columnLayout.opacity opacity: Math.min(brightnessPressedValue, columnLayout.opacity)
anchors { anchors {
left: parent.left left: parent.left
@ -100,7 +101,7 @@ Item {
text: Qt.formatDate(timeSource.data.Local.DateTime, "ddd MMMM d") text: Qt.formatDate(timeSource.data.Local.DateTime, "ddd MMMM d")
verticalAlignment: Qt.AlignTop verticalAlignment: Qt.AlignTop
color: Kirigami.Theme.disabledTextColor color: Kirigami.Theme.disabledTextColor
opacity: columnLayout.opacity opacity: Math.min(brightnessPressedValue, columnLayout.opacity)
anchors { anchors {
left: parent.left left: parent.left

View file

@ -19,10 +19,29 @@ Item {
implicitHeight: brightnessRow.implicitHeight implicitHeight: brightnessRow.implicitHeight
visible: screenBrightness.brightnessAvailable visible: screenBrightness.brightnessAvailable
property double brightnessPressedValue: 1
Behavior on brightnessPressedValue {
NumberAnimation {
duration: Kirigami.Units.longDuration
easing.type: Easing.OutQuad
}
}
ScreenBrightness.ScreenBrightnessUtil { ScreenBrightness.ScreenBrightnessUtil {
id: screenBrightness id: screenBrightness
} }
Rectangle {
anchors.fill: parent
anchors.leftMargin: -Kirigami.Units.smallSpacing
anchors.rightMargin: -Kirigami.Units.smallSpacing
anchors.topMargin: -Kirigami.Units.smallSpacing * 2
anchors.bottomMargin: -Kirigami.Units.smallSpacing * 2
color: Kirigami.Theme.backgroundColor
radius: Kirigami.Units.cornerRadius
}
RowLayout { RowLayout {
id: brightnessRow id: brightnessRow
spacing: Kirigami.Units.smallSpacing * 2 spacing: Kirigami.Units.smallSpacing * 2
@ -47,6 +66,26 @@ Item {
value: screenBrightness.brightness value: screenBrightness.brightness
onMoved: screenBrightness.brightness = value; onMoved: screenBrightness.brightness = value;
onPressedChanged: {
if (pressed) {
brightnessPressedTimer.restart();
} else{
brightnessPressedTimer.stop();
brightnessPressedValue = 1;
}
}
Timer {
id: brightnessPressedTimer
interval: 200
repeat: false
onTriggered: {
if (brightnessSlider.pressed) {
brightnessPressedValue = 0;
}
}
}
// HACK: for some reason, the slider initial value doesn't set without being done after the component completes loading // HACK: for some reason, the slider initial value doesn't set without being done after the component completes loading
Timer { Timer {
interval: 0 interval: 0

View file

@ -16,8 +16,7 @@ Rectangle {
implicitWidth: Kirigami.Units.gridUnit * 3 implicitWidth: Kirigami.Units.gridUnit * 3
implicitHeight: 3 implicitHeight: 3
radius: height radius: height
color: Kirigami.Theme.textColor color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.5)
opacity: 0.5
TapHandler { TapHandler {
cursorShape: pressed ? Qt.ClosedHandCursor : Qt.PointingHandCursor cursorShape: pressed ? Qt.ClosedHandCursor : Qt.PointingHandCursor

View file

@ -60,6 +60,8 @@ Item {
readonly property int pageSize: rowCount * columnCount readonly property int pageSize: rowCount * columnCount
readonly property int quickSettingsCount: quickSettingsModel.count readonly property int quickSettingsCount: quickSettingsModel.count
readonly property alias brightnessPressedValue: brightnessItem.brightnessPressedValue
function resetSwipeView() { function resetSwipeView() {
if (root.mode === QuickSettings.Pages) { if (root.mode === QuickSettings.Pages) {
swipeView.currentIndex = 0; swipeView.currentIndex = 0;
@ -134,6 +136,8 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: rowCount * rowHeight Layout.minimumHeight: rowCount * rowHeight
opacity: brightnessPressedValue
SwipeView { SwipeView {
id: swipeView id: swipeView
@ -199,6 +203,7 @@ Item {
// Brightness slider // Brightness slider
BrightnessItem { BrightnessItem {
id: brightnessItem
Layout.bottomMargin: Kirigami.Units.smallSpacing * 2 Layout.bottomMargin: Kirigami.Units.smallSpacing * 2
Layout.leftMargin: Kirigami.Units.smallSpacing Layout.leftMargin: Kirigami.Units.smallSpacing
Layout.rightMargin: Kirigami.Units.smallSpacing Layout.rightMargin: Kirigami.Units.smallSpacing

View file

@ -49,6 +49,7 @@ MobileShell.BaseItem {
property alias quickSettings: quickSettingsProxy.contentItem property alias quickSettings: quickSettingsProxy.contentItem
property alias statusBar: statusBarProxy.contentItem property alias statusBar: statusBarProxy.contentItem
property alias mediaControlsWidget: mediaControlsWidgetProxy.contentItem property alias mediaControlsWidget: mediaControlsWidgetProxy.contentItem
readonly property double brightnessPressedValue: quickSettings.brightnessPressedValue
// we need extra padding if the background side border is enabled // we need extra padding if the background side border is enabled
topPadding: Kirigami.Units.smallSpacing topPadding: Kirigami.Units.smallSpacing
@ -59,6 +60,7 @@ MobileShell.BaseItem {
background: KSvg.FrameSvgItem { background: KSvg.FrameSvgItem {
enabledBorders: KSvg.FrameSvgItem.BottomBorder enabledBorders: KSvg.FrameSvgItem.BottomBorder
imagePath: "widgets/background" imagePath: "widgets/background"
opacity: brightnessPressedValue
} }
contentItem: Item { contentItem: Item {
@ -103,6 +105,7 @@ MobileShell.BaseItem {
property real fullHeight: height + Layout.topMargin property real fullHeight: height + Layout.topMargin
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.topMargin: Kirigami.Units.smallSpacing * 2 Layout.topMargin: Kirigami.Units.smallSpacing * 2
opacity: brightnessPressedValue
onTapped: { onTapped: {
if (root.minimizedToFullProgress < 0.5) { if (root.minimizedToFullProgress < 0.5) {

View file

@ -35,6 +35,7 @@ MobileShell.BaseItem {
property alias quickSettings: quickSettingsProxy.contentItem property alias quickSettings: quickSettingsProxy.contentItem
property alias statusBar: statusBarProxy.contentItem property alias statusBar: statusBarProxy.contentItem
readonly property double brightnessPressedValue: quickSettings.brightnessPressedValue
// we need extra padding since the background side border is enabled // we need extra padding since the background side border is enabled
topPadding: Kirigami.Units.smallSpacing * 4 topPadding: Kirigami.Units.smallSpacing * 4
@ -45,6 +46,7 @@ MobileShell.BaseItem {
background: KSvg.FrameSvgItem { background: KSvg.FrameSvgItem {
enabledBorders: KSvg.FrameSvgItem.AllBorders enabledBorders: KSvg.FrameSvgItem.AllBorders
imagePath: "widgets/background" imagePath: "widgets/background"
opacity: brightnessPressedValue
} }
contentItem: Item { contentItem: Item {
@ -89,6 +91,7 @@ MobileShell.BaseItem {
id: handle id: handle
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
opacity: brightnessPressedValue
} }
} }
} }