Warning, /plasma-mobile/plasma-settings/src/qml/Sidebar.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright 2021 Devin Lin <devin@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.3
0009 import QtQuick.Controls 2.15 as QQC2
0010 import org.kde.kirigami 2.11 as Kirigami
0011 
0012 import org.kde.plasma.settings 0.1
0013 
0014 Kirigami.OverlayDrawer {
0015     id: drawer
0016     modal: false
0017     height: applicationWindow().height
0018     width: 300
0019     handleVisible: false
0020 
0021     edge: Qt.application.layoutDirection === Qt.RightToLeft ? Qt.RightEdge : Qt.LeftEdge
0022     parent: QQC2.Overlay.overlay
0023     x: 0
0024 
0025     property alias model: listView.model
0026 
0027     Kirigami.Theme.colorSet: Kirigami.Theme.Window
0028     Kirigami.Theme.inherit: false
0029 
0030     leftPadding: 0
0031     rightPadding: 0
0032     topPadding: 0
0033     bottomPadding: 0
0034 
0035     contentItem: ColumnLayout {
0036         spacing: 0
0037 
0038         QQC2.ToolBar {
0039             Layout.fillWidth: true
0040             implicitHeight: applicationWindow().pageStack.globalToolBar.preferredHeight
0041             visible: drawer.visible
0042 
0043             Item {
0044                 anchors.fill: parent
0045 
0046                 Kirigami.Heading {
0047                     level: 1
0048                     text: i18n("Settings")
0049                     anchors.left: parent.left
0050                     anchors.leftMargin: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
0051                     anchors.verticalCenter: parent.verticalCenter
0052                 }
0053 
0054                 QQC2.ToolButton {
0055                     id: searchButton
0056                     anchors.right: parent.right
0057                     anchors.verticalCenter: parent.verticalCenter
0058 
0059                     text: i18n("Search")
0060                     icon.name: "search"
0061                     checkable: true
0062 
0063                     onCheckedChanged: {
0064                         if (!checked) {
0065                             drawer.model.filterString = "";
0066                         }
0067                     }
0068                 }
0069 
0070             }
0071         }
0072 
0073         HeaderSearchBar {
0074             Layout.fillWidth: true
0075 
0076             model: drawer.model
0077             show: searchButton.checked
0078         }
0079 
0080         QQC2.ScrollView {
0081             id: scrollView
0082             Layout.fillHeight: true
0083             Layout.fillWidth: true
0084             z: -1
0085 
0086             property real scrollBarWidth: QQC2.ScrollBar.vertical.width
0087             QQC2.ScrollBar.horizontal.visible: false
0088 
0089             ListView {
0090                 id: listView
0091                 spacing: Kirigami.Units.smallSpacing
0092                 topMargin: Kirigami.Units.smallSpacing
0093                 bottomMargin: Kirigami.Units.smallSpacing
0094 
0095                 delegate: SidebarButton {
0096                     width: listView.width - Kirigami.Units.smallSpacing * 2
0097                     height: Kirigami.Units.gridUnit * 2
0098                     x: Kirigami.Units.smallSpacing
0099 
0100                     property bool pageInView: model.id === applicationWindow().currentModuleName
0101 
0102                     text: model.name
0103                     icon.name: model.iconName
0104                     checked: pageInView
0105 
0106                     onClicked: {
0107                         if (!pageInView) {
0108                             applicationWindow().openModule(model.id);
0109                         }
0110                         checked = Qt.binding(function() { return pageInView; });
0111                     }
0112                 }
0113             }
0114         }
0115     }
0116 }