diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index adb138900b0977c4e2c5a379369c3583da5e57a5..9038999e874140482435468a8f7a46158e25cca4 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -42,7 +42,7 @@ AccountAdapter::instance() void AccountAdapter::initQmlObject() { - connectAccount(LRCInstance::getCurrAccId()); + setSelectedAccount(LRCInstance::getCurrAccId()); } void @@ -50,7 +50,7 @@ AccountAdapter::accountChanged(int index) { auto accountList = LRCInstance::accountModel().getAccountList(); if (accountList.size() > index) - setSelectedAccount(accountList.at(index), index); + setSelectedAccount(accountList.at(index)); } void @@ -331,22 +331,21 @@ AccountAdapter::passwordSetStatusMessageBox(bool success, QString title, QString } void -AccountAdapter::setSelectedAccount(const QString &accountId, int index) +AccountAdapter::setSelectedAccount(const QString &accountId) { LRCInstance::setSelectedAccountId(accountId); - backToWelcomePage(index); + backToWelcomePage(); - QMetaObject::invokeMethod(qmlObj_, "updateSmartList", Q_ARG(QVariant, accountId)); connectAccount(accountId); emit accountSignalsReconnect(accountId); } void -AccountAdapter::backToWelcomePage(int index) +AccountAdapter::backToWelcomePage() { deselectConversation(); - QMetaObject::invokeMethod(qmlObj_, "backToWelcomePage", Q_ARG(QVariant, index)); + QMetaObject::invokeMethod(qmlObj_, "backToWelcomePage"); } void diff --git a/src/accountadapter.h b/src/accountadapter.h index 234489575ed69aab4b14b27348a9098568bc0d1f..9671aed6c270e2c29b9ba1eb42638688be580c6e 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -98,8 +98,8 @@ signals: private: void initQmlObject() override final; - void setSelectedAccount(const QString &accountId, int index); - void backToWelcomePage(int index); + void setSelectedAccount(const QString &accountId); + void backToWelcomePage(); void deselectConversation(); /* diff --git a/src/conversationsadapter.cpp b/src/conversationsadapter.cpp index 04abc04766b12cfdd9f9fb3db1e41aa12c400bfd..e077108d3054f59cf50d7013f719396c70b887c0 100644 --- a/src/conversationsadapter.cpp +++ b/src/conversationsadapter.cpp @@ -44,18 +44,6 @@ ConversationsAdapter::initQmlObject() [this](const QString &accountId, lrc::api::conversation::Info convInfo) { emit showChatView(accountId, convInfo.uid); }); - connect(&LRCInstance::instance(), - &LRCInstance::currentAccountChanged, - this, - &ConversationsAdapter::slotAccountChanged); - - connectConversationModel(); -} - -void -ConversationsAdapter::slotAccountChanged() -{ - connectConversationModel(); } void @@ -139,7 +127,6 @@ ConversationsAdapter::accountChangedSetUp(const QString &accountId) auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountId); currentTypeFilter_ = accountInfo.profileInfo.type; LRCInstance::getCurrentConversationModel()->setFilter(accountInfo.profileInfo.type); - updateConversationsFilterWidget(); connectConversationModel(); } diff --git a/src/conversationsadapter.h b/src/conversationsadapter.h index e4c2aa6a8d4f0ea1a8aa234ebbc0f1dd85524f09..85960cdcc66301a73a04dd733511c6fd76dc3d5a 100644 --- a/src/conversationsadapter.h +++ b/src/conversationsadapter.h @@ -48,9 +48,6 @@ signals: void showConversationTabs(bool visible); void showSearchStatus(const QString &status); -public slots: - void slotAccountChanged(); - private: void initQmlObject() override; void setConversationFilter(lrc::api::profile::Type filter); diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index c9511ce1f6cecf2656269fda248a05f21d1f26d7..d7a0a89ee1ed9ab83f0ab900f45a6574957f28a2 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -301,8 +301,8 @@ Window { function onAccountSignalsReconnect(accountId) { CallAdapter.connectCallModel(accountId) - ConversationsAdapter.accountChangedSetUp(accountId) mainViewWindowSidePanel.accountSignalsReconnect(accountId) + ConversationsAdapter.accountChangedSetUp(accountId) } function onUpdateConversationForAddedContact() { @@ -319,8 +319,7 @@ Window { } onAccountChanged: { - ClientWrapper.accountAdaptor.accountChanged(index) - mainViewWindowSidePanel.refreshAccountComboBox(0) + mainViewWindowSidePanel.refreshAccountComboBox(index) settingsView.slotAccountListChanged() settingsView.setSelected(settingsView.selectedMenu, true) @@ -341,7 +340,7 @@ Window { onNeedToBackToWelcomePage: { if (!inSettingsView) - mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage(index) + mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage() } onNewAccountButtonClicked: { @@ -515,15 +514,15 @@ Window { */ if (!inSettingsView) { mainViewStack.pop(welcomePage) - welcomePage.currentAccountIndex = index - qrDialog.currentAccountIndex = index + welcomePage.updateWelcomePage() + qrDialog.updateQrDialog() } } onConversationSmartListViewNeedToShowWelcomePage: { mainViewStack.pop(welcomePage) - welcomePage.currentAccountIndex = 0 - qrDialog.currentAccountIndex = 0 + welcomePage.updateWelcomePage() + qrDialog.updateQrDialog() } onAccountSignalsReconnect: { diff --git a/src/mainview/components/AccountComboBox.qml b/src/mainview/components/AccountComboBox.qml index 5c587084714fbb797c6509a64371757dea79878a..dce72c8cabe60df8c6ea3f38125ae42a208083ce 100644 --- a/src/mainview/components/AccountComboBox.qml +++ b/src/mainview/components/AccountComboBox.qml @@ -27,35 +27,29 @@ ComboBox { id: accountComboBox signal accountChanged(int index) - signal needToBackToWelcomePage(int index) + signal needToBackToWelcomePage() signal needToUpdateSmartList(string accountId) signal newAccountButtonClicked signal settingBtnClicked currentIndex: 0 - function backToWelcomePage(index) { - accountComboBox.needToBackToWelcomePage(index) + function backToWelcomePage() { + needToBackToWelcomePage() } function updateSmartList(accountId) { - accountComboBox.needToUpdateSmartList(accountId) + needToUpdateSmartList(accountId) } - - /* - * Refresh every item in accountListModel. - */ + // Refresh every item in accountListModel. function updateAccountListModel() { accountListModel.dataChanged(accountListModel.index(0, 0), accountListModel.index( accountListModel.rowCount() - 1, 0)) } - - /* - * Reset accountListModel. - */ + // Reset accountListModel. function resetAccountListModel() { accountListModel.reset() } @@ -72,10 +66,7 @@ ComboBox { fillMode: Image.PreserveAspectFit - - /* - * Base 64 format - */ + // Base 64 format source: { if (currentIndex !== -1) return "data:image/png;base64," + accountListModel.data( @@ -97,10 +88,7 @@ ComboBox { width: 12 height: 12 - - /* - * Visible when account is registered, enum REGISTERED == 5. - */ + // Visible when account is registered, enum REGISTERED == 5. visible: { if (currentIndex !== -1) return accountListModel.data( @@ -153,7 +141,6 @@ ComboBox { source: "qrc:/images/icons/round-arrow_drop_down-24px.svg" } - Text { id: textUsernameRoot @@ -174,10 +161,7 @@ ComboBox { elideWidth: accountComboBox.width - userImageRoot.width - settingsButton.width - arrowDropDown.width - qrCodeGenerateButton.width - 55 - - /* - * Role::Alias - */ + // Role::Alias text: { if (currentIndex !== -1) return accountListModel.data(accountListModel.index( @@ -197,9 +181,8 @@ ComboBox { - qrCodeGenerateButton.width - 55 - /* - * Role::Username - */ + + // Role::Username text: { if (currentIndex !== -1) return accountListModel.data(accountListModel.index( @@ -210,8 +193,6 @@ ComboBox { } } - - HoverableButton { id: qrCodeGenerateButton @@ -308,9 +289,8 @@ ComboBox { rootItemBackground.color = JamiTheme.backgroundColor } onMouseXChanged: { - /* - * Manually making button hover. - */ + + // Manually making button hover. qrCodeGenerateButton.backgroundColor = (isMouseOnButton(mouse, qrCodeGenerateButton)) ? JamiTheme.hoverColor : "white" @@ -334,10 +314,7 @@ ComboBox { indicator: null - - /* - * Overwrite the combo box pop up to add footer (for add accounts). - */ + // Overwrite the combo box pop up to add footer (for add accounts). popup: AccountComboBoxPopup { id: comboBoxPopup diff --git a/src/mainview/components/SidePanel.qml b/src/mainview/components/SidePanel.qml index c37bcb3f7909e69a114e0735c3ef43979af0f31c..736fecb7e1dd4328cbc65a77f43d389bdceeba4e 100644 --- a/src/mainview/components/SidePanel.qml +++ b/src/mainview/components/SidePanel.qml @@ -32,7 +32,7 @@ Rectangle { property int totalUnreadMessagesCount: 0 signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr) - signal accountComboBoxNeedToShowWelcomePage(int index) + signal accountComboBoxNeedToShowWelcomePage() signal conversationSmartListViewNeedToShowWelcomePage signal accountSignalsReconnect(string accountId) signal needToUpdateConversationForAddedContact @@ -87,8 +87,6 @@ Rectangle { } function refreshAccountComboBox(index = -1) { - accountComboBox.resetAccountListModel() - /* * To make sure that the ui is refreshed for accountComboBox. @@ -105,6 +103,7 @@ Rectangle { accountComboBox.currentIndex = currentIndex accountComboBox.update() accountChangedUIReset() + accountComboBox.resetAccountListModel() } function deselectConversationSmartList() { diff --git a/src/mainview/components/WelcomePage.qml b/src/mainview/components/WelcomePage.qml index 3563eeadacb72530927d677b03b73047be22b8af..ad48871743f7b1069b1689510e9e129b98505c06 100644 --- a/src/mainview/components/WelcomePage.qml +++ b/src/mainview/components/WelcomePage.qml @@ -25,11 +25,15 @@ import "../../commoncomponents" Rectangle { id: welcomeRect - - property int currentAccountIndex: 0 property int buttonPreferredSize: 30 anchors.fill: parent + function updateWelcomePage(){ + jamiShareWithFriendText.visible = accountListModel.data(accountListModel.index(0, 0), 260) === 1 + jamiRegisteredNameRect.visible = accountListModel.data(accountListModel.index(0, 0), 260) === 1 + textMetricsjamiRegisteredNameText.text = accountListModel.data(accountListModel.index(0, 0), 258) + } + Rectangle { id: welcomeRectComponentsGroup @@ -86,8 +90,9 @@ Rectangle { verticalAlignment: Text.AlignVCenter visible: accountListModel.data(accountListModel.index( - currentAccountIndex, 0), + 0, 0), 260) === 1 + text: qsTr("This is your ID.\nCopy and share it with your friends") color: JamiTheme.faddedFontColor } @@ -101,9 +106,8 @@ Rectangle { Layout.bottomMargin: 5 visible: accountListModel.data(accountListModel.index( - currentAccountIndex, 0), + 0, 0), 260) === 1 - ColumnLayout { id: jamiRegisteredNameRectColumnLayout @@ -163,4 +167,8 @@ Rectangle { bBorderwidth: 0 borderColor: JamiTheme.tabbarBorderColor } + + Component.onCompleted: { + updateWelcomePage() + } } diff --git a/src/mainview/components/WelcomePageQrDialog.qml b/src/mainview/components/WelcomePageQrDialog.qml index 45c8ff2898f05c6db13cd50d95241aaec1d300da..ccadf0f3c0779f550b705e2c7918b2b802ece922 100644 --- a/src/mainview/components/WelcomePageQrDialog.qml +++ b/src/mainview/components/WelcomePageQrDialog.qml @@ -21,22 +21,21 @@ import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import net.jami.Models 1.0 + Dialog { id: userQrImageDialog - property int currentAccountIndex: 0 + property string accountIdStr: ClientWrapper.utilsAdaptor.getCurrAccId() + function updateQrDialog() { + accountIdStr = ClientWrapper.utilsAdaptor.getCurrAccId() + } - /* - * When dialog is opened, trigger mainViewWindow overlay which is defined in overlay.model. - * (model : true is necessary) - */ + // When dialog is opened, trigger mainViewWindow overlay which is defined in overlay.model. + // (model : true is necessary) modal: true - - /* - * Content height + margin. - */ + //Content height + margin. contentHeight: userQrImage.height + 30 Image { @@ -48,7 +47,7 @@ Dialog { height: 250 fillMode: Image.PreserveAspectFit - source: "image://qrImage/account_" + currentAccountIndex + source: "image://qrImage/account_" + accountIdStr sourceSize.width: 260 sourceSize.height: 260 mipmap: true diff --git a/src/messagesadapter.cpp b/src/messagesadapter.cpp index 056286e54fd721e41a496b26d1719fbbba2f28e9..5214d0bd42fc80902f0a6f21f896d01fa5c7f16c 100644 --- a/src/messagesadapter.cpp +++ b/src/messagesadapter.cpp @@ -39,20 +39,7 @@ MessagesAdapter::MessagesAdapter(QObject *parent) MessagesAdapter::~MessagesAdapter() {} void -MessagesAdapter::initQmlObject() -{ - connect(&LRCInstance::instance(), - &LRCInstance::currentAccountChanged, - this, - &MessagesAdapter::slotAccountChanged); - connectConversationModel(); -} - -void -MessagesAdapter::slotAccountChanged() -{ - connectConversationModel(); -} +MessagesAdapter::initQmlObject() {} void MessagesAdapter::setupChatView(const QString &uid) diff --git a/src/messagesadapter.h b/src/messagesadapter.h index ed5601ab5e206b276384b6ec660c82a3f0cc1912..6b520d2bd6727aaa38b75a9bf12782d7c780be82 100644 --- a/src/messagesadapter.h +++ b/src/messagesadapter.h @@ -91,7 +91,6 @@ public slots: void slotUpdateDraft(const QString &content); void slotMessagesCleared(); void slotMessagesLoaded(); - void slotAccountChanged(); private: void initQmlObject() override final; diff --git a/src/smartlistmodel.cpp b/src/smartlistmodel.cpp index d10d8cec1a9d5da2009e758304c47481f1321899..d7783984ac59e5ef07e84d806b51aeec495d5ff1 100644 --- a/src/smartlistmodel.cpp +++ b/src/smartlistmodel.cpp @@ -65,8 +65,7 @@ SmartListModel::rowCount(const QModelIndex &parent) const } return rowCount; } - return accInfo.conversationModel->allFilteredConversations().size() - + accInfo.conversationModel->getAllSearchResults().size(); + return conversations_.size(); } return 0; }