[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 d1d4c70999
commit 80ca738541
2 changed files with 30 additions and 20 deletions

View file

@ -140,25 +140,32 @@ 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);
offline = true; }
debounceTimer->stop();
// A run cannot survive the session it was started on: the in-flight void DeckSyncManager::onClientStatusChanged(ClientStatus status)
// command comes back RespNotConnected, the remaining queue would be {
// sent on a dead client, and a re-login as another account would if (status != StatusDisconnected) {
// receive this profile's uploads and deletes. return;
if (syncing) { }
activeConflict = ActiveConflict(); offline = true;
failSync(tr("Disconnected.")); debounceTimer->stop();
} // A run cannot survive the session it was started on: the in-flight
} // command comes back RespNotConnected, the remaining queue would be
}); // sent on a dead client, and a re-login as another account would
connect(client, &AbstractClient::userInfoChanged, this, [this](const ServerInfo_User &userInfo) { // receive this profile's uploads and deletes.
offline = false; if (syncing) {
serverUsername = QString::fromStdString(userInfo.name()); activeConflict = ActiveConflict();
autoSyncSoon(); failSync(tr("Disconnected."));
}); }
}
void DeckSyncManager::onUserInfoChanged(const ServerInfo_User &userInfo)
{
offline = false;
serverUsername = QString::fromStdString(userInfo.name());
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
@ -175,6 +176,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;