2017-08-29 23:58:49 +02:00
|
|
|
import QtQuick 2.3
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
import QtQml.Models 2.2
|
2020-11-27 19:09:47 +01:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents3
|
2017-08-29 23:58:49 +02:00
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2023-05-21 20:14:24 +02:00
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
2017-08-29 23:58:49 +02:00
|
|
|
|
2017-10-01 17:54:11 +02:00
|
|
|
ColumnLayout {
|
2017-08-29 23:58:49 +02:00
|
|
|
property alias view: directoryView
|
2017-10-01 17:54:11 +02:00
|
|
|
property alias filter: filter
|
2017-08-29 23:58:49 +02:00
|
|
|
objectName: "DirectoriesPage"
|
|
|
|
|
2021-11-25 20:27:58 +01:00
|
|
|
PlasmaComponents3.TextField {
|
2023-05-21 20:14:24 +02:00
|
|
|
Layout.topMargin: Kirigami.Units.smallSpacing * 2
|
|
|
|
Layout.leftMargin: Kirigami.Units.smallSpacing * 2
|
|
|
|
Layout.rightMargin: Kirigami.Units.smallSpacing * 2
|
2021-11-25 20:27:58 +01:00
|
|
|
property bool explicitelyShown: false
|
|
|
|
id: filter
|
|
|
|
clearButtonShown: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: explicitelyShown || text !== ""
|
2023-09-18 22:16:23 +02:00
|
|
|
placeholderText: qsTr("Filter folders")
|
2021-11-25 20:27:58 +01:00
|
|
|
onTextChanged: directoryView.model.filterRegularExpression = new RegExp(text)
|
|
|
|
}
|
|
|
|
|
2022-05-05 20:51:53 +02:00
|
|
|
PlasmaComponents3.ScrollView {
|
2017-10-01 17:54:11 +02:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2017-08-29 23:58:49 +02:00
|
|
|
|
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 {
|
2017-08-29 23:58:49 +02:00
|
|
|
id: directoryView
|
2023-05-21 20:14:24 +02:00
|
|
|
model: plasmoid.sortFilterDirModel
|
2017-08-29 23:58:49 +02:00
|
|
|
|
|
|
|
delegate: TopLevelItem {
|
|
|
|
id: item
|
2022-09-01 22:32:17 +02:00
|
|
|
width: directoryView.effectiveWidth()
|
2020-10-07 21:34:37 +02:00
|
|
|
readonly property string dirName: name
|
|
|
|
readonly property string dirPath: path
|
2017-09-26 23:46:20 +02:00
|
|
|
property alias errorsButton: errorsButton
|
|
|
|
property alias rescanButton: rescanButton
|
|
|
|
property alias resumePauseButton: resumePauseButton
|
|
|
|
property alias openButton: openButton
|
2017-08-29 23:58:49 +02:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
width: parent.width
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: itemSummary
|
2017-10-01 21:22:37 +02:00
|
|
|
Layout.fillWidth: true
|
2017-08-29 23:58:49 +02:00
|
|
|
|
2023-11-14 01:50:24 +01:00
|
|
|
Kirigami.Icon {
|
2023-11-14 23:58:22 +01:00
|
|
|
Layout.preferredWidth: Kirigami.Units.iconSizes.small
|
|
|
|
Layout.preferredHeight: Kirigami.Units.iconSizes.small
|
2018-06-30 17:45:03 +02:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2017-09-08 16:59:53 +02:00
|
|
|
source: statusIcon
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.Label {
|
2017-08-29 23:58:49 +02:00
|
|
|
Layout.fillWidth: true
|
2018-06-30 17:45:03 +02:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2017-09-08 16:59:53 +02:00
|
|
|
elide: Text.ElideRight
|
|
|
|
text: name
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
id: toolButtonsLayout
|
|
|
|
spacing: 0
|
|
|
|
|
2020-11-27 19:09:47 +01:00
|
|
|
PlasmaComponents3.Label {
|
2017-08-29 23:58:49 +02:00
|
|
|
height: implicitHeight
|
|
|
|
text: statusString
|
2023-11-14 23:58:22 +01:00
|
|
|
color: statusColor ? statusColor : Kirigami.Theme.textColor
|
2018-06-30 17:45:03 +02:00
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
Item {
|
2023-11-14 23:58:22 +01:00
|
|
|
width: Kirigami.Units.smallSpacing
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-12 00:00:16 +02:00
|
|
|
TinyButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: errorsButton
|
2023-05-21 20:14:24 +02:00
|
|
|
icon.source: plasmoid.faUrl + "exclamation-triangle"
|
2017-09-08 16:59:53 +02:00
|
|
|
tooltip: qsTr("Show errors")
|
2018-11-03 21:30:17 +01:00
|
|
|
visible: pullErrorCount > 0
|
2017-09-08 16:59:53 +02:00
|
|
|
onClicked: {
|
2023-05-21 20:14:24 +02:00
|
|
|
plasmoid.showDirectoryErrors(
|
2023-04-26 20:30:23 +02:00
|
|
|
dirId)
|
2017-09-08 16:59:53 +02:00
|
|
|
plasmoid.expanded = false
|
|
|
|
}
|
|
|
|
}
|
2017-09-12 00:00:16 +02:00
|
|
|
TinyButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: rescanButton
|
2023-05-21 20:14:24 +02:00
|
|
|
icon.source: plasmoid.faUrl + "refresh"
|
2017-08-29 23:58:49 +02:00
|
|
|
tooltip: qsTr("Rescan")
|
2017-09-26 15:27:55 +02:00
|
|
|
enabled: !paused
|
2023-05-21 20:14:24 +02:00
|
|
|
onClicked: plasmoid.connection.rescan(
|
2017-09-09 21:40:00 +02:00
|
|
|
dirId)
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-12 00:00:16 +02:00
|
|
|
TinyButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: resumePauseButton
|
2023-05-21 20:14:24 +02:00
|
|
|
icon.source: plasmoid.faUrl + (paused ? "play" : "pause")
|
2017-08-29 23:58:49 +02:00
|
|
|
tooltip: paused ? qsTr("Resume") : qsTr("Pause")
|
2017-09-09 21:40:00 +02:00
|
|
|
onClicked: {
|
2023-05-21 20:14:24 +02:00
|
|
|
paused ? plasmoid.connection.resumeDirectories(
|
|
|
|
[dirId]) : plasmoid.connection.pauseDirectories(
|
2017-09-09 21:40:00 +02:00
|
|
|
[dirId])
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
2017-09-12 00:00:16 +02:00
|
|
|
TinyButton {
|
2017-09-26 23:46:20 +02:00
|
|
|
id: openButton
|
2023-05-21 20:14:24 +02:00
|
|
|
icon.source: plasmoid.faUrl + "folder"
|
2017-08-29 23:58:49 +02:00
|
|
|
tooltip: qsTr("Open in file browser")
|
|
|
|
onClicked: {
|
2023-05-21 20:14:24 +02:00
|
|
|
Qt.openUrlExternally(plasmoid.substituteTilde(path))
|
2017-08-29 23:58:49 +02:00
|
|
|
plasmoid.expanded = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DetailView {
|
|
|
|
id: detailsView
|
|
|
|
visible: item.expanded
|
2017-10-01 21:22:37 +02:00
|
|
|
Layout.fillWidth: true
|
2019-02-27 20:41:50 +01:00
|
|
|
Layout.topMargin: 3
|
2017-08-29 23:58:49 +02:00
|
|
|
|
|
|
|
model: DelegateModel {
|
2023-05-21 20:14:24 +02:00
|
|
|
model: plasmoid.dirModel
|
2020-10-18 15:48:02 +02:00
|
|
|
rootIndex: directoryView.model.mapToSource(directoryView.model.index(index, 0))
|
2017-09-09 21:40:00 +02:00
|
|
|
delegate: DetailItem {
|
2019-03-19 23:05:31 +01:00
|
|
|
width: detailsView.width
|
2017-09-09 21:40:00 +02:00
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-26 22:56:55 +02:00
|
|
|
|
2023-05-21 20:14:24 +02:00
|
|
|
PlasmaExtras.Menu {
|
2018-03-26 22:56:55 +02:00
|
|
|
id: contextMenu
|
|
|
|
|
|
|
|
function init(item) {
|
|
|
|
// use value for properties depending on paused state from buttons
|
|
|
|
rescanItem.enabled = item.rescanButton.enabled
|
|
|
|
resumePauseItem.text = item.resumePauseButton.tooltip
|
2020-04-13 02:04:20 +02:00
|
|
|
resumePauseItem.icon = item.resumePauseButton.icon
|
2018-03-26 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
2023-05-21 20:14:24 +02:00
|
|
|
PlasmaExtras.MenuItem {
|
2020-10-07 21:34:37 +02:00
|
|
|
text: qsTr("Copy label/ID")
|
|
|
|
icon: "edit-copy"
|
|
|
|
onClicked: directoryView.copyCurrentItemData("dirName")
|
|
|
|
}
|
2023-05-21 20:14:24 +02:00
|
|
|
PlasmaExtras.MenuItem {
|
2020-10-07 21:34:37 +02:00
|
|
|
text: qsTr("Copy path")
|
|
|
|
icon: "edit-copy"
|
|
|
|
onClicked: directoryView.copyCurrentItemData("dirPath")
|
|
|
|
}
|
2023-05-21 20:14:24 +02:00
|
|
|
PlasmaExtras.MenuItem {
|
2020-10-07 21:34:37 +02:00
|
|
|
separator: true
|
|
|
|
}
|
2023-05-21 20:14:24 +02:00
|
|
|
PlasmaExtras.MenuItem {
|
2018-03-26 22:56:55 +02:00
|
|
|
id: rescanItem
|
2020-10-07 21:34:37 +02:00
|
|
|
text: qsTr("Rescan")
|
2018-03-26 22:56:55 +02:00
|
|
|
icon: "view-refresh"
|
|
|
|
onClicked: directoryView.clickCurrentItemButton(
|
|
|
|
"rescanButton")
|
|
|
|
}
|
2023-05-21 20:14:24 +02:00
|
|
|
PlasmaExtras.MenuItem {
|
2018-03-26 22:56:55 +02:00
|
|
|
id: resumePauseItem
|
|
|
|
text: qsTr("Pause")
|
|
|
|
icon: "media-playback-pause"
|
|
|
|
onClicked: directoryView.clickCurrentItemButton(
|
|
|
|
"resumePauseButton")
|
|
|
|
}
|
2023-05-21 20:14:24 +02:00
|
|
|
PlasmaExtras.MenuItem {
|
2018-03-26 22:56:55 +02:00
|
|
|
id: openItem
|
2020-10-07 21:34:37 +02:00
|
|
|
text: qsTr("Open in file browser")
|
2018-03-26 22:56:55 +02:00
|
|
|
icon: "folder"
|
|
|
|
onClicked: directoryView.clickCurrentItemButton(
|
|
|
|
"openButton")
|
|
|
|
}
|
|
|
|
}
|
2017-08-29 23:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|