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
|
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Material
import QtQuick.Dialogs
import Main
ItemDelegate {
id: delegate
Layout.fillWidth: true
onClicked: {
selectionEnabledSwitch.toggle();
selectionEnabledSwitch.toggled();
}
contentItem: RowLayout {
spacing: 15
ForkAwesomeIcon {
id: icon
}
ColumnLayout {
Layout.fillWidth: true
Label {
id: mainLabel
text: delegate.text
Layout.fillWidth: true
elide: Text.ElideRight
font.weight: Font.Medium
wrapMode: Text.WordWrap
}
Label {
id: descriptionLabel
Layout.fillWidth: true
elide: Text.ElideRight
font.weight: Font.Light
wrapMode: Text.WordWrap
}
}
Switch {
id: selectionEnabledSwitch
onToggled: selectionEnabledSwitch.checked && selectionDlg.open()
}
}
CustomDialog {
id: selectionDlg
implicitHeight: parent.height
standardButtons: Dialog.Ok
contentItem: CustomListView {
id: selectionView
height: availableHeight
delegate: ItemDelegate {
width: selectionView.width
onClicked: {
selectionCheckBox.toggle();
selectionCheckBox.toggled();
}
contentItem: RowLayout {
CheckBox {
id: selectionCheckBox
onToggled: selectionView.model.setProperty(modelData.index, "checked", checked)
}
ColumnLayout {
Layout.fillWidth: true
Label {
Layout.fillWidth: true
text: modelData.displayName
font.weight: Font.Medium
elide: Text.ElideRight
wrapMode: Text.WordWrap
}
ItemDelegate {
Layout.fillWidth: true
visible: modelData.path !== undefined
height: visible ? implicitHeight : 0
text: modelData.path ?? ""
icon.source: App.faUrlBase + "folder-open-o"
icon.width: App.iconWidthDelegate
icon.height: App.iconSize
onClicked: folderDlg.open()
}
}
}
FolderDialog {
id: folderDlg
title: qsTr("Set folder path of %1").arg(modelData.displayName)
currentFolder: "file://" + encodeURIComponent(modelData.path ?? "")
onAccepted: selectionView.model.setProperty(modelData.index, "path", App.resolveUrl(folderDlg.selectedFolder))
}
property alias folderDialog: folderDlg
required property var modelData
}
}
}
property alias description: descriptionLabel.text
property alias iconName: icon.iconName
property alias dialogTitle: selectionDlg.title
property alias model: selectionView.model
property alias selectionEnabled: selectionEnabledSwitch.checked
property alias selectionView: selectionView
function accept() {
selectionDlg.accept();
}
}
|