2015-11-29 16:43:56 +00:00
|
|
|
import QtQuick 2.4
|
2015-05-27 10:34:55 +00:00
|
|
|
import QtQuick.Controls 1.2
|
2015-07-26 11:52:46 +00:00
|
|
|
import QtQuick.Controls.Styles 1.2
|
2015-05-27 10:34:55 +00:00
|
|
|
import QtQuick.Window 2.2
|
2015-06-04 08:27:38 +00:00
|
|
|
import QtQuick.Dialogs 1.2
|
2015-07-10 08:05:13 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2015-07-30 06:17:09 +00:00
|
|
|
import QtQuick.Window 2.2
|
2015-06-04 10:36:36 +00:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
2016-03-08 20:26:54 +00:00
|
|
|
import org.kde.kirigami 1.0 as Kirigami
|
2015-10-08 23:57:10 +00:00
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.ApplicationWindow {
|
2015-12-03 22:27:27 +00:00
|
|
|
id: rootItem
|
2016-01-01 17:34:32 +00:00
|
|
|
title: qsTr("Subsurface-mobile")
|
2016-04-01 21:54:22 +00:00
|
|
|
|
|
|
|
header.minimumHeight: 0
|
|
|
|
header.preferredHeight: Kirigami.Units.gridUnit
|
|
|
|
header.maximumHeight: Kirigami.Units.gridUnit * 2
|
2015-07-12 17:42:23 +00:00
|
|
|
property bool fullscreen: true
|
2016-02-11 02:09:16 +00:00
|
|
|
property int oldStatus: -1
|
2016-03-03 01:14:47 +00:00
|
|
|
property alias accessingCloud: manager.accessingCloud
|
|
|
|
property QtObject notification: null
|
2016-03-31 01:38:51 +00:00
|
|
|
property bool showingDiveList: false
|
2016-03-03 01:14:47 +00:00
|
|
|
onAccessingCloudChanged: {
|
2016-04-04 00:00:49 +00:00
|
|
|
if (accessingCloud >= 0) {
|
2016-04-04 01:00:00 +00:00
|
|
|
// we now keep updating this to show progress, so timing out after 30 seconds is more useful
|
|
|
|
// but should still be very conservative
|
|
|
|
showPassiveNotification("Accessing Subsurface Cloud Storage " + accessingCloud +"%", 30000);
|
2016-03-03 01:14:47 +00:00
|
|
|
} else {
|
2016-03-03 18:35:33 +00:00
|
|
|
hidePassiveNotification();
|
2016-03-03 01:14:47 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-29 16:43:56 +00:00
|
|
|
|
|
|
|
FontMetrics {
|
|
|
|
id: fontMetrics
|
|
|
|
}
|
|
|
|
|
2016-01-19 20:42:58 +00:00
|
|
|
visible: false
|
|
|
|
opacity: 0
|
2015-06-04 08:27:38 +00:00
|
|
|
|
2016-02-11 05:47:09 +00:00
|
|
|
function returnTopPage() {
|
|
|
|
for (var i=stackView.depth; i>1; i--) {
|
|
|
|
stackView.pop()
|
|
|
|
}
|
|
|
|
detailsWindow.endEditMode()
|
|
|
|
}
|
|
|
|
|
2016-03-31 01:39:25 +00:00
|
|
|
function scrollToTop() {
|
|
|
|
diveList.scrollToTop()
|
|
|
|
}
|
|
|
|
|
2016-04-02 12:09:40 +00:00
|
|
|
function showMap(location) {
|
|
|
|
var urlPrefix = "https://www.google.com/maps/place/"
|
|
|
|
var locationPair = location + "/@" + location
|
|
|
|
var urlSuffix = ",5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0"
|
|
|
|
Qt.openUrlExternally(urlPrefix + locationPair + urlSuffix)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-02 03:29:39 +00:00
|
|
|
function startAddDive() {
|
|
|
|
detailsWindow.state = "add"
|
|
|
|
detailsWindow.dive_id = manager.addDive();
|
|
|
|
detailsWindow.number = manager.getNumber(detailsWindow.dive_id)
|
|
|
|
detailsWindow.date = manager.getDate(detailsWindow.dive_id)
|
|
|
|
detailsWindow.airtemp = ""
|
|
|
|
detailsWindow.watertemp = ""
|
|
|
|
detailsWindow.buddy = ""
|
|
|
|
detailsWindow.depth = ""
|
|
|
|
detailsWindow.divemaster = ""
|
|
|
|
detailsWindow.notes = ""
|
|
|
|
detailsWindow.location = ""
|
|
|
|
detailsWindow.duration = ""
|
|
|
|
detailsWindow.suit = ""
|
|
|
|
detailsWindow.weight = ""
|
|
|
|
detailsWindow.gasmix = ""
|
|
|
|
detailsWindow.startpressure = ""
|
|
|
|
detailsWindow.endpressure = ""
|
|
|
|
stackView.push(detailsWindow)
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
globalDrawer: Kirigami.GlobalDrawer {
|
2015-11-29 16:43:56 +00:00
|
|
|
title: "Subsurface"
|
|
|
|
titleIcon: "qrc:/qml/subsurface-mobile-icon.png"
|
2015-11-07 02:08:05 +00:00
|
|
|
|
2015-11-29 16:43:56 +00:00
|
|
|
bannerImageSource: "dive.jpg"
|
|
|
|
actions: [
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2016-01-25 14:24:26 +00:00
|
|
|
text: "Dive list"
|
2015-12-03 23:26:45 +00:00
|
|
|
onTriggered: {
|
2016-03-27 04:35:35 +00:00
|
|
|
manager.appendTextToLog("requested dive list with credential status " + manager.credentialStatus)
|
2016-03-13 18:41:09 +00:00
|
|
|
if (manager.credentialStatus == QMLManager.UNKNOWN) {
|
|
|
|
// the user has asked to change credentials - if the credentials before that
|
|
|
|
// were valid, go back to dive list
|
|
|
|
if (oldStatus == QMLManager.VALID || oldStatus == QMLManager.VALID_EMAIL) {
|
|
|
|
manager.credentialStatus = oldStatus
|
|
|
|
}
|
|
|
|
}
|
2016-02-11 05:47:09 +00:00
|
|
|
returnTopPage()
|
2016-03-03 23:12:09 +00:00
|
|
|
globalDrawer.close()
|
2015-12-03 23:26:45 +00:00
|
|
|
}
|
|
|
|
},
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2016-01-25 14:24:26 +00:00
|
|
|
text: "Cloud credentials"
|
2015-12-03 23:26:45 +00:00
|
|
|
onTriggered: {
|
2016-02-11 05:47:09 +00:00
|
|
|
returnTopPage()
|
2016-02-11 02:09:16 +00:00
|
|
|
oldStatus = manager.credentialStatus
|
|
|
|
if (diveList.numDives > 0) {
|
|
|
|
manager.startPageText = "Enter different credentials or return to dive list"
|
|
|
|
} else {
|
2016-03-25 04:35:03 +00:00
|
|
|
manager.startPageText = "Enter valid cloud storage credentials"
|
2016-02-11 02:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
manager.credentialStatus = QMLManager.UNKNOWN
|
2015-12-03 23:26:45 +00:00
|
|
|
}
|
|
|
|
},
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Manage dives"
|
2016-02-11 04:54:36 +00:00
|
|
|
enabled: manager.credentialStatus === QMLManager.VALID || manager.credentialStatus === QMLManager.VALID_EMAIL
|
2016-02-05 17:22:54 +00:00
|
|
|
/*
|
|
|
|
* disable for the beta to avoid confusion
|
2015-12-08 01:33:11 +00:00
|
|
|
Action {
|
|
|
|
text: "Download from computer"
|
|
|
|
onTriggered: {
|
2016-02-07 21:23:07 +00:00
|
|
|
detailsWindow.endEditMode()
|
2015-12-08 01:33:11 +00:00
|
|
|
stackView.push(downloadDivesWindow)
|
|
|
|
}
|
2015-12-03 23:26:45 +00:00
|
|
|
}
|
2016-02-05 17:22:54 +00:00
|
|
|
*/
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Add dive manually"
|
|
|
|
onTriggered: {
|
2016-04-02 16:04:44 +00:00
|
|
|
returnTopPage() // otherwise odd things happen with the page stack
|
2016-04-02 03:29:39 +00:00
|
|
|
startAddDive()
|
2015-12-08 01:33:11 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Refresh"
|
|
|
|
onTriggered: {
|
2016-03-11 16:05:29 +00:00
|
|
|
globalDrawer.close()
|
2016-02-07 21:23:07 +00:00
|
|
|
detailsWindow.endEditMode()
|
2015-12-08 01:33:11 +00:00
|
|
|
manager.loadDives();
|
|
|
|
}
|
|
|
|
}
|
2016-04-02 01:40:12 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Upload to cloud"
|
|
|
|
onTriggered: {
|
2016-03-11 16:05:29 +00:00
|
|
|
globalDrawer.close()
|
2016-02-07 21:23:07 +00:00
|
|
|
detailsWindow.endEditMode()
|
2015-12-08 01:33:11 +00:00
|
|
|
manager.saveChanges();
|
|
|
|
}
|
2015-11-29 16:43:56 +00:00
|
|
|
}
|
2015-12-03 23:26:45 +00:00
|
|
|
},
|
2015-11-29 16:43:56 +00:00
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-03 23:26:45 +00:00
|
|
|
text: "GPS"
|
2016-02-11 04:54:36 +00:00
|
|
|
enabled: manager.credentialStatus === QMLManager.VALID || manager.credentialStatus === QMLManager.VALID_EMAIL
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "GPS-tag dives"
|
2015-12-03 23:26:45 +00:00
|
|
|
onTriggered: {
|
2015-12-08 01:33:11 +00:00
|
|
|
manager.applyGpsData();
|
2015-12-03 23:26:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Upload GPS data"
|
2015-12-03 23:26:45 +00:00
|
|
|
onTriggered: {
|
2015-12-08 01:33:11 +00:00
|
|
|
manager.sendGpsData();
|
2015-12-03 23:26:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2016-01-08 05:37:36 +00:00
|
|
|
text: "Download GPS data"
|
|
|
|
onTriggered: {
|
|
|
|
manager.downloadGpsData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2016-01-08 05:40:15 +00:00
|
|
|
text: "Show GPS fixes"
|
|
|
|
onTriggered: {
|
2016-04-02 16:04:44 +00:00
|
|
|
returnTopPage()
|
2016-01-08 05:40:15 +00:00
|
|
|
manager.populateGpsData();
|
|
|
|
stackView.push(gpsWindow)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Clear GPS cache"
|
2015-12-03 23:26:45 +00:00
|
|
|
onTriggered: {
|
2015-12-08 01:33:11 +00:00
|
|
|
manager.clearGpsData();
|
2015-12-03 23:26:45 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2016-02-08 05:38:24 +00:00
|
|
|
text: "Preferences"
|
|
|
|
onTriggered: {
|
|
|
|
stackView.push(prefsWindow)
|
2016-02-14 05:53:01 +00:00
|
|
|
detailsWindow.endEditMode()
|
2016-02-08 05:38:24 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-03 23:26:45 +00:00
|
|
|
},
|
2015-11-29 16:43:56 +00:00
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Developer"
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "App log"
|
|
|
|
onTriggered: {
|
|
|
|
stackView.push(logWindow)
|
|
|
|
}
|
2015-11-29 16:43:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2015-12-08 01:33:11 +00:00
|
|
|
text: "Theme information"
|
|
|
|
onTriggered: {
|
|
|
|
stackView.push(themetest)
|
|
|
|
}
|
2015-12-03 23:26:45 +00:00
|
|
|
}
|
2016-02-10 20:53:59 +00:00
|
|
|
},
|
2016-04-01 02:57:12 +00:00
|
|
|
Kirigami.Action {
|
2016-03-13 18:13:04 +00:00
|
|
|
text: "User manual"
|
|
|
|
onTriggered: {
|
2016-04-02 12:02:44 +00:00
|
|
|
Qt.openUrlExternally("https://subsurface-divelog.org/documentation/subsurface-mobile-user-manual/")
|
2016-03-13 18:13:04 +00:00
|
|
|
}
|
|
|
|
},
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Action {
|
2016-02-10 20:53:59 +00:00
|
|
|
text: "About"
|
|
|
|
onTriggered: {
|
|
|
|
stackView.push(aboutWindow)
|
|
|
|
detailsWindow.endEditMode()
|
|
|
|
}
|
2015-11-29 16:43:56 +00:00
|
|
|
}
|
2015-12-03 23:26:45 +00:00
|
|
|
] // end actions
|
2015-10-08 23:57:10 +00:00
|
|
|
|
2015-11-30 00:48:10 +00:00
|
|
|
MouseArea {
|
|
|
|
height: childrenRect.height
|
2016-03-08 20:26:54 +00:00
|
|
|
width: Kirigami.Units.gridUnit * 10
|
2015-11-30 00:48:10 +00:00
|
|
|
CheckBox {
|
|
|
|
//text: "Run location service"
|
|
|
|
id: locationCheckbox
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
top: parent.top
|
|
|
|
}
|
|
|
|
checked: manager.locationServiceEnabled
|
|
|
|
onCheckedChanged: {
|
|
|
|
manager.locationServiceEnabled = checked;
|
|
|
|
}
|
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
|
|
|
x: Kirigami.Units.gridUnit * 1.5
|
2015-11-30 00:48:10 +00:00
|
|
|
anchors {
|
|
|
|
left: locationCheckbox.right
|
|
|
|
//leftMargin: units.smallSpacing
|
|
|
|
verticalCenter: locationCheckbox.verticalCenter
|
|
|
|
}
|
|
|
|
text: "Run location service"
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
print("Click.")
|
|
|
|
locationCheckbox.checked = !locationCheckbox.checked
|
2015-11-30 00:32:55 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-08 23:57:10 +00:00
|
|
|
}
|
2015-11-29 18:09:59 +00:00
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
contextDrawer: Kirigami.ContextDrawer {
|
2015-12-04 02:32:52 +00:00
|
|
|
id: contextDrawer
|
|
|
|
actions: rootItem.pageStack.currentPage ? rootItem.pageStack.currentPage.contextualActions : null
|
|
|
|
title: "Actions"
|
|
|
|
}
|
|
|
|
|
2015-11-29 18:09:59 +00:00
|
|
|
QtObject {
|
|
|
|
id: subsurfaceTheme
|
|
|
|
property int titlePointSize: Math.round(fontMetrics.font.pointSize * 1.5)
|
2015-11-29 22:39:14 +00:00
|
|
|
property int smallPointSize: Math.round(fontMetrics.font.pointSize * 0.8)
|
2015-11-29 18:09:59 +00:00
|
|
|
property color accentColor: "#2d5b9a"
|
2016-01-22 12:07:53 +00:00
|
|
|
property color shadedColor: "#132744"
|
2015-11-29 18:09:59 +00:00
|
|
|
property color accentTextColor: "#ececec"
|
2016-04-01 21:55:24 +00:00
|
|
|
property color diveListTextColor: "#000000" // the Kirigami theme text color is too light
|
2016-03-08 20:26:54 +00:00
|
|
|
property int columnWidth: Math.round(rootItem.width/(Kirigami.Units.gridUnit*30)) > 0 ? Math.round(rootItem.width / Math.round(rootItem.width/(Kirigami.Units.gridUnit*30))) : rootItem.width
|
2015-11-29 18:09:59 +00:00
|
|
|
}
|
2016-04-01 02:57:12 +00:00
|
|
|
/*
|
2015-11-29 20:13:57 +00:00
|
|
|
toolBar: TopBar {
|
|
|
|
width: parent.width
|
|
|
|
height: Layout.minimumHeight
|
|
|
|
}
|
2016-04-01 02:57:12 +00:00
|
|
|
*/
|
2015-07-17 15:28:01 +00:00
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
property Item stackView: pageStack
|
2016-03-08 20:26:54 +00:00
|
|
|
pageStack.initialPage: DiveList {
|
2015-11-29 21:51:49 +00:00
|
|
|
anchors.fill: detailsPage
|
2016-01-29 02:27:54 +00:00
|
|
|
id: diveList
|
2016-01-19 20:42:58 +00:00
|
|
|
opacity: 0
|
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
easing.type: Easing.OutQuad
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-12 17:56:48 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
|
2015-07-12 17:56:48 +00:00
|
|
|
QMLManager {
|
|
|
|
id: manager
|
2015-06-09 19:20:44 +00:00
|
|
|
}
|
2015-07-12 17:56:48 +00:00
|
|
|
|
|
|
|
Preferences {
|
|
|
|
id: prefsWindow
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
2016-02-10 20:53:59 +00:00
|
|
|
About {
|
|
|
|
id: aboutWindow
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
2015-07-21 12:00:29 +00:00
|
|
|
DiveDetails {
|
|
|
|
id: detailsWindow
|
|
|
|
visible: false
|
2016-01-12 00:15:02 +00:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2015-07-21 12:00:29 +00:00
|
|
|
}
|
2015-07-23 11:46:02 +00:00
|
|
|
|
|
|
|
DownloadFromDiveComputer {
|
|
|
|
id: downloadDivesWindow
|
|
|
|
visible: false
|
|
|
|
}
|
2015-08-19 07:18:26 +00:00
|
|
|
|
|
|
|
Log {
|
|
|
|
id: logWindow
|
|
|
|
visible: false
|
|
|
|
}
|
2015-10-08 23:57:10 +00:00
|
|
|
|
2016-01-08 05:40:15 +00:00
|
|
|
GpsList {
|
|
|
|
id: gpsWindow
|
2016-03-08 20:26:54 +00:00
|
|
|
visible: false
|
2016-01-08 05:40:15 +00:00
|
|
|
}
|
|
|
|
|
2015-11-06 21:53:26 +00:00
|
|
|
ThemeTest {
|
|
|
|
id: themetest
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
2015-10-08 23:57:10 +00:00
|
|
|
Component.onCompleted: {
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Theme.highlightColor = subsurfaceTheme.accentColor
|
2015-12-05 03:34:59 +00:00
|
|
|
manager.finishSetup();
|
2016-01-19 20:42:58 +00:00
|
|
|
rootItem.visible = true
|
2016-01-29 02:27:54 +00:00
|
|
|
diveList.opacity = 1
|
2016-01-19 20:42:58 +00:00
|
|
|
rootItem.opacity = 1
|
|
|
|
}
|
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
easing.type: Easing.OutQuad
|
|
|
|
}
|
2015-10-08 23:57:10 +00:00
|
|
|
}
|
2015-05-27 10:34:55 +00:00
|
|
|
}
|