mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 10:03:26 -08:00
[DeckSync] Move the client signal handlers out of the constructor lambdas
This commit is contained in:
parent
cc9321b648
commit
1863764713
2 changed files with 30 additions and 20 deletions
|
|
@ -106,25 +106,32 @@ DeckSyncManager::DeckSyncManager(AbstractClient *_client, ColorIdentityProvider
|
|||
if (client == nullptr) {
|
||||
return;
|
||||
}
|
||||
connect(client, &AbstractClient::statusChanged, this, [this](ClientStatus status) {
|
||||
if (status == StatusDisconnected) {
|
||||
offline = true;
|
||||
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
|
||||
// receive this profile's uploads and deletes.
|
||||
if (syncing) {
|
||||
activeConflict = ActiveConflict();
|
||||
failSync(tr("Disconnected."));
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(client, &AbstractClient::userInfoChanged, this, [this](const ServerInfo_User &userInfo) {
|
||||
offline = false;
|
||||
serverUsername = QString::fromStdString(userInfo.name());
|
||||
autoSyncSoon();
|
||||
});
|
||||
connect(client, &AbstractClient::statusChanged, this, &DeckSyncManager::onClientStatusChanged);
|
||||
connect(client, &AbstractClient::userInfoChanged, this, &DeckSyncManager::onUserInfoChanged);
|
||||
}
|
||||
|
||||
void DeckSyncManager::onClientStatusChanged(ClientStatus status)
|
||||
{
|
||||
if (status != StatusDisconnected) {
|
||||
return;
|
||||
}
|
||||
offline = true;
|
||||
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
|
||||
// receive this profile's uploads and deletes.
|
||||
if (syncing) {
|
||||
activeConflict = ActiveConflict();
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -17,15 +17,16 @@
|
|||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <functional>
|
||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||
#include <libcockatrice/settings/deck_sync_settings.h>
|
||||
|
||||
class AbstractClient;
|
||||
class CommandContainer;
|
||||
class DeckList;
|
||||
class QFileSystemWatcher;
|
||||
class QTimer;
|
||||
class Response;
|
||||
class ServerInfo_DeckStorage_Folder;
|
||||
class ServerInfo_User;
|
||||
|
||||
/**
|
||||
* @class DeckSyncManager
|
||||
|
|
@ -169,6 +170,8 @@ private:
|
|||
[[nodiscard]] bool canAutoRun() const;
|
||||
void onDebounceTimeout();
|
||||
void onWatchedPathChanged(const QString &path);
|
||||
void onClientStatusChanged(ClientStatus status);
|
||||
void onUserInfoChanged(const ServerInfo_User &userInfo);
|
||||
void refreshWatcher();
|
||||
void refreshInterval();
|
||||
[[nodiscard]] DeckSyncProfile buildProfile() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue