Skip to content
Snippets Groups Projects
Commit 69f5dfcd authored by Albert  Babí Oller's avatar Albert Babí Oller Committed by Andreas Traczyk
Browse files

mainview: fix account selection

- avoid duplicate call of LRC's setTopAccount()
- welcome view displays always the first account on the list, so passing the index is not necessary
- conversationsadapter and messagesadapter no longer listen to currentAccountChanged signal since there is a specific function for the setup

Gitlab: #12
Change-Id: Iac932d2596bf59c7528d83be799342ccefeea6b0
parent adc78a80
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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();
/*
......
......@@ -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();
}
......
......@@ -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);
......
......@@ -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: {
......
......@@ -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
......
......@@ -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() {
......
......@@ -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()
}
}
......@@ -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
......
......@@ -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)
......
......@@ -91,7 +91,6 @@ public slots:
void slotUpdateDraft(const QString &content);
void slotMessagesCleared();
void slotMessagesLoaded();
void slotAccountChanged();
private:
void initQmlObject() override final;
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment