mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-11-07 13:02:17 +00:00
wip: qml components
This commit is contained in:
33
ui/qmls/Components/FileSelector.qml
Normal file
33
ui/qmls/Components/FileSelector.qml
Normal file
@ -0,0 +1,33 @@
|
||||
import QtQuick
|
||||
import QtQuick.Dialogs
|
||||
|
||||
import internal.ui.utils
|
||||
|
||||
SelectorBase {
|
||||
id: base
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
onAccepted: {
|
||||
base.url = this.selectedFile;
|
||||
}
|
||||
}
|
||||
|
||||
function isFileUrlValid(url: url): bool {
|
||||
return url.toString().startsWith("file://");
|
||||
}
|
||||
|
||||
property alias fileUrl: base.url
|
||||
onFileUrlChanged: {
|
||||
if (isFileUrlValid(fileUrl)) {
|
||||
fileDialog.selectedFile = fileUrl;
|
||||
fileDialog.currentFolder = UrlUtils.parent(fileUrl);
|
||||
}
|
||||
}
|
||||
|
||||
shouldAcceptUrl: url => UrlUtils.isFile(url)
|
||||
onBrowseButtonClicked: {
|
||||
fileDialog.open();
|
||||
}
|
||||
placeholderText: '<font color="gray">Select a file…</font>'
|
||||
}
|
||||
Reference in New Issue
Block a user