added disconnection from vpn when closing application for desktop
- many small ui fixes
This commit is contained in:
parent
14fa0b4fd3
commit
e157160337
24 changed files with 121 additions and 64 deletions
|
|
@ -17,6 +17,23 @@ ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &s
|
|||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
ConnectionController::~ConnectionController()
|
||||
{
|
||||
// todo use ConnectionController instead of using m_vpnConnection directly
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (m_vpnConnection->connectionState() != Vpn::ConnectionState::Disconnected) {
|
||||
m_vpnConnection->disconnectFromVpn();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
QThread::msleep(100);
|
||||
if (m_vpnConnection->isDisconnected()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ConnectionController::openConnection()
|
||||
{
|
||||
int serverIndex = m_serversModel->getDefaultServerIndex();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ public:
|
|||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const QSharedPointer<VpnConnection> &vpnConnection, QObject *parent = nullptr);
|
||||
|
||||
~ConnectionController();
|
||||
|
||||
bool isConnected() const;
|
||||
bool isConnectionInProgress() const;
|
||||
QString connectionStateText() const;
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ void InstallController::installContainer(DockerContainer container, QJsonObject
|
|||
"All installed containers have been added to the application");
|
||||
}
|
||||
|
||||
emit installContainerFinished(finishMessage);
|
||||
emit installContainerFinished(finishMessage, ContainerProps::containerService(container) == ServiceType::Other);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public slots:
|
|||
void setEncryptedPassphrase(QString passphrase);
|
||||
|
||||
signals:
|
||||
void installContainerFinished(const QString &finishMessage);
|
||||
void installContainerFinished(const QString &finishMessage, bool isServiceInstall);
|
||||
void installServerFinished(const QString &finishMessage);
|
||||
|
||||
void updateContainerFinished();
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ signals:
|
|||
void goToPageHome();
|
||||
void goToPageSettings();
|
||||
void goToPageViewConfig();
|
||||
void goToPageSettingsServerServices();
|
||||
|
||||
void closePage();
|
||||
|
||||
void restorePageHomeState(bool isContainerInstalled = false);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,13 @@
|
|||
|
||||
SettingsController::SettingsController(const QSharedPointer<ServersModel> &serversModel,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const QSharedPointer<LanguageModel> &languageModel,
|
||||
const std::shared_ptr<Settings> &settings, QObject *parent)
|
||||
: QObject(parent), m_serversModel(serversModel), m_containersModel(containersModel), m_settings(settings)
|
||||
: QObject(parent),
|
||||
m_serversModel(serversModel),
|
||||
m_containersModel(containersModel),
|
||||
m_languageModel(languageModel),
|
||||
m_settings(settings)
|
||||
{
|
||||
m_appVersion = QString("%1: %2 (%3)").arg(tr("Software version"), QString(APP_MAJOR_VERSION), __DATE__);
|
||||
}
|
||||
|
|
@ -95,6 +100,8 @@ void SettingsController::restoreAppConfig()
|
|||
bool ok = m_settings->restoreAppConfig(data);
|
||||
if (ok) {
|
||||
m_serversModel->resetModel();
|
||||
m_languageModel->changeLanguage(
|
||||
static_cast<LanguageSettings::AvailableLanguageEnum>(m_languageModel->getCurrentLanguageIndex()));
|
||||
emit restoreBackupFinished();
|
||||
} else {
|
||||
emit changeSettingsErrorOccurred(tr("Backup file is corrupted"));
|
||||
|
|
@ -110,6 +117,15 @@ void SettingsController::clearSettings()
|
|||
{
|
||||
m_settings->clearSettings();
|
||||
m_serversModel->resetModel();
|
||||
m_languageModel->changeLanguage(
|
||||
static_cast<LanguageSettings::AvailableLanguageEnum>(m_languageModel->getCurrentLanguageIndex()));
|
||||
emit changeSettingsFinished(tr("All settings have been reset to default values"));
|
||||
}
|
||||
|
||||
void SettingsController::clearCachedProfiles()
|
||||
{
|
||||
m_containersModel->clearCachedProfiles();
|
||||
emit changeSettingsFinished(tr("Cached profiles cleared"));
|
||||
}
|
||||
|
||||
bool SettingsController::isAutoConnectEnabled()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <QObject>
|
||||
|
||||
#include "ui/models/containers_model.h"
|
||||
#include "ui/models/languageModel.h"
|
||||
#include "ui/models/servers_model.h"
|
||||
|
||||
class SettingsController : public QObject
|
||||
|
|
@ -12,6 +13,7 @@ class SettingsController : public QObject
|
|||
public:
|
||||
explicit SettingsController(const QSharedPointer<ServersModel> &serversModel,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const QSharedPointer<LanguageModel> &languageModel,
|
||||
const std::shared_ptr<Settings> &settings, QObject *parent = nullptr);
|
||||
|
||||
Q_PROPERTY(QString primaryDns READ getPrimaryDns WRITE setPrimaryDns NOTIFY primaryDnsChanged)
|
||||
|
|
@ -41,6 +43,7 @@ public slots:
|
|||
QString getAppVersion();
|
||||
|
||||
void clearSettings();
|
||||
void clearCachedProfiles();
|
||||
|
||||
bool isAutoConnectEnabled();
|
||||
void toggleAutoConnect(bool enable);
|
||||
|
|
@ -51,11 +54,13 @@ signals:
|
|||
void loggingStateChanged();
|
||||
|
||||
void restoreBackupFinished();
|
||||
void changeSettingsFinished(const QString &finishedMessage);
|
||||
void changeSettingsErrorOccurred(const QString &errorMessage);
|
||||
|
||||
private:
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
QSharedPointer<ContainersModel> m_containersModel;
|
||||
QSharedPointer<LanguageModel> m_languageModel;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
||||
QString m_appVersion;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue