summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp8
-rw-r--r--mobile-widgets/qmlmanager.h5
-rw-r--r--mobile-widgets/qmlprefs.cpp17
-rw-r--r--mobile-widgets/qmlprefs.h8
4 files changed, 4 insertions, 34 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 858f2c730..3c9adebbd 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -44,7 +44,6 @@
#include "core/settings/qPrefUnit.h"
#include "core/trip.h"
-QMLManager *QMLManager::m_instance = NULL;
bool noCloudToCloud = false;
#define RED_FONT QLatin1Literal("<font color=\"red\">")
@@ -150,7 +149,6 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
m_showNonDiveComputers(false)
{
LOG_STP("qmlmgr starting");
- m_instance = this;
m_lastDevicePixelRatio = qApp->devicePixelRatio();
timer.start();
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
@@ -451,12 +449,6 @@ QMLManager::~QMLManager()
if (appLogFileOpen)
appLogFile.close();
#endif
- m_instance = NULL;
-}
-
-QMLManager *QMLManager::instance()
-{
- return m_instance;
}
#define CLOUDURL QString(prefs.cloud_base_url)
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index e47119a71..963c563d7 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -13,13 +13,14 @@
#include "core/btdiscovery.h"
#include "core/gpslocation.h"
#include "core/downloadfromdcthread.h"
+#include "core/singleton.h"
#include "qt-models/divelistmodel.h"
#include "qt-models/completionmodels.h"
#include "qt-models/divelocationmodel.h"
#define NOCLOUD_LOCALSTORAGE format_string("%s/cloudstorage/localrepo[master]", system_default_directory())
-class QMLManager : public QObject {
+class QMLManager : public QObject, public SillySingleton<QMLManager> {
Q_OBJECT
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
Q_PROPERTY(bool locationServiceEnabled MEMBER m_locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
@@ -89,7 +90,6 @@ public:
Q_INVOKABLE void setGitLocalOnly(const bool &value);
Q_INVOKABLE void setFilter(const QString filterText);
- static QMLManager *instance();
Q_INVOKABLE void registerError(QString error);
QString consumeError();
@@ -219,7 +219,6 @@ private:
bool m_verboseEnabled;
GpsLocation *locationProvider;
bool m_loadFromCloud;
- static QMLManager *m_instance;
struct dive *deletedDive;
struct dive_trip *deletedTrip;
QString m_notificationText;
diff --git a/mobile-widgets/qmlprefs.cpp b/mobile-widgets/qmlprefs.cpp
index cf7b5ddbb..e415c0e5d 100644
--- a/mobile-widgets/qmlprefs.cpp
+++ b/mobile-widgets/qmlprefs.cpp
@@ -8,30 +8,13 @@
/*** Global and constructors ***/
-QMLPrefs *QMLPrefs::m_instance = NULL;
-
QMLPrefs::QMLPrefs() :
m_credentialStatus(qPrefCloudStorage::CS_UNKNOWN),
m_oldStatus(qPrefCloudStorage::CS_UNKNOWN),
m_showPin(false)
{
- // This strange construct is needed because QMLEngine calls new and that
- // cannot be overwritten
- if (!m_instance)
- m_instance = this;
-}
-
-QMLPrefs::~QMLPrefs()
-{
- m_instance = NULL;
}
-QMLPrefs *QMLPrefs::instance()
-{
- return m_instance;
-}
-
-
/*** public functions ***/
const QString QMLPrefs::cloudPassword() const
{
diff --git a/mobile-widgets/qmlprefs.h b/mobile-widgets/qmlprefs.h
index 99819fd7c..70964608b 100644
--- a/mobile-widgets/qmlprefs.h
+++ b/mobile-widgets/qmlprefs.h
@@ -5,9 +5,9 @@
#include <QObject>
#include "core/settings/qPrefCloudStorage.h"
#include "core/settings/qPrefDisplay.h"
+#include "core/singleton.h"
-
-class QMLPrefs : public QObject {
+class QMLPrefs : public QObject, public SillySingleton<QMLPrefs> {
Q_OBJECT
Q_PROPERTY(QString cloudPassword
MEMBER m_cloudPassword
@@ -35,9 +35,6 @@ class QMLPrefs : public QObject {
NOTIFY oldStatusChanged)
public:
QMLPrefs();
- ~QMLPrefs();
-
- static QMLPrefs *instance();
const QString cloudPassword() const;
void setCloudPassword(const QString &cloudPassword);
@@ -66,7 +63,6 @@ private:
QString m_cloudPin;
QString m_cloudUserName;
qPrefCloudStorage::cloud_status m_credentialStatus;
- static QMLPrefs *m_instance;
qPrefCloudStorage::cloud_status m_oldStatus;
bool m_showPin;