2024-10-31 05:05:44 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021-2024 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2024-10-31 05:05:44 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls as QQC2
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Window
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
import org.kde.kirigami 2.12 as Kirigami
|
|
|
|
|
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2023-03-08 13:26:36 +00:00
|
|
|
import org.kde.plasma.plasma5support 2.0 as P5Support
|
2021-12-22 23:29:00 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2024-07-27 15:02:48 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
/**
|
2024-06-16 20:50:06 +00:00
|
|
|
* Root element that contains all the ActionDrawer's contents, and is anchored to the screen.
|
2021-12-22 23:29:00 +00:00
|
|
|
*/
|
2023-07-25 01:13:52 +00:00
|
|
|
Item {
|
2021-12-22 23:29:00 +00:00
|
|
|
id: root
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
required property var actionDrawer
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2024-10-31 05:05:44 +00:00
|
|
|
property alias quickSettings: quickSettingsPanel.quickSettings
|
|
|
|
|
property alias statusBar: quickSettingsPanel.statusBar
|
|
|
|
|
property alias mediaControlsWidget: mediaControlsWidgetProxy.contentItem
|
|
|
|
|
property alias notificationsWidget: notificationWidgetProxy.contentItem
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
readonly property real minimizedQuickSettingsOffset: height
|
|
|
|
|
readonly property real maximizedQuickSettingsOffset: height
|
2024-10-31 05:05:44 +00:00
|
|
|
readonly property bool isOnLargeScreen: width > quickSettingsPanel.width * 2.5
|
2022-05-15 13:45:26 +00:00
|
|
|
readonly property real minWidthHeight: Math.min(root.width, root.height)
|
|
|
|
|
readonly property real opacityValue: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset))
|
2024-11-14 03:34:01 +00:00
|
|
|
readonly property double brightnessPressedValue: quickSettings.brightnessPressedValue
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
|
|
|
|
Kirigami.Theme.inherit: false
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-03-08 13:26:36 +00:00
|
|
|
P5Support.DataSource {
|
2021-12-22 23:29:00 +00:00
|
|
|
id: timeSource
|
|
|
|
|
engine: "time"
|
|
|
|
|
connectedSources: ["Local"]
|
|
|
|
|
interval: 60 * 1000
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
// dismiss drawer when background is clicked
|
|
|
|
|
onClicked: root.actionDrawer.close();
|
2024-07-27 03:47:44 +00:00
|
|
|
|
|
|
|
|
// left side
|
2022-04-08 00:23:36 +00:00
|
|
|
ColumnLayout {
|
2022-05-14 19:15:46 +00:00
|
|
|
id: columnLayout
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-15 13:45:26 +00:00
|
|
|
opacity: opacityValue
|
2022-04-08 00:23:36 +00:00
|
|
|
spacing: 0
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
anchors {
|
2024-10-31 05:05:44 +00:00
|
|
|
top: mediaControlsWidgetProxy.bottom
|
2022-05-16 17:06:35 +00:00
|
|
|
topMargin: 0
|
2022-04-08 00:23:36 +00:00
|
|
|
bottom: parent.bottom
|
2022-06-24 15:44:30 +00:00
|
|
|
bottomMargin: 0
|
2024-10-31 05:05:44 +00:00
|
|
|
right: quickSettingsPanel.left
|
2022-04-08 00:23:36 +00:00
|
|
|
left: parent.left
|
|
|
|
|
}
|
2022-05-16 17:06:35 +00:00
|
|
|
anchors.margins: minWidthHeight * 0.06
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2024-10-31 05:05:44 +00:00
|
|
|
MobileShell.BaseItem {
|
|
|
|
|
id: notificationWidgetProxy
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
// don't allow notifications widget to get too wide
|
2023-07-25 01:13:52 +00:00
|
|
|
Layout.maximumWidth: Kirigami.Units.gridUnit * 25
|
2022-04-08 00:23:36 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.fillWidth: true
|
2022-05-15 13:45:26 +00:00
|
|
|
Layout.topMargin: minWidthHeight * 0.02
|
2022-04-07 18:11:08 +00:00
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-14 19:15:46 +00:00
|
|
|
PlasmaComponents.Label {
|
|
|
|
|
id: clock
|
|
|
|
|
text: Qt.formatTime(timeSource.data.Local.DateTime, MobileShell.ShellUtil.isSystem24HourFormat ? "h:mm" : "h:mm ap")
|
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
2024-11-14 03:34:01 +00:00
|
|
|
opacity: Math.min(brightnessPressedValue, columnLayout.opacity)
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-14 19:15:46 +00:00
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
top: parent.top
|
2022-05-16 17:06:35 +00:00
|
|
|
topMargin: columnLayout.anchors.margins / 2
|
|
|
|
|
leftMargin: columnLayout.anchors.margins
|
2022-05-14 19:15:46 +00:00
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-15 13:45:26 +00:00
|
|
|
font.pixelSize: Math.min(40, minWidthHeight * 0.1)
|
2022-05-14 19:15:46 +00:00
|
|
|
font.weight: Font.ExtraLight
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-14 19:15:46 +00:00
|
|
|
PlasmaComponents.Label {
|
|
|
|
|
id: date
|
|
|
|
|
text: Qt.formatDate(timeSource.data.Local.DateTime, "ddd MMMM d")
|
|
|
|
|
verticalAlignment: Qt.AlignTop
|
2023-09-27 04:21:06 +00:00
|
|
|
color: Kirigami.Theme.disabledTextColor
|
2024-11-14 03:34:01 +00:00
|
|
|
opacity: Math.min(brightnessPressedValue, columnLayout.opacity)
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-14 19:15:46 +00:00
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
top: clock.bottom
|
2024-10-31 05:05:44 +00:00
|
|
|
bottom: isOnLargeScreen ? columnLayout.top : mediaControlsWidgetProxy.top
|
2023-07-25 01:13:52 +00:00
|
|
|
topMargin: Kirigami.Units.smallSpacing
|
2022-05-16 17:06:35 +00:00
|
|
|
leftMargin: columnLayout.anchors.margins
|
2022-05-14 19:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-15 13:45:26 +00:00
|
|
|
font.pixelSize: Math.min(20, minWidthHeight * 0.05)
|
2022-05-14 19:15:46 +00:00
|
|
|
font.weight: Font.Light
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2024-10-31 05:05:44 +00:00
|
|
|
MobileShell.BaseItem {
|
|
|
|
|
id: mediaControlsWidgetProxy
|
2023-07-25 01:13:52 +00:00
|
|
|
property real fullHeight: visible ? height + Kirigami.Units.smallSpacing * 6 : 0
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-16 17:06:35 +00:00
|
|
|
y: isOnLargeScreen ? date.y - height + date.implicitHeight : date.y + date.implicitHeight + columnLayout.anchors.margins / 2
|
2022-05-14 19:15:46 +00:00
|
|
|
opacity: columnLayout.opacity
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-14 19:15:46 +00:00
|
|
|
anchors {
|
2024-10-31 05:05:44 +00:00
|
|
|
right: quickSettingsPanel.left
|
2022-05-14 19:15:46 +00:00
|
|
|
left: isOnLargeScreen ? date.right : parent.left
|
2022-05-16 17:06:35 +00:00
|
|
|
leftMargin: columnLayout.anchors.margins
|
2024-10-31 05:05:44 +00:00
|
|
|
rightMargin: columnLayout.anchors.margins - quickSettingsPanel.leftPadding
|
2022-05-14 19:15:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
// right sidebar
|
2023-11-02 11:08:17 +00:00
|
|
|
MobileShell.QuickSettingsPanel {
|
2024-10-31 05:05:44 +00:00
|
|
|
id: quickSettingsPanel
|
|
|
|
|
height: quickSettingsPanel.contentImplicitHeight + quickSettingsPanel.topPadding + quickSettingsPanel.bottomPadding
|
2022-04-08 00:23:36 +00:00
|
|
|
width: intendedWidth
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
readonly property real intendedWidth: 360
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2024-10-31 05:05:44 +00:00
|
|
|
property real offsetRatio: quickSettingsPanel.height / root.height
|
|
|
|
|
anchors.topMargin: Math.min(root.actionDrawer.offset * offsetRatio - quickSettingsPanel.height, 0)
|
2022-04-08 00:23:36 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.right: parent.right
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
actionDrawer: root.actionDrawer
|
2022-12-07 00:01:42 +00:00
|
|
|
fullScreenHeight: root.height
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|