mobile/export: fix horrendous user interface

This should never have been merged as it was. The UI was atrocious and the
functionality was by and large untested.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-02-15 11:46:01 -08:00
parent d8cc2b57b2
commit d6c47ad362

View file

@ -7,7 +7,7 @@ import QtQuick.Dialogs 1.3
import org.subsurfacedivelog.mobile 1.0 import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 2.4 as Kirigami import org.kde.kirigami 2.4 as Kirigami
Kirigami.ScrollablePage { TemplatePage {
title: qsTr("Export Divelog information") title: qsTr("Export Divelog information")
property int selectedExport: ExportType.EX_DIVES_XML property int selectedExport: ExportType.EX_DIVES_XML
@ -28,56 +28,66 @@ Kirigami.ScrollablePage {
} }
} }
Dialog {
id: uploadDialog
title: radioGroup.current.text
standardButtons: StandardButton.Apply | StandardButton.Cancel
GridLayout { GridLayout {
id: uploadDialog
visible: false
anchors {
top: parent.top
left: parent.left
right: parent.right
margins: Kirigami.Units.gridUnit / 2
}
rowSpacing: Kirigami.Units.smallSpacing * 2 rowSpacing: Kirigami.Units.smallSpacing * 2
columnSpacing: Kirigami.Units.smallSpacing columnSpacing: Kirigami.Units.smallSpacing
columns: 2 columns: 3
TemplateLabel {
Text { text: qsTr("Export credentials")
Layout.columnSpan: 3
}
TemplateLabel {
id: textUserID id: textUserID
text: qsTr("User ID") text: qsTr("User ID")
} }
TextField { TemplateTextField {
id: fieldUserID id: fieldUserID
Layout.columnSpan: 2
Layout.fillWidth: true Layout.fillWidth: true
inputMethodHints: Qt.ImhNoAutoUppercase inputMethodHints: Qt.ImhNoAutoUppercase
} }
Text { TemplateLabel {
id: textPassword id: textPassword
text: qsTr("Password:") text: qsTr("Password:")
} }
TextField { TemplateTextField {
id: fieldPassword id: fieldPassword
Layout.columnSpan: 2
Layout.fillWidth: true Layout.fillWidth: true
inputMethodHints: Qt.ImhSensitiveData | inputMethodHints: Qt.ImhSensitiveData |
Qt.ImhHiddenText | Qt.ImhHiddenText |
Qt.ImhNoAutoUppercase Qt.ImhNoAutoUppercase
echoMode: TextInput.PasswordEchoOnEdit echoMode: TextInput.PasswordEchoOnEdit
} }
CheckBox { TemplateCheckBox {
id: fieldPrivate id: fieldPrivate
visible: selectedExport === ExportType.EX_DIVESHARE
Layout.fillWidth: true Layout.fillWidth: true
text: qsTr("Private") text: qsTr("Private")
} }
ProgressBar { ProgressBar {
id: progress id: progress
value: 0.0 value: 0.0
Layout.columnSpan: 2
} }
Text { TemplateLabel {
id: statusText id: statusText
Layout.fillWidth: true Layout.fillWidth: true
Layout.columnSpan: 2 Layout.columnSpan: 3
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
} TemplateButton {
text: qsTr("Export")
onApply: { onClicked: {
if (selectedExport === ExportType.EX_DIVELOGS_DE) { if (selectedExport === ExportType.EX_DIVELOGS_DE) {
if (fieldUserID.text !== PrefCloudStorage.divelogde_user) { if (fieldUserID.text !== PrefCloudStorage.divelogde_user) {
PrefCloudStorage.divelogde_user = fieldUserID.text PrefCloudStorage.divelogde_user = fieldUserID.text
@ -93,17 +103,18 @@ Kirigami.ScrollablePage {
manager.exportToWEB(selectedExport, fieldUserID.text, fieldPassword.text, fieldPrivate.checked) manager.exportToWEB(selectedExport, fieldUserID.text, fieldPassword.text, fieldPrivate.checked)
} }
} }
onRejected: {
pageStack.pop()
close()
} }
TemplateButton {
text: qsTr("Cancel")
onClicked: {
pageStack.pop()
}
}
Connections { Connections {
target: manager target: manager
onUploadFinish: { onUploadFinish: {
if (success) { if (success) {
pageStack.pop() pageStack.pop()
uploadDialog.close()
} }
statusText.text = text statusText.text = text
progress.value = 0 progress.value = 0
@ -119,9 +130,11 @@ Kirigami.ScrollablePage {
// export really doesn't make sense on Android // export really doesn't make sense on Android
ColumnLayout { ColumnLayout {
id: exportSelection
visible: true
width: parent.width width: parent.width
spacing: 1 spacing: 3
Layout.margins: 10 Layout.margins: Kirigami.Units.gridUnit / 2
ExclusiveGroup { id: radioGroup } ExclusiveGroup { id: radioGroup }
RadioButton { RadioButton {
@ -173,12 +186,22 @@ Kirigami.ScrollablePage {
explain.text = qsTr("Send the dive data to dive-share.appspot.com website.") explain.text = qsTr("Send the dive data to dive-share.appspot.com website.")
} }
} }
Text { Rectangle {
width: 1
height: Kirigami.Units.gridUnit
color: "transparent"
}
TemplateLabel {
id: explain id: explain
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
CheckBox { Rectangle {
width: 1
height: Kirigami.Units.gridUnit
color: "transparent"
}
TemplateCheckBox {
id: anonymize id: anonymize
Layout.fillWidth: true Layout.fillWidth: true
text: qsTr("Anonymize") text: qsTr("Anonymize")
@ -195,17 +218,17 @@ Kirigami.ScrollablePage {
fieldPassword.text = PrefCloudStorage.divelogde_pass fieldPassword.text = PrefCloudStorage.divelogde_pass
anonymize.visible = false anonymize.visible = false
statusText.text = "" statusText.text = ""
fieldPrivate.visible = false exportSelection.visible = false
uploadDialog.open() uploadDialog.visible = true
} else if (selectedExport === ExportType.EX_DIVESHARE) { } else if (selectedExport === ExportType.EX_DIVESHARE) {
textUserID.visible = true textUserID.visible = true
fieldUserID.visible = true fieldUserID.visible = true
fieldUserID.text = PrefCloudStorage.diveshare_uid fieldUserID.text = PrefCloudStorage.diveshare_uid
fieldPrivate.visible = true fieldPrivate.visible = true
fieldPrivate.checked = PrefCloudStorage.diveshare_private fieldPrivate.checked = PrefCloudStorage.diveshare_private
exportSelection.visible = false
textPassword.visible = false textPassword.visible = false
fieldPassword.visible = false uploadDialog.visible = true
uploadDialog.open()
} else if (Qt.platform.os !== "android") { } else if (Qt.platform.os !== "android") {
saveAsDialog.open() saveAsDialog.open()
} }