Files
amnezia-client/client/ui/controllers/connectionUiController.h
T
vkamn 06372c8fd7 refactor: remove serverConfig struct (#2595)
* refactor: remove serverConfig struct

* refactor: add warnings for api v1 configs

* refactor: moved the server type definition to a separate namespace

* refactor: simplified gateway stacks

* fix: fixed server description

* fix: fixed postAsync reply usage

* fix: fixed validateConfig call

* fix: fixed server name in notifications

* fix: fixed initPrepareConfigHandler for lagacy configs
2026-05-15 12:33:36 +08:00

67 lines
1.8 KiB
C++

#ifndef CONNECTIONUICONTROLLER_H
#define CONNECTIONUICONTROLLER_H
#include <QObject>
#include "core/controllers/connectionController.h"
#include "core/utils/errorCodes.h"
#include "core/utils/routeModes.h"
#include "core/utils/commonStructs.h"
#include "core/protocols/vpnProtocol.h"
#include "core/controllers/serversController.h"
class ConnectionUiController : public QObject
{
Q_OBJECT
public:
Q_PROPERTY(bool isConnected READ isConnected NOTIFY connectionStateChanged)
Q_PROPERTY(bool isConnectionInProgress READ isConnectionInProgress NOTIFY connectionStateChanged)
Q_PROPERTY(QString connectionStateText READ connectionStateText NOTIFY connectionStateChanged)
explicit ConnectionUiController(ConnectionController* connectionController,
ServersController* serversController,
QObject *parent = nullptr);
~ConnectionUiController() = default;
bool isConnected() const;
bool isConnectionInProgress() const;
QString connectionStateText() const;
public slots:
void toggleConnection();
void openConnection();
void closeConnection();
ErrorCode getLastConnectionError();
void onConnectionStateChanged(Vpn::ConnectionState state);
void onTranslationsUpdated();
signals:
void connectionStateChanged();
void connectionErrorOccurred(ErrorCode errorCode);
void reconnectWithUpdatedContainer(const QString &message);
void connectButtonClicked();
void preparingConfig();
void prepareConfig();
private:
Vpn::ConnectionState getCurrentConnectionState();
ConnectionController* m_connectionController;
ServersController* m_serversController;
bool m_isConnected = false;
bool m_isConnectionInProgress = false;
QString m_connectionStateText = tr("Connect");
Vpn::ConnectionState m_state;
};
#endif