Warning, /plasma/plasma-desktop/applets/kickoff/package/contents/ui/PlacesPage.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2021 Mikel Johnson <mikel5764@gmail.com>
0003 * SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com>
0004 * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.15
0009 import QtQuick.Templates 2.15 as T
0010 import QtQml 2.15
0011
0012 BasePage {
0013 id: root
0014 sideBarComponent: KickoffListView {
0015 id: sideBar
0016 focus: true // needed for Loaders
0017 model: placesCategoryModel
0018 delegate: KickoffListDelegate {
0019 url: ""
0020 description: ""
0021 width: view.availableWidth
0022 isCategoryListItem: true
0023 }
0024 }
0025 contentAreaComponent: KickoffListView {
0026 id: contentArea
0027 mainContentView: true
0028 focus: true
0029 objectName: "frequentlyUsedView"
0030 model: switch (root.sideBarItem.currentIndex) {
0031 case 0: return kickoff.computerModel
0032 case 1: return kickoff.recentUsageModel
0033 case 2: return kickoff.frequentUsageModel
0034 }
0035 onActiveFocusChanged: if (activeFocus && count < 1) {
0036 root.sideBarItem.forceActiveFocus()
0037 }
0038 }
0039
0040 // we make our model ourselves
0041 ListModel {
0042 id: placesCategoryModel
0043 ListElement { display: "Computer"; decoration: "computer" }
0044 ListElement { display: "History"; decoration: "view-history" }
0045 ListElement { display: "Frequently Used"; decoration: "clock" }
0046 Component.onCompleted: {
0047 // Can't use a function in a QML ListElement declaration
0048 placesCategoryModel.setProperty(0, "display", i18nc("category in Places sidebar", "Computer"))
0049 placesCategoryModel.setProperty(1, "display", i18nc("category in Places sidebar", "History"))
0050 placesCategoryModel.setProperty(2, "display", i18nc("category in Places sidebar", "Frequently Used"))
0051 if (KickoffSingleton.powerManagement.data["PowerDevil"]
0052 && KickoffSingleton.powerManagement.data["PowerDevil"]["Is Lid Present"]) {
0053 placesCategoryModel.setProperty(0, "decoration", "computer-laptop")
0054 }
0055 }
0056 }
0057 // NormalPage doesn't get destroyed when deactivated, so the binding uses
0058 // StackView.status and visible. This way the bindings are reset when
0059 // NormalPage is Activated again.
0060 Binding {
0061 target: kickoff
0062 property: "sideBar"
0063 value: root.sideBarItem
0064 when: root.T.StackView.status === T.StackView.Active && root.visible
0065 restoreMode: Binding.RestoreBinding
0066 }
0067 Binding {
0068 target: kickoff
0069 property: "contentArea"
0070 value: root.contentAreaItem // NOT root.contentAreaItem.currentItem
0071 when: root.T.StackView.status === T.StackView.Active && root.visible
0072 restoreMode: Binding.RestoreBinding
0073 }
0074 }