From 81a78fdebd67ee67a76702fe1629ff8cf863946b Mon Sep 17 00:00:00 2001 From: snoutie <71790678+SnoutBug@users.noreply.github.com> Date: Thu, 3 Mar 2022 18:32:39 +0100 Subject: [PATCH] Add files via upload --- contents/ui/CompactRepresentation.qml | 105 +++++++++++ contents/ui/ConfigGeneral.qml | 256 ++++++++++++++++++++++++++ contents/ui/MainView.qml | 3 + contents/ui/MenuRepresentation.qml | 122 ++++++++++++ contents/ui/RunnerList.qml | 4 + contents/ui/main.qml | 222 ++++++++++++++++++++++ 6 files changed, 712 insertions(+) create mode 100644 contents/ui/CompactRepresentation.qml create mode 100644 contents/ui/ConfigGeneral.qml create mode 100644 contents/ui/MenuRepresentation.qml create mode 100644 contents/ui/main.qml diff --git a/contents/ui/CompactRepresentation.qml b/contents/ui/CompactRepresentation.qml new file mode 100644 index 0000000..81eb34d --- /dev/null +++ b/contents/ui/CompactRepresentation.qml @@ -0,0 +1,105 @@ +/***************************************************************************** + * Copyright (C) 2013-2014 by Eike Hein * + * Copyright (C) 2021 by Prateek SU * + * Copyright (C) 2022 by Friedrich Schriewer * + * * + * 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.12 +import QtQuick.Layouts 1.12 + +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +Item { + id: root + + property QtObject dashWindow: null + readonly property bool useCustomButtonImage: (plasmoid.configuration.useCustomButtonImage && plasmoid.configuration.customButtonImage.length != 0) + + PlasmaCore.IconItem { + id: buttonIcon + + width: plasmoid.configuration.activationIndicator ? parent.width * 0.65 : parent.width + height: plasmoid.configuration.activationIndicator ? parent.height * 0.65 : parent.height + anchors.centerIn: parent + //anchors.fill: parent + + /*readonly property double aspectRatio: (vertical ? implicitHeight / implicitWidth + : implicitWidth / implicitHeight)*/ + + source: useCustomButtonImage ? plasmoid.configuration.customButtonImage : plasmoid.configuration.icon + + active: mouseArea.containsMouse + + smooth: true + + Rectangle { + id: indicator + width: 0 + anchors.horizontalCenter: parent.horizontalCenter + height: 3 + radius: 10 + y: parent.height + height + color: plasmoid.configuration.indicatorColor + visible: plasmoid.configuration.activationIndicator + + states: [ + State { name: "inactive" + when: !dashWindow.visible + PropertyChanges { + target: indicator + width: 0 + + } + }, + State { name: "active" + when: dashWindow.visible + PropertyChanges { + target: indicator + width: parent.width * 0.65 + } + } + ] + transitions: [ + Transition { + NumberAnimation { properties: 'width'; duration: 60} + } + ] + } + } + + MouseArea + { + id: mouseArea + + anchors.fill: parent + + hoverEnabled: true + + onClicked: { + dashWindow.visible = !dashWindow.visible; + } + } + + Component.onCompleted: { + dashWindow = Qt.createQmlObject("MenuRepresentation {}", root); + plasmoid.activated.connect(function() { + dashWindow.visible = !dashWindow.visible; + }); + } +} diff --git a/contents/ui/ConfigGeneral.qml b/contents/ui/ConfigGeneral.qml new file mode 100644 index 0000000..ee95ebc --- /dev/null +++ b/contents/ui/ConfigGeneral.qml @@ -0,0 +1,256 @@ +/***************************************************************************** + * Copyright (C) 2013-2014 by Eike Hein * + * Copyright (C) 2021 by Prateek SU * + * Copyright (C) 2022 by Friedrich Schriewer * + * * + * 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.12 +import QtQuick.Controls 2.5 +import QtQuick.Dialogs 1.0 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.kquickcontrolsaddons 2.0 as KQuickAddons +import org.kde.draganddrop 2.0 as DragDrop +import org.kde.kirigami 2.3 as Kirigami + +import org.kde.plasma.private.kicker 0.1 as Kicker + +Kirigami.FormLayout { + id: configGeneral + + anchors.left: parent.left + anchors.right: parent.right + + property bool isDash: (plasmoid.pluginName === "org.kde.plasma.kickerdash") + + property string cfg_icon: plasmoid.configuration.icon + property bool cfg_useCustomButtonImage: plasmoid.configuration.useCustomButtonImage + property string cfg_customButtonImage: plasmoid.configuration.customButtonImage + property bool cfg_activationIndicator: plasmoid.configuration.activationIndicator + property color cfg_indicatorColor: plasmoid.configuration.indicatorColor + property bool cfg_enableGreeting: plasmoid.configuration.indicatorColor + property string cfg_defaultState: plasmoid.configuration.defaultState + property string cfg_defaultStateIcon: plasmoid.configuration.defaultStateIcon + property bool cfg_isCentered: plasmoid.configuration.isCentered + property alias cfg_defaultPage: defaultPage.currentIndex + property alias cfg_theming: theming.currentIndex + property alias cfg_useExtraRunners: useExtraRunners.checked + property alias cfg_customGreeting: customGreeting.text + + Button { + id: iconButton + + Kirigami.FormData.label: i18n("Icon:") + + implicitWidth: previewFrame.width + units.smallSpacing * 2 + implicitHeight: previewFrame.height + units.smallSpacing * 2 + + // Just to provide some visual feedback when dragging; + // cannot have checked without checkable enabled + checkable: true + checked: dropArea.containsAcceptableDrag + + onPressed: iconMenu.opened ? iconMenu.close() : iconMenu.open() + + DragDrop.DropArea { + id: dropArea + + property bool containsAcceptableDrag: false + + anchors.fill: parent + + onDragEnter: { + // Cannot use string operations (e.g. indexOf()) on "url" basic type. + var urlString = event.mimeData.url.toString(); + + // This list is also hardcoded in KIconDialog. + var extensions = [".png", ".xpm", ".svg", ".svgz"]; + containsAcceptableDrag = urlString.indexOf("file:///") === 0 && extensions.some(function (extension) { + return urlString.indexOf(extension) === urlString.length - extension.length; // "endsWith" + }); + + if (!containsAcceptableDrag) { + event.ignore(); + } + } + onDragLeave: containsAcceptableDrag = false + + onDrop: { + if (containsAcceptableDrag) { + // Strip file:// prefix, we already verified in onDragEnter that we have only local URLs. + iconDialog.setCustomButtonImage(event.mimeData.url.toString().substr("file://".length)); + } + containsAcceptableDrag = false; + } + } + + KQuickAddons.IconDialog { + id: iconDialog + + function setCustomButtonImage(image) { + cfg_customButtonImage = image || cfg_icon || "start-here-kde" + cfg_useCustomButtonImage = true; + } + + onIconNameChanged: setCustomButtonImage(iconName); + } + + PlasmaCore.FrameSvgItem { + id: previewFrame + anchors.centerIn: parent + imagePath: plasmoid.location === PlasmaCore.Types.Vertical || plasmoid.location === PlasmaCore.Types.Horizontal + ? "widgets/panel-background" : "widgets/background" + width: units.iconSizes.large + fixedMargins.left + fixedMargins.right + height: units.iconSizes.large + fixedMargins.top + fixedMargins.bottom + + PlasmaCore.IconItem { + anchors.centerIn: parent + width: units.iconSizes.large + height: width + source: cfg_useCustomButtonImage ? cfg_customButtonImage : cfg_icon + } + } + + Menu { + id: iconMenu + + // Appear below the button + y: +parent.height + + onClosed: iconButton.checked = false; + + MenuItem { + text: i18nc("@item:inmenu Open icon chooser dialog", "Choose...") + icon.name: "document-open-folder" + onClicked: iconDialog.open() + } + MenuItem { + text: i18nc("@item:inmenu Reset icon to default", "Clear Icon") + icon.name: "edit-clear" + onClicked: { + cfg_icon = "start-here-kde" + cfg_useCustomButtonImage = false + } + } + } + } + CheckBox { + id: activationIndicatorCheck + Kirigami.FormData.label: i18n("Indicator:") + text: i18n("Enabled") + checked: plasmoid.configuration.activationIndicator + onCheckedChanged: { + plasmoid.configuration.activationIndicator = checked + cfg_activationIndicator = checked + } + } + Button { + id: colorButton + width: units.iconSizes.small + height: width + Kirigami.FormData.label: i18n("Indicator Color:") + + Rectangle { + anchors.centerIn: parent + anchors.fill: parent + radius: 10 + color: cfg_indicatorColor + } + onPressed: colorDialog.visible ? colorDialog.close() : colorDialog.open() + ColorDialog { + id: colorDialog + title: "Please choose a color" + onAccepted: { + cfg_indicatorColor = colorDialog.color + } + } + } + Item { + Kirigami.FormData.isSection: true + } + CheckBox { + id: enableGreetingCheck + Kirigami.FormData.label: i18n("Greeting:") + text: i18n("Enabled") + checked: plasmoid.configuration.enableGreeting + onCheckedChanged: { + plasmoid.configuration.enableGreeting = checked + cfg_enableGreeting = checked + } + } + TextField { + id: customGreeting + Kirigami.FormData.label: i18n("Custom Greeting Text:") + placeholderText: "No custom greeting set" + } + Item { + Kirigami.FormData.isSection: true + } + CheckBox { + Kirigami.FormData.label: i18n("In Center:") + text: i18n("Enabled") + checked: plasmoid.configuration.isCentered + onCheckedChanged: { + plasmoid.configuration.isCentered = checked + cfg_isCentered = checked + } + } + Item { + Kirigami.FormData.isSection: true + } + ComboBox { + id: defaultPage + Kirigami.FormData.label: i18n("Default Page:") + model: [ + i18n("All Applications (Default)"), + i18n("Developement"), + i18n("Games"), + i18n("Graphics"), + i18n("Internet"), + i18n("Multimedia"), + i18n("Office"), + i18n("Science & Math"), + i18n("Settings"), + i18n("System"), + i18n("Utilities"), + i18n("Lost & Found"), + ] + } + Item { + Kirigami.FormData.isSection: true + } + CheckBox { + id: useExtraRunners + + Kirigami.FormData.label: i18n("Search:") + + text: i18n("Expand search to bookmarks, files and emails") + } + Item { + Kirigami.FormData.isSection: true + } + ComboBox { + id: theming + Kirigami.FormData.label: i18n("Theming:") + model: [ + i18n("Dark (Default)"), + i18n("Light"), + i18n("Matching"), + ] + } +} diff --git a/contents/ui/MainView.qml b/contents/ui/MainView.qml index 22294bc..759bc3b 100644 --- a/contents/ui/MainView.qml +++ b/contents/ui/MainView.qml @@ -188,6 +188,9 @@ Item { } else { root.toggle() } + } else if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) { + runnerList.setFocus() + runnerList.triggerFirst() } } } diff --git a/contents/ui/MenuRepresentation.qml b/contents/ui/MenuRepresentation.qml new file mode 100644 index 0000000..3d21d78 --- /dev/null +++ b/contents/ui/MenuRepresentation.qml @@ -0,0 +1,122 @@ +/*************************************************************************** + * Copyright (C) 2014 by Weng Xuetian + * Copyright (C) 2013-2017 by Eike Hein * + * Copyright (C) 2021 by Prateek SU * + * * + * 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.12 +import QtQuick.Layouts 1.12 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 3.0 as PlasmaComponents + +PlasmaCore.Dialog { + id: root + + type: "Normal" + + objectName: "popupWindow" + flags: Qt.WindowStaysOnTopHint + //location: PlasmaCore.Types.Floating + hideOnWindowDeactivate: true + + onVisibleChanged: { + if (!visible) { + reset(); + } else { + var pos = popupPosition(width, height); + x = pos.x; + y = pos.y; + requestActivate(); + } + } + + function toggle() { + root.visible = false; + } + + function reset() { + main.reset() + } + + function popupPosition(width, height) { + var screenAvail = plasmoid.availableScreenRect; + var screenGeom = plasmoid.screenGeometry; + //QtBug - QTBUG-64115 + var screen = Qt.rect(screenAvail.x + screenGeom.x, + screenAvail.y + screenGeom.y, + screenAvail.width, + screenAvail.height); + + var offset = 0; + + // Fall back to bottom-left of screen area when the applet is on the desktop or floating. + var x = offset; + var y = screen.height - height - offset; + var horizMidPoint = screen.x + (screen.width / 2); + var vertMidPoint = screen.y + (screen.height / 2); + var appletTopLeft = parent.mapToGlobal(0, 0); + var appletBottomLeft = parent.mapToGlobal(0, parent.height); + + if (plasmoid.configuration.isCentered){ + x = horizMidPoint - width / 2; + } else { + x = (appletTopLeft.x < horizMidPoint) ? screen.x : (screen.x + screen.width) - width; + } + + y = screen.height - fs.height + root.margins.bottom + root.margins.top; + + return Qt.point(x, y); + } + + FocusScope { + id: fs + focus: true + Layout.minimumWidth: 515//450 + Layout.minimumHeight: 600//530 + Layout.maximumWidth: Layout.minimumWidth + Layout.maximumHeight: Layout.minimumHeight + + Item { + x: - root.margins.left + y: - root.margins.top + width: parent.width + root.margins.left + root.margins.right + height: parent.height + root.margins.top + root.margins.bottom + + MainView { + id: main + } + } + + + Keys.onPressed: { + if (event.key == Qt.Key_Escape) { + root.visible = false; + } + } + } + + function refreshModel() { + main.reload() + } + + Component.onCompleted: { + rootModel.refreshed.connect(refreshModel) + kicker.reset.connect(reset); + reset(); + } +} diff --git a/contents/ui/RunnerList.qml b/contents/ui/RunnerList.qml index 54b481b..690cd89 100644 --- a/contents/ui/RunnerList.qml +++ b/contents/ui/RunnerList.qml @@ -33,6 +33,7 @@ import QtGraphicalEffects 1.0 PlasmaExtras.ScrollArea { id: runnerList + focus: true property alias model: repeater.model property alias count: repeater.count @@ -75,6 +76,9 @@ PlasmaExtras.ScrollArea { } } } + function triggerFirst(){ + repeater.itemAt(currentSubIndex).nGrid.currentItem.trigger() + } Column { y: 25 diff --git a/contents/ui/main.qml b/contents/ui/main.qml new file mode 100644 index 0000000..9ad5ff3 --- /dev/null +++ b/contents/ui/main.qml @@ -0,0 +1,222 @@ +/*************************************************************************** + * Copyright (C) 2014-2015 by Eike Hein * + * Copyright (C) 2021 by Prateek SU * + * * + * 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.12 +import QtQuick.Layouts 1.12 +import org.kde.plasma.plasmoid 2.0 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 3.0 as PlasmaComponents + +import org.kde.plasma.private.kicker 0.1 as Kicker + +Item { + id: kicker + + anchors.fill: parent + + signal reset + + property bool isDash: false + + Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation + + Plasmoid.compactRepresentation: null + Plasmoid.fullRepresentation: compactRepresentation + + property Item dragSource: null + + property QtObject globalFavorites: rootModel.favoritesModel + property QtObject systemFavorites: rootModel.systemFavoritesModel + + function action_menuedit() { + processRunner.runMenuEditor(); + } + + Component { + id: compactRepresentation + CompactRepresentation { } + } + + Component { + id: menuRepresentation + MenuRepresentation { } + } + + Kicker.RootModel { + id: rootModel + + autoPopulate: false + + appNameFormat: plasmoid.configuration.appNameFormat + flat: true + sorted: true + showSeparators: false + appletInterface: plasmoid + + showAllApps: true + showAllAppsCategorized: true + showTopLevelItems: !isDash + showRecentApps: plasmoid.configuration.showRecentApps + showRecentDocs: plasmoid.configuration.showRecentDocs + showRecentContacts: plasmoid.configuration.showRecentContacts + recentOrdering: plasmoid.configuration.recentOrdering + + onShowRecentAppsChanged: { + plasmoid.configuration.showRecentApps = showRecentApps; + } + + onShowRecentDocsChanged: { + plasmoid.configuration.showRecentDocs = showRecentDocs; + } + + onShowRecentContactsChanged: { + plasmoid.configuration.showRecentContacts = showRecentContacts; + } + + onRecentOrderingChanged: { + plasmoid.configuration.recentOrdering = recentOrdering; + } + + 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 = 6; + } + + 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 + + onFavoritesChanged: { + plasmoid.configuration.favoriteApps = target.favorites; + } + } + + Connections { + target: systemFavorites + + onFavoritesChanged: { + plasmoid.configuration.favoriteSystemActions = target.favorites; + } + } + + Connections { + target: plasmoid.configuration + + onFavoriteAppsChanged: { + globalFavorites.favorites = plasmoid.configuration.favoriteApps; + } + + onFavoriteSystemActionsChanged: { + 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 { + id: processRunner; + } + + PlasmaCore.FrameSvgItem { + id: highlightItemSvg + + visible: false + + imagePath: "widgets/viewitem" + prefix: "hover" + } + + PlasmaCore.FrameSvgItem { + id: panelSvg + + visible: false + + imagePath: "widgets/panel-background" + } + + 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...")); + + rootModel.refreshed.connect(reset); + + dragHelper.dropped.connect(resetDragSource); + } +}