QtDeployer/source/QML/PathChooser.qml

71 lines
1.3 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
2018-05-10 14:08:58 +03:00
placeholderText: qsTr("Enter path or browse")
2018-03-12 11:43:03 +03:30
onTextChanged: {
if (!MainManager.pathExists(isdir, text))
{
2018-05-10 14:08:58 +03:00
wlabel.text = qsTr("Path doesn't exist")
2018-03-12 11:43:03 +03:30
confirmed = false
}
else if (!MainManager.hasPrems(text))
{
2018-05-10 14:08:58 +03:00
wlabel.text = qsTr("I don't have permission to access this path")
2018-03-12 11:43:03 +03:30
confirmed = false
}
else
{
2018-05-10 14:08:58 +03:00
wlabel.text = qsTr("This path is OK")
2018-03-12 11:43:03 +03:30
confirmed = true
}
}
}
Button {
2018-08-16 19:20:04 +03:00
text: qsTr("Browse")
2018-03-12 11:43:03 +03:30
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)
}
}