Warning, /plasma/plasma-systemmonitor/src/page/LoadPresetDialog.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003 * SPDX-FileCopyrightText: 2023 Nate Graham <nate@kde.org>
0004 *
0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007
0008 import QtQuick
0009 import QtQuick.Controls
0010 import QtQuick.Layouts
0011
0012 import org.kde.kirigami as Kirigami
0013
0014 Kirigami.Dialog {
0015 id: dialog
0016
0017 property QtObject controller
0018
0019 readonly property string selectedTitle: presetList.currentItem ? presetList.currentItem.title : ""
0020 readonly property string selectedFace: presetList.currentItem ? presetList.currentItem.chartFace : ""
0021 readonly property string selectedPreset: presetList.currentItem ? presetList.currentItem.preset : ""
0022
0023 title: i18nc("@title:window", "Load Preset")
0024
0025 preferredWidth: Kirigami.Units.gridUnit * 20
0026 preferredHeight: Kirigami.Units.gridUnit * 30
0027
0028 focus: true
0029
0030 // We already have a cancel button in the footer
0031 showCloseButton: false
0032
0033 standardButtons: Dialog.Cancel
0034
0035 customFooterActions: [
0036 Kirigami.Action {
0037 text: i18nc("@action:button", "Load")
0038 icon.name: "document-open"
0039 enabled: presetList.currentIndex != -1
0040 onTriggered: dialog.accept()
0041 }
0042 ]
0043
0044 ListView {
0045 id: presetList
0046
0047 currentIndex: -1
0048 clip: true
0049
0050 model: dialog.controller.availablePresetsModel
0051 delegate: Kirigami.SwipeListItem {
0052 highlighted: ListView.isCurrentItem
0053
0054 property string title: model.display
0055 property string chartFace: model.config && model.config.chartFace !== undefined ? model.config.chartFace : ""
0056 property string preset: model.pluginId
0057
0058 contentItem: Label {
0059 Layout.fillWidth: true
0060 text: model.display
0061 }
0062 actions: Kirigami.Action {
0063 icon.name: "delete"
0064 visible: model.writable
0065 onTriggered: dialog.controller.uninstallPreset(model.pluginId);
0066 }
0067 onClicked: {
0068 presetList.currentIndex = index
0069 }
0070 }
0071 }
0072 }