mirror of
https://github.com/amnezia-vpn/DefaultVPN.git
synced 2026-05-17 08:36:37 +03:00
added logic to the connect to vpn button
This commit is contained in:
@@ -11,13 +11,18 @@ ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &s
|
||||
|
||||
bool ConnectionController::onConnectionButtonClicked()
|
||||
{
|
||||
if (!isConnected) {
|
||||
if (!isConnected()) {
|
||||
openVpnConnection();
|
||||
} else {
|
||||
closeVpnConnection();
|
||||
}
|
||||
}
|
||||
|
||||
bool ConnectionController::isConnected()
|
||||
{
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
bool ConnectionController::openVpnConnection()
|
||||
{
|
||||
int serverIndex = m_serversModel->getDefaultServerIndex();
|
||||
@@ -33,7 +38,7 @@ bool ConnectionController::openVpnConnection()
|
||||
//todo error handling
|
||||
qApp->processEvents();
|
||||
emit connectToVpn(serverIndex, credentials, container, containerConfig);
|
||||
isConnected = true;
|
||||
m_isConnected = true;
|
||||
|
||||
|
||||
// int serverIndex = m_settings->defaultServerIndex();
|
||||
@@ -67,5 +72,6 @@ bool ConnectionController::openVpnConnection()
|
||||
bool ConnectionController::closeVpnConnection()
|
||||
{
|
||||
emit disconnectFromVpn();
|
||||
m_isConnected = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user