melawy-plasma-plasmoid-Menu.../com.github.adhec.MenuDitto/contents/ui/main.qml

255 lines
7.0 KiB
QML

/***************************************************************************
* 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
import org.kde.plasma.plasmoid
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PC3
import org.kde.plasma.private.kicker 0.1 as Kicker
import org.kde.plasma.plasma5support 2.0 as P5Support
import org.kde.kirigami as Kirigami
import org.kde.ksvg 1.0 as KSvg
PlasmoidItem {
id: kicker
anchors.fill: parent
signal reset
preferredRepresentation: compactRepresentation
compactRepresentation: compactRepresentation
fullRepresentation: compactRepresentation
property Item dragSource: null
function action_menuedit() {
processRunner.runMenuEditor();
}
Component {
id: compactRepresentation
CompactRepresentation {}
}
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;
}
Kicker.RootModel {
id: rootModel
autoPopulate: false
appNameFormat: 0
flat: true
sorted: true
showSeparators: false
appletInterface: kicker
showAllApps: true
showRecentApps: false
showRecentDocs: false
showPowerSession: false
onShowRecentAppsChanged: {
Plasmoid.configuration.showRecentApps = showRecentApps;
}
onShowRecentDocsChanged: {
Plasmoid.configuration.showRecentDocs = showRecentDocs;
}
onRecentOrderingChanged: {
Plasmoid.configuration.recentOrdering = recentOrdering;
}
Component.onCompleted: {
favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + Plasmoid.id)
if (!Plasmoid.configuration.favoritesPortedToKAstats) {
if (favoritesModel.count < 1) {
favoritesModel.portOldFavorites(Plasmoid.configuration.favoriteApps);
}
Plasmoid.configuration.favoritesPortedToKAstats = true;
}
}
}
Connections {
target: globalFavorites
function onFavoritesChanged() {
Plasmoid.configuration.favoriteApps = target.favorites;
}
}
Connections {
target: systemFavorites
function onFavoritesChanged() {
Plasmoid.configuration.favoriteSystemActions = target.favorites;
}
}
Connections {
target: Plasmoid.configuration
function onFavoriteAppsChanged () {
globalFavorites.favorites = Plasmoid.configuration.favoriteApps;
}
function onFavoriteSystemActionsChanged () {
systemFavorites.favorites = Plasmoid.configuration.favoriteSystemActions;
}
function onHiddenApplicationsChanged(){
rootModel.refresh(); // Force refresh on hidden
}
}
Kicker.RunnerModel {
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;
}
}
Kicker.DragHelper {
id: dragHelper
}
Kicker.ProcessRunner {
id: processRunner;
}
Kicker.WindowSystem {
id: windowSystem
}
KSvg.FrameSvgItem {
id : highlightItemSvg
visible: false
imagePath: "widgets/viewitem"
prefix: "hover"
}
KSvg.FrameSvgItem {
id : panelSvg
visible: false
imagePath: "widgets/panel-background"
}
KSvg.FrameSvgItem {
id : scrollbarSvg
visible: false
imagePath: "widgets/scrollbar"
}
KSvg.FrameSvgItem {
id : backgroundSvg
visible: false
imagePath: "dialogs/background"
}
PC3.Label {
id: toolTipDelegate
width: contentWidth
height: undefined
property Item toolTip
text: toolTip ? toolTip.text : ""
textFormat: Text.PlainText
}
function resetDragSource() {
dragSource = null;
}
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()
}
]
Component.onCompleted: {
// plasmoid.setAction("menuedit", i18n("Edit Applications..."));
// //rootModel.refreshed.connect(reset);
// //dragHelper.dropped.connect(resetDragSource);
if (Plasmoid.hasOwnProperty("activationTogglesExpanded")) {
Plasmoid.activationTogglesExpanded = !kicker.isDash
}
windowSystem.focusIn.connect(enableHideOnWindowDeactivate);
kicker.hideOnWindowDeactivate = true;
//updateSvgMetrics();
//PlasmaCore.Theme.themeChanged.connect(updateSvgMetrics);
//rootModel.refreshed.connect(reset);
dragHelper.dropped.connect(resetDragSource);
}
}