mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 08:52:19 -07:00
Move impl to cpp, fix lifetime issues.
Took 11 minutes Took 2 minutes
This commit is contained in:
parent
961a973772
commit
a9077aa65b
27 changed files with 442 additions and 281 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COCKATRICE_INTENT_DISCONNECT_FROM_SERVER_H
|
||||
#define COCKATRICE_INTENT_DISCONNECT_FROM_SERVER_H
|
||||
|
||||
#include "intent.h"
|
||||
#include "remote_client.h"
|
||||
|
||||
|
|
@ -8,40 +9,18 @@ class IntentDisconnectFromServer : public Intent
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IntentDisconnectFromServer(RemoteClient *_remoteClient) : Intent(), remoteClient(_remoteClient)
|
||||
{
|
||||
}
|
||||
IntentDisconnectFromServer(RemoteClient *_remoteClient);
|
||||
|
||||
protected:
|
||||
bool checkPrecondition() const override
|
||||
{
|
||||
return remoteClient->getStatus() == ClientStatus::StatusDisconnected;
|
||||
}
|
||||
|
||||
void onPreconditionSatisfied() override
|
||||
{
|
||||
qWarning() << "Client disconnected, disconnect is finished";
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void onPreconditionNotSatisfied() override
|
||||
{
|
||||
qWarning() << "Client not disconnected, hooking up signal and disconnecting." << remoteClient->getStatus();
|
||||
connect(remoteClient, &RemoteClient::statusChanged, this, &IntentDisconnectFromServer::onStatusChanged);
|
||||
remoteClient->disconnectFromServer();
|
||||
}
|
||||
bool checkPrecondition() const override;
|
||||
void onPreconditionSatisfied() override;
|
||||
void onPreconditionNotSatisfied() override;
|
||||
|
||||
private:
|
||||
RemoteClient *remoteClient;
|
||||
|
||||
private slots:
|
||||
void onStatusChanged(ClientStatus status)
|
||||
{
|
||||
qWarning() << "Client Status changed: " << status;
|
||||
if (status == ClientStatus::StatusDisconnected) {
|
||||
qWarning() << "Client disconnected, finished";
|
||||
emit finished();
|
||||
}
|
||||
}
|
||||
void onStatusChanged(ClientStatus status);
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_INTENT_DISCONNECT_FROM_SERVER_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue