aerothemeplasma/Plasma/Plasma_Widgets/User/io.gitgud.wackyideas.SevenStart/contents/ui/main.qml

245 lines
7.6 KiB
QML
Raw Normal View History

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
2021-07-16 19:33:52 +00:00
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
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
import org.kde.kwindowsystem 1.0
2021-07-16 19:33:52 +00:00
Item {
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
clip: true
2021-07-16 19:33:52 +00:00
2023-08-24 22:32:11 +00:00
// With this we can make the compact representation be any
// item we want.
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.compactRepresentation: null
Plasmoid.fullRepresentation: compactRepresentation
2021-07-16 19:33:52 +00:00
property QtObject globalFavorites: rootModel.favoritesModel
property QtObject systemFavorites: rootModel.systemFavoritesModel
property bool compositingEnabled: kwindowsystem.compositingActive
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");
}
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.
PlasmaCore.DataSource {
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
}
KWindowSystem { id: kwindowsystem } // Used for detecting compositing changes.
2021-07-16 19:33:52 +00:00
Kicker.RootModel {
id: rootModel
autoPopulate: false
appNameFormat: plasmoid.configuration.appNameFormat
flat: true
sorted: true
2024-01-20 02:08:06 +00:00
showSeparators: false
2021-07-16 19:33:52 +00:00
appletInterface: plasmoid
2022-09-01 23:00:01 +00:00
paginate: false
2021-07-16 19:33:52 +00:00
pageSize: plasmoid.configuration.numberColumns * plasmoid.configuration.numberRows
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
showRecentContacts: false
showPowerSession: false
onFavoritesModelChanged: {
if ("initForClient" in favoritesModel) {
favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + plasmoid.id)
if (!plasmoid.configuration.favoritesPortedToKAstats) {
favoritesModel.portOldFavorites(plasmoid.configuration.favoriteApps);
plasmoid.configuration.favoritesPortedToKAstats = true;
}
} else {
favoritesModel.favorites = plasmoid.configuration.favoriteApps;
}
favoritesModel.maxFavorites = pageSize;
}
onSystemFavoritesModelChanged: {
systemFavoritesModel.enabled = false;
systemFavoritesModel.favorites = plasmoid.configuration.favoriteSystemActions;
systemFavoritesModel.maxFavorites = 8;
}
Component.onCompleted: {
if ("initForClient" in favoritesModel) {
favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + plasmoid.id)
if (!plasmoid.configuration.favoritesPortedToKAstats) {
favoritesModel.portOldFavorites(plasmoid.configuration.favoriteApps);
plasmoid.configuration.favoritesPortedToKAstats = true;
}
} else {
favoritesModel.favorites = plasmoid.configuration.favoriteApps;
}
favoritesModel.maxFavorites = pageSize;
rootModel.refresh();
}
}
Connections {
target: globalFavorites
2023-08-24 22:32:11 +00:00
function onFavoritesChanged() {
2021-07-16 19:33:52 +00:00
plasmoid.configuration.favoriteApps = target.favorites;
}
}
Connections {
target: systemFavorites
2023-08-24 22:32:11 +00:00
function onFavoritesChanged() {
2021-07-16 19:33:52 +00:00
plasmoid.configuration.favoriteSystemActions = target.favorites;
}
}
Connections {
target: plasmoid.configuration
2023-08-24 22:32:11 +00:00
function onFavoriteAppsChanged() {
2021-07-16 19:33:52 +00:00
globalFavorites.favorites = plasmoid.configuration.favoriteApps;
}
2023-08-24 22:32:11 +00:00
function onFavoriteSystemActionsChanged() {
2021-07-16 19:33:52 +00:00
systemFavorites.favorites = plasmoid.configuration.favoriteSystemActions;
}
}
Kicker.RunnerModel {
id: runnerModel
favoritesModel: globalFavorites
runners: plasmoid.configuration.useExtraRunners ? new Array("services").concat(plasmoid.configuration.extraRunners) : "services"
appletInterface: plasmoid
deleteWhenEmpty: false
}
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
2021-07-16 19:33:52 +00:00
PlasmaCore.FrameSvgItem {
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"
}
PlasmaCore.FrameSvgItem {
id : panelSvg
visible: false
imagePath: "widgets/panel-background"
}
2022-09-01 23:00:01 +00:00
PlasmaCore.Svg {
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-01-20 02:08:06 +00:00
PlasmaCore.Svg {
id: separatorSvg
imagePath: Qt.resolvedUrl("svgs/sidebarseparator.svg")
}
PlasmaCore.Svg {
id: lockScreenSvg
2023-08-24 22:32:11 +00:00
imagePath: Qt.resolvedUrl("svgs/system-lock-screen.svg")
}
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;
}
Component.onCompleted: {
plasmoid.setAction("menuedit", i18n("Edit Applications..."));
2022-09-01 23:00:01 +00:00
plasmoid.setAction("taskman", i18n("Task Manager"));
2021-07-16 19:33:52 +00:00
rootModel.refreshed.connect(reset);
dragHelper.dropped.connect(resetDragSource);
2021-07-16 19:33:52 +00:00
}
}