Changeset View
Changeset View
Standalone View
Standalone View
applets/minimizeall/package/contents/ui/main.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2015 Sebastian Kügler <sebas@kde.org> | 2 | * Copyright 2015 Sebastian Kügler <sebas@kde.org> | ||
3 | * Copyright 2016 Anthony Fieroni <bvbfan@abv.bg> | 3 | * Copyright 2016 Anthony Fieroni <bvbfan@abv.bg> | ||
4 | * Copyright 2018 David Edmundson <davidedmundson@kde.org> | ||||
4 | * | 5 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | 6 | * 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 | * 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 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | 9 | * (at your option) any later version. | ||
9 | * | 10 | * | ||
10 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. | ||
14 | * | 15 | * | ||
15 | * You should have received a copy of the GNU General Public License along | 16 | * 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 | * with this program; if not, write to the 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 QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
22 | 23 | | |||
23 | import org.kde.plasma.plasmoid 2.0 | 24 | import org.kde.plasma.plasmoid 2.0 | ||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | 26 | | |||
26 | import org.kde.plasma.private.minimizeall 1.0 | 27 | import org.kde.taskmanager 0.1 as TaskManager | ||
27 | | ||||
28 | 28 | | |||
29 | Item { | 29 | Item { | ||
30 | id: root | 30 | id: root | ||
31 | 31 | | |||
32 | readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge | 32 | readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge | ||
33 | || plasmoid.location === PlasmaCore.Types.RightEdge | 33 | || plasmoid.location === PlasmaCore.Types.RightEdge | ||
34 | || plasmoid.location === PlasmaCore.Types.BottomEdge | 34 | || plasmoid.location === PlasmaCore.Types.BottomEdge | ||
35 | || plasmoid.location === PlasmaCore.Types.LeftEdge) | 35 | || plasmoid.location === PlasmaCore.Types.LeftEdge) | ||
36 | 36 | | |||
37 | Layout.minimumWidth: units.gridUnit | 37 | Layout.minimumWidth: units.gridUnit | ||
38 | Layout.minimumHeight: units.gridUnit | 38 | Layout.minimumHeight: units.gridUnit | ||
39 | 39 | | |||
40 | Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 | 40 | Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 | ||
41 | Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 | 41 | Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 | ||
42 | 42 | | |||
43 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | 43 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | ||
44 | 44 | | |||
45 | Plasmoid.onActivated: activate() | ||||
46 | | ||||
47 | property bool active: false | ||||
48 | property var minimizedClients: [] //list of persistentmodelindexes from task manager model of clients minimised by us | ||||
49 | | ||||
45 | function activate() { | 50 | function activate() { | ||
46 | if (!minimizeall.active) { | 51 | if (!root.active) { | ||
47 | minimizeall.minimizeAllWindows(); | 52 | var clients = [] | ||
53 | for (var i = 0 ; i < tasksModel.count; i++) { | ||||
54 | var idx = tasksModel.makeModelIndex(i); | ||||
55 | if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsMinimized)) { | ||||
56 | tasksModel.requestToggleMinimized(idx); | ||||
broulik: This method does not exist, did you forget to commit the plasma-workspace part? | |||||
57 | clients.push(tasksModel.makePeristentModelndex(i)); | ||||
broulik: typo | |||||
58 | } | ||||
59 | } | ||||
60 | root.active = true; | ||||
61 | root.minimizedClients = clients; | ||||
48 | } else { | 62 | } else { | ||
49 | minimizeall.unminimizeAllWindows(); | 63 | for (var i = 0 ; i < root.minimizedClients.length; i++) { | ||
64 | var idx = root.minimizedClients[i] | ||||
65 | //client deleted, do nothing | ||||
66 | if (!idx.valid) { | ||||
67 | continue; | ||||
68 | } | ||||
69 | //if the user has restored it already, do nothing | ||||
70 | if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsMinimized)) { | ||||
71 | continue; | ||||
72 | } | ||||
73 | tasksModel.requestToggleMinimized(idx); | ||||
74 | } | ||||
75 | root.active = false; | ||||
76 | root.minimizedClients = []; | ||||
50 | } | 77 | } | ||
51 | } | 78 | } | ||
52 | 79 | | |||
53 | Plasmoid.onActivated: activate() | 80 | TaskManager.TasksModel { | ||
54 | 81 | id: tasksModel | |||
55 | MinimizeAll { | 82 | sortMode: TasksModel.SortDisabled | ||
56 | id: minimizeall | 83 | groupMode: TasksModel.GroupDisabled | ||
57 | } | 84 | } | ||
58 | 85 | | |||
59 | PlasmaCore.FrameSvgItem { | 86 | PlasmaCore.FrameSvgItem { | ||
60 | id: expandedItem | 87 | id: expandedItem | ||
61 | anchors.fill: parent | 88 | anchors.fill: parent | ||
62 | imagePath: "widgets/tabbar" | 89 | imagePath: "widgets/tabbar" | ||
63 | prefix: { | 90 | prefix: { | ||
64 | var prefix; | 91 | var prefix; | ||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |
This method does not exist, did you forget to commit the plasma-workspace part?