From a5705dbd703427152d34249811cf894413670a0a Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Fri, 27 Jun 2025 15:42:13 +0400 Subject: [PATCH 1/4] fixed issue when ui was not getting update about clearing profile cache right after it --- client/ui/qml/Pages2/PageSettingsServerProtocol.qml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml index fce9b2a3..2de82531 100644 --- a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml +++ b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml @@ -24,6 +24,13 @@ PageType { ColumnLayout { id: header + Connections { + target: InstallController + function onCachedProfileCleared(message) { + ProtocolsModel.updateModel(ProtocolsModel.getConfig()) + } + } + anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right From bbb5a19700203a9512092e02a09f3fb25d374c31 Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Tue, 1 Jul 2025 16:18:43 +0400 Subject: [PATCH 2/4] fixed the problem of not clearing the profile --- client/ui/models/protocols_model.cpp | 7 +++++++ client/ui/models/protocols_model.h | 2 ++ .../ui/qml/Pages2/PageSettingsServerProtocol.qml | 14 +++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/client/ui/models/protocols_model.cpp b/client/ui/models/protocols_model.cpp index 019b2d2f..231a3fbf 100644 --- a/client/ui/models/protocols_model.cpp +++ b/client/ui/models/protocols_model.cpp @@ -68,6 +68,13 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const return QVariant(); } +void ProtocolsModel::reload() +{ + beginResetModel(); + endResetModel(); +} + + void ProtocolsModel::updateModel(const QJsonObject &content) { m_container = ContainerProps::containerFromString(content.value(config_key::container).toString()); diff --git a/client/ui/models/protocols_model.h b/client/ui/models/protocols_model.h index 5c52ee86..986390ec 100644 --- a/client/ui/models/protocols_model.h +++ b/client/ui/models/protocols_model.h @@ -26,6 +26,8 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Q_INVOKABLE void reload(); + public slots: void updateModel(const QJsonObject &content); diff --git a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml index 2de82531..8e1792db 100644 --- a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml +++ b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml @@ -24,12 +24,19 @@ PageType { ColumnLayout { id: header - Connections { + /*Connections { target: InstallController function onCachedProfileCleared(message) { - ProtocolsModel.updateModel(ProtocolsModel.getConfig()) + console.log("СИГНАЛ cachedProfileCleared СРАБОТАЛ:", message) + //ProtocolsModel.updateModel(ProtocolsModel.getConfig()) + ProtocolsModel.clear() + console.log("isClientProtocolExists =", ProtocolsModel.get(0).isClientProtocolExists) + /*PageController.goToPage(PageEnum.PageMainSettings) + Qt.callLater(function() { + PageController.goToPage(PageEnum.PageSettingsServerProtocol) + }) } - } + }*/ anchors.top: parent.top anchors.left: parent.left @@ -193,6 +200,7 @@ PageType { PageController.showBusyIndicator(true) InstallController.clearCachedProfile() + ProtocolsModel.reload() PageController.showBusyIndicator(false) } var noButtonFunction = function() { From 254e23be48a8367603b9cdb9327096fb11d48bdf Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Wed, 2 Jul 2025 12:18:33 +0400 Subject: [PATCH 3/4] refactored reload function in protolocolsModel --- client/ui/models/protocols_model.cpp | 16 +++++++++++++++- .../ui/qml/Pages2/PageSettingsServerProtocol.qml | 14 -------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/ui/models/protocols_model.cpp b/client/ui/models/protocols_model.cpp index 231a3fbf..9c29d336 100644 --- a/client/ui/models/protocols_model.cpp +++ b/client/ui/models/protocols_model.cpp @@ -71,10 +71,24 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const void ProtocolsModel::reload() { beginResetModel(); + + QJsonObject config = getConfig(); + + QStringList keys = m_content.keys(); + if (keys.size() == 1) { + QString protocolKey = keys.first(); + + if (config.contains(protocolKey)) { + QJsonObject protocolConfig = config.value(protocolKey).toObject(); + protocolConfig.remove(config_key::last_config); + config[protocolKey] = protocolConfig; + } + } + + updateModel(config); endResetModel(); } - void ProtocolsModel::updateModel(const QJsonObject &content) { m_container = ContainerProps::containerFromString(content.value(config_key::container).toString()); diff --git a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml index 8e1792db..a5f6f7dc 100644 --- a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml +++ b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml @@ -24,20 +24,6 @@ PageType { ColumnLayout { id: header - /*Connections { - target: InstallController - function onCachedProfileCleared(message) { - console.log("СИГНАЛ cachedProfileCleared СРАБОТАЛ:", message) - //ProtocolsModel.updateModel(ProtocolsModel.getConfig()) - ProtocolsModel.clear() - console.log("isClientProtocolExists =", ProtocolsModel.get(0).isClientProtocolExists) - /*PageController.goToPage(PageEnum.PageMainSettings) - Qt.callLater(function() { - PageController.goToPage(PageEnum.PageSettingsServerProtocol) - }) - } - }*/ - anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right From 071bebfc11db7b43bbd79ac9835fca59c2cc4009 Mon Sep 17 00:00:00 2001 From: Mitternacht822 Date: Thu, 3 Jul 2025 21:06:36 +0400 Subject: [PATCH 4/4] refactored the issue with signal connect in corecontroller --- client/core/controllers/coreController.cpp | 3 +++ client/ui/controllers/installController.cpp | 2 ++ client/ui/controllers/installController.h | 2 ++ client/ui/models/protocols_model.cpp | 21 ------------------- client/ui/models/protocols_model.h | 2 -- .../qml/Pages2/PageSettingsServerProtocol.qml | 1 - 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/client/core/controllers/coreController.cpp b/client/core/controllers/coreController.cpp index 0e72ef1a..04ef8d46 100644 --- a/client/core/controllers/coreController.cpp +++ b/client/core/controllers/coreController.cpp @@ -120,6 +120,9 @@ void CoreController::initControllers() connect(m_installController.get(), &InstallController::currentContainerUpdated, m_connectionController.get(), &ConnectionController::onCurrentContainerUpdated); // TODO remove this + connect(m_installController.get(), &InstallController::profileCleared, + m_protocolsModel.get(), &ProtocolsModel::updateModel); + m_importController.reset(new ImportController(m_serversModel, m_containersModel, m_settings)); m_engine->rootContext()->setContextProperty("ImportController", m_importController.get()); diff --git a/client/ui/controllers/installController.cpp b/client/ui/controllers/installController.cpp index eab8979a..3cfc327d 100755 --- a/client/ui/controllers/installController.cpp +++ b/client/ui/controllers/installController.cpp @@ -669,6 +669,8 @@ void InstallController::clearCachedProfile(QSharedPointer serv m_clientManagementModel->revokeClient(containerConfig, container, serverCredentials, serverIndex, serverController); emit cachedProfileCleared(tr("%1 cached profile cleared").arg(ContainerProps::containerHumanNames().value(container))); + QJsonObject updatedConfig = m_settings->containerConfig(serverIndex, container); + emit profileCleared(updatedConfig); } QRegularExpression InstallController::ipAddressPortRegExp() diff --git a/client/ui/controllers/installController.h b/client/ui/controllers/installController.h index 8e42b5b2..d18ba946 100644 --- a/client/ui/controllers/installController.h +++ b/client/ui/controllers/installController.h @@ -83,6 +83,8 @@ signals: void noInstalledContainers(); + void profileCleared(const QJsonObject &config); + private: void installServer(const DockerContainer container, const QMap &installedContainers, const ServerCredentials &serverCredentials, const QSharedPointer &serverController, diff --git a/client/ui/models/protocols_model.cpp b/client/ui/models/protocols_model.cpp index 9c29d336..019b2d2f 100644 --- a/client/ui/models/protocols_model.cpp +++ b/client/ui/models/protocols_model.cpp @@ -68,27 +68,6 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const return QVariant(); } -void ProtocolsModel::reload() -{ - beginResetModel(); - - QJsonObject config = getConfig(); - - QStringList keys = m_content.keys(); - if (keys.size() == 1) { - QString protocolKey = keys.first(); - - if (config.contains(protocolKey)) { - QJsonObject protocolConfig = config.value(protocolKey).toObject(); - protocolConfig.remove(config_key::last_config); - config[protocolKey] = protocolConfig; - } - } - - updateModel(config); - endResetModel(); -} - void ProtocolsModel::updateModel(const QJsonObject &content) { m_container = ContainerProps::containerFromString(content.value(config_key::container).toString()); diff --git a/client/ui/models/protocols_model.h b/client/ui/models/protocols_model.h index 986390ec..5c52ee86 100644 --- a/client/ui/models/protocols_model.h +++ b/client/ui/models/protocols_model.h @@ -26,8 +26,6 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - Q_INVOKABLE void reload(); - public slots: void updateModel(const QJsonObject &content); diff --git a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml index a5f6f7dc..fce9b2a3 100644 --- a/client/ui/qml/Pages2/PageSettingsServerProtocol.qml +++ b/client/ui/qml/Pages2/PageSettingsServerProtocol.qml @@ -186,7 +186,6 @@ PageType { PageController.showBusyIndicator(true) InstallController.clearCachedProfile() - ProtocolsModel.reload() PageController.showBusyIndicator(false) } var noButtonFunction = function() {