QtDeployer/source/QML/PathChooser.qml

71 lines
1.2 KiB
QML
Raw Normal View History

2018-03-12 11:43:03 +03:30
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
ColumnLayout {
id: root
Layout.fillHeight: false
property string title
property bool isdir: true
property bool confirmed: false
property alias content: field.text
Label {
text: title
elide: Text.ElideRight
Layout.fillWidth: true
font.pointSize: mediumFont
}
RowLayout {
Layout.fillHeight: false
TextField {
id: field
Layout.fillWidth: true
placeholderText: "Enter path or browse"
onTextChanged: {
if (!MainManager.pathExists(isdir, text))
{
wlabel.text = "Path doesn't exist"
confirmed = false
}
else if (!MainManager.hasPrems(text))
{
wlabel.text = "I don't have permission to access this path"
confirmed = false
}
else
{
wlabel.text = "This path is OK"
confirmed = true
}
}
}
Button {
text: "Browse"
onClicked: fd.open()
Material.background: buttonColor
}
}
Label {
id: wlabel
elide: Text.ElideRight
Layout.fillWidth: true
}
FileDialog {
id: fd
selectFolder: isdir
selectMultiple: false
onAccepted: field.text = MainManager.stringFromUrl(isdir ? folder:fileUrl)
}
}