2017-04-27 18:30:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-05-12 15:55:19 +00:00
|
|
|
import QtQuick 2.6
|
2017-05-27 21:36:32 +00:00
|
|
|
import QtQuick.Controls 2.0
|
2015-07-23 11:46:02 +00:00
|
|
|
import QtQuick.Window 2.2
|
|
|
|
import QtQuick.Dialogs 1.2
|
2017-05-12 15:55:19 +00:00
|
|
|
import QtQuick.Layouts 1.3
|
2015-07-23 11:46:02 +00:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
2017-03-31 14:15:14 +00:00
|
|
|
import org.kde.kirigami 2.0 as Kirigami
|
2015-07-23 11:46:02 +00:00
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Page {
|
2015-07-23 11:46:02 +00:00
|
|
|
id: diveComputerDownloadWindow
|
2016-02-02 19:48:43 +00:00
|
|
|
anchors.top:parent.top
|
2015-07-23 11:46:02 +00:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2016-02-02 19:48:43 +00:00
|
|
|
Layout.fillWidth: true;
|
2016-05-03 19:24:00 +00:00
|
|
|
title: qsTr("Dive Computer")
|
2015-07-23 11:46:02 +00:00
|
|
|
|
2017-05-29 18:36:00 +00:00
|
|
|
property bool selectAll : false
|
2017-06-16 08:22:44 +00:00
|
|
|
property alias dcImportModel: importModel
|
2017-05-29 18:36:00 +00:00
|
|
|
|
2017-05-26 14:40:50 +00:00
|
|
|
DCDownloadThread {
|
2017-05-28 09:23:03 +00:00
|
|
|
id: downloadThread
|
2017-05-26 14:40:50 +00:00
|
|
|
deviceData.vendor : comboVendor.currentText
|
|
|
|
deviceData.product : comboProduct.currentText
|
|
|
|
|
|
|
|
//TODO: make this dynamic?
|
|
|
|
deviceData.devName : "/tmp/ttyS1"
|
|
|
|
|
|
|
|
//TODO: Make this the default on the C++
|
2017-05-29 22:11:11 +00:00
|
|
|
deviceData.bluetoothMode : isBluetooth.checked
|
2017-05-26 14:40:50 +00:00
|
|
|
deviceData.forceDownload : false
|
|
|
|
deviceData.createNewTrip : false
|
|
|
|
deviceData.deviceId : 0
|
|
|
|
deviceData.diveId : 0
|
|
|
|
deviceData.saveDump : false
|
|
|
|
deviceData.saveLog : false
|
2017-05-26 15:53:25 +00:00
|
|
|
|
|
|
|
onFinished : {
|
|
|
|
importModel.repopulate()
|
2017-05-28 10:22:46 +00:00
|
|
|
acceptButton.enabled = true
|
2017-06-25 22:52:07 +00:00
|
|
|
dcDownloadProgress.visible = false
|
2017-05-28 09:44:24 +00:00
|
|
|
manager.appendTextToLog("DCDownloadThread finished")
|
2017-05-26 15:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DCImportModel {
|
|
|
|
id: importModel
|
2017-05-26 14:40:50 +00:00
|
|
|
}
|
|
|
|
|
2016-02-02 19:48:43 +00:00
|
|
|
ColumnLayout {
|
2015-07-23 11:46:02 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
height: parent.height
|
2016-02-02 19:48:43 +00:00
|
|
|
width: parent.width
|
|
|
|
Layout.fillWidth: true
|
2017-05-12 15:55:19 +00:00
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
2017-05-12 16:17:23 +00:00
|
|
|
Kirigami.Label { text: qsTr(" Vendor name: ") }
|
Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-12 08:38:24 +00:00
|
|
|
property var vendoridx: downloadThread.data().getDetectedVendorIndex("")
|
2017-05-12 16:17:23 +00:00
|
|
|
ComboBox {
|
2017-05-12 16:29:45 +00:00
|
|
|
id: comboVendor
|
2017-05-12 16:17:23 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
model: vendorList
|
Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-12 08:38:24 +00:00
|
|
|
currentIndex: parent.vendoridx
|
2017-06-05 16:18:17 +00:00
|
|
|
onCurrentTextChanged: {
|
Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-12 08:38:24 +00:00
|
|
|
comboProduct.model = downloadThread.data().getProductListFromVendor(currentText)
|
2017-06-10 08:09:56 +00:00
|
|
|
if (currentIndex == downloadThread.data().getDetectedVendorIndex(currentText))
|
|
|
|
comboProduct.currentIndex = downloadThread.data().getDetectedProductIndex(currentText, comboProduct.currentText)
|
2017-06-05 16:18:17 +00:00
|
|
|
}
|
2017-05-12 16:17:23 +00:00
|
|
|
}
|
2017-05-12 16:29:45 +00:00
|
|
|
Kirigami.Label { text: qsTr(" Dive Computer:") }
|
|
|
|
ComboBox {
|
|
|
|
id: comboProduct
|
Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-12 08:38:24 +00:00
|
|
|
property var productidx: downloadThread.data().getDetectedProductIndex(comboVendor.currentText, currentText)
|
2017-05-12 16:29:45 +00:00
|
|
|
Layout.fillWidth: true
|
2017-06-05 16:18:17 +00:00
|
|
|
model: null
|
Mobile: wrap up fixes for BT download on Android
Major functional change in this commit is the addition of found static BT devices
to the internal administration (on Android), in a way that is equivalent to
mobile-on-desktop. So, in both cases, the list of devices in the app are
as in the list of devices on the host OS (Linux or Android). To minimize code
duplication, the btDeviceDiscovered slot is split in two parts, the part to
act as slot for the Qt BT discovery agent (Linux, so mobile-on-desktop), and
the part only needed for Android.
Remaining to be fixed: the correct handling of the QML UI selection of
vendor/product. The first default dive computer is correctly detected,
all paired devices from the virtual vendow can be selected, but clicking
through vendors results in non logical selections. It is obvious why
this is, but a fix is not straigforward at this point.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-12 08:38:24 +00:00
|
|
|
currentIndex: productidx
|
|
|
|
onModelChanged: {
|
|
|
|
currentIndex = productidx
|
|
|
|
}
|
2017-05-29 22:11:11 +00:00
|
|
|
}
|
|
|
|
Kirigami.Label { text: qsTr("Bluetooth download:") }
|
|
|
|
CheckBox {
|
|
|
|
id: isBluetooth
|
2017-06-10 08:09:56 +00:00
|
|
|
checked: downloadThread.data().getDetectedVendorIndex(ComboBox.currentText) != -1
|
2017-05-12 16:29:45 +00:00
|
|
|
}
|
2016-02-02 19:48:43 +00:00
|
|
|
}
|
2017-05-12 15:55:19 +00:00
|
|
|
|
|
|
|
ProgressBar {
|
2017-06-25 22:52:07 +00:00
|
|
|
id: dcDownloadProgress
|
2016-02-02 19:48:43 +00:00
|
|
|
Layout.fillWidth: true
|
2017-06-25 22:52:07 +00:00
|
|
|
indeterminate: true
|
2017-05-12 15:55:19 +00:00
|
|
|
visible: false
|
2016-02-02 19:48:43 +00:00
|
|
|
}
|
2017-05-12 15:55:19 +00:00
|
|
|
|
2016-02-02 19:48:43 +00:00
|
|
|
RowLayout {
|
2017-03-31 14:15:14 +00:00
|
|
|
Button {
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Download")
|
2016-02-02 19:48:43 +00:00
|
|
|
onClicked: {
|
2017-06-13 07:54:21 +00:00
|
|
|
text = qsTr("Retry")
|
2017-05-31 00:49:51 +00:00
|
|
|
if (downloadThread.deviceData.bluetoothMode) {
|
2017-06-10 08:09:56 +00:00
|
|
|
var addr = downloadThread.data().getDetectedDeviceAddress(comboVendor.currentText,
|
2017-06-13 07:54:21 +00:00
|
|
|
comboProduct.currentText)
|
2017-05-31 00:49:51 +00:00
|
|
|
if (addr !== "")
|
2017-06-13 07:54:21 +00:00
|
|
|
downloadThread.deviceData.devName = addr
|
2017-06-10 12:22:28 +00:00
|
|
|
var vendor = downloadThread.deviceData.getDeviceDescriptorVendor(comboVendor.currentText,
|
2017-06-13 07:54:21 +00:00
|
|
|
comboProduct.currentText)
|
2017-06-10 12:22:28 +00:00
|
|
|
downloadThread.deviceData.vendor = vendor;
|
|
|
|
|
|
|
|
var product = downloadThread.deviceData.getDeviceDescriptorProduct(comboVendor.currentText,
|
2017-06-13 07:54:21 +00:00
|
|
|
comboProduct.currentText)
|
2017-06-10 12:22:28 +00:00
|
|
|
downloadThread.deviceData.product = product;
|
2017-05-31 00:49:51 +00:00
|
|
|
}
|
2017-06-08 12:15:22 +00:00
|
|
|
manager.appendTextToLog("DCDownloadThread started for " + downloadThread.deviceData.devName)
|
2017-06-25 22:52:07 +00:00
|
|
|
dcDownloadProgress.visible = true
|
2017-05-28 09:23:03 +00:00
|
|
|
downloadThread.start()
|
2016-02-02 19:48:43 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-31 14:15:14 +00:00
|
|
|
Button {
|
2016-02-02 19:48:43 +00:00
|
|
|
id:quitbutton
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Quit")
|
2016-02-02 19:48:43 +00:00
|
|
|
onClicked: {
|
2017-05-28 09:44:24 +00:00
|
|
|
manager.appendTextToLog("exit DCDownload screen")
|
2016-02-02 19:48:43 +00:00
|
|
|
stackView.pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-29 18:38:36 +00:00
|
|
|
|
|
|
|
Kirigami.Label {
|
|
|
|
text: qsTr(" Downloaded dives")
|
2016-02-02 19:48:43 +00:00
|
|
|
}
|
2017-05-26 15:53:25 +00:00
|
|
|
|
2017-05-29 17:55:36 +00:00
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
model : importModel
|
|
|
|
delegate : DownloadedDiveDelegate {
|
2017-05-29 18:36:00 +00:00
|
|
|
id: delegate
|
2017-06-25 23:12:07 +00:00
|
|
|
datetime: model.datetime ? model.datetime : ""
|
|
|
|
duration: model.duration ? model.duration : ""
|
|
|
|
depth: model.depth ? model.depth : ""
|
|
|
|
selected: model.selected ? model.selected : false
|
2017-05-29 18:36:00 +00:00
|
|
|
|
2017-06-21 22:47:29 +00:00
|
|
|
backgroundColor: selectAll ? subsurfaceTheme.darkPrimaryColor : subsurfaceTheme.backgroundColor
|
2017-05-29 18:36:00 +00:00
|
|
|
|
|
|
|
onClicked : {
|
|
|
|
console.log("Selecting index" + index);
|
|
|
|
importModel.selectRow(index)
|
|
|
|
}
|
2016-02-02 19:48:43 +00:00
|
|
|
}
|
2017-05-12 15:55:19 +00:00
|
|
|
}
|
2017-05-29 17:55:36 +00:00
|
|
|
|
2016-02-02 19:48:43 +00:00
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
2017-03-31 14:15:14 +00:00
|
|
|
Button {
|
2017-05-28 10:22:46 +00:00
|
|
|
id: acceptButton
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Accept")
|
2017-05-28 10:22:46 +00:00
|
|
|
enabled: false
|
2016-02-02 19:48:43 +00:00
|
|
|
onClicked: {
|
2017-05-28 18:48:30 +00:00
|
|
|
manager.appendTextToLog("Save downloaded dives that were selected")
|
|
|
|
importModel.recordDives()
|
|
|
|
manager.saveChangesLocal()
|
|
|
|
diveModel.clear()
|
|
|
|
diveModel.addAllDives()
|
2016-02-02 19:48:43 +00:00
|
|
|
stackView.pop();
|
2015-07-23 11:46:02 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-31 14:15:14 +00:00
|
|
|
Kirigami.Label {
|
2016-02-02 19:48:43 +00:00
|
|
|
text: "" // Spacer between 2 button groups
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2017-03-31 14:15:14 +00:00
|
|
|
Button {
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Select All")
|
2017-05-29 18:36:00 +00:00
|
|
|
onClicked : {
|
|
|
|
selectAll = true
|
|
|
|
importModel.selectAll()
|
|
|
|
}
|
2016-02-02 19:48:43 +00:00
|
|
|
}
|
2017-03-31 14:15:14 +00:00
|
|
|
Button {
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Unselect All")
|
2017-05-29 18:36:00 +00:00
|
|
|
onClicked : {
|
|
|
|
selectAll = false
|
|
|
|
importModel.selectNone()
|
|
|
|
}
|
2016-02-02 19:48:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-23 11:46:02 +00:00
|
|
|
}
|
|
|
|
}
|