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

145 lines
5.9 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
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
Item {
property alias view: downloadView
anchors.fill: parent
objectName: "DownloadsPage"
PlasmaExtras.ScrollArea {
anchors.fill: parent
TopLevelView {
id: downloadView
model: plasmoid.nativeInterface.downloadModel
delegate: TopLevelItem {
2017-09-07 19:21:37 +02:00
id: item
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
2017-09-07 19:21:37 +02:00
PlasmaComponents.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
}
}
PlasmaComponents.ProgressBar {
Layout.fillWidth: true
Layout.fillHeight: true
minimumValue: 0
maximumValue: 100
value: percentage ? percentage : 0
2017-09-07 19:21:37 +02:00
}
RowLayout {
id: toolButtonsLayout
spacing: 0
PlasmaComponents.Label {
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
2017-09-07 19:21:37 +02:00
iconSource: "folder"
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
PlasmaComponents.Label {
Layout.fillWidth: true
text: name
font.pointSize: theme.defaultFont.pointSize * 0.8
2017-09-07 19:21:37 +02:00
elide: Text.ElideRight
}
PlasmaComponents.Label {
text: progressLabel
font.pointSize: theme.defaultFont.pointSize * 0.8
2017-09-07 19:21:37 +02:00
elide: Text.ElideRight
}
}
PlasmaComponents.ProgressBar {
Layout.fillWidth: true
Layout.preferredHeight: 8
Layout.topMargin: 0
minimumValue: 0
maximumValue: 100
value: percentage
}
}
TinyButton {
2017-09-07 19:21:37 +02:00
iconSource: "folder"
tooltip: qsTr("Open in file browser")
onClicked: {
Qt.openUrlExternally(path + "/..")
2017-09-07 19:21:37 +02:00
plasmoid.expanded = false
}
}
}
}
}
}
}
PlasmaComponents.Menu {
id: contextMenu
PlasmaComponents.MenuItem {
id: openItem
text: qsTr('Open in file browser')
icon: "folder"
onClicked: downloadView.clickCurrentItemButton("openButton")
}
}
}
}
}