Changeset View
Changeset View
Standalone View
Standalone View
applets/systemtray/package/contents/ui/HiddenItemsView.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2016 Marco Martin <mart@kde.org> | 2 | * Copyright 2016 Marco Martin <mart@kde.org> | ||
3 | * Copyright 2020 Konrad Materka <materka@gmail.com> | ||||
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 QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
22 | import org.kde.plasma.core 2.0 as PlasmaCore | 23 | import org.kde.plasma.core 2.1 as PlasmaCore | ||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 24 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 25 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
25 | 26 | | |||
27 | import "items" | ||||
26 | 28 | | |||
27 | PlasmaExtras.ScrollArea { | 29 | MouseArea { | ||
28 | id: hiddenTasksView | 30 | id: hiddenTasksView | ||
29 | 31 | | |||
30 | visible: !root.activeApplet || (root.activeApplet.parent && root.activeApplet.parent.inHiddenLayout) | 32 | visible: !root.activeApplet || (root.activeApplet.parent && root.activeApplet.parent.inHiddenLayout) | ||
31 | implicitWidth: root.activeApplet ? iconColumnWidth : parent.width | 33 | implicitWidth: root.activeApplet ? iconColumnWidth : parent.width | ||
32 | property alias layout: hiddenTasksColumn | 34 | property alias layout: hiddenTasksColumn | ||
33 | //Useful to align stuff to the column of icons, both in expanded and shrink modes | 35 | //Useful to align stuff to the column of icons, both in expanded and shrink modes | ||
34 | property int iconColumnWidth: root.hiddenItemSize + highlight.marginHints.left + highlight.marginHints.right | 36 | property int iconColumnWidth: root.hiddenItemSize + highlight.marginHints.left + highlight.marginHints.right | ||
35 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | | |||
36 | verticalScrollBarPolicy: activeApplet ? Qt.ScrollBarAlwaysOff : Qt.ScrollBarAsNeeded | | |||
37 | 37 | | |||
38 | Flickable { | 38 | hoverEnabled: true | ||
39 | contentWidth: width | 39 | onExited: hiddenTasksColumn.currentIndex = -1 | ||
40 | contentHeight: hiddenTasksColumn.height | | |||
41 | 40 | | |||
42 | MouseArea { | 41 | PlasmaExtras.ScrollArea { | ||
43 | width: parent.width | 42 | width: parent.width | ||
44 | height: hiddenTasksColumn.height | 43 | height: parent.height | ||
45 | drag.filterChildren: true | | |||
46 | hoverEnabled: true | | |||
47 | onExited: hiddenTasksColumn.hoveredItem = null; | | |||
48 | 44 | | |||
49 | CurrentItemHighLight { | 45 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | ||
50 | target: root.activeApplet && root.activeApplet.parent.parent == hiddenTasksColumn ? root.activeApplet.parent : null | 46 | verticalScrollBarPolicy: root.activeApplet ? Qt.ScrollBarAlwaysOff : Qt.ScrollBarAsNeeded | ||
51 | location: PlasmaCore.Types.LeftEdge | | |||
52 | } | | |||
53 | PlasmaComponents.Highlight { | | |||
54 | id: highlight | | |||
55 | visible: hiddenTasksColumn.hoveredItem != null && !root.activeApplet | | |||
56 | y: hiddenTasksColumn.hoveredItem ? hiddenTasksColumn.hoveredItem.y : 0 | | |||
57 | width: hiddenTasksColumn.hoveredItem ? hiddenTasksColumn.hoveredItem.width : 0 | | |||
58 | height: hiddenTasksColumn.hoveredItem ? hiddenTasksColumn.hoveredItem.height : 0 | | |||
59 | } | | |||
60 | 47 | | |||
61 | Column { | 48 | ListView { | ||
62 | id: hiddenTasksColumn | 49 | id: hiddenTasksColumn | ||
63 | 50 | | |||
64 | spacing: units.smallSpacing | 51 | spacing: units.smallSpacing | ||
65 | width: parent.width | 52 | | ||
66 | property Item hoveredItem | 53 | currentIndex: -1 | ||
54 | highlight: PlasmaComponents.Highlight {} | ||||
55 | highlightMoveDuration: 0 | ||||
56 | highlightResizeDuration: 0 | ||||
57 | | ||||
67 | readonly property int iconItemHeight: root.hiddenItemSize + highlight.marginHints.top + highlight.marginHints.bottom | 58 | readonly property int iconItemHeight: root.hiddenItemSize + highlight.marginHints.top + highlight.marginHints.bottom | ||
59 | | ||||
60 | model: PlasmaCore.SortFilterModel { | ||||
61 | sourceModel: plasmoid.nativeInterface.systemTrayModel | ||||
62 | filterRole: "effectiveStatus" | ||||
63 | filterCallback: function(source_row, value) { | ||||
64 | return value === PlasmaCore.Types.PassiveStatus | ||||
68 | } | 65 | } | ||
69 | } | 66 | } | ||
67 | delegate: ItemLoader {} | ||||
68 | } | ||||
69 | } | ||||
70 | | ||||
71 | PlasmaComponents.Highlight { | ||||
72 | id: highlight | ||||
73 | visible: false | ||||
74 | } | ||||
75 | | ||||
76 | CurrentItemHighLight { | ||||
77 | parent: hiddenTasksColumn.contentItem | ||||
78 | target: root.activeApplet && root.activeApplet.parent && root.activeApplet.parent.inHiddenLayout ? root.activeApplet.parent.parent : null | ||||
79 | location: PlasmaCore.Types.LeftEdge | ||||
70 | } | 80 | } | ||
71 | } | 81 | } |