mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 16:25:54 +00:00
Move serialization and deserialization into NvApp class
This commit is contained in:
parent
350c7d7081
commit
dc3c565ec0
@ -133,6 +133,7 @@ macx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
backend/nvapp.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
backend/computerseeker.cpp \
|
backend/computerseeker.cpp \
|
||||||
backend/identitymanager.cpp \
|
backend/identitymanager.cpp \
|
||||||
@ -167,6 +168,7 @@ SOURCES += \
|
|||||||
wm.cpp
|
wm.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
backend/nvapp.h \
|
||||||
utils.h \
|
utils.h \
|
||||||
backend/computerseeker.h \
|
backend/computerseeker.h \
|
||||||
backend/identitymanager.h \
|
backend/identitymanager.h \
|
||||||
|
22
app/backend/nvapp.cpp
Normal file
22
app/backend/nvapp.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "nvapp.h"
|
||||||
|
|
||||||
|
#define SER_APPNAME "name"
|
||||||
|
#define SER_APPID "id"
|
||||||
|
#define SER_APPHDR "hdr"
|
||||||
|
#define SER_APPCOLLECTOR "appcollector"
|
||||||
|
|
||||||
|
NvApp::NvApp(QSettings& settings)
|
||||||
|
{
|
||||||
|
name = settings.value(SER_APPNAME).toString();
|
||||||
|
id = settings.value(SER_APPID).toInt();
|
||||||
|
hdrSupported = settings.value(SER_APPHDR).toBool();
|
||||||
|
isAppCollectorGame = settings.value(SER_APPCOLLECTOR).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NvApp::serialize(QSettings& settings) const
|
||||||
|
{
|
||||||
|
settings.setValue(SER_APPNAME, name);
|
||||||
|
settings.setValue(SER_APPID, id);
|
||||||
|
settings.setValue(SER_APPHDR, hdrSupported);
|
||||||
|
settings.setValue(SER_APPCOLLECTOR, isAppCollectorGame);
|
||||||
|
}
|
30
app/backend/nvapp.h
Normal file
30
app/backend/nvapp.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
class NvApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NvApp() {}
|
||||||
|
explicit NvApp(QSettings& settings);
|
||||||
|
|
||||||
|
bool operator==(const NvApp& other) const
|
||||||
|
{
|
||||||
|
return id == other.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInitialized()
|
||||||
|
{
|
||||||
|
return id != 0 && !name.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
serialize(QSettings& settings) const;
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
|
QString name;
|
||||||
|
bool hdrSupported = false;
|
||||||
|
bool isAppCollectorGame = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(NvApp)
|
@ -1,4 +1,5 @@
|
|||||||
#include "nvcomputer.h"
|
#include "nvcomputer.h"
|
||||||
|
#include "nvapp.h"
|
||||||
|
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
@ -16,11 +17,6 @@
|
|||||||
#define SER_SRVCERT "srvcert"
|
#define SER_SRVCERT "srvcert"
|
||||||
#define SER_CUSTOMNAME "customname"
|
#define SER_CUSTOMNAME "customname"
|
||||||
|
|
||||||
#define SER_APPNAME "name"
|
|
||||||
#define SER_APPID "id"
|
|
||||||
#define SER_APPHDR "hdr"
|
|
||||||
#define SER_APPCOLLECTOR "appcollector"
|
|
||||||
|
|
||||||
NvComputer::NvComputer(QSettings& settings)
|
NvComputer::NvComputer(QSettings& settings)
|
||||||
{
|
{
|
||||||
this->name = settings.value(SER_NAME).toString();
|
this->name = settings.value(SER_NAME).toString();
|
||||||
@ -35,15 +31,9 @@ NvComputer::NvComputer(QSettings& settings)
|
|||||||
|
|
||||||
int appCount = settings.beginReadArray(SER_APPLIST);
|
int appCount = settings.beginReadArray(SER_APPLIST);
|
||||||
for (int i = 0; i < appCount; i++) {
|
for (int i = 0; i < appCount; i++) {
|
||||||
NvApp app;
|
|
||||||
|
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
|
|
||||||
app.name = settings.value(SER_APPNAME).toString();
|
NvApp app(settings);
|
||||||
app.id = settings.value(SER_APPID).toInt();
|
|
||||||
app.hdrSupported = settings.value(SER_APPHDR).toBool();
|
|
||||||
app.isAppCollectorGame = settings.value(SER_APPCOLLECTOR).toBool();
|
|
||||||
|
|
||||||
this->appList.append(app);
|
this->appList.append(app);
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
@ -81,11 +71,7 @@ void NvComputer::serialize(QSettings& settings) const
|
|||||||
settings.beginWriteArray(SER_APPLIST);
|
settings.beginWriteArray(SER_APPLIST);
|
||||||
for (int i = 0; i < appList.count(); i++) {
|
for (int i = 0; i < appList.count(); i++) {
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
|
appList[i].serialize(settings);
|
||||||
settings.setValue(SER_APPNAME, appList[i].name);
|
|
||||||
settings.setValue(SER_APPID, appList[i].id);
|
|
||||||
settings.setValue(SER_APPHDR, appList[i].hdrSupported);
|
|
||||||
settings.setValue(SER_APPCOLLECTOR, appList[i].isAppCollectorGame);
|
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "identitymanager.h"
|
#include "identitymanager.h"
|
||||||
|
#include "nvapp.h"
|
||||||
|
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
|
|
||||||
@ -8,27 +9,6 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
class NvApp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool operator==(const NvApp& other) const
|
|
||||||
{
|
|
||||||
return id == other.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isInitialized()
|
|
||||||
{
|
|
||||||
return id != 0 && !name.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
int id;
|
|
||||||
QString name;
|
|
||||||
bool hdrSupported;
|
|
||||||
bool isAppCollectorGame;
|
|
||||||
};
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(NvApp)
|
|
||||||
|
|
||||||
class NvDisplayMode
|
class NvDisplayMode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user