From 3bfd60b708c12611e87a9a612d70e704c5d728e1 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 14 Jul 2023 16:36:07 +0200 Subject: [PATCH] Copilot: Move AuthWidget update to the class itself Change-Id: Iab23566c6d74760eab732fdbad2d9eac645faaff Reviewed-by: Marcus Tillmanns --- src/plugins/copilot/authwidget.cpp | 16 ++++++++++++++-- src/plugins/copilot/copilotsettings.cpp | 16 ---------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/plugins/copilot/authwidget.cpp b/src/plugins/copilot/authwidget.cpp index 559dee30cf9..f4d9c0e0561 100644 --- a/src/plugins/copilot/authwidget.cpp +++ b/src/plugins/copilot/authwidget.cpp @@ -4,6 +4,7 @@ #include "authwidget.h" #include "copilotclient.h" +#include "copilotsettings.h" #include "copilottr.h" #include @@ -16,6 +17,7 @@ using namespace LanguageClient; using namespace Copilot::Internal; +using namespace Utils; namespace Copilot { @@ -26,7 +28,7 @@ AuthWidget::AuthWidget(QWidget *parent) m_button = new QPushButton(Tr::tr("Sign In")); m_button->setEnabled(false); - m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Small); + m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Small); m_progressIndicator->setVisible(false); m_statusLabel = new QLabel(); m_statusLabel->setVisible(false); @@ -48,6 +50,16 @@ AuthWidget::AuthWidget(QWidget *parent) else if (m_status == Status::SignedOut) signIn(); }); + + auto update = [this] { + updateClient(FilePath::fromUserInput(settings().nodeJsPath.volatileValue()), + FilePath::fromUserInput(settings().distPath.volatileValue())); + }; + + connect(settings().nodeJsPath.pathChooser(), &PathChooser::textChanged, this, update); + connect(settings().distPath.pathChooser(), &PathChooser::textChanged, this, update); + + update(); } AuthWidget::~AuthWidget() @@ -89,7 +101,7 @@ void AuthWidget::checkStatus() }); } -void AuthWidget::updateClient(const Utils::FilePath &nodeJs, const Utils::FilePath &agent) +void AuthWidget::updateClient(const FilePath &nodeJs, const FilePath &agent) { LanguageClientManager::shutdownClient(m_client); m_client = nullptr; diff --git a/src/plugins/copilot/copilotsettings.cpp b/src/plugins/copilot/copilotsettings.cpp index 089e30448aa..22c38f30e26 100644 --- a/src/plugins/copilot/copilotsettings.cpp +++ b/src/plugins/copilot/copilotsettings.cpp @@ -189,22 +189,6 @@ public: }.attachTo(this); // clang-format on - auto updateAuthWidget = [authWidget]() { - authWidget->updateClient( - FilePath::fromUserInput(settings().nodeJsPath.volatileValue()), - FilePath::fromUserInput(settings().distPath.volatileValue())); - }; - - connect(settings().nodeJsPath.pathChooser(), - &PathChooser::textChanged, - authWidget, - updateAuthWidget); - connect(settings().distPath.pathChooser(), - &PathChooser::textChanged, - authWidget, - updateAuthWidget); - updateAuthWidget(); - setOnApply([] { settings().apply(); settings().writeSettings();