shift-shell/kcms/mobileshell/ui/QuickSettingsForm.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

145 lines
4.2 KiB
QML
Raw Normal View History

/*
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami as Kirigami
import org.kde.kcmutils as KCM
2023-09-21 17:24:32 +00:00
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
2023-09-21 17:24:32 +00:00
FormCard.FormCardPage {
id: root
2023-09-21 17:24:32 +00:00
title: i18n("Quick Settings")
2023-09-21 17:24:32 +00:00
component Delegate : FormCard.AbstractFormDelegate {
id: qsDelegate
2023-09-21 17:24:32 +00:00
property bool isEnabled: false
2023-09-21 17:24:32 +00:00
width: ListView.view.width
2023-09-21 17:24:32 +00:00
background: null
contentItem: RowLayout {
Kirigami.ListItemDragHandle {
visible: qsDelegate.isEnabled
Layout.rightMargin: Kirigami.Units.largeSpacing
2023-09-21 17:24:32 +00:00
listItem: qsDelegate
listView: qsDelegate.ListView.view
onMoveRequested: savedQuickSettings.enabledModel.moveRow(oldIndex, newIndex)
}
2023-09-21 17:24:32 +00:00
Kirigami.Icon {
readonly property bool iconAvailable: model && model.icon !== ""
2023-09-21 17:24:32 +00:00
visible: iconAvailable
source: model ? model.icon : ""
Layout.rightMargin: iconAvailable ? Kirigami.Units.gridUnit : 0
implicitWidth: iconAvailable ? Kirigami.Units.iconSizes.small : 0
implicitHeight: iconAvailable ? Kirigami.Units.iconSizes.small : 0
}
2023-09-21 17:24:32 +00:00
QQC2.Label {
Layout.fillWidth: true
text: model ? model.name : ""
elide: Text.ElideRight
}
QQC2.ToolButton {
display: QQC2.AbstractButton.IconOnly
text: qsDelegate.isEnabled ? i18nc("@action:button", "Hide") : i18nc("@action:button", "Show")
icon.name: qsDelegate.isEnabled ? "hide_table_row" : "show_table_row"
onClicked: qsDelegate.isEnabled ? savedQuickSettings.disableQS(model.index) : savedQuickSettings.enableQS(model.index)
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
}
}
2023-09-21 17:24:32 +00:00
data: QS.SavedQuickSettings {
id: savedQuickSettings
}
2023-09-21 17:24:32 +00:00
FormCard.FormHeader {
title: i18n("Quick Settings")
visible: enabledRepeater.count > 0
}
FormCard.FormCard {
FormCard.FormComboBoxDelegate {
id: statusBarScaleFactorDelegate
text: i18n("Quick Settings Columns")
description: i18n("Maximum number of columns in landscape orientation.")
model: [3, 4, 5, 6]
Component.onCompleted: {
currentIndex = indexOfValue(ShellSettings.Settings.quickSettingsColumns);
dialog.parent = root;
}
onCurrentValueChanged: ShellSettings.Settings.quickSettingsColumns = currentValue
}
}
2023-09-21 17:24:32 +00:00
FormCard.FormSectionText {
text: i18n("Customize the order of quick settings in the pull-down panel and hide them.")
visible: enabledRepeater.count > 0
}
FormCard.FormCard {
visible: enabledRepeater.count > 0
ListView {
id: enabledRepeater
interactive: false
model: savedQuickSettings.enabledModel
delegate: Delegate {
isEnabled: true
}
Layout.fillWidth: true
2023-09-21 17:24:32 +00:00
Layout.preferredHeight: contentHeight
}
}
2023-09-21 17:24:32 +00:00
FormCard.FormHeader {
title: i18n("Disabled Quick Settings")
visible: disabledRepeater.count > 0
}
FormCard.FormSectionText {
text: i18n("Re-enable previously disabled quick settings.")
visible: disabledRepeater.count > 0
}
2023-09-21 17:24:32 +00:00
FormCard.FormCard {
visible: disabledRepeater.count > 0
2023-09-21 17:24:32 +00:00
ListView {
id: disabledRepeater
2023-09-21 17:24:32 +00:00
interactive: false
2023-09-21 17:24:32 +00:00
model: savedQuickSettings.disabledModel
delegate: Delegate {
isEnabled: false
}
2023-09-21 17:24:32 +00:00
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
}
}
}