melawy-plasma-plasmoid-Onze.../com.github.adhec.OnzeMenuKDE/contents/ui/main.qml

185 lines
5.4 KiB
QML
Raw Permalink Normal View History

2023-04-17 20:56:22 +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
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.private.kicker 0.1 as Kicker
Item {
id: kicker
anchors.fill: parent
signal reset
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.compactRepresentation: null
Plasmoid.fullRepresentation: compactRepresentation
property Item dragSource: null
function action_menuedit() {
processRunner.runMenuEditor();
}
Component {
id: compactRepresentation
CompactRepresentation {}
}
Component {
id: menuRepresentation
MenuRepresentation {}
}
2023-07-02 11:51:48 +05:00
readonly property Kicker.RootModel rootModel: Kicker.RootModel {
2023-04-17 20:56:22 +05:00
id: rootModel
autoPopulate: false
appletInterface: plasmoid
2023-07-02 11:51:48 +05:00
flat: true // have categories, but no subcategories
showSeparators: false
showTopLevelItems: false//true
2023-04-17 20:56:22 +05:00
showAllApps: true
showAllAppsCategorized: true
showRecentApps: true
showRecentDocs: true
showRecentContacts: false
2023-07-02 11:51:48 +05:00
showPowerSession: false
2023-04-17 20:56:22 +05:00
Component.onCompleted: {
2023-07-02 11:51:48 +05:00
favoritesModel.initForClient("org.kde.plasma.kickoff.favorites.instance-" + plasmoid.id)
if (!plasmoid.configuration.favoritesPortedToKAstats) {
if (favoritesModel.count < 1) {
favoritesModel.portOldFavorites(plasmoid.configuration.favorites);
2023-04-17 20:56:22 +05:00
}
2023-07-02 11:51:48 +05:00
plasmoid.configuration.favoritesPortedToKAstats = true;
2023-04-17 20:56:22 +05:00
}
}
}
2023-07-02 11:51:48 +05:00
readonly property Kicker.RecentUsageModel frequentUsageModel: Kicker.RecentUsageModel {
favoritesModel: rootModel.favoritesModel
ordering: 1 // Popular / Frequently Used
2023-04-17 20:56:22 +05:00
}
2023-07-02 11:51:48 +05:00
readonly property Kicker.RecentUsageModel recentUsageModel: Kicker.RecentUsageModel {
favoritesModel: rootModel.favoritesModel
2023-04-17 20:56:22 +05:00
}
Kicker.RunnerModel {
id: runnerModel
appletInterface: plasmoid
2023-07-02 11:51:48 +05:00
favoritesModel: rootModel.favoritesModel
mergeResults: false
2023-04-17 20:56:22 +05:00
deleteWhenEmpty: true
}
Kicker.DragHelper {
id: dragHelper
}
Kicker.ProcessRunner {
id: processRunner;
}
Kicker.WindowSystem {
id: windowSystem
}
2023-07-02 11:51:48 +05:00
Connections {
target: plasmoid.configuration
function onHiddenApplicationsChanged(){
rootModel.refresh(); // Force refresh on hidden
}
}
2023-04-17 20:56:22 +05:00
PlasmaCore.FrameSvgItem {
id : highlightItemSvg
visible: false
imagePath: "widgets/viewitem"
prefix: "hover"
}
PlasmaCore.FrameSvgItem {
id : panelSvg
visible: false
imagePath: "widgets/panel-background"
}
PlasmaCore.FrameSvgItem {
id : backgroundSvg
visible: false
imagePath: "dialogs/background"
}
PlasmaComponents.Label {
id: toolTipDelegate
width: contentWidth
height: contentHeight
property Item toolTip
text: (toolTip != null) ? toolTip.text : ""
}
function resetDragSource() {
dragSource = null;
}
function enableHideOnWindowDeactivate() {
plasmoid.hideOnWindowDeactivate = true;
}
Component.onCompleted: {
//plasmoid.setAction("menuedit", i18n("Edit Applications..."));
//rootModel.refreshed.connect(reset);
//dragHelper.dropped.connect(resetDragSource);
if (plasmoid.hasOwnProperty("activationTogglesExpanded")) {
2023-07-02 11:51:48 +05:00
plasmoid.activationTogglesExpanded = false
2023-04-17 20:56:22 +05:00
}
windowSystem.focusIn.connect(enableHideOnWindowDeactivate);
plasmoid.hideOnWindowDeactivate = true;
if (plasmoid.immutability !== PlasmaCore.Types.SystemImmutable) {
plasmoid.setAction("menuedit", i18n("Edit Applications…"), "kmenuedit");
}
//updateSvgMetrics();
2023-07-02 11:51:48 +05:00
//PlasmaCore.Theme.themeChanged.connect(updateSvgMetrics);
2023-04-17 20:56:22 +05:00
dragHelper.dropped.connect(resetDragSource);
}
}