diff --git a/applets/systemtray/package/contents/config/config.qml b/applets/systemtray/package/contents/config/config.qml index 2ce4e73db..e6eeac327 100644 --- a/applets/systemtray/package/contents/config/config.qml +++ b/applets/systemtray/package/contents/config/config.qml @@ -1,30 +1,35 @@ /*************************************************************************** * Copyright 2013 by Sebastian Kügler * * * * 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 org.kde.plasma.configuration 2.0 ConfigModel { + ConfigCategory { + name: i18n("General") + icon: "plasma" + source: "ConfigGeneral.qml" + } ConfigCategory { name: i18n("Entries") icon: "preferences-desktop-notification" source: "ConfigEntries.qml" } } diff --git a/applets/systemtray/package/contents/config/config.qml b/applets/systemtray/package/contents/ui/ConfigGeneral.qml similarity index 70% copy from applets/systemtray/package/contents/config/config.qml copy to applets/systemtray/package/contents/ui/ConfigGeneral.qml index 2ce4e73db..367e146b8 100644 --- a/applets/systemtray/package/contents/config/config.qml +++ b/applets/systemtray/package/contents/ui/ConfigGeneral.qml @@ -1,30 +1,38 @@ + + /*************************************************************************** - * Copyright 2013 by Sebastian Kügler * + * Copyright (C) 2020 Konrad Materka * * * * 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.14 +import QtQuick.Controls 2.14 as QtControls +import QtQuick.Layouts 1.14 as QtLayouts +import org.kde.kirigami 2.13 as Kirigami + +Kirigami.FormLayout { -import QtQuick 2.0 + property alias cfg_iconSize: iconSizeComboBox.currentIndex -import org.kde.plasma.configuration 2.0 + QtControls.ComboBox { + id: iconSizeComboBox -ConfigModel { - ConfigCategory { - name: i18n("Entries") - icon: "preferences-desktop-notification" - source: "ConfigEntries.qml" + Kirigami.FormData.label: i18n("Maximum icon size:") + + model: [i18n("Very Small"), i18n("Small"), i18n("Medium"), i18n("Large"), i18n("Huge"), i18n("Enormous")] } + } diff --git a/applets/systemtray/package/contents/ui/items/AbstractItem.qml b/applets/systemtray/package/contents/ui/items/AbstractItem.qml index a2f323e2e..85908fa7b 100644 --- a/applets/systemtray/package/contents/ui/items/AbstractItem.qml +++ b/applets/systemtray/package/contents/ui/items/AbstractItem.qml @@ -1,151 +1,151 @@ /* * Copyright 2016 Marco Martin * Copyright 2020 Konrad Materka * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents PlasmaCore.ToolTipArea { id: abstractItem height: inVisibleLayout ? visibleLayout.cellHeight : hiddenLayout.iconItemHeight width: inVisibleLayout ? visibleLayout.cellWidth : hiddenLayout.width property var model: itemModel property string itemId property alias text: label.text property alias iconContainer: iconContainer property int /*PlasmaCore.Types.ItemStatus*/ status: model.status || PlasmaCore.Types.UnknownStatus property int /*PlasmaCore.Types.ItemStatus*/ effectiveStatus: model.effectiveStatus || PlasmaCore.Types.UnknownStatus readonly property bool inHiddenLayout: effectiveStatus === PlasmaCore.Types.PassiveStatus readonly property bool inVisibleLayout: effectiveStatus === PlasmaCore.Types.ActiveStatus signal clicked(var mouse) signal pressed(var mouse) signal wheel(var wheel) signal contextMenu(var mouse) /* subclasses need to assign to this tooltip properties mainText: subText: */ location: { if (inHiddenLayout) { if (LayoutMirroring.enabled && plasmoid.location !== PlasmaCore.Types.RightEdge) { return PlasmaCore.Types.LeftEdge; } else if (plasmoid.location !== PlasmaCore.Types.LeftEdge) { return PlasmaCore.Types.RightEdge; } } return plasmoid.location; } //BEGIN CONNECTIONS onContainsMouseChanged: { if (inHiddenLayout && containsMouse) { root.hiddenLayout.currentIndex = index } } //END CONNECTIONS PulseAnimation { targetItem: iconContainer running: (abstractItem.status === PlasmaCore.Types.NeedsAttentionStatus || abstractItem.status === PlasmaCore.Types.RequiresAttentionStatus ) && units.longDuration > 0 } function activated() { activatedAnimation.start() } SequentialAnimation { id: activatedAnimation loops: 1 ScaleAnimator { target: iconContainer from: 1 to: 0.5 duration: units.shortDuration easing.type: Easing.InQuad } ScaleAnimator { target: iconContainer from: 0.5 to: 1 duration: units.shortDuration easing.type: Easing.OutQuad } } MouseArea { anchors.fill: abstractItem hoverEnabled: true drag.filterChildren: true acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton onClicked: abstractItem.clicked(mouse) onPressed: { abstractItem.hideToolTip() abstractItem.pressed(mouse) } onPressAndHold: { abstractItem.contextMenu(mouse) } onWheel: { abstractItem.wheel(wheel); //Don't accept the event in order to make the scrolling by mouse wheel working //for the parent scrollview this icon is in. wheel.accepted = false; } } Row { spacing: units.smallSpacing anchors.horizontalCenter: inVisibleLayout ? parent.horizontalCenter : undefined Item { id: iconContainer anchors.verticalCenter: parent.verticalCenter - width: Math.min(abstractItem.width, abstractItem.height) + width: inVisibleLayout ? root.itemSize : hiddenLayout.iconItemHeight height: width property alias inHiddenLayout: abstractItem.inHiddenLayout property alias inVisibleLayout: abstractItem.inVisibleLayout } PlasmaComponents.Label { id: label anchors.verticalCenter: parent.verticalCenter visible: abstractItem.inHiddenLayout && !root.activeApplet opacity: visible ? 1 : 0 Behavior on opacity { NumberAnimation { duration: units.longDuration easing.type: Easing.InOutQuad } } } } } diff --git a/applets/systemtray/package/contents/ui/main.qml b/applets/systemtray/package/contents/ui/main.qml index 23bfb4e89..edcc5da55 100644 --- a/applets/systemtray/package/contents/ui/main.qml +++ b/applets/systemtray/package/contents/ui/main.qml @@ -1,252 +1,252 @@ /* * Copyright 2011 Marco Martin * Copyright 2020 Konrad Materka * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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.5 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.1 as PlasmaCore import org.kde.plasma.plasmoid 2.0 import org.kde.draganddrop 2.0 as DnD import org.kde.kirigami 2.5 as Kirigami import "items" MouseArea { id: root Layout.minimumWidth: vertical ? units.iconSizes.small : tasksGrid.implicitWidth + (expander.visible ? expander.implicitWidth : 0) + units.smallSpacing Layout.minimumHeight: vertical ? tasksGrid.implicitHeight + (expander.visible ? expander.implicitHeight : 0) + units.smallSpacing : units.smallSpacing Layout.preferredHeight: Layout.minimumHeight LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true property var iconSizes: ["small", "smallMedium", "medium", "large", "huge", "enormous"]; property int iconSize: plasmoid.configuration.iconSize + (Kirigami.Settings.tabletMode ? 1 : 0) property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical readonly property int itemSize: { var baseSize = units.roundToIconSize(Math.min(Math.min(width, height), units.iconSizes[iconSizes[Math.min(iconSizes.length-1, iconSize)]])); if (Kirigami.Settings.tabletMode) { // Set the tray items' clickable areas on the panel to be bigger than normal to allow for easier touchability return baseSize + units.smallSpacing; } else { return baseSize + Math.round(units.smallSpacing/2); } } property int hiddenItemSize: units.iconSizes.smallMedium property alias expanded: dialog.visible property Item activeApplet property int status: dialog.visible ? PlasmaCore.Types.RequiresAttentionStatus : PlasmaCore.Types.PassiveStatus property alias visibleLayout: tasksGrid property alias hiddenLayout: expandedRepresentation.hiddenLayout Plasmoid.onExpandedChanged: { if (!plasmoid.expanded) { dialog.visible = plasmoid.expanded; } } onWheel: { // Don't propagate unhandled wheel events wheel.accepted = true; } //being there forces the items to fully load, and they will be reparented in the popup one by one, this item is *never* visible Item { id: preloadedStorage visible: false } Connections { target: plasmoid function onUserConfiguringChanged() { if (plasmoid.userConfiguring) { dialog.visible = false } } } Connections { target: plasmoid.configuration function onExtraItemsChanged() { plasmoid.nativeInterface.allowedPlasmoids = plasmoid.configuration.extraItems } } CurrentItemHighLight { readonly property bool visibleAppletActivated: root.activeApplet && root.activeApplet.parent && root.activeApplet.parent.inVisibleLayout parent: visibleAppletActivated ? root.activeApplet.parent : root target: visibleAppletActivated ? root.activeApplet.parent : root location: plasmoid.location } DnD.DropArea { anchors.fill: parent preventStealing: true; /** Extracts the name of the system tray applet in the drag data if present * otherwise returns null*/ function systemTrayAppletName(event) { if (event.mimeData.formats.indexOf("text/x-plasmoidservicename") < 0) { return null; } var plasmoidId = event.mimeData.getDataAsByteArray("text/x-plasmoidservicename"); if (!plasmoid.nativeInterface.isSystemTrayApplet(plasmoidId)) { return null; } return plasmoidId; } onDragEnter: { if (!systemTrayAppletName(event)) { event.ignore(); } } onDrop: { var plasmoidId = systemTrayAppletName(event); if (!plasmoidId) { event.ignore(); return; } if (plasmoid.configuration.extraItems.indexOf(plasmoidId) < 0) { var extraItems = plasmoid.configuration.extraItems; extraItems.push(plasmoidId); plasmoid.configuration.extraItems = extraItems; } } } //Main Layout GridLayout { id: mainLayout rowSpacing: 0 columnSpacing: 0 anchors.fill: parent flow: vertical ? GridLayout.TopToBottom : GridLayout.LeftToRight GridView { id: tasksGrid Layout.alignment: Qt.AlignCenter interactive: false //disable features we don't need flow: vertical ? GridView.LeftToRight : GridView.TopToBottom - cellHeight: Math.min(root.itemSize + units.smallSpacing, root.height) - cellWidth: Math.min(root.itemSize + units.smallSpacing, root.width) + cellHeight: root.itemSize + units.smallSpacing + cellWidth: root.itemSize + units.smallSpacing readonly property int columns: !vertical ? Math.ceil(count / rows) : Math.max(1, Math.floor(root.width / cellWidth)) readonly property int rows: vertical ? Math.ceil(count / columns) : Math.max(1, Math.floor(root.height / cellHeight)) implicitHeight: rows * cellHeight implicitWidth: columns * cellWidth model: PlasmaCore.SortFilterModel { sourceModel: plasmoid.nativeInterface.systemTrayModel filterRole: "effectiveStatus" filterCallback: function(source_row, value) { return value === PlasmaCore.Types.ActiveStatus } } delegate: ItemLoader {} add: Transition { enabled: root.itemSize > 0 NumberAnimation { property: "scale" from: 0 to: 1 easing.type: Easing.InOutQuad duration: units.longDuration } } displaced: Transition { //ensure scale value returns to 1.0 //https://doc.qt.io/qt-5/qml-qtquick-viewtransition.html#handling-interrupted-animations NumberAnimation { property: "scale" to: 1 easing.type: Easing.InOutQuad duration: units.longDuration } } move: Transition { NumberAnimation { properties: "x,y" easing.type: Easing.InOutQuad duration: units.longDuration } } } ExpanderArrow { id: expander Layout.fillWidth: vertical Layout.fillHeight: !vertical } } //Main popup PlasmaCore.Dialog { id: dialog visualParent: root flags: Qt.WindowStaysOnTopHint location: plasmoid.location hideOnWindowDeactivate: !plasmoid.configuration.pin onVisibleChanged: { if (!visible) { plasmoid.status = PlasmaCore.Types.PassiveStatus; if (root.activeApplet) { root.activeApplet.expanded = false; } } else { plasmoid.status = PlasmaCore.Types.RequiresAttentionStatus; } plasmoid.expanded = visible; } mainItem: ExpandedRepresentation { id: expandedRepresentation Keys.onEscapePressed: { root.expanded = false; } activeApplet: root.activeApplet LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true } } }