Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/package/contents/ui/items/PlasmoidItem.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2015 Marco Martin <mart@kde.org> | 2 | * Copyright 2015 Marco Martin <mart@kde.org> | ||
3 | * Copyright 2019 ivan tkachenko <ratijastk@kde.org> | ||||
3 | * | 4 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU Library General Public License as | 6 | * it under the terms of the GNU Library General Public License as | ||
6 | * published by the Free Software Foundation; either version 2, or | 7 | * published by the Free Software Foundation; either version 2, or | ||
7 | * (at your option) any later version. | 8 | * (at your option) any later version. | ||
8 | * | 9 | * | ||
9 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU Library General Public License for more details | 13 | * GNU Library General Public License for more details | ||
13 | * | 14 | * | ||
14 | * You should have received a copy of the GNU Library General Public | 15 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 16 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 17 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 19 | */ | ||
19 | 20 | | |||
20 | import QtQuick 2.1 | 21 | import QtQuick 2.1 | ||
21 | import org.kde.plasma.core 2.0 as PlasmaCore | 22 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
22 | import org.kde.plasma.components 2.0 as PlasmaComponents | 23 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
23 | 24 | | |||
25 | // Container for Plasma applet with expandable section, like Bluetooth, Volume, Networks etc. | ||||
24 | AbstractItem { | 26 | AbstractItem { | ||
25 | id: plasmoidContainer | 27 | id: plasmoidContainer | ||
26 | 28 | | |||
27 | property Item applet | 29 | property Item applet | ||
28 | iconItem: applet | | |||
29 | text: applet ? applet.title : "" | | |||
30 | 30 | | |||
31 | text: applet ? applet.title : "" | ||||
32 | iconItem: applet | ||||
31 | itemId: applet ? applet.pluginName : "" | 33 | itemId: applet ? applet.pluginName : "" | ||
32 | category: applet ? plasmoid.nativeInterface.plasmoidCategory(applet) : "UnknownCategory" | 34 | category: applet ? plasmoid.nativeInterface.plasmoidCategory(applet) : "UnknownCategory" | ||
33 | mainText: applet ? applet.toolTipMainText : "" | 35 | mainText: applet ? applet.toolTipMainText : "" | ||
34 | subText: applet ? applet.toolTipSubText : "" | 36 | subText: applet ? applet.toolTipSubText : "" | ||
35 | icon: applet ? applet.icon : "" | 37 | icon: applet ? applet.icon : "" | ||
36 | mainItem: applet && applet.toolTipItem ? applet.toolTipItem : null | 38 | mainItem: applet && applet.toolTipItem ? applet.toolTipItem : null | ||
37 | textFormat: applet ? applet.toolTipTextFormat : "" | 39 | textFormat: applet ? applet.toolTipTextFormat : "" | ||
38 | status: applet ? applet.status : PlasmaCore.Types.UnknownStatus | 40 | status: applet ? applet.status : PlasmaCore.Types.UnknownStatus | ||
39 | active: root.activeApplet !== applet | 41 | active: root.activeApplet !== applet | ||
40 | 42 | | |||
41 | onClicked: { | 43 | onClicked: { | ||
42 | if (applet && mouse.button === Qt.LeftButton) { | 44 | if (applet && mouse.button === Qt.LeftButton) { | ||
43 | applet.expanded = true; | 45 | applet.expanded = !applet.expanded; | ||
davidedmundson: Huh? how did this work before? | |||||
Applets do it by itself, when it not do, it does not work like Weather Widget embed in systray. anthonyfieroni: Applets do it by itself, when it not do, it does not work like Weather Widget embed in systray. | |||||
44 | } | 46 | } | ||
45 | } | 47 | } | ||
46 | onContextMenu: { | 48 | onContextMenu: { | ||
47 | if (applet) { | 49 | if (applet) { | ||
48 | plasmoid.nativeInterface.showPlasmoidMenu(applet, 0, plasmoidContainer.hidden ? applet.height : 0); | 50 | plasmoid.nativeInterface.showPlasmoidMenu(applet, 0, plasmoidContainer.hidden ? applet.height : 0); | ||
49 | } | 51 | } | ||
50 | } | 52 | } | ||
51 | 53 | | |||
Show All 15 Lines | 68 | if (expanded) { | |||
67 | var oldApplet = root.activeApplet; | 69 | var oldApplet = root.activeApplet; | ||
68 | root.activeApplet = applet; | 70 | root.activeApplet = applet; | ||
69 | if (oldApplet) { | 71 | if (oldApplet) { | ||
70 | oldApplet.expanded = false; | 72 | oldApplet.expanded = false; | ||
71 | } | 73 | } | ||
72 | dialog.visible = true; | 74 | dialog.visible = true; | ||
73 | 75 | | |||
74 | } else if (root.activeApplet === applet) { | 76 | } else if (root.activeApplet === applet) { | ||
75 | if (!applet.parent.hidden) { | 77 | if (!hidden) { | ||
76 | dialog.visible = false; | 78 | dialog.visible = false; | ||
77 | } | 79 | } | ||
78 | //if not expanded we don't have an active applet anymore | 80 | //if not expanded we don't have an active applet anymore | ||
79 | root.activeApplet = null; | 81 | root.activeApplet = null; | ||
80 | } | 82 | } | ||
81 | } | 83 | } | ||
82 | } | 84 | } | ||
83 | } | 85 | } |
Huh? how did this work before?