Warning, /system/plasma-packagekit/applet/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 Copyright © 2017 Harald Sitter <sitter@kde.org>
0003
0004 This program is free software; you can redistribute it and/or
0005 modify it under the terms of the GNU General Public License as
0006 published by the Free Software Foundation; either version 2 of
0007 the License or (at your option) version 3 or any later version
0008 accepted by the membership of KDE e.V. (or its successor approved
0009 by the membership of KDE e.V.), which shall act as a proxy
0010 defined in Section 14 of version 3 of the license.
0011
0012 This program is distributed in the hope that it will be useful,
0013 but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0015 GNU General Public License for more details.
0016
0017 You should have received a copy of the GNU General Public License
0018 along with this program. If not, see <http://www.gnu.org/licenses/>.
0019 */
0020
0021 import QtQuick 2.0
0022 import QtQuick.Layouts 1.0
0023
0024 import org.kde.plasma.core 2.1 as PlasmaCore
0025 import org.kde.plasma.extras 2.0 as PlasmaExtras
0026 import org.kde.plasma.plasmoid 2.0
0027
0028 import org.kde.plasma.private.packagekit 0.1
0029
0030 import "../code/role.js" as Role
0031
0032 Item {
0033 id: main
0034
0035 function stateText() {
0036 return Daemon.isRunning ? i18n("PackageKit is Running") : i18n("PackageKit is not Running")
0037 }
0038
0039 function flavorText() {
0040 var options = ['']
0041
0042 if (Daemon.isRunning && Daemon.locked) {
0043 // Running and doing something important.
0044 options = [
0045 i18n("Aligning the Flux Capacitor"),
0046 i18n("Preparing for brain surgery"),
0047 i18n("Initiating launch sequence"),
0048 i18n("Checking matrix for glitches"),
0049 i18n("Using the Force")
0050 ]
0051 } else if (Daemon.isRunning && !Daemon.locked) {
0052 // Running but not doing anything worthwhile.
0053 options = [
0054 i18n("Watering the flowers"),
0055 i18n("Having a chat with Systemd"),
0056 i18n("Ordering some pizza"),
0057 i18n("Dusting the bookshelf"),
0058 i18n("Learning the flute")
0059 ]
0060 } else if (!Daemon.isRunning) {
0061 // Not even running
0062 options = [
0063 i18n("zzzzZZZZZZzz")
0064 ]
0065 }
0066
0067 return options[Math.floor(Math.random() * options.length)];
0068 }
0069
0070 Layout.minimumHeight: units.gridUnit * 12
0071 Layout.minimumWidth: units.gridUnit * 12
0072 Layout.preferredHeight: units.gridUnit * 20
0073 Layout.preferredWidth: units.gridUnit * 20
0074 // Plasmoid.switchWidth: units.gridUnit * 12
0075 // Plasmoid.switchHeight: units.gridUnit * 12
0076
0077 // State is set through timer so we avoid state-switch spam (see below).
0078 Plasmoid.status: PlasmaCore.Types.PassiveStatus
0079 // FIXME: need to talk to AndreasK about iconing
0080 Plasmoid.icon: "apper" // plasmoid.status === PlasmaCore.Types.ActiveStatus ? "package-install" : "apper"
0081 Plasmoid.toolTipMainText: stateText()
0082 Plasmoid.toolTipSubText: flavorText()
0083 Plasmoid.compactRepresentation: PlasmaCore.IconItem {
0084 source: plasmoid.icon
0085 colorGroup: PlasmaCore.ColorScope.colorGroup
0086 }
0087
0088 Connections {
0089 target: Daemon
0090 onIsRunningChanged: {
0091 plasmoid.toolTipMainText = stateText()
0092 plasmoid.toolTipSubText = flavorText()
0093 }
0094 onLockedChanged: {
0095 plasmoid.toolTipSubText = flavorText()
0096 }
0097 }
0098
0099 StateSwitcher {}
0100
0101 ListView {
0102 anchors.fill: parent
0103 model: FilteredTransactionModel {
0104 id: transactionModel
0105 filters: Role.mappedRoles() // Whitelist
0106 onCountChanged: plasmoid.toolTipSubText = flavorText()
0107 }
0108 delegate: TransactionListItem {}
0109 }
0110
0111 PlasmaExtras.Heading {
0112 anchors.centerIn: parent
0113 level: 3
0114 opacity: 0.6
0115 text: plasmoid.toolTipSubText
0116 visible: transactionModel.count === 0
0117 }
0118 }