HiddenItemsView.qml 3.75 KB
Newer Older
1
2
/*
 *   Copyright 2016 Marco Martin <mart@kde.org>
3
 *   Copyright 2020 Konrad Materka <materka@gmail.com>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import QtQuick 2.1
import QtQuick.Layouts 1.1
23
import org.kde.plasma.core 2.1 as PlasmaCore
Marco Martin's avatar
Marco Martin committed
24
import org.kde.plasma.components 2.0 as PlasmaComponents
25
26
import org.kde.plasma.extras 2.0 as PlasmaExtras

27
import "items"
28

29
MouseArea {
30
31
    id: hiddenTasksView

32
33
    visible: !root.activeApplet || (root.activeApplet.parent && root.activeApplet.parent.inHiddenLayout)
    implicitWidth: root.activeApplet ? iconColumnWidth : parent.width
34
    property alias layout: hiddenTasksColumn
Marco Martin's avatar
Marco Martin committed
35
36
    //Useful to align stuff to the column of icons, both in expanded and shrink modes
    property int iconColumnWidth: root.hiddenItemSize + highlight.marginHints.left + highlight.marginHints.right
37

38
39
    hoverEnabled: true
    onExited: hiddenTasksColumn.currentIndex = -1
40

41
42
43
    PlasmaExtras.ScrollArea {
        width: parent.width
        height: parent.height
44
        frameVisible: false
45

46
47
48
49
50
51
52
53
54
55
56
57
        horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
        verticalScrollBarPolicy: root.activeApplet ? Qt.ScrollBarAlwaysOff : Qt.ScrollBarAsNeeded

        ListView {
            id: hiddenTasksColumn

            spacing: units.smallSpacing

            currentIndex: -1
            highlight: PlasmaComponents.Highlight {}
            highlightMoveDuration: 0
            highlightResizeDuration: 0
58

59
            readonly property int iconItemHeight: root.hiddenItemSize + highlight.marginHints.top + highlight.marginHints.bottom
60
            property int itemCount: model.rowCount()
61

62
63
64
65
66
67
            model: PlasmaCore.SortFilterModel {
                sourceModel: plasmoid.nativeInterface.systemTrayModel
                filterRole: "effectiveStatus"
                filterCallback: function(source_row, value) {
                    return value === PlasmaCore.Types.PassiveStatus
                }
68
            }
69
            delegate: ItemLoader {}
70
71
        }
    }
72

73
74
75
76
77
78
79
80
81
82
    Connections {
        target: hiddenTasksColumn.model
        // hiddenTasksColumn.count is not updated when ListView is hidden and is not rendered
        // manually update itemCount so that expander arrow hides/shows itself correctly
        onModelReset: hiddenTasksColumn.itemCount = hiddenTasksColumn.model.rowCount()
        onRowsInserted: hiddenTasksColumn.itemCount = hiddenTasksColumn.model.rowCount()
        onRowsRemoved: hiddenTasksColumn.itemCount = hiddenTasksColumn.model.rowCount()
        onLayoutChanged: hiddenTasksColumn.itemCount = hiddenTasksColumn.model.rowCount()
    }

83
84
85
86
87
88
    PlasmaComponents.Highlight {
        id: highlight
        visible: false
    }

    CurrentItemHighLight {
89
90
91
92
        readonly property bool hiddenAppletActivated: root.activeApplet && root.activeApplet.parent && root.activeApplet.parent.inHiddenLayout
        parent: hiddenAppletActivated ? root.activeApplet.parent : hiddenTasksColumn.contentItem
        target: hiddenAppletActivated ? root.activeApplet.parent : null
        location: LayoutMirroring.enabled ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.LeftEdge
93
    }
94
}