Add support for hiding games

Fixes #255
This commit is contained in:
Cameron Gutman
2020-08-01 21:06:01 -07:00
parent 9385d62c89
commit 539bf0cb30
10 changed files with 239 additions and 47 deletions
+10 -6
View File
@@ -68,12 +68,7 @@ private:
}
QWriteLocker lock(&m_Computer->lock);
if (m_Computer->appList != appList) {
m_Computer->appList = appList;
m_Computer->sortAppList();
changed = true;
}
changed = m_Computer->updateAppList(appList);
return true;
}
@@ -433,6 +428,15 @@ void ComputerManager::renameHost(NvComputer* computer, QString name)
handleComputerStateChanged(computer);
}
void ComputerManager::clientSideAttributeUpdated(NvComputer* computer)
{
// Persist the change
saveHosts();
// Notify the UI of the state change
handleComputerStateChanged(computer);
}
void ComputerManager::handleAboutToQuit()
{
QWriteLocker lock(&m_Lock);
+2
View File
@@ -181,6 +181,8 @@ public:
void renameHost(NvComputer* computer, QString name);
void clientSideAttributeUpdated(NvComputer* computer);
signals:
void computerStateChanged(NvComputer* computer);
+3
View File
@@ -4,6 +4,7 @@
#define SER_APPID "id"
#define SER_APPHDR "hdr"
#define SER_APPCOLLECTOR "appcollector"
#define SER_HIDDEN "hidden"
NvApp::NvApp(QSettings& settings)
{
@@ -11,6 +12,7 @@ NvApp::NvApp(QSettings& settings)
id = settings.value(SER_APPID).toInt();
hdrSupported = settings.value(SER_APPHDR).toBool();
isAppCollectorGame = settings.value(SER_APPCOLLECTOR).toBool();
hidden = settings.value(SER_HIDDEN).toBool();
}
void NvApp::serialize(QSettings& settings) const
@@ -19,4 +21,5 @@ void NvApp::serialize(QSettings& settings) const
settings.setValue(SER_APPID, id);
settings.setValue(SER_APPHDR, hdrSupported);
settings.setValue(SER_APPCOLLECTOR, isAppCollectorGame);
settings.setValue(SER_HIDDEN, hidden);
}
+11 -1
View File
@@ -10,7 +10,16 @@ public:
bool operator==(const NvApp& other) const
{
return id == other.id;
return id == other.id &&
name == other.name &&
hdrSupported == other.hdrSupported &&
isAppCollectorGame == other.isAppCollectorGame &&
hidden == other.hidden;
}
bool operator!=(const NvApp& other) const
{
return !operator==(other);
}
bool isInitialized()
@@ -25,6 +34,7 @@ public:
QString name;
bool hdrSupported = false;
bool isAppCollectorGame = false;
bool hidden = false;
};
Q_DECLARE_METATYPE(NvApp)
+25 -1
View File
@@ -306,6 +306,25 @@ bool NvComputer::isReachableOverVpn()
}
}
bool NvComputer::updateAppList(QVector<NvApp> newAppList) {
if (appList == newAppList) {
return false;
}
// Propagate client-side attributes to the new app list
for (const NvApp& existingApp : appList) {
for (NvApp& newApp : newAppList) {
if (existingApp.id == newApp.id) {
newApp.hidden = existingApp.hidden;
}
}
}
appList = newAppList;
sortAppList();
return true;
}
QVector<QString> NvComputer::uniqueAddresses() const
{
QVector<QString> uniqueAddressList;
@@ -389,7 +408,12 @@ bool NvComputer::update(NvComputer& that)
ASSIGN_IF_CHANGED(maxLumaPixelsHEVC);
ASSIGN_IF_CHANGED(gpuModel);
ASSIGN_IF_CHANGED_AND_NONNULL(serverCert);
ASSIGN_IF_CHANGED_AND_NONEMPTY(appList);
ASSIGN_IF_CHANGED_AND_NONEMPTY(displayModes);
if (!that.appList.isEmpty()) {
// updateAppList() handles merging client-side attributes
updateAppList(that.appList);
}
return changed;
}
+2
View File
@@ -16,6 +16,8 @@ class NvComputer
private:
void sortAppList();
bool updateAppList(QVector<NvApp> newAppList);
bool pendingQuit;
public: