From 371da8f1e6eb2e06dea66469b3a83a6e9a2a8360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Fri, 17 Aug 2018 16:31:07 -0400 Subject: [PATCH] mainwindow: connect to updateProfile signal for the account combobox This is needed to update the combobox when the user change the avatar or the alias. Change-Id: I3c836cfb0929e608b240728f6d042c5c81ef5d07 Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com> --- src/ringmainwindow.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ringmainwindow.cpp b/src/ringmainwindow.cpp index 91643379..7722a833 100644 --- a/src/ringmainwindow.cpp +++ b/src/ringmainwindow.cpp @@ -329,6 +329,7 @@ public: QMetaObject::Connection newConversationConnection_; QMetaObject::Connection conversationRemovedConnection_; QMetaObject::Connection accountStatusChangedConnection_; + QMetaObject::Connection profileUpdatedConnection_; private: CppImpl() = delete; @@ -360,6 +361,7 @@ private: void slotNewInteraction(const std::string& accountId, const std::string& conversation, uint64_t, const lrc::api::interaction::Info& interaction); void slotCloseInteraction(const std::string& accountId, const std::string& conversation, uint64_t); + void slotProfileUpdated(const std::string& id); }; inline namespace gtk_callbacks @@ -944,6 +946,11 @@ CppImpl::init() accountStatusChangedConnection_ = QObject::connect(&lrc_->getAccountModel(), &lrc::api::NewAccountModel::accountStatusChanged, [this](const std::string& id){ slotAccountStatusChanged(id); }); + profileUpdatedConnection_ = QObject::connect(&lrc_->getAccountModel(), + &lrc::api::NewAccountModel::profileUpdated, + [this](const std::string& id){ + slotProfileUpdated(id); + }); newAccountConnection_ = QObject::connect(&lrc_->getAccountModel(), &lrc::api::NewAccountModel::accountAdded, [this](const std::string& id){ slotAccountAddedFromLrc(id); }); @@ -1156,6 +1163,7 @@ CppImpl::~CppImpl() QObject::disconnect(slotNewInteraction_); QObject::disconnect(slotReadInteraction_); QObject::disconnect(accountStatusChangedConnection_); + QObject::disconnect(profileUpdatedConnection_); g_clear_object(&widgets->welcome_view); g_clear_object(&widgets->webkit_chat_container); @@ -2076,6 +2084,15 @@ CppImpl::slotShowIncomingCallView(const std::string& id, lrc::api::conversation: changeView(INCOMING_CALL_VIEW_TYPE, origin); } +void +CppImpl::slotProfileUpdated(const std::string& id) +{ + auto currentIdx = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->combobox_account_selector)); + if (currentIdx == -1) + currentIdx = 0; // If no account selected, select the first account + refreshAccountSelectorWidget(currentIdx, id); +} + }} // namespace <anonymous>::details void -- GitLab