2023-05-02 10:11:19 +05: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
|
2024-10-07 22:45:20 +05:00
|
|
|
|
|
|
|
import org.kde.plasma.plasmoid
|
2023-05-02 10:11:19 +05:00
|
|
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2024-10-07 22:45:20 +05:00
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2023-05-02 10:11:19 +05:00
|
|
|
|
|
|
|
import org.kde.plasma.private.kicker 0.1 as Kicker
|
2024-10-07 22:45:20 +05:00
|
|
|
import org.kde.plasma.plasma5support 2.0 as P5Support
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
import org.kde.ksvg 1.0 as KSvg
|
|
|
|
|
|
|
|
PlasmoidItem {
|
2023-05-02 10:11:19 +05:00
|
|
|
|
|
|
|
id: kicker
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
signal reset
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
preferredRepresentation: compactRepresentation
|
|
|
|
compactRepresentation: compactRepresentation
|
|
|
|
fullRepresentation: compactRepresentation
|
2023-05-02 10:11:19 +05:00
|
|
|
|
|
|
|
property Item dragSource: null
|
|
|
|
|
|
|
|
function action_menuedit() {
|
|
|
|
processRunner.runMenuEditor();
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: compactRepresentation
|
|
|
|
CompactRepresentation {}
|
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
property QtObject globalFavorites: rootModel.favoritesModel
|
|
|
|
property QtObject systemFavorites: rootModel.systemFavoritesModel
|
|
|
|
|
|
|
|
Plasmoid.icon: Plasmoid.configuration.useCustomButtonImage ? Plasmoid.configuration.customButtonImage : Plasmoid.configuration.icon
|
|
|
|
|
|
|
|
onSystemFavoritesChanged: {
|
|
|
|
systemFavorites.favorites = Plasmoid.configuration.favoriteSystemActions;
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
Kicker.RootModel {
|
2023-05-02 10:11:19 +05:00
|
|
|
id: rootModel
|
|
|
|
|
|
|
|
autoPopulate: false
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
appNameFormat: 0
|
2023-05-02 10:11:19 +05:00
|
|
|
flat: true
|
|
|
|
sorted: true
|
|
|
|
showSeparators: false
|
2024-10-07 22:45:20 +05:00
|
|
|
appletInterface: kicker
|
2023-05-02 10:11:19 +05:00
|
|
|
showAllApps: true
|
|
|
|
showRecentApps: false
|
|
|
|
showRecentDocs: false
|
|
|
|
showPowerSession: false
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
onShowRecentAppsChanged: {
|
|
|
|
Plasmoid.configuration.showRecentApps = showRecentApps;
|
|
|
|
}
|
2023-05-02 10:11:19 +05:00
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
onShowRecentDocsChanged: {
|
|
|
|
Plasmoid.configuration.showRecentDocs = showRecentDocs;
|
|
|
|
}
|
|
|
|
|
|
|
|
onRecentOrderingChanged: {
|
|
|
|
Plasmoid.configuration.recentOrdering = recentOrdering;
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + Plasmoid.id)
|
2023-05-02 10:11:19 +05:00
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
if (!Plasmoid.configuration.favoritesPortedToKAstats) {
|
2023-05-02 10:11:19 +05:00
|
|
|
if (favoritesModel.count < 1) {
|
2024-10-07 22:45:20 +05:00
|
|
|
favoritesModel.portOldFavorites(Plasmoid.configuration.favoriteApps);
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
2024-10-07 22:45:20 +05:00
|
|
|
Plasmoid.configuration.favoritesPortedToKAstats = true;
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
|
2023-05-02 10:11:19 +05:00
|
|
|
Connections {
|
|
|
|
target: globalFavorites
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
function onFavoritesChanged() {
|
|
|
|
Plasmoid.configuration.favoriteApps = target.favorites;
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: systemFavorites
|
|
|
|
|
|
|
|
function onFavoritesChanged() {
|
2024-10-07 22:45:20 +05:00
|
|
|
Plasmoid.configuration.favoriteSystemActions = target.favorites;
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2024-10-07 22:45:20 +05:00
|
|
|
target: Plasmoid.configuration
|
2023-05-02 10:11:19 +05:00
|
|
|
|
|
|
|
function onFavoriteAppsChanged () {
|
2024-10-07 22:45:20 +05:00
|
|
|
globalFavorites.favorites = Plasmoid.configuration.favoriteApps;
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFavoriteSystemActionsChanged () {
|
2024-10-07 22:45:20 +05:00
|
|
|
systemFavorites.favorites = Plasmoid.configuration.favoriteSystemActions;
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
function onHiddenApplicationsChanged(){
|
|
|
|
rootModel.refresh(); // Force refresh on hidden
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Kicker.RunnerModel {
|
2024-10-07 22:45:20 +05:00
|
|
|
id: runnerModel
|
|
|
|
|
|
|
|
appletInterface: kicker
|
|
|
|
|
|
|
|
favoritesModel: globalFavorites
|
|
|
|
|
|
|
|
runners: {
|
|
|
|
const results = ["krunner_services",
|
|
|
|
"krunner_systemsettings",
|
|
|
|
"krunner_sessions",
|
|
|
|
"krunner_powerdevil",
|
|
|
|
"calculator",
|
|
|
|
"unitconverter"];
|
|
|
|
|
|
|
|
if (Plasmoid.configuration.useExtraRunners) {
|
|
|
|
results.push(...Plasmoid.configuration.extraRunners);
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
}
|
2023-05-02 10:11:19 +05:00
|
|
|
|
|
|
|
|
|
|
|
Kicker.DragHelper {
|
|
|
|
id: dragHelper
|
|
|
|
}
|
|
|
|
|
|
|
|
Kicker.ProcessRunner {
|
|
|
|
id: processRunner;
|
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
Kicker.WindowSystem {
|
|
|
|
id: windowSystem
|
|
|
|
}
|
|
|
|
|
|
|
|
KSvg.FrameSvgItem {
|
2023-05-02 10:11:19 +05:00
|
|
|
id : highlightItemSvg
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
imagePath: "widgets/viewitem"
|
|
|
|
prefix: "hover"
|
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
KSvg.FrameSvgItem {
|
2023-05-02 10:11:19 +05:00
|
|
|
id : panelSvg
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
imagePath: "widgets/panel-background"
|
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
KSvg.FrameSvgItem {
|
2023-05-02 10:11:19 +05:00
|
|
|
id : scrollbarSvg
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
imagePath: "widgets/scrollbar"
|
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
KSvg.FrameSvgItem {
|
2023-05-02 10:11:19 +05:00
|
|
|
id : backgroundSvg
|
|
|
|
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
imagePath: "dialogs/background"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
PC3.Label {
|
2023-05-02 10:11:19 +05:00
|
|
|
id: toolTipDelegate
|
|
|
|
|
|
|
|
width: contentWidth
|
2024-10-07 22:45:20 +05:00
|
|
|
height: undefined
|
2023-05-02 10:11:19 +05:00
|
|
|
|
|
|
|
property Item toolTip
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
text: toolTip ? toolTip.text : ""
|
|
|
|
textFormat: Text.PlainText
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
function resetDragSource() {
|
|
|
|
dragSource = null;
|
|
|
|
}
|
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
function enableHideOnWindowDeactivate() {
|
|
|
|
kicker.hideOnWindowDeactivate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Plasmoid.contextualActions: [
|
|
|
|
PlasmaCore.Action {
|
|
|
|
text: i18n("Edit Applications…")
|
|
|
|
icon.name: "kmenuedit"
|
|
|
|
visible: Plasmoid.immutability !== PlasmaCore.Types.SystemImmutable
|
|
|
|
onTriggered: processRunner.runMenuEditor()
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2023-05-02 10:11:19 +05:00
|
|
|
Component.onCompleted: {
|
2024-10-07 22:45:20 +05:00
|
|
|
// plasmoid.setAction("menuedit", i18n("Edit Applications..."));
|
|
|
|
// //rootModel.refreshed.connect(reset);
|
|
|
|
// //dragHelper.dropped.connect(resetDragSource);
|
2023-05-02 10:11:19 +05:00
|
|
|
|
2024-10-07 22:45:20 +05:00
|
|
|
if (Plasmoid.hasOwnProperty("activationTogglesExpanded")) {
|
|
|
|
Plasmoid.activationTogglesExpanded = !kicker.isDash
|
|
|
|
}
|
|
|
|
|
|
|
|
windowSystem.focusIn.connect(enableHideOnWindowDeactivate);
|
|
|
|
kicker.hideOnWindowDeactivate = true;
|
|
|
|
|
|
|
|
//updateSvgMetrics();
|
|
|
|
//PlasmaCore.Theme.themeChanged.connect(updateSvgMetrics);
|
2023-05-02 10:11:19 +05:00
|
|
|
//rootModel.refreshed.connect(reset);
|
2024-10-07 22:45:20 +05:00
|
|
|
dragHelper.dropped.connect(resetDragSource);
|
|
|
|
|
2023-05-02 10:11:19 +05:00
|
|
|
}
|
|
|
|
}
|