Refactoring
Ui improvements Bug fixes
This commit is contained in:
parent
3645735053
commit
441811e277
13 changed files with 773 additions and 123 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
|
|
@ -64,9 +65,13 @@ ErrorCode VpnConnection::connectToVpn(const ServerCredentials &credentials, Prot
|
|||
// TODO: Implement some behavior in case if connection not stable
|
||||
qDebug() << "Connect to VPN";
|
||||
|
||||
emit connectionStateChanged(VpnProtocol::ConnectionState::Connecting);
|
||||
qApp->processEvents();
|
||||
|
||||
if (protocol == Protocol::Any || protocol == Protocol::OpenVpn) {
|
||||
ErrorCode e = requestVpnConfig(credentials, Protocol::OpenVpn);
|
||||
if (e) {
|
||||
emit connectionStateChanged(VpnProtocol::ConnectionState::Error);
|
||||
return e;
|
||||
}
|
||||
if (m_vpnProtocol) {
|
||||
|
|
@ -76,6 +81,7 @@ ErrorCode VpnConnection::connectToVpn(const ServerCredentials &credentials, Prot
|
|||
connect(m_vpnProtocol.data(), &VpnProtocol::protocolError, this, &VpnConnection::vpnProtocolError);
|
||||
}
|
||||
else if (protocol == Protocol::ShadowSocks) {
|
||||
emit connectionStateChanged(VpnProtocol::ConnectionState::Error);
|
||||
return ErrorCode::NotImplementedError;
|
||||
}
|
||||
|
||||
|
|
@ -85,9 +91,10 @@ ErrorCode VpnConnection::connectToVpn(const ServerCredentials &credentials, Prot
|
|||
return m_vpnProtocol.data()->start();
|
||||
}
|
||||
|
||||
QString VpnConnection::bytesToText(quint64 bytes)
|
||||
QString VpnConnection::bytesPerSecToText(quint64 bytes)
|
||||
{
|
||||
return QString("%1 %2").arg(bytes / 1000000).arg(tr("Mbps"));
|
||||
double mbps = bytes * 8 / 1e6;
|
||||
return QString("%1 %2").arg(QString::number(mbps, 'f', 2)).arg(tr("Mbps")); // Mbit/s
|
||||
}
|
||||
|
||||
void VpnConnection::disconnectFromVpn()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue