File: ProgressStatusBar.qml

package info (click to toggle)
merkuro 24.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,408 kB
  • sloc: cpp: 14,285; xml: 1,334; javascript: 280; makefile: 8; sh: 3
file content (117 lines) | stat: -rw-r--r-- 4,123 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// SPDX-FileCopyrightText: 2024 Claudio Cambra <claudio.cambra@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later

import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.akonadi as Akonadi
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.delegates as Delegates

RowLayout {
    id: root

    readonly property alias working: progressModel.working
    readonly property bool popupOpen: popupLoader.active && popupLoader.item.visible
    
    property int popupMaxHeight: 300

    onVisibleChanged: if (!visible) popupLoader.active = false

    Akonadi.ProgressModel {
        id: progressModel
        onShowProgressView: popupLoader.active = true
    }

    QQC2.ProgressBar {
        id: progressBar

        Layout.fillWidth: true

        from: 0
        to: 100
        value: progressModel.progress
        indeterminate: progressModel.indeterminate
    }

    QQC2.Button {
        Layout.maximumHeight: progressBar.implicitHeight
        display: QQC2.AbstractButton.IconOnly
        icon.name: root.popupOpen ? "usermenu-down" : "usermenu-up"
        visible: progressModel.working
        onClicked: popupLoader.active = !popupLoader.active
    }

    Loader {
        id: popupLoader

        active: false
        sourceComponent: QQC2.Popup {
            id: progressPopup

            readonly property point rootPoint: mapFromItem(root, root.x, root.y)
            readonly property int listViewTopMargin: Kirigami.Units.largeSpacing
            readonly property int listViewBottomMargin: Kirigami.Units.largeSpacing
            readonly property int scrollInternalHeight:
                contentItem.contentHeight + listViewTopMargin + listViewBottomMargin

            x: rootPoint.x
            y: rootPoint.y - height
            width: root.width
            height: Math.min(scrollInternalHeight, root.popupMaxHeight)
            padding: 0

            contentItem: QQC2.ScrollView {
                ListView {
                    topMargin: progressPopup.listViewTopMargin
                    bottomMargin: progressPopup.listViewBottomMargin
                    spacing: Kirigami.Units.largeSpacing

                    model: progressModel
                    delegate: ColumnLayout {
                        anchors.left: parent.left
                        anchors.right: parent.right
                        anchors.leftMargin: Kirigami.Units.smallSpacing
                        anchors.rightMargin: Kirigami.Units.smallSpacing

                        spacing: 0

                        QQC2.Label {
                            Layout.fillWidth: true
                            text: model.display
                            font.bold: true
                            elide: Text.ElideRight
                        }
                        QQC2.Label {
                            Layout.fillWidth: true
                            text: model.status
                            wrapMode: Text.Wrap
                        }
                        RowLayout {
                            spacing: 0

                            QQC2.ProgressBar {
                                Layout.fillWidth: true
                                id: itemProgressBar
                                from: 0
                                to: 100
                                value: model.progress
                                indeterminate: model.usesBusyIndicator
                            }
                            QQC2.Button {
                                Layout.maximumHeight: itemProgressBar.implicitHeight
                                display: QQC2.AbstractButton.IconOnly
                                flat: true
                                text: i18n("Cancel")
                                icon.name: "process-stop"
                                visible: model.canBeCancelled
                                onClicked: progressModel.cancelItem(model.id)
                            }
                        }
                    }
                }
            }
        }
        onLoaded: item.open()
    }
}