syncthingtray/plasmoid/package/contents/ui/DownloadsPage.qml

154 lines
6.4 KiB
QML
Raw Normal View History

import QtQuick 2.3
import QtQuick.Layouts 1.1
2017-09-07 19:21:37 +02:00
import QtQml.Models 2.2
2020-11-30 19:11:50 +01:00
import QtQuick.Controls 2.15 as QQC2
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
property alias view: downloadView
objectName: "DownloadsPage"
PlasmaComponents3.ScrollView {
anchors.fill: parent
2022-05-09 23:14:22 +02:00
// HACK: workaround for https://bugreports.qt.io/browse/QTBUG-83890
PlasmaComponents3.ScrollBar.horizontal.policy: PlasmaComponents3.ScrollBar.AlwaysOff
contentItem: TopLevelView {
id: downloadView
model: plasmoid.nativeInterface.downloadModel
delegate: TopLevelItem {
2017-09-07 19:21:37 +02:00
id: item
width: downloadView.width
readonly property string downloadName: name
property alias openButton: openButton
2017-09-07 19:21:37 +02:00
ColumnLayout {
width: parent.width
spacing: 0
RowLayout {
id: itemSummary
Layout.fillWidth: true
2017-09-07 19:21:37 +02:00
RowLayout {
spacing: units.smallSpacing
PlasmaComponents3.Label {
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
2017-09-07 19:21:37 +02:00
elide: Text.ElideRight
text: name ? name : "?"
2017-09-07 19:21:37 +02:00
}
}
PlasmaComponents3.ProgressBar {
2017-09-07 19:21:37 +02:00
Layout.fillWidth: true
Layout.fillHeight: true
from: 0.0
to: 100.0
value: percentage ? percentage : 0.0
2017-09-07 19:21:37 +02:00
}
RowLayout {
id: toolButtonsLayout
spacing: 0
PlasmaComponents3.Label {
2017-09-07 19:21:37 +02:00
height: implicitHeight
text: progressLabel ? progressLabel : ""
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
2017-09-07 19:21:37 +02:00
}
Item {
width: 3
}
TinyButton {
id: openButton
icon.source: "image://fa/folder"
2017-09-07 19:21:37 +02:00
tooltip: qsTr("Open in file browser")
enabled: path !== undefined
2017-09-07 19:21:37 +02:00
onClicked: {
Qt.openUrlExternally(path)
plasmoid.expanded = false
}
}
}
}
2017-09-07 19:21:37 +02:00
DetailView {
id: detailsView
visible: item.expanded
Layout.fillWidth: true
2017-09-07 19:21:37 +02:00
model: DelegateModel {
model: plasmoid.nativeInterface.downloadModel
rootIndex: detailsView.model.modelIndex(index)
delegate: RowLayout {
width: detailsView.width
2017-09-07 19:21:37 +02:00
PlasmaCore.IconItem {
Layout.preferredWidth: units.iconSizes.medium
Layout.preferredHeight: units.iconSizes.medium
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
2017-09-07 19:21:37 +02:00
source: fileIcon
}
ColumnLayout {
spacing: 0
Layout.fillWidth: true
RowLayout {
spacing: units.smallSpacing
2017-09-07 19:21:37 +02:00
Layout.fillWidth: true
PlasmaComponents3.Label {
2017-09-07 19:21:37 +02:00
Layout.fillWidth: true
text: name
font.pointSize: theme.defaultFont.pointSize * 0.8
2017-09-07 19:21:37 +02:00
elide: Text.ElideRight
}
PlasmaComponents3.Label {
2017-09-07 19:21:37 +02:00
text: progressLabel
font.pointSize: theme.defaultFont.pointSize * 0.8
2017-09-07 19:21:37 +02:00
elide: Text.ElideRight
}
}
PlasmaComponents3.ProgressBar {
2017-09-07 19:21:37 +02:00
Layout.fillWidth: true
Layout.preferredHeight: 8
Layout.topMargin: 0
from: 0.0
to: 100.0
2017-09-07 19:21:37 +02:00
value: percentage
}
}
TinyButton {
icon.source: "image://fa/folder"
2017-09-07 19:21:37 +02:00
tooltip: qsTr("Open in file browser")
onClicked: {
Qt.openUrlExternally(path + "/..")
2017-09-07 19:21:37 +02:00
plasmoid.expanded = false
}
}
}
}
}
}
}
2020-11-30 19:11:50 +01:00
QQC2.Menu {
id: contextMenu
2020-11-30 19:11:50 +01:00
QQC2.MenuItem {
text: qsTr("Copy label/ID")
2020-11-30 19:11:50 +01:00
icon.name: "edit-copy"
onTriggered: downloadView.copyCurrentItemData("downloadName")
}
2020-11-30 19:11:50 +01:00
QQC2.MenuSeparator {
}
2020-11-30 19:11:50 +01:00
QQC2.MenuItem {
id: openItem
text: qsTr("Open in file browser")
2020-11-30 19:11:50 +01:00
icon.name: "folder"
onTriggered: downloadView.clickCurrentItemButton("openButton")
}
}
}
}
}