[DeckSync] Move the client signal handlers out of the constructor lambdas

This commit is contained in:
Lukas Brübach 2026-11-06 12:04:17 +01:00
parent 63f57fae7d
commit f52431cf96
2 changed files with 30 additions and 20 deletions

View file

@ -108,8 +108,15 @@ DeckSyncManager::DeckSyncManager(AbstractClient *_client, ColorIdentityProvider
if (client == nullptr) { if (client == nullptr) {
return; return;
} }
connect(client, &AbstractClient::statusChanged, this, [this](ClientStatus status) { connect(client, &AbstractClient::statusChanged, this, &DeckSyncManager::onClientStatusChanged);
if (status == StatusDisconnected) { connect(client, &AbstractClient::userInfoChanged, this, &DeckSyncManager::onUserInfoChanged);
}
void DeckSyncManager::onClientStatusChanged(ClientStatus status)
{
if (status != StatusDisconnected) {
return;
}
offline = true; offline = true;
debounceTimer->stop(); debounceTimer->stop();
// A run cannot survive the session it was started on: the in-flight // A run cannot survive the session it was started on: the in-flight
@ -121,12 +128,12 @@ DeckSyncManager::DeckSyncManager(AbstractClient *_client, ColorIdentityProvider
failSync(tr("Disconnected.")); failSync(tr("Disconnected."));
} }
} }
});
connect(client, &AbstractClient::userInfoChanged, this, [this](const ServerInfo_User &userInfo) { void DeckSyncManager::onUserInfoChanged(const ServerInfo_User &userInfo)
{
offline = false; offline = false;
serverUsername = QString::fromStdString(userInfo.name()); serverUsername = QString::fromStdString(userInfo.name());
autoSyncSoon(); autoSyncSoon();
});
} }
void DeckSyncManager::setServerIdentity(const QString &host, int port, const QString &username) void DeckSyncManager::setServerIdentity(const QString &host, int port, const QString &username)

View file

@ -17,15 +17,16 @@
#include <QString> #include <QString>
#include <QVariant> #include <QVariant>
#include <functional> #include <functional>
#include <libcockatrice/network/client/abstract/abstract_client.h>
#include <libcockatrice/settings/deck_sync_settings.h> #include <libcockatrice/settings/deck_sync_settings.h>
class AbstractClient;
class CommandContainer; class CommandContainer;
class DeckList; class DeckList;
class QFileSystemWatcher; class QFileSystemWatcher;
class QTimer; class QTimer;
class Response; class Response;
class ServerInfo_DeckStorage_Folder; class ServerInfo_DeckStorage_Folder;
class ServerInfo_User;
/** /**
* @class DeckSyncManager * @class DeckSyncManager
@ -169,6 +170,8 @@ private:
[[nodiscard]] bool canAutoRun() const; [[nodiscard]] bool canAutoRun() const;
void onDebounceTimeout(); void onDebounceTimeout();
void onWatchedPathChanged(const QString &path); void onWatchedPathChanged(const QString &path);
void onClientStatusChanged(ClientStatus status);
void onUserInfoChanged(const ServerInfo_User &userInfo);
void refreshWatcher(); void refreshWatcher();
void refreshInterval(); void refreshInterval();
[[nodiscard]] DeckSyncProfile buildProfile() const; [[nodiscard]] DeckSyncProfile buildProfile() const;