Changeset View
Changeset View
Standalone View
Standalone View
applets/showActivityManager/package/contents/ui/main.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2012 Gregor Taetzner <gregor@freenet.de> | 2 | * Copyright 2012 Gregor Taetzner <gregor@freenet.de> | ||
3 | * Copyright 2020 Ivan Čukić <ivan.cukic at 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 General Public License for more details | 13 | * GNU 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.0 | 21 | import QtQuick 2.0 | ||
21 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
22 | import org.kde.plasma.plasmoid 2.0 | 23 | import org.kde.plasma.plasmoid 2.0 | ||
23 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||||
26 | | ||||
27 | import org.kde.activities 0.1 as Activities | ||||
24 | 28 | | |||
25 | MouseArea { | 29 | MouseArea { | ||
26 | id: iconContainer | 30 | id: root | ||
27 | property string activeSource: "Status" | 31 | property string activeSource: "Status" | ||
28 | height: units.iconSizes.large | 32 | height: units.iconSizes.large | ||
29 | width: units.iconSizes.large | 33 | width: units.iconSizes.large | ||
30 | 34 | | |||
35 | property bool showActivityName: plasmoid.configuration.showActivityName | ||||
36 | property bool showActivityIcon: plasmoid.configuration.showActivityIcon | ||||
37 | | ||||
31 | readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge | 38 | readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge | ||
32 | || plasmoid.location === PlasmaCore.Types.RightEdge | 39 | || plasmoid.location === PlasmaCore.Types.RightEdge | ||
33 | || plasmoid.location === PlasmaCore.Types.BottomEdge | 40 | || plasmoid.location === PlasmaCore.Types.BottomEdge | ||
34 | || plasmoid.location === PlasmaCore.Types.LeftEdge) | 41 | || plasmoid.location === PlasmaCore.Types.LeftEdge) | ||
35 | 42 | | |||
36 | Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 | 43 | Layout.maximumWidth: Infinity | ||
37 | Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 | 44 | Layout.maximumHeight: Infinity | ||
45 | | ||||
46 | Layout.preferredWidth : icon.width + units.smallSpacing + (root.showActivityName ? name.implicitWidth : 0) | ||||
47 | Layout.preferredHeight: inPanel ? units.iconSizeHints.panel : -1 | ||||
48 | | ||||
49 | Layout.minimumWidth: 0 | ||||
50 | Layout.minimumHeight: 0 | ||||
38 | 51 | | |||
39 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | 52 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | ||
40 | 53 | | |||
41 | onClicked: { | 54 | onClicked: { | ||
42 | var service = dataSource.serviceForSource(activeSource) | 55 | var service = dataSource.serviceForSource(activeSource) | ||
43 | var operation = service.operationDescription("toggleActivityManager") | 56 | var operation = service.operationDescription("toggleActivityManager") | ||
44 | service.startOperationCall(operation) | 57 | service.startOperationCall(operation) | ||
45 | } | 58 | } | ||
46 | 59 | | |||
47 | PlasmaCore.DataSource { | 60 | PlasmaCore.DataSource { | ||
48 | id: dataSource | 61 | id: dataSource | ||
49 | engine: "org.kde.activities" | 62 | engine: "org.kde.activities" | ||
50 | connectedSources: [activeSource] | 63 | connectedSources: [activeSource] | ||
51 | } | 64 | } | ||
52 | 65 | | |||
53 | PlasmaCore.ToolTipArea { | 66 | PlasmaCore.ToolTipArea { | ||
54 | id: tooltip | 67 | id: tooltip | ||
55 | mainText: i18n("Show Activity Manager") | 68 | mainText: i18n("Show Activity Manager") | ||
56 | subText: i18n("Click to show the activity manager") | 69 | subText: i18n("Click to show the activity manager") | ||
57 | anchors.fill: parent | 70 | anchors.fill: parent | ||
58 | icon: "activities" | 71 | icon: "activities" | ||
59 | } | 72 | } | ||
60 | 73 | | |||
74 | Activities.ActivityInfo { | ||||
75 | id: currentActivity | ||||
76 | activityId: ":current" | ||||
77 | } | ||||
78 | | ||||
61 | PlasmaCore.IconItem { | 79 | PlasmaCore.IconItem { | ||
62 | id: icon | 80 | id: icon | ||
63 | source: "activities" | 81 | source: !root.showActivityIcon ? "activities" : | ||
64 | width: parent.width | 82 | currentActivity.icon == "" ? "activities" : | ||
83 | currentActivity.icon | ||||
84 | | ||||
65 | height: parent.height | 85 | height: parent.height | ||
86 | width: height | ||||
66 | } | 87 | } | ||
88 | | ||||
89 | PlasmaComponents.Label { | ||||
90 | id: name | ||||
91 | | ||||
92 | text: currentActivity.name | ||||
93 | height: parent.height | ||||
94 | width: implicitWidth | ||||
95 | | ||||
96 | visible: root.showActivityName | ||||
97 | | ||||
98 | anchors { | ||||
99 | left: icon.right | ||||
100 | leftMargin: units.smallSpacing | ||||
101 | } | ||||
102 | } | ||||
103 | | ||||
67 | } | 104 | } | ||
68 | 105 | |