summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2017-01-11 10:26:10 +0100
committerKai Uwe Broulik <[email protected]>2017-01-11 10:26:34 +0100
commitb9af99140365c8c8cf4e3744af7e13b35c35fa18 (patch)
treeb3df49c4c6f293cd5c9de21e89c7c651ed60000d
parent2eab88a063e8cb2957990e7bd0aec18ddc5fa370 (diff)
[System Tray] Trigger context menu on press
Everywhere else context menus are triggered on mouse *press* not on release. Differential Revision: https://phabricator.kde.org/D4024
-rw-r--r--applets/systemtray/package/contents/ui/items/AbstractItem.qml10
-rw-r--r--applets/systemtray/package/contents/ui/items/PlasmoidItem.qml12
-rw-r--r--applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml28
3 files changed, 30 insertions, 20 deletions
diff --git a/applets/systemtray/package/contents/ui/items/AbstractItem.qml b/applets/systemtray/package/contents/ui/items/AbstractItem.qml
index 5e337ad..34d0891 100644
--- a/applets/systemtray/package/contents/ui/items/AbstractItem.qml
+++ b/applets/systemtray/package/contents/ui/items/AbstractItem.qml
@@ -41,6 +41,7 @@ PlasmaCore.ToolTipArea {
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
@@ -99,8 +100,15 @@ PlasmaCore.ToolTipArea {
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);
diff --git a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml
index 494e01c..3fa92e6 100644
--- a/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml
+++ b/applets/systemtray/package/contents/ui/items/PlasmoidItem.qml
@@ -39,14 +39,16 @@ AbstractItem {
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
diff --git a/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml b/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml
index 889b8b5..b19dc53 100644
--- a/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml
+++ b/applets/systemtray/package/contents/ui/items/StatusNotifierItem.qml
@@ -71,19 +71,6 @@ AbstractItem {
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");
@@ -92,10 +79,23 @@ AbstractItem {
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) {