mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Replace on version struct with QVersionNumber
This commit is contained in:
parent
70fe34812e
commit
dc4aad776f
@ -4,6 +4,7 @@
|
||||
|
||||
Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QGuiApplication* app, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_version(QVersionNumber(0, 0, 1))
|
||||
, m_qSettings(QSettings(QSettings::NativeFormat, QSettings::Scope::UserScope, app->organizationName(), app->applicationName()))
|
||||
{
|
||||
|
||||
@ -71,16 +72,18 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo
|
||||
}
|
||||
|
||||
configObj = configJsonDocument.object();
|
||||
|
||||
QString tmp(configObj.value("version").toVariant().toString());
|
||||
int major, minor, patch;
|
||||
major = QString(tmp.at(0)).toInt();
|
||||
minor = QString(tmp.at(2)).toInt();
|
||||
patch = QString(tmp.at(4)).toInt();
|
||||
QVersionNumber fileVersion(major, minor, patch);
|
||||
|
||||
//Checks if the settings file has the same version as ScreeenPlay
|
||||
if (!(major == m_version.major && minor == m_version.minor && patch == m_version.patch)) {
|
||||
if (fileVersion != m_version) {
|
||||
// TODO(Kelteseth): Display error message
|
||||
qWarning("Version missmatch");
|
||||
qWarning() << "Version missmatch fileVersion: " << fileVersion.toString() << "m_version: " << m_version.toString();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -265,7 +268,7 @@ void Settings::saveWallpaper(int monitorIndex, QUrl absoluteStoragePath, QString
|
||||
{
|
||||
}
|
||||
|
||||
void Settings::setqSetting(const QString &key, const QString &value)
|
||||
void Settings::setqSetting(const QString& key, const QString& value)
|
||||
{
|
||||
m_qSettings.setValue(key, value);
|
||||
m_qSettings.sync();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QVariant>
|
||||
#include <QVector>
|
||||
#include <QtGlobal>
|
||||
#include <QVersionNumber>
|
||||
|
||||
#include "installedlistmodel.h"
|
||||
#include "monitorlistmodel.h"
|
||||
@ -52,7 +53,7 @@ public:
|
||||
explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, SDKConnector* sdkc, QGuiApplication* app, QObject* parent = nullptr);
|
||||
~Settings();
|
||||
|
||||
Q_PROPERTY(Version version READ version)
|
||||
Q_PROPERTY(QVersionNumber version READ version)
|
||||
Q_PROPERTY(bool hasWorkshopBannerSeen READ hasWorkshopBannerSeen WRITE setHasWorkshopBannerSeen NOTIFY hasWorkshopBannerSeenChanged)
|
||||
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged)
|
||||
@ -73,13 +74,7 @@ public:
|
||||
};
|
||||
Q_ENUM(LocalCopyResult)
|
||||
|
||||
struct Version {
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
int patch = 1;
|
||||
};
|
||||
|
||||
Version version() const
|
||||
QVersionNumber version() const
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
@ -299,7 +294,7 @@ public slots:
|
||||
private:
|
||||
void createDefaultConfig();
|
||||
|
||||
Version m_version;
|
||||
QVersionNumber m_version;
|
||||
QSettings m_qSettings;
|
||||
QTranslator m_translator;
|
||||
ProfileListModel* m_plm;
|
||||
|
Loading…
Reference in New Issue
Block a user