2017-04-27 18:30:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-06-04 10:29:50 +00:00
|
|
|
#ifndef QMLMANAGER_H
|
|
|
|
#define QMLMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2015-12-05 03:34:59 +00:00
|
|
|
#include <QNetworkAccessManager>
|
2016-03-09 03:31:05 +00:00
|
|
|
#include <QScreen>
|
QML UI: don't immediately save data after we make changes
Much as this felt like the prudent thing to do, it makes the UI painful
to use. In bad network conditions, with a large dive log, on a phone,
the save operation can take more than a minute - which is just completely
ludicrous.
So instead we mark the dive list changed when we make changes and wait
for the app to not be in the foreground. Once the OS tells us that we are
hidden (on the desktop that generally means we don't have focus, on a
mobile device it usually does mean that the app is not on the screen), we
check if there are data to be saved and do so.
There is of course a major problem with this logic. If the user switches
away from Subsurface-mobile but comes back fairly quickly (just reacting
to a notification or briefly checking something, changing a song,
something... then the app may still be non-responsive for quite a while.
So we need to do something about the time it takes us to save the git
tree locally, and then figure out if we can move at least some of the
network traffic to another thread.
And we need to make sure the user immediately notices that the app is not
crashed but is actually saving their data. But that's for another commit.
tl;dr: CAREFUL, don't kill Subsurface-mobile before it had time to save
your data or your changes may be gone. In typical use that shouldn't be
an issue, but it is something that we need to tell the user about.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 00:37:17 +00:00
|
|
|
#include <QElapsedTimer>
|
2017-06-23 14:31:44 +00:00
|
|
|
#include <QColor>
|
2018-06-03 20:15:19 +00:00
|
|
|
#include <QFile>
|
2024-03-30 20:55:22 +00:00
|
|
|
#include <QTimer>
|
2015-06-04 10:29:50 +00:00
|
|
|
|
2017-06-06 02:41:57 +00:00
|
|
|
#include "core/btdiscovery.h"
|
2017-06-08 11:38:52 +00:00
|
|
|
#include "core/downloadfromdcthread.h"
|
2018-01-28 08:52:51 +00:00
|
|
|
#include "qt-models/completionmodels.h"
|
2018-01-28 14:21:28 +00:00
|
|
|
#include "qt-models/divelocationmodel.h"
|
2019-12-29 11:29:05 +00:00
|
|
|
#include "core/settings/qPrefCloudStorage.h"
|
2020-02-18 01:16:11 +00:00
|
|
|
#include "core/subsurface-qt/divelistnotifier.h"
|
2015-11-11 20:34:56 +00:00
|
|
|
|
2020-03-15 01:05:06 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
#include "core/serial_usb_android.h"
|
2022-08-29 23:46:58 +00:00
|
|
|
#elif defined(Q_OS_IOS)
|
|
|
|
#include "ios/ios-share.h"
|
2020-03-15 01:05:06 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-14 21:19:58 +00:00
|
|
|
class QAction;
|
2020-10-26 17:56:45 +00:00
|
|
|
struct DiveSiteChange; // An obscure implementation artifact - remove in due course.
|
2019-11-14 21:19:58 +00:00
|
|
|
|
2019-09-27 23:26:54 +00:00
|
|
|
class QMLManager : public QObject {
|
2015-06-04 10:29:50 +00:00
|
|
|
Q_OBJECT
|
2018-01-17 20:15:43 +00:00
|
|
|
Q_PROPERTY(bool loadFromCloud MEMBER m_loadFromCloud WRITE setLoadFromCloud NOTIFY loadFromCloudChanged)
|
|
|
|
Q_PROPERTY(QString startPageText MEMBER m_startPageText WRITE setStartPageText NOTIFY startPageTextChanged)
|
|
|
|
Q_PROPERTY(bool verboseEnabled MEMBER m_verboseEnabled WRITE setVerboseEnabled NOTIFY verboseEnabledChanged)
|
|
|
|
Q_PROPERTY(QString notificationText MEMBER m_notificationText WRITE setNotificationText NOTIFY notificationTextChanged)
|
2018-01-28 08:52:51 +00:00
|
|
|
Q_PROPERTY(QStringList suitList READ suitList NOTIFY suitListChanged)
|
2018-01-28 09:26:45 +00:00
|
|
|
Q_PROPERTY(QStringList buddyList READ buddyList NOTIFY buddyListChanged)
|
2022-02-12 13:03:18 +00:00
|
|
|
Q_PROPERTY(QStringList diveguideList READ diveguideList NOTIFY diveguideListChanged)
|
2018-01-28 14:21:28 +00:00
|
|
|
Q_PROPERTY(QStringList locationList READ locationList NOTIFY locationListChanged)
|
2021-09-01 21:35:48 +00:00
|
|
|
Q_PROPERTY(QStringList cylinderListInit READ cylinderListInit CONSTANT)
|
|
|
|
Q_PROPERTY(QStringList defaultCylinderListInit READ defaultCylinderListInit CONSTANT)
|
2020-06-06 16:51:40 +00:00
|
|
|
Q_PROPERTY(QStringList cloudCacheList READ cloudCacheList NOTIFY cloudCacheListChanged)
|
2018-01-17 20:15:43 +00:00
|
|
|
Q_PROPERTY(QString progressMessage MEMBER m_progressMessage WRITE setProgressMessage NOTIFY progressMessageChanged)
|
|
|
|
Q_PROPERTY(bool btEnabled MEMBER m_btEnabled WRITE setBtEnabled NOTIFY btEnabledChanged)
|
2016-03-03 01:13:42 +00:00
|
|
|
|
2018-06-09 11:14:54 +00:00
|
|
|
Q_PROPERTY(QString DC_vendor READ DC_vendor WRITE DC_setVendor)
|
|
|
|
Q_PROPERTY(QString DC_product READ DC_product WRITE DC_setProduct)
|
|
|
|
Q_PROPERTY(QString DC_devName READ DC_devName WRITE DC_setDevName)
|
|
|
|
Q_PROPERTY(QString DC_devBluetoothName READ DC_devBluetoothName WRITE DC_setDevBluetoothName)
|
|
|
|
Q_PROPERTY(QString descriptor READ DC_descriptor)
|
2019-09-21 23:31:27 +00:00
|
|
|
Q_PROPERTY(bool DC_forceDownload READ DC_forceDownload WRITE DC_setForceDownload NOTIFY DC_ForceDownloadChanged)
|
2018-06-09 11:14:54 +00:00
|
|
|
Q_PROPERTY(bool DC_bluetoothMode READ DC_bluetoothMode WRITE DC_setBluetoothMode)
|
|
|
|
Q_PROPERTY(bool DC_saveDump READ DC_saveDump WRITE DC_setSaveDump)
|
2018-08-06 13:24:51 +00:00
|
|
|
Q_PROPERTY(QString pluggedInDeviceName MEMBER m_pluggedInDeviceName NOTIFY pluggedInDeviceNameChanged)
|
2019-02-14 06:48:50 +00:00
|
|
|
Q_PROPERTY(bool showNonDiveComputers MEMBER m_showNonDiveComputers WRITE setShowNonDiveComputers NOTIFY showNonDiveComputersChanged)
|
2019-12-29 11:29:05 +00:00
|
|
|
Q_PROPERTY(qPrefCloudStorage::cloud_status oldStatus MEMBER m_oldStatus WRITE setOldStatus NOTIFY oldStatusChanged)
|
2020-01-11 23:26:13 +00:00
|
|
|
Q_PROPERTY(QString undoText READ getUndoText NOTIFY undoTextChanged) // this is a read-only property
|
|
|
|
Q_PROPERTY(QString redoText READ getRedoText NOTIFY redoTextChanged) // this is a read-only property
|
2020-03-29 19:53:01 +00:00
|
|
|
Q_PROPERTY(bool diveListProcessing MEMBER m_diveListProcessing WRITE setDiveListProcessing NOTIFY diveListProcessingChanged)
|
2020-04-01 13:10:18 +00:00
|
|
|
Q_PROPERTY(bool initialized MEMBER m_initialized NOTIFY initializedChanged)
|
2020-06-13 20:52:04 +00:00
|
|
|
Q_PROPERTY(QString syncState READ getSyncState NOTIFY syncStateChanged)
|
2024-02-24 00:21:17 +00:00
|
|
|
Q_PROPERTY(QString passwordState READ getPasswordState NOTIFY passwordStateChanged)
|
2015-06-04 10:29:50 +00:00
|
|
|
public:
|
|
|
|
QMLManager();
|
|
|
|
~QMLManager();
|
|
|
|
|
2019-11-19 18:27:20 +00:00
|
|
|
enum export_types {
|
|
|
|
EX_DIVES_XML,
|
|
|
|
EX_DIVE_SITES_XML,
|
|
|
|
EX_DIVELOGS_DE,
|
2020-02-15 19:44:14 +00:00
|
|
|
EX_DIVESHARE
|
2019-11-19 18:27:20 +00:00
|
|
|
};
|
|
|
|
Q_ENUM(export_types)
|
2020-02-15 19:44:14 +00:00
|
|
|
#if !defined(Q_OS_ANDROID)
|
2019-11-19 18:27:20 +00:00
|
|
|
Q_INVOKABLE void exportToFile(export_types type, QString directory, bool anonymize);
|
2020-02-15 19:44:14 +00:00
|
|
|
#endif
|
2019-11-19 18:27:20 +00:00
|
|
|
Q_INVOKABLE void exportToWEB(export_types type, QString userId, QString password, bool anonymize);
|
2022-08-30 18:53:02 +00:00
|
|
|
Q_INVOKABLE void shareViaEmail(export_types type, bool anonymize);
|
2019-11-19 18:27:20 +00:00
|
|
|
|
2018-06-09 11:14:54 +00:00
|
|
|
QString DC_vendor() const;
|
|
|
|
void DC_setVendor(const QString& vendor);
|
|
|
|
|
|
|
|
QString DC_product() const;
|
|
|
|
void DC_setProduct(const QString& product);
|
|
|
|
|
|
|
|
QString DC_devName() const;
|
|
|
|
void DC_setDevName(const QString& devName);
|
|
|
|
|
2018-12-21 22:52:02 +00:00
|
|
|
Q_INVOKABLE void retrieveBluetoothName();
|
|
|
|
|
2018-06-09 11:14:54 +00:00
|
|
|
QString DC_devBluetoothName() const;
|
|
|
|
void DC_setDevBluetoothName(const QString& devBluetoothName);
|
|
|
|
|
|
|
|
QString DC_descriptor() const;
|
|
|
|
|
|
|
|
bool DC_forceDownload() const;
|
|
|
|
void DC_setForceDownload(bool force);
|
|
|
|
|
|
|
|
bool DC_bluetoothMode() const;
|
|
|
|
void DC_setBluetoothMode(bool mode);
|
|
|
|
|
|
|
|
bool DC_saveDump() const;
|
|
|
|
void DC_setSaveDump(bool dumpMode);
|
|
|
|
|
2020-01-11 23:26:13 +00:00
|
|
|
QString getUndoText() const;
|
|
|
|
QString getRedoText() const;
|
|
|
|
|
2018-06-09 11:14:54 +00:00
|
|
|
Q_INVOKABLE QStringList getProductListFromVendor(const QString& vendor);
|
|
|
|
Q_INVOKABLE int getMatchingAddress(const QString &vendor, const QString &product);
|
|
|
|
Q_INVOKABLE int getDetectedVendorIndex();
|
|
|
|
Q_INVOKABLE int getDetectedProductIndex(const QString ¤tVendorText);
|
2018-09-23 05:53:43 +00:00
|
|
|
Q_INVOKABLE int getConnectionIndex(const QString &deviceSubstr);
|
2018-10-09 08:23:24 +00:00
|
|
|
Q_INVOKABLE void setGitLocalOnly(const bool &value);
|
2020-02-19 20:39:23 +00:00
|
|
|
Q_INVOKABLE void setFilter(const QString filterText, int mode);
|
2019-12-06 13:14:00 +00:00
|
|
|
Q_INVOKABLE void selectRow(int row);
|
2019-12-21 19:41:06 +00:00
|
|
|
Q_INVOKABLE void selectSwipeRow(int row);
|
2020-06-06 16:55:49 +00:00
|
|
|
Q_INVOKABLE void importCacheRepo(QString repo);
|
2018-08-06 13:24:51 +00:00
|
|
|
|
2019-09-27 23:26:54 +00:00
|
|
|
static QMLManager *instance();
|
2018-03-12 09:55:26 +00:00
|
|
|
Q_INVOKABLE void registerError(QString error);
|
2018-01-24 21:56:52 +00:00
|
|
|
QString consumeError();
|
2015-12-03 23:59:40 +00:00
|
|
|
|
2015-12-20 02:41:10 +00:00
|
|
|
bool verboseEnabled() const;
|
|
|
|
void setVerboseEnabled(bool verboseMode);
|
|
|
|
|
2015-12-03 02:49:02 +00:00
|
|
|
void setLoadFromCloud(bool done);
|
2016-02-08 19:08:49 +00:00
|
|
|
void syncLoadFromCloud();
|
2015-12-03 02:49:02 +00:00
|
|
|
|
2015-12-15 07:00:19 +00:00
|
|
|
QString startPageText() const;
|
2016-01-26 15:02:42 +00:00
|
|
|
void setStartPageText(const QString& text);
|
2015-12-15 07:00:19 +00:00
|
|
|
|
2017-06-18 06:22:37 +00:00
|
|
|
QString notificationText() const;
|
|
|
|
void setNotificationText(QString text);
|
2016-03-03 01:13:42 +00:00
|
|
|
|
2017-07-09 22:07:16 +00:00
|
|
|
QString progressMessage() const;
|
|
|
|
void setProgressMessage(QString text);
|
|
|
|
|
2017-10-12 07:43:40 +00:00
|
|
|
bool btEnabled() const;
|
|
|
|
void setBtEnabled(bool value);
|
|
|
|
|
2019-02-14 06:48:50 +00:00
|
|
|
void setShowNonDiveComputers(bool show);
|
2020-03-30 18:31:28 +00:00
|
|
|
qreal lastDevicePixelRatio();
|
|
|
|
void setDevicePixelRatio(qreal dpr, QScreen *screen);
|
2019-02-14 06:48:50 +00:00
|
|
|
|
2020-03-29 19:53:01 +00:00
|
|
|
void setDiveListProcessing(bool value);
|
|
|
|
|
2018-01-28 08:52:51 +00:00
|
|
|
QStringList suitList() const;
|
2018-01-28 09:26:45 +00:00
|
|
|
QStringList buddyList() const;
|
2022-02-12 13:03:18 +00:00
|
|
|
QStringList diveguideList() const;
|
2018-01-28 14:21:28 +00:00
|
|
|
QStringList locationList() const;
|
2021-09-01 21:35:48 +00:00
|
|
|
QStringList cylinderListInit() const;
|
|
|
|
QStringList defaultCylinderListInit() const;
|
2020-06-06 16:51:40 +00:00
|
|
|
QStringList cloudCacheList() const;
|
2017-06-23 14:31:44 +00:00
|
|
|
Q_INVOKABLE void setStatusbarColor(QColor color);
|
2017-10-12 07:43:40 +00:00
|
|
|
void btHostModeChange(QBluetoothLocalDevice::HostMode state);
|
2018-10-20 15:53:36 +00:00
|
|
|
QObject *qmlWindow;
|
2017-07-12 11:14:24 +00:00
|
|
|
|
2018-04-13 23:53:51 +00:00
|
|
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
2017-07-10 00:03:57 +00:00
|
|
|
void writeToAppLogFile(QString logText);
|
|
|
|
#endif
|
2019-12-29 11:29:05 +00:00
|
|
|
qPrefCloudStorage::cloud_status oldStatus() const;
|
|
|
|
void setOldStatus(const qPrefCloudStorage::cloud_status value);
|
2020-04-04 21:23:39 +00:00
|
|
|
void rememberOldStatus();
|
2016-06-13 23:41:26 +00:00
|
|
|
|
2020-06-13 20:52:04 +00:00
|
|
|
QString getSyncState() const;
|
2024-02-24 00:21:17 +00:00
|
|
|
QString getPasswordState() const;
|
2020-06-13 20:52:04 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
public slots:
|
2018-08-09 14:12:32 +00:00
|
|
|
void appInitialized();
|
QML UI: don't immediately save data after we make changes
Much as this felt like the prudent thing to do, it makes the UI painful
to use. In bad network conditions, with a large dive log, on a phone,
the save operation can take more than a minute - which is just completely
ludicrous.
So instead we mark the dive list changed when we make changes and wait
for the app to not be in the foreground. Once the OS tells us that we are
hidden (on the desktop that generally means we don't have focus, on a
mobile device it usually does mean that the app is not on the screen), we
check if there are data to be saved and do so.
There is of course a major problem with this logic. If the user switches
away from Subsurface-mobile but comes back fairly quickly (just reacting
to a notification or briefly checking something, changing a song,
something... then the app may still be non-responsive for quite a while.
So we need to do something about the time it takes us to save the git
tree locally, and then figure out if we can move at least some of the
network traffic to another thread.
And we need to make sure the user immediately notices that the app is not
crashed but is actually saving their data. But that's for another commit.
tl;dr: CAREFUL, don't kill Subsurface-mobile before it had time to save
your data or your changes may be gone. In typical use that shouldn't be
an issue, but it is something that we need to tell the user about.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 00:37:17 +00:00
|
|
|
void applicationStateChanged(Qt::ApplicationState state);
|
2019-12-27 12:56:33 +00:00
|
|
|
void saveCloudCredentials(const QString &email, const QString &password, const QString &pin);
|
2019-10-21 00:13:59 +00:00
|
|
|
void commitChanges(QString diveId, QString number, QString date, QString location, QString gps,
|
2016-08-30 14:24:19 +00:00
|
|
|
QString duration, QString depth, QString airtemp,
|
|
|
|
QString watertemp, QString suit, QString buddy,
|
2022-02-12 13:03:18 +00:00
|
|
|
QString diveGuide, QString tags, QString weight, QString notes, QStringList startpressure,
|
2018-07-29 13:42:56 +00:00
|
|
|
QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state);
|
2020-02-22 22:05:13 +00:00
|
|
|
void updateTripDetails(QString tripIdString, QString tripLocation, QString tripNotes);
|
2020-02-19 22:06:03 +00:00
|
|
|
void removeDiveFromTrip(int id);
|
2020-03-26 19:12:38 +00:00
|
|
|
void addTripForDive(int id);
|
2020-02-20 21:24:38 +00:00
|
|
|
void addDiveToTrip(int id, int tripId);
|
2021-01-17 21:09:01 +00:00
|
|
|
void changesNeedSaving(bool fromUndo = false);
|
mobile: No cloud repo creation more explicit
Before this change, there was only one way to create the local
no cloud repo on the device. The user needed to add at least
one dive to the no cloud account (so that there is something
to save). While this worked in some scenarios, it could also
get things in an inconsistent state: credential status = CS_NOCLOUD
but no local repo. This was a dead end.
In this commit, the creation of the no cloud repo is made more
explicit. When asking for no cloud mode, just create an (empty)
repo for it when it does not yet exist, and otherwise, just
open the existing (possibly empty) repo.
Now, a user can have no cloud repo, next to (any number of)
cloud accounts.
This leaves one functional aspect left: how does a user abandon
the no cloud repo, by merging his data into a true cloud
account. This is code for this, that tries to do this merge in
a smart way. This seems to be broken (too). To be clear: this
is no part of this commit.
Fixes: #667
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-17 07:51:00 +00:00
|
|
|
void openNoCloudRepo();
|
2024-03-30 20:39:08 +00:00
|
|
|
void saveChangesCloud(bool forceRemoteSync);
|
2019-10-08 03:37:31 +00:00
|
|
|
void selectDive(int id);
|
2016-02-23 12:39:40 +00:00
|
|
|
void deleteDive(int id);
|
2022-08-08 00:11:05 +00:00
|
|
|
void deleteAccount();
|
2020-03-20 22:59:38 +00:00
|
|
|
void toggleDiveInvalid(int id);
|
2018-10-27 07:21:40 +00:00
|
|
|
void copyDiveData(int id);
|
|
|
|
void pasteDiveData(int id);
|
2018-11-18 05:42:15 +00:00
|
|
|
bool toggleDiveSite(bool toggle);
|
|
|
|
bool toggleNotes(bool toggle);
|
2022-02-12 13:03:18 +00:00
|
|
|
bool toggleDiveGuide(bool toggle);
|
2018-11-18 05:42:15 +00:00
|
|
|
bool toggleBuddy(bool toggle);
|
|
|
|
bool toggleSuit(bool toggle);
|
|
|
|
bool toggleRating(bool toggle);
|
|
|
|
bool toggleVisibility(bool toggle);
|
|
|
|
bool toggleTags(bool toggle);
|
|
|
|
bool toggleCylinders(bool toggle);
|
|
|
|
bool toggleWeights(bool toggle);
|
2020-01-11 23:29:45 +00:00
|
|
|
void undo();
|
2020-01-11 23:26:13 +00:00
|
|
|
void redo();
|
2020-01-01 22:45:52 +00:00
|
|
|
int addDive();
|
2017-07-19 07:16:47 +00:00
|
|
|
void cancelDownloadDC();
|
2019-11-09 18:14:15 +00:00
|
|
|
QString getCombinedLogs();
|
2018-05-16 14:50:17 +00:00
|
|
|
void copyAppLogToClipboard();
|
2019-11-09 18:14:15 +00:00
|
|
|
bool createSupportEmail();
|
2015-12-05 03:34:59 +00:00
|
|
|
void finishSetup();
|
2016-01-26 15:02:42 +00:00
|
|
|
QString getNumber(const QString& diveId);
|
|
|
|
QString getDate(const QString& diveId);
|
2017-11-22 18:22:02 +00:00
|
|
|
QString getGpsFromSiteName(const QString& siteName);
|
2016-02-10 20:53:58 +00:00
|
|
|
QString getVersion() const;
|
2016-01-11 03:34:21 +00:00
|
|
|
void refreshDiveList();
|
2016-03-09 03:31:05 +00:00
|
|
|
void screenChanged(QScreen *screen);
|
2016-03-27 04:31:41 +00:00
|
|
|
void appendTextToLog(const QString &newText);
|
2016-04-15 21:42:08 +00:00
|
|
|
void quit();
|
2017-12-05 19:58:54 +00:00
|
|
|
void btRescan();
|
2020-03-15 01:52:45 +00:00
|
|
|
void usbRescan();
|
|
|
|
void rescanConnections();
|
2020-03-15 01:05:06 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
void showDownloadPage(QAndroidJniObject usbDevice);
|
2020-03-15 19:27:10 +00:00
|
|
|
void restartDownload(QAndroidJniObject usbDevice);
|
2020-03-15 01:52:45 +00:00
|
|
|
void androidUsbPopoulateConnections();
|
2020-03-15 01:11:46 +00:00
|
|
|
QString getProductVendorConnectionIdx(android_usb_serial_device_descriptor descriptor);
|
2020-03-15 01:05:06 +00:00
|
|
|
#endif
|
2020-02-18 01:16:11 +00:00
|
|
|
void divesChanged(const QVector<dive *> &dives, DiveField field);
|
2015-11-11 20:34:56 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
private:
|
2018-01-28 08:52:51 +00:00
|
|
|
BuddyCompletionModel buddyModel;
|
|
|
|
SuitCompletionModel suitModel;
|
2022-02-12 13:03:18 +00:00
|
|
|
DiveGuideCompletionModel diveguideModel;
|
2019-03-12 16:28:43 +00:00
|
|
|
DiveSiteSortedModel locationModel;
|
2015-12-15 07:00:19 +00:00
|
|
|
QString m_startPageText;
|
2018-01-24 21:56:52 +00:00
|
|
|
QString m_lastError;
|
2015-12-20 02:41:10 +00:00
|
|
|
bool m_verboseEnabled;
|
2020-03-29 19:53:01 +00:00
|
|
|
bool m_diveListProcessing;
|
2020-04-01 13:10:18 +00:00
|
|
|
bool m_initialized;
|
2015-12-03 02:49:02 +00:00
|
|
|
bool m_loadFromCloud;
|
2019-09-27 23:26:54 +00:00
|
|
|
static QMLManager *m_instance;
|
2017-06-18 06:22:37 +00:00
|
|
|
QString m_notificationText;
|
2016-03-09 03:31:05 +00:00
|
|
|
qreal m_lastDevicePixelRatio;
|
QML UI: don't immediately save data after we make changes
Much as this felt like the prudent thing to do, it makes the UI painful
to use. In bad network conditions, with a large dive log, on a phone,
the save operation can take more than a minute - which is just completely
ludicrous.
So instead we mark the dive list changed when we make changes and wait
for the app to not be in the foreground. Once the OS tells us that we are
hidden (on the desktop that generally means we don't have focus, on a
mobile device it usually does mean that the app is not on the screen), we
check if there are data to be saved and do so.
There is of course a major problem with this logic. If the user switches
away from Subsurface-mobile but comes back fairly quickly (just reacting
to a notification or briefly checking something, changing a song,
something... then the app may still be non-responsive for quite a while.
So we need to do something about the time it takes us to save the git
tree locally, and then figure out if we can move at least some of the
network traffic to another thread.
And we need to make sure the user immediately notices that the app is not
crashed but is actually saving their data. But that's for another commit.
tl;dr: CAREFUL, don't kill Subsurface-mobile before it had time to save
your data or your changes may be gone. In typical use that shouldn't be
an issue, but it is something that we need to tell the user about.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 00:37:17 +00:00
|
|
|
QElapsedTimer timer;
|
2020-12-15 15:10:08 +00:00
|
|
|
bool checkDate(struct dive *d, QString date);
|
|
|
|
bool checkLocation(DiveSiteChange &change, struct dive *d, QString location, QString gps);
|
|
|
|
bool checkDuration(struct dive *d, QString duration);
|
|
|
|
bool checkDepth(struct dive *d, QString depth);
|
2016-04-30 18:08:33 +00:00
|
|
|
bool currentGitLocalOnly;
|
2020-06-13 20:45:06 +00:00
|
|
|
bool localChanges;
|
2017-07-09 22:07:16 +00:00
|
|
|
QString m_progressMessage;
|
2017-07-12 11:14:24 +00:00
|
|
|
bool m_btEnabled;
|
2018-01-28 16:39:01 +00:00
|
|
|
void updateAllGlobalLists();
|
2020-06-13 20:45:06 +00:00
|
|
|
void updateHaveLocalChanges(bool status);
|
2020-01-10 00:25:37 +00:00
|
|
|
|
|
|
|
location_t getGps(QString &gps);
|
2018-08-06 13:24:51 +00:00
|
|
|
QString m_pluggedInDeviceName;
|
2019-02-14 06:48:50 +00:00
|
|
|
bool m_showNonDiveComputers;
|
2018-10-27 09:00:12 +00:00
|
|
|
struct dive *m_copyPasteDive = NULL;
|
2018-10-27 07:21:40 +00:00
|
|
|
struct dive_components what;
|
2019-11-14 21:19:58 +00:00
|
|
|
QAction *undoAction;
|
2017-07-12 11:14:24 +00:00
|
|
|
|
2019-12-27 13:05:47 +00:00
|
|
|
bool verifyCredentials(QString email, QString password, QString pin);
|
2020-03-30 18:31:28 +00:00
|
|
|
void loadDivesWithValidCredentials();
|
|
|
|
void revertToNoCloudIfNeeded();
|
|
|
|
void consumeFinishedLoad();
|
2020-03-31 07:51:14 +00:00
|
|
|
void mergeLocalRepo();
|
|
|
|
void openLocalThenRemote(QString url);
|
2024-03-30 20:39:08 +00:00
|
|
|
void saveChangesLocal();
|
2019-12-27 13:05:47 +00:00
|
|
|
|
2018-04-13 06:05:23 +00:00
|
|
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
2017-07-10 00:03:57 +00:00
|
|
|
QString appLogFileName;
|
|
|
|
QFile appLogFile;
|
|
|
|
bool appLogFileOpen;
|
2022-08-29 23:46:58 +00:00
|
|
|
#endif
|
|
|
|
#if defined(Q_OS_IOS)
|
|
|
|
IosShare iosshare;
|
2017-07-10 00:03:57 +00:00
|
|
|
#endif
|
2019-12-29 11:29:05 +00:00
|
|
|
qPrefCloudStorage::cloud_status m_oldStatus;
|
2017-06-01 18:07:19 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
signals:
|
2015-12-20 02:41:10 +00:00
|
|
|
void verboseEnabledChanged();
|
2020-03-29 19:53:01 +00:00
|
|
|
void diveListProcessingChanged();
|
2020-04-01 13:10:18 +00:00
|
|
|
void initializedChanged();
|
2015-12-03 02:49:02 +00:00
|
|
|
void loadFromCloudChanged();
|
2015-12-15 07:00:19 +00:00
|
|
|
void startPageTextChanged();
|
2017-06-18 06:22:37 +00:00
|
|
|
void notificationTextChanged();
|
2016-03-09 03:31:05 +00:00
|
|
|
void sendScreenChanged(QScreen *screen);
|
2017-07-09 22:07:16 +00:00
|
|
|
void progressMessageChanged();
|
2017-10-12 07:43:40 +00:00
|
|
|
void btEnabledChanged();
|
2018-01-28 08:52:51 +00:00
|
|
|
void suitListChanged();
|
2018-01-28 09:26:45 +00:00
|
|
|
void buddyListChanged();
|
2022-02-12 13:03:18 +00:00
|
|
|
void diveguideListChanged();
|
2018-01-28 14:21:28 +00:00
|
|
|
void locationListChanged();
|
2020-06-06 16:51:40 +00:00
|
|
|
void cloudCacheListChanged();
|
2018-04-14 18:12:07 +00:00
|
|
|
void waitingForPositionChanged();
|
2018-08-06 13:24:51 +00:00
|
|
|
void pluggedInDeviceNameChanged();
|
2019-02-14 06:48:50 +00:00
|
|
|
void showNonDiveComputersChanged();
|
2019-09-21 23:31:27 +00:00
|
|
|
void DC_ForceDownloadChanged();
|
2019-12-29 11:29:05 +00:00
|
|
|
void oldStatusChanged();
|
2020-01-11 23:26:13 +00:00
|
|
|
void undoTextChanged();
|
|
|
|
void redoTextChanged();
|
2020-03-15 19:27:10 +00:00
|
|
|
void restartDownloadSignal();
|
2020-06-13 20:52:04 +00:00
|
|
|
void syncStateChanged();
|
2024-02-24 00:21:17 +00:00
|
|
|
void passwordStateChanged();
|
2024-03-30 20:55:22 +00:00
|
|
|
void changesNeedSavingSignal();
|
2019-12-08 08:23:45 +00:00
|
|
|
|
|
|
|
// From upload process
|
|
|
|
void uploadFinish(bool success, const QString &text);
|
|
|
|
void uploadProgress(qreal percentage);
|
2019-12-08 10:52:38 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void uploadFinishSlot(bool success, const QString &text, const QByteArray &html);
|
2024-03-30 20:55:22 +00:00
|
|
|
void saveUnsaved();
|
2015-06-04 10:29:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|