From eda24765e70e4561b470bd2a8352be6010687a55 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Wed, 19 Feb 2025 20:27:15 +0700 Subject: [PATCH] feature: added error messages handler --- client/core/controllers/coreController.cpp | 22 +++++++++++-------- client/core/controllers/coreController.h | 3 ++- .../PageSettingsApiAvailableCountries.qml | 1 + client/ui/qml/Pages2/PageStart.qml | 7 ------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/client/core/controllers/coreController.cpp b/client/core/controllers/coreController.cpp index a077d809..3d71ce80 100644 --- a/client/core/controllers/coreController.cpp +++ b/client/core/controllers/coreController.cpp @@ -196,10 +196,11 @@ void CoreController::initAppleController() void CoreController::initSignalHandlers() { + initErrorMessagesHandler(); + initApiCountryModelUpdateHandler(); initContainerModelUpdateHandler(); initAdminConfigRevokedHandler(); - initConnectionErrorOccurredHandler(); initPassphraseRequestHandler(); initTranslationsUpdatedHandler(); initAutoConnectHandler(); @@ -244,6 +245,17 @@ void CoreController::updateTranslator(const QLocale &locale) emit translationsUpdated(); } +void CoreController::initErrorMessagesHandler() +{ + connect(m_connectionController.get(), &ConnectionController::connectionErrorOccurred, this, [this](ErrorCode errorCode) { + emit m_pageController->showErrorMessage(errorCode); + emit m_vpnConnection->connectionStateChanged(Vpn::ConnectionState::Disconnected); + }); + + connect(m_apiConfigsController.get(), &ApiConfigsController::errorOccurred, m_pageController.get(), + qOverload(&PageController::showErrorMessage)); +} + void CoreController::setQmlRoot() { m_systemController->setQmlRoot(m_engine->rootObjects().value(0)); @@ -274,14 +286,6 @@ void CoreController::initAdminConfigRevokedHandler() &ServersModel::clearCachedProfile); } -void CoreController::initConnectionErrorOccurredHandler() -{ - connect(m_connectionController.get(), &ConnectionController::connectionErrorOccurred, this, [this](ErrorCode errorCode) { - emit m_pageController->showErrorMessage(errorCode); - emit m_vpnConnection->connectionStateChanged(Vpn::ConnectionState::Disconnected); - }); -} - void CoreController::initPassphraseRequestHandler() { connect(m_installController.get(), &InstallController::passphraseRequestStarted, m_pageController.get(), diff --git a/client/core/controllers/coreController.h b/client/core/controllers/coreController.h index 1b725825..029044c4 100644 --- a/client/core/controllers/coreController.h +++ b/client/core/controllers/coreController.h @@ -69,10 +69,11 @@ private: void updateTranslator(const QLocale &locale); + void initErrorMessagesHandler(); + void initApiCountryModelUpdateHandler(); void initContainerModelUpdateHandler(); void initAdminConfigRevokedHandler(); - void initConnectionErrorOccurredHandler(); void initPassphraseRequestHandler(); void initTranslationsUpdatedHandler(); void initAutoConnectHandler(); diff --git a/client/ui/qml/Pages2/PageSettingsApiAvailableCountries.qml b/client/ui/qml/Pages2/PageSettingsApiAvailableCountries.qml index 353547ef..dfbc70b4 100644 --- a/client/ui/qml/Pages2/PageSettingsApiAvailableCountries.qml +++ b/client/ui/qml/Pages2/PageSettingsApiAvailableCountries.qml @@ -139,6 +139,7 @@ PageType { if (!ApiConfigsController.updateServiceFromGateway(ServersModel.defaultIndex, countryCode, countryName)) { ApiCountryModel.currentIndex = prevIndex } + PageController.showBusyIndicator(false) } } diff --git a/client/ui/qml/Pages2/PageStart.qml b/client/ui/qml/Pages2/PageStart.qml index bf13552c..0a21497d 100644 --- a/client/ui/qml/Pages2/PageStart.qml +++ b/client/ui/qml/Pages2/PageStart.qml @@ -212,12 +212,7 @@ PageType { Connections { target: ApiConfigsController - function onErrorOccurred(error) { - PageController.showErrorMessage(error) - } - function onInstallServerFromApiFinished(message) { - PageController.showBusyIndicator(false) if (!ConnectionController.isConnected) { ServersModel.setDefaultServerIndex(ServersModel.getServersCount() - 1); ServersModel.processedIndex = ServersModel.defaultIndex @@ -228,8 +223,6 @@ PageType { } function onChangeApiCountryFinished(message) { - PageController.showBusyIndicator(false) - PageController.goToPageHome() PageController.showNotificationMessage(message) }