Warning, /plasma/plasma-desktop/desktoppackage/contents/activitymanager/ActivityManager.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
0003     SPDX-FileCopyrightText: 2014 Ivan Cukic <ivan.cukic@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 import QtQuick 2.0
0009 
0010 import org.kde.plasma.components 3.0 as PlasmaComponents
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.config as KConfig  // KAuthorized
0013 import org.kde.kcmutils  // KCMLauncher
0014 
0015 
0016 FocusScope {
0017     id: root
0018     signal closed()
0019 
0020     function parentClosed() {
0021         activityBrowser.parentClosed();
0022     }
0023 
0024     //this is used to perfectly align the filter field and delegates
0025     property int cellWidth: Kirigami.Units.iconSizes.sizeForLabels * 30
0026     property int spacing: 2 * Kirigami.Units.smallSpacing
0027 
0028     property bool showSwitcherOnly: false
0029 
0030     width: Kirigami.Units.gridUnit * 16
0031 
0032     Item {
0033         id: activityBrowser
0034 
0035         property int spacing: 2 * Kirigami.Units.smallSpacing
0036 
0037         signal closeRequested()
0038 
0039         Keys.onPressed: {
0040             if (event.key === Qt.Key_Escape) {
0041                 if (heading.searchString.length > 0) {
0042                     heading.searchString = "";
0043                 } else {
0044                     activityBrowser.closeRequested();
0045                 }
0046 
0047             } else if (event.key === Qt.Key_Up) {
0048                 activityList.selectPrevious();
0049 
0050             } else if (event.key === Qt.Key_Down) {
0051                 activityList.selectNext();
0052 
0053             } else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
0054                 activityList.openSelected();
0055 
0056             } else if (event.key === Qt.Key_Tab) {
0057                 // console.log("TAB KEY");
0058 
0059             } else  {
0060                 // console.log("OTHER KEY");
0061                 // event.accepted = false;
0062                 // heading.forceActiveFocus();
0063             }
0064         }
0065 
0066         // Rectangle {
0067         //     anchors.fill : parent
0068         //     opacity      : .4
0069         //     color        : "white"
0070         // }
0071 
0072         Heading {
0073             id: heading
0074 
0075             anchors {
0076                 top: parent.top
0077                 left: parent.left
0078                 right: parent.right
0079 
0080                 leftMargin: Kirigami.Units.smallSpacing
0081                 rightMargin: Kirigami.Units.smallSpacing
0082             }
0083 
0084             visible: !root.showSwitcherOnly
0085 
0086             onCloseRequested: activityBrowser.closeRequested()
0087         }
0088 
0089         PlasmaComponents.ScrollView {
0090             anchors {
0091                 top:    heading.visible ? heading.bottom : parent.top
0092                 bottom: bottomPanel.visible ? bottomPanel.top : parent.bottom
0093                 left:   parent.left
0094                 right:  parent.right
0095                 topMargin: activityBrowser.spacing
0096             }
0097 
0098             ActivityList {
0099                 id: activityList
0100                 showSwitcherOnly: root.showSwitcherOnly
0101                 filterString: heading.searchString.toLowerCase()
0102                 itemsWidth: root.width - Kirigami.Units.smallSpacing
0103             }
0104         }
0105 
0106         Item {
0107             id: bottomPanel
0108 
0109             height: newActivityButton.height + Kirigami.Units.gridUnit
0110 
0111             visible: !root.showSwitcherOnly
0112 
0113             anchors {
0114                 bottom: parent.bottom
0115                 left: parent.left
0116                 right: parent.right
0117             }
0118 
0119             PlasmaComponents.ToolButton {
0120                 id: newActivityButton
0121 
0122                 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Create activity…")
0123                 icon.name: "list-add"
0124 
0125                 width: parent.width
0126 
0127                 onClicked: KCMLauncher.openSystemSettings("kcm_activities", "newActivity")
0128 
0129                 visible: KConfig.KAuthorized.authorize("plasma-desktop/add_activities")
0130                 opacity: newActivityDialog.status == Loader.Ready ?
0131                               1 - newActivityDialog.item.opacity : 1
0132             }
0133 
0134             Loader {
0135                 id: newActivityDialog
0136 
0137                 z: 100
0138 
0139                 anchors.bottom: newActivityButton.bottom
0140                 anchors.left:   newActivityButton.left
0141                 anchors.right:  newActivityButton.right
0142 
0143             }
0144         }
0145 
0146         onCloseRequested: root.closed()
0147 
0148         anchors.fill: parent
0149     }
0150 
0151 }
0152