Warning, /plasma/plasma-simplemenu/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2014-2015 Eike Hein <hein@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.0
0008 import QtQuick.Layouts 1.1
0009 import org.kde.plasma.plasmoid 2.0
0010 
0011 import org.kde.plasma.core 2.0 as PlasmaCore
0012 import org.kde.plasma.components 2.0 as PlasmaComponents
0013 
0014 import org.kde.plasma.private.kicker 0.1 as Kicker
0015 
0016 Item {
0017     id: kicker
0018 
0019     anchors.fill: parent
0020 
0021     signal reset
0022 
0023     property bool isDash: false
0024 
0025     Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
0026 
0027     Plasmoid.compactRepresentation: null
0028     Plasmoid.fullRepresentation: compactRepresentation
0029 
0030     property Item dragSource: null
0031 
0032     property QtObject globalFavorites: rootModel.favoritesModel
0033     property QtObject systemFavorites: rootModel.systemFavoritesModel
0034 
0035     function action_menuedit() {
0036         processRunner.runMenuEditor();
0037     }
0038 
0039     Component {
0040         id: compactRepresentation
0041         CompactRepresentation {}
0042     }
0043 
0044     Component {
0045         id: menuRepresentation
0046         MenuRepresentation {}
0047     }
0048 
0049     Kicker.RootModel {
0050         id: rootModel
0051 
0052         autoPopulate: false
0053 
0054         appNameFormat: plasmoid.configuration.appNameFormat
0055         flat: true
0056         sorted: true
0057         showSeparators: false
0058         appletInterface: plasmoid
0059 
0060         paginate: true
0061         pageSize: 24
0062 
0063         showAllApps: true
0064         showRecentApps: false
0065         showRecentDocs: false
0066         showRecentContacts: false
0067         showPowerSession: false
0068 
0069         onFavoritesModelChanged: {
0070             if ("initForClient" in favoritesModel) {
0071                 favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + plasmoid.id)
0072 
0073                 if (!plasmoid.configuration.favoritesPortedToKAstats) {
0074                     favoritesModel.portOldFavorites(plasmoid.configuration.favoriteApps);
0075                     plasmoid.configuration.favoritesPortedToKAstats = true;
0076                 }
0077             } else {
0078                 favoritesModel.favorites = plasmoid.configuration.favoriteApps;
0079             }
0080 
0081             favoritesModel.maxFavorites = pageSize;
0082         }
0083 
0084         onSystemFavoritesModelChanged: {
0085             systemFavoritesModel.enabled = false;
0086             systemFavoritesModel.favorites = plasmoid.configuration.favoriteSystemActions;
0087             systemFavoritesModel.maxFavorites = 6;
0088         }
0089 
0090         Component.onCompleted: {
0091             if ("initForClient" in favoritesModel) {
0092                 favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + plasmoid.id)
0093 
0094                 if (!plasmoid.configuration.favoritesPortedToKAstats) {
0095                     favoritesModel.portOldFavorites(plasmoid.configuration.favoriteApps);
0096                     plasmoid.configuration.favoritesPortedToKAstats = true;
0097                 }
0098             } else {
0099                 favoritesModel.favorites = plasmoid.configuration.favoriteApps;
0100             }
0101 
0102             favoritesModel.maxFavorites = pageSize;
0103             rootModel.refresh();
0104         }
0105     }
0106 
0107     Connections {
0108         target: globalFavorites
0109 
0110         onFavoritesChanged: {
0111             plasmoid.configuration.favoriteApps = target.favorites;
0112         }
0113     }
0114 
0115     Connections {
0116         target: systemFavorites
0117 
0118         onFavoritesChanged: {
0119             plasmoid.configuration.favoriteSystemActions = target.favorites;
0120         }
0121     }
0122 
0123     Connections {
0124         target: plasmoid.configuration
0125 
0126         onFavoriteAppsChanged: {
0127             globalFavorites.favorites = plasmoid.configuration.favoriteApps;
0128         }
0129 
0130         onFavoriteSystemActionsChanged: {
0131             systemFavorites.favorites = plasmoid.configuration.favoriteSystemActions;
0132         }
0133     }
0134 
0135     Kicker.RunnerModel {
0136         id: runnerModel
0137 
0138         favoritesModel: globalFavorites
0139         runners: plasmoid.configuration.useExtraRunners ? new Array("services").concat(plasmoid.configuration.extraRunners) : "services"
0140         appletInterface: plasmoid
0141 
0142         deleteWhenEmpty: false
0143     }
0144 
0145     Kicker.DragHelper {
0146         id: dragHelper
0147     }
0148 
0149     Kicker.ProcessRunner {
0150         id: processRunner;
0151     }
0152 
0153     PlasmaCore.FrameSvgItem {
0154         id : highlightItemSvg
0155 
0156         visible: false
0157 
0158         imagePath: "widgets/viewitem"
0159         prefix: "hover"
0160     }
0161 
0162     PlasmaCore.FrameSvgItem {
0163         id : panelSvg
0164 
0165         visible: false
0166 
0167         imagePath: "widgets/panel-background"
0168     }
0169 
0170     PlasmaComponents.Label {
0171         id: toolTipDelegate
0172 
0173         width: contentWidth
0174         height: contentHeight
0175 
0176         property Item toolTip
0177 
0178         text: (toolTip != null) ? toolTip.text : ""
0179     }
0180 
0181     function resetDragSource() {
0182         dragSource = null;
0183     }
0184 
0185     Component.onCompleted: {
0186         plasmoid.setAction("menuedit", i18n("Edit Applications..."));
0187 
0188         rootModel.refreshed.connect(reset);
0189 
0190         dragHelper.dropped.connect(resetDragSource);
0191     }
0192 }