Commit 58cc2a47 authored by Don Gagne's avatar Don Gagne

Show existing file to save to

parent 44682709
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
...@@ -21,12 +22,14 @@ Item { ...@@ -21,12 +22,14 @@ Item {
property bool selectExisting property bool selectExisting
property bool selectFolder property bool selectFolder
property bool _openForLoad property bool _openForLoad: true
property real _margins: ScreenTools.defaultFontPixelHeight / 2 property real _margins: ScreenTools.defaultFontPixelHeight / 2
property bool _mobile: ScreenTools.isMobile
function openForLoad() { function openForLoad() {
_openForLoad = true _openForLoad = true
if (ScreenTools.isMobile && folder.length !== 0) { if (_mobile && folder.length !== 0) {
qgcView.showDialog(mobileFileOpenDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel) qgcView.showDialog(mobileFileOpenDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel)
} else { } else {
fullFileDialog.open() fullFileDialog.open()
...@@ -35,7 +38,7 @@ Item { ...@@ -35,7 +38,7 @@ Item {
function openForSave() { function openForSave() {
_openForLoad = false _openForLoad = false
if (ScreenTools.isMobile && folder.length !== 0) { if (_mobile && folder.length !== 0) {
qgcView.showDialog(mobileFileSaveDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) qgcView.showDialog(mobileFileSaveDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
} else { } else {
fullFileDialog.open() fullFileDialog.open()
...@@ -76,30 +79,36 @@ Item { ...@@ -76,30 +79,36 @@ Item {
id: mobileFileOpenDialog id: mobileFileOpenDialog
QGCViewDialog { QGCViewDialog {
Item { QGCFlickable {
anchors.margins: _margins anchors.fill: parent
anchors.fill: parent contentHeight: fileOpenColumn.height
QGCListView { Column {
id: listView id: fileOpenColumn
anchors.fill: parent anchors.left: parent.left
spacing: _margins / 2 anchors.right: parent.right
orientation: ListView.Vertical spacing: ScreenTools.defaultFontPixelHeight / 2
model: controller.getFiles(folder, fileExtension)
Repeater {
delegate: QGCButton { id: fileList;
text: modelData model: controller.getFiles(folder, fileExtension)
onClicked: { QGCButton {
hideDialog() anchors.left: parent.left
_root.acceptedForLoad(controller.fullyQualifiedFilename(folder, modelData, fileExtension)) anchors.right: parent.right
text: modelData
onClicked: {
hideDialog()
_root.acceptedForLoad(controller.fullyQualifiedFilename(folder, modelData, fileExtension))
}
} }
} }
}
QGCLabel { QGCLabel {
text: qsTr("No files") text: qsTr("No files")
visible: listView.model.length == 0 visible: fileList.model.length == 0
}
} }
} }
} }
...@@ -123,35 +132,69 @@ Item { ...@@ -123,35 +132,69 @@ Item {
hideDialog() hideDialog()
} }
Column { QGCFlickable {
anchors.left: parent.left anchors.fill: parent
anchors.right: parent.right contentHeight: fileSaveColumn.height
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel { Column {
text: qsTr("File name:") id: fileSaveColumn
}
QGCTextField {
id: filenameTextField
onTextChanged: replaceMessage.visible = false
}
QGCLabel {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
wrapMode: Text.WordWrap spacing: ScreenTools.defaultFontPixelHeight / 2
text: qsTr("File names must end with .%1 file extension. If missing it will be added.").arg(fileExtension)
} RowLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel { text: qsTr("New file name:") }
QGCTextField {
id: filenameTextField
Layout.fillWidth: true
onTextChanged: replaceMessage.visible = false
}
}
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("File names must end with .%1 file extension. If missing it will be added.").arg(fileExtension)
}
QGCLabel {
id: replaceMessage
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("The file %1 exists. Click Save again to replace it.").arg(filenameTextField.text)
visible: false
color: qgcPal.warningText
}
SectionHeader {
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Save to existing file:")
}
Repeater {
model: controller.getFiles(folder, fileExtension)
QGCButton {
anchors.left: parent.left
anchors.right: parent.right
text: modelData
onClicked: {
hideDialog()
_root.acceptedForSave(controller.fullyQualifiedFilename(folder, modelData, fileExtension))
}
}
}
QGCLabel {
id: replaceMessage
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("The file %1 exists. Click Save again to replace it.").arg(filenameTextField.text)
visible: false
color: qgcPal.warningText
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment