From 2dfb9ff539b4ccce729a9994c86670af3195b5a0 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Tue, 28 Sep 2021 13:45:39 +0200 Subject: [PATCH] RemoteDialog: Fix button states after adding remote As adding a remote leads to a model reset which does not trigger the selectionChanged signal, all buttons were enabled despite no remote was selected. Change-Id: I2f752fcf5f1830728d1bcf9810ca4648bd2f287b Reviewed-by: Orgad Shaneh --- src/plugins/git/remotedialog.cpp | 2 ++ src/plugins/git/remotemodel.cpp | 1 + src/plugins/git/remotemodel.h | 3 +++ 3 files changed, 6 insertions(+) diff --git a/src/plugins/git/remotedialog.cpp b/src/plugins/git/remotedialog.cpp index 6463433f377..e99572ad11f 100644 --- a/src/plugins/git/remotedialog.cpp +++ b/src/plugins/git/remotedialog.cpp @@ -145,6 +145,8 @@ RemoteDialog::RemoteDialog(QWidget *parent) : connect(m_ui->remoteView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RemoteDialog::updateButtonState); + connect(m_remoteModel, &RemoteModel::refreshed, + this, &RemoteDialog::updateButtonState); updateButtonState(); } diff --git a/src/plugins/git/remotemodel.cpp b/src/plugins/git/remotemodel.cpp index 71d49397ac3..5f8bcd3488b 100644 --- a/src/plugins/git/remotemodel.cpp +++ b/src/plugins/git/remotemodel.cpp @@ -199,6 +199,7 @@ bool RemoteModel::refresh(const FilePath &workingDirectory, QString *errorMessag m_remotes.push_back(newRemote); } endResetModel(); + emit refreshed(); return true; } diff --git a/src/plugins/git/remotemodel.h b/src/plugins/git/remotemodel.h index 1ef6b7ffc64..85ceabdafe8 100644 --- a/src/plugins/git/remotemodel.h +++ b/src/plugins/git/remotemodel.h @@ -65,6 +65,9 @@ public: Utils::FilePath workingDirectory() const; int findRemoteByName(const QString &name) const; +signals: + void refreshed(); + protected: class Remote { public: