diff --git a/applets/systemtray/package/contents/ui/items/AbstractItem.qml b/applets/systemtray/package/contents/ui/items/AbstractItem.qml index 5e337ad3..34d0891a 100644 --- a/applets/systemtray/package/contents/ui/items/AbstractItem.qml +++ b/applets/systemtray/package/contents/ui/items/AbstractItem.qml @@ -1,130 +1,138 @@ /* * Copyright 2016 Marco Martin * * 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.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents PlasmaCore.ToolTipArea { id: abstractItem height: effectiveItemSize + marginHints.top + marginHints.bottom width: labelVisible ? parent.width : effectiveItemSize + marginHints.left + marginHints.right property real effectiveItemSize: hidden ? root.hiddenItemSize : root.itemSize property string itemId property string category property alias text: label.text property bool hidden: parent.objectName == "hiddenTasksColumn" property QtObject marginHints: parent.marginHints property bool labelVisible: abstractItem.hidden && !root.activeApplet property Item iconItem //PlasmaCore.Types.ItemStatus property int status property QtObject model signal clicked(var mouse) signal wheel(var wheel) + signal contextMenu(var mouse) property bool forcedHidden: plasmoid.configuration.hiddenItems.indexOf(itemId) !== -1 property bool forcedShown: plasmoid.configuration.showAllItems || plasmoid.configuration.shownItems.indexOf(itemId) !== -1 property bool categoryShown: shownCategories.indexOf(category) != -1; /* subclasses need to assign to this tiiltip properties mainText: subText: icon: */ location: { if (abstractItem.parent && abstractItem.parent.objectName === "hiddenTasksColumn") { 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 onStatusChanged: updateItemVisibility(abstractItem); onContainsMouseChanged: { if (hidden && containsMouse) { root.hiddenLayout.hoveredItem = abstractItem } } Component.onCompleted: updateItemVisibility(abstractItem); onForcedHiddenChanged: updateItemVisibility(abstractItem); onForcedShownChanged: updateItemVisibility(abstractItem); onCategoryShownChanged: updateItemVisibility(abstractItem); //dangerous but needed due how repeater reparents onParentChanged: updateItemVisibility(abstractItem); //END CONNECTIONS PulseAnimation { targetItem: iconItem running: (abstractItem.status === PlasmaCore.Types.NeedsAttentionStatus || abstractItem.status === PlasmaCore.Types.RequiresAttentionStatus ) && units.longDuration > 0 } MouseArea { id: mouseArea anchors.fill: abstractItem hoverEnabled: true drag.filterChildren: true acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton onClicked: { + if (mouse.button !== Qt.RightButton) { + abstractItem.clicked(mouse) + } + } + onPressed: { abstractItem.hideToolTip() - abstractItem.clicked(mouse) + if (mouse.button === Qt.RightButton) { + 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; } } PlasmaComponents.Label { id: label anchors { left: parent.left leftMargin: iconItem ? iconItem.width + units.smallSpacing : 0 verticalCenter: parent.verticalCenter } opacity: labelVisible ? 1 : 0 visible: abstractItem.hidden Behavior on opacity { NumberAnimation { duration: units.longDuration easing.type: Easing.InOutQuad } } } } diff --git a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml index 494e01c4..3fa92e6a 100644 --- a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml +++ b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml @@ -1,81 +1,83 @@ /* * Copyright 2015 Marco Martin * * 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.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents AbstractItem { id: plasmoidContainer property Item applet iconItem: applet text: applet ? applet.title : "" itemId: applet ? applet.pluginName : "" category: applet ? plasmoid.nativeInterface.plasmoidCategory(applet) : "UnknownCategory" mainText: applet ? applet.toolTipMainText : "" subText: applet ? applet.toolTipSubText : "" icon: applet ? applet.icon : "" mainItem: applet && applet.toolTipItem ? applet.toolTipItem : null textFormat: applet ? applet.toolTipTextFormat : "" status: applet ? applet.status : PlasmaCore.Types.UnknownStatus active: root.activeApplet != applet onClicked: { + if (applet && mouse.button == Qt.LeftButton) { + applet.expanded = true; + } + } + onContextMenu: { if (applet) { - if (mouse.button == Qt.LeftButton) { - applet.expanded = true; - } else if (mouse.button == Qt.RightButton) { - plasmoid.nativeInterface.showPlasmoidMenu(applet, 0, plasmoidContainer.hidden ? applet.height : 0); - } + plasmoid.nativeInterface.showPlasmoidMenu(applet, 0, plasmoidContainer.hidden ? applet.height : 0); } } + onHeightChanged: { if (applet) { applet.width = height } } onAppletChanged: { if (!applet) { plasmoidContainer.destroy(); print("applet destroyed") } } Connections { target: applet onExpandedChanged: { if (expanded) { var oldApplet = root.activeApplet; root.activeApplet = applet; if (oldApplet) { oldApplet.expanded = false; } dialog.visible = true; } else if (root.activeApplet == applet) { if (!applet.parent.hidden) { dialog.visible = false; } //if not expanded we don't have an active applet anymore root.activeApplet = null; } } } } diff --git a/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml b/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml index 889b8b53..b19dc53a 100644 --- a/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml +++ b/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml @@ -1,116 +1,116 @@ /* * Copyright 2016 Marco Martin * * 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.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents AbstractItem { id: taskIcon itemId: Id text: Title mainText: ToolTipTitle != "" ? ToolTipTitle : Title subText: ToolTipSubTitle icon: ToolTipIcon != "" ? ToolTipIcon : Icon ? Icon : IconName textFormat: Text.AutoText category: Category status: { switch (Status) { case "Active": return PlasmaCore.Types.ActiveStatus; case "NeedsAttention": return PlasmaCore.Types.NeedsAttentionStatus; //just assume passive default: return PlasmaCore.Types.PassiveStatus; } } iconItem: iconItem PlasmaCore.IconItem { id: iconItem source: Icon ? Icon : IconName width: Math.min(parent.width, parent.height) height: width active: taskIcon.containsMouse anchors { left: parent.left verticalCenter: parent.verticalCenter } } onClicked: { var pos = plasmoid.nativeInterface.popupPosition(taskIcon, 0, 0); switch (mouse.button) { case Qt.LeftButton: { var service = statusNotifierSource.serviceForSource(DataEngineSource); var operation = service.operationDescription("Activate"); operation.x = pos.x; operation.y = pos.y; service.startOperationCall(operation); break; } - case Qt.RightButton: { - var service = statusNotifierSource.serviceForSource(DataEngineSource); - var operation = service.operationDescription("ContextMenu"); - operation.x = pos.x; - operation.y = pos.y; - - var job = service.startOperationCall(operation); - job.finished.connect(function () { - plasmoid.nativeInterface.showStatusNotifierContextMenu(job, taskIcon); - }); - - break; - } case Qt.MiddleButton: var service = statusNotifierSource.serviceForSource(DataEngineSource); var operation = service.operationDescription("SecondaryActivate"); operation.x = pos.x; operation.y = pos.y; service.startOperationCall(operation); break; - break; } } + onContextMenu: { + var pos = plasmoid.nativeInterface.popupPosition(taskIcon, 0, 0); + + var service = statusNotifierSource.serviceForSource(DataEngineSource); + var operation = service.operationDescription("ContextMenu"); + operation.x = pos.x; + operation.y = pos.y; + + var job = service.startOperationCall(operation); + job.finished.connect(function () { + plasmoid.nativeInterface.showStatusNotifierContextMenu(job, taskIcon); + }); + } + onWheel: { //don't send activateVertScroll with a delta of 0, some clients seem to break (kmix) if (wheel.angleDelta.y !== 0) { var service = statusNotifierSource.serviceForSource(DataEngineSource); var operation = service.operationDescription("Scroll"); operation.delta =wheel.angleDelta.y; operation.direction = "Vertical"; service.startOperationCall(operation); } if (wheel.angleDelta.x !== 0) { var service = statusNotifierSource.serviceForSource(DataEngineSource); var operation = service.operationDescription("Scroll"); operation.delta =wheel.angleDelta.x; operation.direction = "Horizontal"; service.startOperationCall(operation); } } }