2021-12-22 23:29:00 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2014 Marco Martin <notmart@gmail.com>
|
|
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
import QtQuick.Window 2.2
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2022-03-13 21:47:42 +00:00
|
|
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
import "../../components" as Components
|
|
|
|
|
import "../../components/util.js" as Util
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Quick settings elements layout, change the height to clip.
|
|
|
|
|
*/
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
|
|
required property var actionDrawer
|
|
|
|
|
|
|
|
|
|
readonly property real columns: Math.round(Util.applyMinMaxRange(3, 6, width / intendedColumnWidth))
|
|
|
|
|
readonly property real columnWidth: Math.floor(width / columns)
|
2022-05-07 17:10:02 +00:00
|
|
|
readonly property int minimizedColumns: Math.round(Util.applyMinMaxRange(5, 8, width / intendedMinimizedColumnWidth))
|
2021-12-22 23:29:00 +00:00
|
|
|
readonly property real minimizedColumnWidth: Math.floor(width / minimizedColumns)
|
|
|
|
|
|
|
|
|
|
readonly property real rowHeight: columnWidth * 0.7
|
|
|
|
|
readonly property real fullHeight: fullView.implicitHeight
|
|
|
|
|
|
|
|
|
|
readonly property real intendedColumnWidth: 120
|
|
|
|
|
readonly property real intendedMinimizedColumnWidth: PlasmaCore.Units.gridUnit * 3 + PlasmaCore.Units.largeSpacing
|
|
|
|
|
readonly property real minimizedRowHeight: PlasmaCore.Units.gridUnit * 3 + PlasmaCore.Units.largeSpacing
|
|
|
|
|
|
|
|
|
|
property real minimizedViewProgress: 0
|
|
|
|
|
property real fullViewProgress: 1
|
2022-05-07 17:10:02 +00:00
|
|
|
|
|
|
|
|
readonly property MobileShell.QuickSettingsModel quickSettingsModel: MobileShell.QuickSettingsModel {}
|
|
|
|
|
|
2022-05-07 21:19:56 +00:00
|
|
|
readonly property int rowCount: Math.floor((Window.height * 60/100) / rowHeight)
|
|
|
|
|
readonly property int columnCount: Math.floor(width/columnWidth)
|
|
|
|
|
readonly property int pageSize: rowCount * columnCount
|
|
|
|
|
readonly property int quickSettingsCount: quickSettingsModel.count
|
|
|
|
|
|
2022-05-07 17:10:02 +00:00
|
|
|
|
|
|
|
|
function resetSwipeView() {
|
|
|
|
|
swipeView.currentIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return to the first page when the action drawer is closed
|
|
|
|
|
Connections {
|
|
|
|
|
target: actionDrawer
|
|
|
|
|
|
|
|
|
|
onOpenedChanged: {
|
|
|
|
|
if(!actionDrawer.opened) {
|
|
|
|
|
resetSwipeView();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
// view when fully open
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: fullView
|
2022-05-07 17:10:02 +00:00
|
|
|
height: 1
|
2021-12-22 23:29:00 +00:00
|
|
|
opacity: root.fullViewProgress
|
|
|
|
|
visible: opacity !== 0
|
|
|
|
|
transform: Translate { y: (1 - fullView.opacity) * root.rowHeight }
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
2022-05-07 17:10:02 +00:00
|
|
|
SwipeView {
|
|
|
|
|
id: swipeView
|
|
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
Layout.fillWidth: true
|
2022-05-07 21:19:56 +00:00
|
|
|
Layout.minimumHeight: Math.min(quickSettingsCount / columnCount * rowHeight, rowCount * rowHeight)
|
2022-05-07 17:10:02 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
Repeater {
|
2022-05-07 21:19:56 +00:00
|
|
|
model: Math.ceil(quickSettingsCount / pageSize)
|
2022-05-07 17:10:02 +00:00
|
|
|
delegate: Flow {
|
|
|
|
|
id: flow
|
|
|
|
|
spacing: 0
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2022-05-07 17:10:02 +00:00
|
|
|
required property int index
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2022-05-07 17:10:02 +00:00
|
|
|
Repeater {
|
|
|
|
|
model: MobileShell.PaginateModel {
|
|
|
|
|
sourceModel: quickSettingsModel
|
2022-05-07 21:19:56 +00:00
|
|
|
pageSize: root.pageSize
|
|
|
|
|
firstItem: pageSize * flow.index
|
2022-05-07 17:10:02 +00:00
|
|
|
}
|
|
|
|
|
delegate: Components.BaseItem {
|
|
|
|
|
|
|
|
|
|
required property var modelData
|
|
|
|
|
|
|
|
|
|
height: root.rowHeight
|
|
|
|
|
width: root.columnWidth
|
|
|
|
|
padding: PlasmaCore.Units.smallSpacing
|
|
|
|
|
|
|
|
|
|
contentItem: QuickSettingsFullDelegate {
|
|
|
|
|
restrictedPermissions: actionDrawer.restrictedPermissions
|
|
|
|
|
|
|
|
|
|
text: modelData.text
|
|
|
|
|
status: modelData.status
|
|
|
|
|
icon: modelData.icon
|
|
|
|
|
enabled: modelData.enabled
|
|
|
|
|
settingsCommand: modelData.settingsCommand
|
|
|
|
|
toggleFunction: modelData.toggle
|
|
|
|
|
|
|
|
|
|
onCloseRequested: {
|
|
|
|
|
actionDrawer.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-29 05:08:32 +00:00
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-07 21:19:56 +00:00
|
|
|
Loader {
|
|
|
|
|
id: indicatorLoader
|
|
|
|
|
active: swipeView.count > 1
|
|
|
|
|
|
2022-05-07 17:10:02 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
2022-05-07 21:19:56 +00:00
|
|
|
sourceComponent: PageIndicator {
|
|
|
|
|
count: swipeView.count
|
|
|
|
|
currentIndex: swipeView.currentIndex
|
|
|
|
|
|
|
|
|
|
delegate: Rectangle {
|
|
|
|
|
implicitWidth: 8
|
|
|
|
|
implicitHeight: 8
|
2022-05-07 17:10:02 +00:00
|
|
|
|
2022-05-07 21:19:56 +00:00
|
|
|
radius: width / 2
|
|
|
|
|
color: PlasmaCore.Theme.disabledTextColor
|
2022-05-07 17:10:02 +00:00
|
|
|
|
2022-05-07 21:19:56 +00:00
|
|
|
opacity: index === currentIndex ? 0.95 : 0.45
|
2022-05-07 17:10:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
BrightnessItem {
|
|
|
|
|
id: brightnessItem
|
|
|
|
|
Layout.topMargin: PlasmaCore.Units.smallSpacing * 2
|
|
|
|
|
Layout.bottomMargin: PlasmaCore.Units.smallSpacing * 2
|
|
|
|
|
Layout.leftMargin: PlasmaCore.Units.smallSpacing
|
|
|
|
|
Layout.rightMargin: PlasmaCore.Units.smallSpacing
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// view when in minimized mode
|
|
|
|
|
RowLayout {
|
|
|
|
|
id: minimizedView
|
|
|
|
|
spacing: 0
|
|
|
|
|
opacity: root.minimizedViewProgress
|
|
|
|
|
visible: opacity !== 0
|
|
|
|
|
transform: Translate { y: (1 - minimizedView.opacity) * -root.rowHeight }
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
Repeater {
|
2022-05-07 17:10:02 +00:00
|
|
|
model: MobileShell.PaginateModel {
|
|
|
|
|
sourceModel: quickSettingsModel
|
|
|
|
|
pageSize: minimizedColumns
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
delegate: Components.BaseItem {
|
|
|
|
|
required property var modelData
|
|
|
|
|
|
|
|
|
|
implicitHeight: root.minimizedRowHeight
|
|
|
|
|
implicitWidth: root.minimizedColumnWidth
|
|
|
|
|
horizontalPadding: (width - PlasmaCore.Units.gridUnit * 3) / 2
|
|
|
|
|
verticalPadding: (height - PlasmaCore.Units.gridUnit * 3) / 2
|
|
|
|
|
|
|
|
|
|
contentItem: QuickSettingsMinimizedDelegate {
|
2022-04-07 18:11:08 +00:00
|
|
|
restrictedPermissions: actionDrawer.restrictedPermissions
|
|
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
text: modelData.text
|
|
|
|
|
status: modelData.status
|
|
|
|
|
icon: modelData.icon
|
|
|
|
|
enabled: modelData.enabled
|
|
|
|
|
settingsCommand: modelData.settingsCommand
|
|
|
|
|
toggleFunction: modelData.toggle
|
2021-12-29 05:08:32 +00:00
|
|
|
|
|
|
|
|
onCloseRequested: {
|
|
|
|
|
actionDrawer.close();
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|