Warning, /plasma/plasma-desktop/applets/kicker/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.15
0008 import QtQuick.Layouts 1.15
0009
0010 import org.kde.plasma.components 3.0 as PlasmaComponents3
0011 import org.kde.plasma.core as PlasmaCore
0012 import org.kde.ksvg 1.0 as KSvg
0013 import org.kde.plasma.plasmoid 2.0
0014 import org.kde.kirigami 2.20 as Kirigami
0015
0016 import org.kde.plasma.private.kicker 0.1 as Kicker
0017
0018 PlasmoidItem {
0019 id: kicker
0020
0021 anchors.fill: parent
0022
0023 signal reset
0024
0025 property bool isDash: Plasmoid.pluginName === "org.kde.plasma.kickerdash"
0026
0027 switchWidth: isDash || !fullRepresentationItem ? 0 :fullRepresentationItem.Layout.minimumWidth
0028 switchHeight: isDash || !fullRepresentationItem ? 0 :fullRepresentationItem.Layout.minimumHeight
0029
0030 // this is a bit of a hack to prevent Plasma from spawning a dialog on its own when we're Dash
0031 preferredRepresentation: isDash ?fullRepresentation : null
0032
0033 compactRepresentation: isDash ? null : compactRepresentation
0034 fullRepresentation: isDash ? compactRepresentation : menuRepresentation
0035
0036 property Component itemListDialogComponent: Qt.createComponent(Qt.resolvedUrl("./ItemListDialog.qml"))
0037 property Item dragSource: null
0038
0039 property QtObject globalFavorites: rootModel.favoritesModel
0040 property QtObject systemFavorites: rootModel.systemFavoritesModel
0041
0042 Plasmoid.icon: Plasmoid.configuration.useCustomButtonImage ? Plasmoid.configuration.customButtonImage : Plasmoid.configuration.icon
0043
0044 onSystemFavoritesChanged: {
0045 systemFavorites.favorites = Plasmoid.configuration.favoriteSystemActions;
0046 }
0047
0048 function action_menuedit() {
0049 processRunner.runMenuEditor();
0050 }
0051
0052 function updateSvgMetrics() {
0053 lineSvg.horLineHeight = lineSvg.elementSize("horizontal-line").height;
0054 lineSvg.vertLineWidth = lineSvg.elementSize("vertical-line").width;
0055 }
0056
0057 Component {
0058 id: compactRepresentation
0059 CompactRepresentation {}
0060 }
0061
0062 Component {
0063 id: menuRepresentation
0064 MenuRepresentation {}
0065 }
0066
0067 Kicker.RootModel {
0068 id: rootModel
0069
0070 autoPopulate: false
0071
0072 appNameFormat: Plasmoid.configuration.appNameFormat
0073 flat: kicker.isDash || Plasmoid.configuration.limitDepth
0074 sorted: Plasmoid.configuration.alphaSort
0075 showSeparators: !kicker.isDash
0076 // TODO: appletInterface property now can be ported to "applet" and have the real Applet* assigned directly
0077 appletInterface: kicker
0078
0079 showAllApps: kicker.isDash
0080 showAllAppsCategorized: true
0081 showTopLevelItems: !kicker.isDash
0082 showRecentApps: Plasmoid.configuration.showRecentApps
0083 showRecentDocs: Plasmoid.configuration.showRecentDocs
0084 recentOrdering: Plasmoid.configuration.recentOrdering
0085
0086 onShowRecentAppsChanged: {
0087 Plasmoid.configuration.showRecentApps = showRecentApps;
0088 }
0089
0090 onShowRecentDocsChanged: {
0091 Plasmoid.configuration.showRecentDocs = showRecentDocs;
0092 }
0093
0094 onRecentOrderingChanged: {
0095 Plasmoid.configuration.recentOrdering = recentOrdering;
0096 }
0097
0098 Component.onCompleted: {
0099 favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + Plasmoid.id)
0100
0101 if (!Plasmoid.configuration.favoritesPortedToKAstats) {
0102 if (favoritesModel.count < 1) {
0103 favoritesModel.portOldFavorites(Plasmoid.configuration.favoriteApps);
0104 }
0105 Plasmoid.configuration.favoritesPortedToKAstats = true;
0106 }
0107 }
0108 }
0109
0110 Connections {
0111 target: globalFavorites
0112
0113 function onFavoritesChanged() {
0114 Plasmoid.configuration.favoriteApps = target.favorites;
0115 }
0116 }
0117
0118 Connections {
0119 target: systemFavorites
0120
0121 function onFavoritesChanged() {
0122 Plasmoid.configuration.favoriteSystemActions = target.favorites;
0123 }
0124 }
0125
0126 Connections {
0127 target: Plasmoid.configuration
0128
0129 function onFavoriteAppsChanged() {
0130 globalFavorites.favorites = Plasmoid.configuration.favoriteApps;
0131 }
0132
0133 function onFavoriteSystemActionsChanged() {
0134 systemFavorites.favorites = Plasmoid.configuration.favoriteSystemActions;
0135 }
0136 }
0137
0138 Kicker.RunnerModel {
0139 id: runnerModel
0140
0141 appletInterface: kicker
0142
0143 favoritesModel: globalFavorites
0144
0145 runners: {
0146 const results = ["krunner_services", "krunner_systemsettings"];
0147
0148 if (kicker.isDash) {
0149 results.push("krunner_sessions", "krunner_powerdevil", "calculator", "unitconverter");
0150 }
0151
0152 if (Plasmoid.configuration.useExtraRunners) {
0153 results.push(...Plasmoid.configuration.extraRunners);
0154 }
0155
0156 return results;
0157 }
0158 }
0159
0160 Kicker.DragHelper {
0161 id: dragHelper
0162
0163 dragIconSize: Kirigami.Units.iconSizes.medium
0164 }
0165
0166 Kicker.ProcessRunner {
0167 id: processRunner
0168 }
0169
0170 Kicker.WindowSystem {
0171 id: windowSystem
0172 }
0173
0174 KSvg.FrameSvgItem {
0175 id: highlightItemSvg
0176
0177 visible: false
0178
0179 imagePath: "widgets/viewitem"
0180 prefix: "hover"
0181 }
0182
0183 KSvg.FrameSvgItem {
0184 id: listItemSvg
0185
0186 visible: false
0187
0188 imagePath: "widgets/listitem"
0189 prefix: "normal"
0190 }
0191
0192 KSvg.Svg {
0193 id: lineSvg
0194 imagePath: "widgets/line"
0195
0196 property int horLineHeight
0197 property int vertLineWidth
0198 }
0199
0200 PlasmaComponents3.Label {
0201 id: toolTipDelegate
0202
0203 width: contentWidth
0204 height: undefined
0205
0206 property Item toolTip
0207
0208 text: toolTip ? toolTip.text : ""
0209 textFormat: Text.PlainText
0210 }
0211
0212 Timer {
0213 id: justOpenedTimer
0214
0215 repeat: false
0216 interval: 600
0217 }
0218
0219 Connections {
0220 target: kicker
0221
0222 function onExpandedChanged(expanded) {
0223 if (expanded) {
0224 windowSystem.monitorWindowVisibility(Plasmoid.fullRepresentationItem);
0225 justOpenedTimer.start();
0226 } else {
0227 kicker.reset();
0228 }
0229 }
0230 }
0231
0232 function resetDragSource() {
0233 dragSource = null;
0234 }
0235
0236 function enableHideOnWindowDeactivate() {
0237 Plasmoid.hideOnWindowDeactivate = true;
0238 }
0239
0240 Plasmoid.contextualActions: [
0241 PlasmaCore.Action {
0242 text: i18n("Edit Applications…")
0243 icon.name: "kmenuedit"
0244 visible: Plasmoid.immutability !== PlasmaCore.Types.SystemImmutable
0245 onTriggered: processRunner.runMenuEditor()
0246 }
0247 ]
0248
0249 Component.onCompleted: {
0250 if (Plasmoid.hasOwnProperty("activationTogglesExpanded")) {
0251 Plasmoid.activationTogglesExpanded = !kicker.isDash
0252 }
0253
0254 windowSystem.focusIn.connect(enableHideOnWindowDeactivate);
0255 kicker.hideOnWindowDeactivate = true;
0256
0257 updateSvgMetrics();
0258 PlasmaCore.Theme.themeChanged.connect(updateSvgMetrics);
0259
0260 rootModel.refreshed.connect(reset);
0261
0262 dragHelper.dropped.connect(resetDragSource);
0263 }
0264 }