Changeset View
Changeset View
Standalone View
Standalone View
applets/showdesktop/package/contents/ui/main.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2014 Ashish Madeti <ashishmadeti@gmail.com> | ||||
3 | Copyright (C) 2016 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
4 | | ||||
5 | This program is free software; you can redistribute it and/or modify | ||||
6 | it under the terms of the GNU General Public License as published by | ||||
7 | the Free Software Foundation; either version 2 of the License, or | ||||
8 | (at your option) any later version. | ||||
9 | | ||||
10 | This program is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | GNU General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU General Public License along | ||||
16 | with this program; if not, write to the Free Software Foundation, Inc., | ||||
17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.1 | ||||
21 | import QtQuick.Layouts 1.1 | ||||
22 | | ||||
23 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
24 | | ||||
25 | import org.kde.plasma.plasmoid 2.0 | ||||
26 | | ||||
27 | import org.kde.plasma.private.showdesktop 0.1 | ||||
28 | | ||||
29 | QtObject { | ||||
30 | id: root | ||||
31 | | ||||
32 | // you can't have an applet with just a compact representation :( | ||||
33 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | ||||
34 | Plasmoid.onActivated: showdesktop.showingDesktop = !showdesktop.showingDesktop | ||||
35 | Plasmoid.icon: plasmoid.configuration.icon | ||||
36 | Plasmoid.title: i18n("Show Desktop") | ||||
37 | Plasmoid.toolTipSubText: i18n("Show the Plasma desktop") | ||||
38 | | ||||
39 | // QtObject has no default property | ||||
40 | property QtObject showdesktop: ShowDesktop { } | ||||
41 | | ||||
42 | Component.onCompleted: { | ||||
43 | plasmoid.setAction("minimizeall", i18nc("@action", "Minimize All Windows")) | ||||
44 | } | ||||
45 | | ||||
46 | function action_minimizeall() { | ||||
47 | showdesktop.minimizeAll() | ||||
48 | } | ||||
49 | | ||||
50 | Plasmoid.fullRepresentation: PlasmaCore.ToolTipArea { | ||||
51 | readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge | ||||
52 | || plasmoid.location === PlasmaCore.Types.RightEdge | ||||
53 | || plasmoid.location === PlasmaCore.Types.BottomEdge | ||||
54 | || plasmoid.location === PlasmaCore.Types.LeftEdge) | ||||
55 | | ||||
56 | Layout.minimumWidth: units.iconSizes.small | ||||
57 | Layout.minimumHeight: Layout.minimumWidth | ||||
58 | | ||||
59 | Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 | ||||
60 | Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 | ||||
61 | | ||||
62 | icon: plasmoid.icon | ||||
63 | mainText: plasmoid.title | ||||
64 | subText: plasmoid.toolTipSubText | ||||
65 | | ||||
66 | MouseArea { | ||||
67 | anchors.fill: parent | ||||
68 | onClicked: showdesktop.showingDesktop = !showdesktop.showingDesktop | ||||
69 | } | ||||
70 | | ||||
71 | PlasmaCore.IconItem { | ||||
72 | anchors.fill: parent | ||||
73 | source: plasmoid.icon | ||||
74 | active: parent.containsMouse || showdesktop.showingDesktop | ||||
75 | } | ||||
76 | | ||||
77 | // also activate when dragging an item over the plasmoid so a user can easily drag data to the desktop | ||||
78 | DropArea { | ||||
79 | anchors.fill: parent | ||||
80 | onEntered: activateTimer.start() | ||||
81 | onExited: activateTimer.stop() | ||||
82 | | ||||
83 | Timer { | ||||
84 | id: activateTimer | ||||
85 | interval: 250 //to match TaskManager | ||||
86 | onTriggered: plasmoid.activated() | ||||
87 | } | ||||
88 | } | ||||
89 | } | ||||
90 | | ||||
91 | } |