2021-07-16 19:33:52 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2014-2015 by Eike Hein <hein@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Layouts 1.1
|
2023-08-24 22:32:11 +00:00
|
|
|
import org.kde.plasma.plasmoid 2.0
|
2024-08-09 01:20:25 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
|
|
|
import org.kde.plasma.components as PlasmaComponents
|
2021-07-16 19:33:52 +00:00
|
|
|
import org.kde.plasma.private.kicker 0.1 as Kicker
|
2024-08-09 01:20:25 +00:00
|
|
|
import org.kde.kquickcontrolsaddons as KQuickControlsAddons
|
|
|
|
import org.kde.kwindowsystem
|
|
|
|
import org.kde.ksvg as KSvg
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
import org.kde.plasma.plasma5support as Plasma5Support
|
2021-07-16 19:33:52 +00:00
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
PlasmoidItem {
|
2021-07-16 19:33:52 +00:00
|
|
|
id: kicker
|
|
|
|
|
|
|
|
signal reset
|
|
|
|
|
2023-08-24 22:32:11 +00:00
|
|
|
anchors.fill: parent
|
2021-07-16 19:33:52 +00:00
|
|
|
property bool isDash: false
|
2023-08-24 22:32:11 +00:00
|
|
|
property Item dragSource: null
|
2021-07-16 19:33:52 +00:00
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
switchWidth: isDash || !fullRepresentationItem ? 0 :fullRepresentationItem.Layout.minimumWidth
|
|
|
|
switchHeight: isDash || !fullRepresentationItem ? 0 :fullRepresentationItem.Layout.minimumHeight
|
2021-07-16 19:33:52 +00:00
|
|
|
|
|
|
|
property QtObject globalFavorites: rootModel.favoritesModel
|
|
|
|
property QtObject systemFavorites: rootModel.systemFavoritesModel
|
2024-08-09 01:20:25 +00:00
|
|
|
// I see what you did here
|
|
|
|
//property bool compositingEnabled: kwindowsystem.compositingActive
|
|
|
|
property bool compositingEnabled: KWindowSystem.isPlatformX11 ? KX11Extras.compositingActive : true
|
|
|
|
|
|
|
|
preferredRepresentation: isDash ? menuRepresentation : null
|
|
|
|
|
|
|
|
compactRepresentation: isDash ? null : compactRepresentation
|
|
|
|
fullRepresentation: isDash ? compactRepresentation : menuRepresentation
|
|
|
|
Plasmoid.constraintHints: Plasmoid.CanFillArea
|
|
|
|
|
2021-07-16 19:33:52 +00:00
|
|
|
|
2023-08-24 22:32:11 +00:00
|
|
|
// Runs KMenuEdit.
|
2021-07-16 19:33:52 +00:00
|
|
|
function action_menuedit() {
|
|
|
|
processRunner.runMenuEditor();
|
|
|
|
}
|
2023-08-24 22:32:11 +00:00
|
|
|
|
2022-09-01 23:00:01 +00:00
|
|
|
function action_taskman() {
|
|
|
|
menu_executable.exec("ksysguard");
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
|
2021-07-16 19:33:52 +00:00
|
|
|
Component {
|
|
|
|
id: compactRepresentation
|
|
|
|
CompactRepresentation {}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: menuRepresentation
|
2024-01-20 02:08:06 +00:00
|
|
|
MenuRepresentation { }
|
2023-08-24 22:32:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Used to run separate programs through this plasmoid.
|
2024-08-09 01:20:25 +00:00
|
|
|
Plasma5Support.DataSource {
|
2023-08-24 22:32:11 +00:00
|
|
|
id: menu_executable
|
|
|
|
engine: "executable"
|
|
|
|
connectedSources: []
|
|
|
|
onNewData: {
|
|
|
|
var exitCode = data["exit code"]
|
|
|
|
var exitStatus = data["exit status"]
|
|
|
|
var stdout = data["stdout"]
|
|
|
|
var stderr = data["stderr"]
|
|
|
|
exited(sourceName, exitCode, exitStatus, stdout, stderr)
|
|
|
|
disconnectSource(sourceName)
|
|
|
|
}
|
|
|
|
function exec(cmd) {
|
|
|
|
if (cmd) {
|
|
|
|
connectSource(cmd)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
signal exited(string cmd, int exitCode, int exitStatus, string stdout, string stderr)
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
Kicker.WindowSystem {
|
|
|
|
id: windowSystem
|
|
|
|
}
|
|
|
|
|
|
|
|
Kicker.RecentUsageModel {
|
|
|
|
id: recentUsageModel
|
|
|
|
favoritesModel: globalFavorites
|
|
|
|
ordering: 0
|
|
|
|
shownItems: Kicker.RecentUsageModel.OnlyApps
|
|
|
|
}
|
|
|
|
|
|
|
|
Kicker.RunnerModel {
|
|
|
|
id: runnerModel
|
|
|
|
|
|
|
|
appletInterface: kicker
|
|
|
|
|
|
|
|
//query: kickoff.searchField ? kickoff.searchField.text : ""
|
|
|
|
//deleteWhenEmpty: false
|
|
|
|
favoritesModel: rootModel.favoritesModel
|
|
|
|
//runners: ["Dictionary","services","calculator","shell","org.kde.windowedwidgets","org.kde.datetime","baloosearch","locations","unitconverter","bookmarks", "krunner_services", "krunner_systemsettings", "krunner_sessions", "krunner_powerdevil"]
|
|
|
|
/*runners: {
|
|
|
|
const results = ["Dictionary","services","calculator","shell","org.kde.windowedwidgets","org.kde.datetime","baloosearch","locations","unitconverter","bookmarks", "krunner_services", "krunner_systemsettings", "krunner_sessions", "krunner_powerdevil"];
|
|
|
|
|
|
|
|
if (Plasmoid.configuration.useExtraRunners) {
|
|
|
|
results.push(...Plasmoid.configuration.extraRunners);
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
}*/
|
|
|
|
mergeResults: true
|
|
|
|
}
|
|
|
|
//KWindowSystem { id: kwindowsystem } // Used for detecting compositing changes.
|
2021-07-16 19:33:52 +00:00
|
|
|
Kicker.RootModel {
|
|
|
|
id: rootModel
|
|
|
|
|
|
|
|
autoPopulate: false
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
appNameFormat: Plasmoid.configuration.appNameFormat
|
2021-07-16 19:33:52 +00:00
|
|
|
flat: true
|
|
|
|
sorted: true
|
2024-01-20 02:08:06 +00:00
|
|
|
showSeparators: false
|
2024-08-09 01:20:25 +00:00
|
|
|
appletInterface: kicker
|
2021-07-16 19:33:52 +00:00
|
|
|
|
2022-09-01 23:00:01 +00:00
|
|
|
paginate: false
|
2024-08-09 01:20:25 +00:00
|
|
|
pageSize: Plasmoid.configuration.numberColumns * Plasmoid.configuration.numberRows
|
2021-07-16 19:33:52 +00:00
|
|
|
|
2022-09-01 23:00:01 +00:00
|
|
|
showAllApps: false
|
2024-01-20 02:08:06 +00:00
|
|
|
showAllAppsCategorized: false
|
2022-09-01 23:00:01 +00:00
|
|
|
showRecentApps: true
|
2021-07-16 19:33:52 +00:00
|
|
|
showRecentDocs: false
|
2024-08-09 01:20:25 +00:00
|
|
|
//showRecentContacts: false
|
2021-07-16 19:33:52 +00:00
|
|
|
showPowerSession: false
|
|
|
|
|
|
|
|
onFavoritesModelChanged: {
|
|
|
|
if ("initForClient" in favoritesModel) {
|
|
|
|
favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + plasmoid.id)
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
if (!Plasmoid.configuration.favoritesPortedToKAstats) {
|
|
|
|
favoritesModel.portOldFavorites(Plasmoid.configuration.favoriteApps);
|
|
|
|
Plasmoid.configuration.favoritesPortedToKAstats = true;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
} else {
|
2024-08-09 01:20:25 +00:00
|
|
|
favoritesModel.favorites = Plasmoid.configuration.favoriteApps;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
favoritesModel.maxFavorites = pageSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSystemFavoritesModelChanged: {
|
|
|
|
systemFavoritesModel.enabled = false;
|
2024-08-09 01:20:25 +00:00
|
|
|
systemFavoritesModel.favorites = Plasmoid.configuration.favoriteSystemActions;
|
2021-07-16 19:33:52 +00:00
|
|
|
systemFavoritesModel.maxFavorites = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
if ("initForClient" in favoritesModel) {
|
|
|
|
favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + plasmoid.id)
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
if (!Plasmoid.configuration.favoritesPortedToKAstats) {
|
|
|
|
favoritesModel.portOldFavorites(Plasmoid.configuration.favoriteApps);
|
|
|
|
Plasmoid.configuration.favoritesPortedToKAstats = true;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
} else {
|
2024-08-09 01:20:25 +00:00
|
|
|
favoritesModel.favorites = Plasmoid.configuration.favoriteApps;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
favoritesModel.maxFavorites = pageSize;
|
|
|
|
rootModel.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: globalFavorites
|
|
|
|
|
2023-08-24 22:32:11 +00:00
|
|
|
function onFavoritesChanged() {
|
2024-08-09 01:20:25 +00:00
|
|
|
Plasmoid.configuration.favoriteApps = target.favorites;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: systemFavorites
|
|
|
|
|
2023-08-24 22:32:11 +00:00
|
|
|
function onFavoritesChanged() {
|
2024-08-09 01:20:25 +00:00
|
|
|
Plasmoid.configuration.favoriteSystemActions = target.favorites;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2024-08-09 01:20:25 +00:00
|
|
|
target: Plasmoid.configuration
|
2021-07-16 19:33:52 +00:00
|
|
|
|
2023-08-24 22:32:11 +00:00
|
|
|
function onFavoriteAppsChanged() {
|
2024-08-09 01:20:25 +00:00
|
|
|
globalFavorites.favorites = Plasmoid.configuration.favoriteApps;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
|
2023-08-24 22:32:11 +00:00
|
|
|
function onFavoriteSystemActionsChanged() {
|
2024-08-09 01:20:25 +00:00
|
|
|
systemFavorites.favorites = Plasmoid.configuration.favoriteSystemActions;
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Kicker.DragHelper {
|
|
|
|
id: dragHelper
|
|
|
|
}
|
|
|
|
|
|
|
|
Kicker.ProcessRunner {
|
2023-08-24 22:32:11 +00:00
|
|
|
id: processRunner
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|
|
|
|
|
2023-08-24 22:32:11 +00:00
|
|
|
// SVGs
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.FrameSvgItem {
|
2021-07-16 19:33:52 +00:00
|
|
|
id : highlightItemSvg
|
|
|
|
visible: false
|
2023-08-24 22:32:11 +00:00
|
|
|
imagePath: Qt.resolvedUrl("svgs/menuitem.svg")
|
2021-07-16 19:33:52 +00:00
|
|
|
prefix: "hover"
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.FrameSvgItem {
|
2021-07-16 19:33:52 +00:00
|
|
|
id : panelSvg
|
|
|
|
visible: false
|
|
|
|
imagePath: "widgets/panel-background"
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.Svg {
|
2022-09-01 23:00:01 +00:00
|
|
|
id: arrowsSvg
|
2023-08-24 22:32:11 +00:00
|
|
|
imagePath: Qt.resolvedUrl("svgs/arrows.svgz")
|
2022-09-01 23:00:01 +00:00
|
|
|
size: "16x16"
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.Svg {
|
2024-01-20 02:08:06 +00:00
|
|
|
id: separatorSvg
|
|
|
|
imagePath: Qt.resolvedUrl("svgs/sidebarseparator.svg")
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.Svg {
|
2022-11-20 00:17:12 +00:00
|
|
|
id: lockScreenSvg
|
2023-08-24 22:32:11 +00:00
|
|
|
imagePath: Qt.resolvedUrl("svgs/system-lock-screen.svg")
|
2022-11-20 00:17:12 +00:00
|
|
|
}
|
2023-08-24 22:32:11 +00:00
|
|
|
|
2021-07-16 19:33:52 +00:00
|
|
|
PlasmaComponents.Label {
|
|
|
|
id: toolTipDelegate
|
|
|
|
|
|
|
|
width: contentWidth
|
|
|
|
height: contentHeight
|
|
|
|
|
|
|
|
property Item toolTip
|
|
|
|
|
|
|
|
text: (toolTip != null) ? toolTip.text : ""
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetDragSource() {
|
|
|
|
dragSource = null;
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
function enableHideOnWindowDeactivate() {
|
|
|
|
kicker.hideOnWindowDeactivate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Plasmoid.contextualActions: [
|
|
|
|
PlasmaCore.Action {
|
|
|
|
text: i18n("Edit Applications...")
|
|
|
|
icon.name: "application-menu"
|
|
|
|
onTriggered: menu_executable.exec("kmenuedit");
|
|
|
|
},
|
|
|
|
PlasmaCore.Action {
|
|
|
|
text: i18n("Task Manager")
|
|
|
|
icon.name: "ksysguardd"
|
|
|
|
onTriggered: menu_executable.exec("ksysguard");
|
|
|
|
}
|
|
|
|
]
|
2021-07-16 19:33:52 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2024-08-09 01:20:25 +00:00
|
|
|
if (Plasmoid.hasOwnProperty("activationTogglesExpanded")) {
|
|
|
|
Plasmoid.activationTogglesExpanded = !kicker.isDash
|
|
|
|
}
|
|
|
|
|
|
|
|
windowSystem.focusIn.connect(enableHideOnWindowDeactivate);
|
|
|
|
kicker.hideOnWindowDeactivate = true;
|
2021-07-16 19:33:52 +00:00
|
|
|
|
|
|
|
rootModel.refreshed.connect(reset);
|
|
|
|
|
|
|
|
dragHelper.dropped.connect(resetDragSource);
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
|
2021-07-16 19:33:52 +00:00
|
|
|
}
|