mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
mobile-widgets: make cloud_verification_status type proof in QML.
Add CLOUD_STATUS enum to interface. Add cloud_verifification_status variable to interface, and make it strongly typed in QML. using backend.cloud_verification_status = 1 will fail but backend.cloud_verification_status = backend.CS_UNKNOWN is correct. Added note to the original definitions of the enums that they have been duplicated. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9105a4c39b
commit
c93b76eee6
3 changed files with 24 additions and 0 deletions
|
@ -31,6 +31,7 @@ public:
|
||||||
static void sync() { loadSync(true); }
|
static void sync() { loadSync(true); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// NOTE: these enums are duplicated in mobile-widgets/qmlinterface.h
|
||||||
enum cloud_status {
|
enum cloud_status {
|
||||||
CS_UNKNOWN,
|
CS_UNKNOWN,
|
||||||
CS_INCORRECT_USER_PASSWD,
|
CS_INCORRECT_USER_PASSWD,
|
||||||
|
|
|
@ -18,4 +18,6 @@ void QMLInterface::setup(QQmlContext *ct)
|
||||||
qmlRegisterUncreatableType<QMLInterface>("org.subsurfacedivelog.mobile",1,0,"Enums","Enum is not a type");
|
qmlRegisterUncreatableType<QMLInterface>("org.subsurfacedivelog.mobile",1,0,"Enums","Enum is not a type");
|
||||||
|
|
||||||
// relink signals to QML
|
// relink signals to QML
|
||||||
|
connect(qPrefCloudStorage::instance(), &qPrefCloudStorage::cloud_verification_statusChanged,
|
||||||
|
[=] (int value) { emit instance()->cloud_verification_statusChanged(CLOUD_STATUS(value)); });
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#ifndef QMLINTERFACE_H
|
#ifndef QMLINTERFACE_H
|
||||||
#define QMLINTERFACE_H
|
#define QMLINTERFACE_H
|
||||||
|
#include "core/settings/qPrefCloudStorage.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
// This class is a pure interface class and may not contain any implementation code
|
// This class is a pure interface class and may not contain any implementation code
|
||||||
|
@ -22,6 +24,7 @@ class QMLInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// Q_PROPERTY used in QML
|
// Q_PROPERTY used in QML
|
||||||
|
Q_PROPERTY(CLOUD_STATUS cloud_verification_status READ cloud_verification_status WRITE set_cloud_verification_status NOTIFY cloud_verification_statusChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QMLInterface *instance();
|
static QMLInterface *instance();
|
||||||
|
@ -88,6 +91,24 @@ public:
|
||||||
};
|
};
|
||||||
Q_ENUM(DURATION);
|
Q_ENUM(DURATION);
|
||||||
|
|
||||||
|
enum CLOUD_STATUS {
|
||||||
|
CS_UNKNOWN,
|
||||||
|
CS_INCORRECT_USER_PASSWD,
|
||||||
|
CS_NEED_TO_VERIFY,
|
||||||
|
CS_VERIFIED,
|
||||||
|
CS_NOCLOUD
|
||||||
|
};
|
||||||
|
Q_ENUM(CLOUD_STATUS);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CLOUD_STATUS cloud_verification_status() { return (CLOUD_STATUS)prefs.cloud_verification_status; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void set_cloud_verification_status(CLOUD_STATUS value) { qPrefCloudStorage::set_cloud_verification_status(value); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void cloud_verification_statusChanged(CLOUD_STATUS);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMLInterface() {}
|
QMLInterface() {}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue