diff --git a/qml.qrc b/qml.qrc index 3cc709929b95234eb6bd37fe526087c7a161d1f2..b60c0929e583be83638c2b1e42433bebe41a7633 100644 --- a/qml.qrc +++ b/qml.qrc @@ -105,5 +105,6 @@ <file>src/mainview/components/SipInputPanel.qml</file> <file>src/commoncomponents/js/contextmenugenerator.js</file> <file>src/commoncomponents/BaseContextMenu.qml</file> + <file>src/mainview/components/AccountPresenceCycle.qml</file> </qresource> </RCC> diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 315e3ed7ff7a7234a10739f86717f04c8eb1c10e..48b3e1e07cafca493eac22c7ba15543fd2dfd658 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -304,7 +304,7 @@ Window { } function onAccountStatusChanged() { - accountComboBox.updateAccountListModel() + accountComboBox.resetAccountListModel() } } diff --git a/src/mainview/components/AccountComboBox.qml b/src/mainview/components/AccountComboBox.qml index 6037d436f8609bb4d1c9e6f08c067b2e21c7ad7d..0fd3fa8630bdcff020106224b99ccc8e791df3a7 100644 --- a/src/mainview/components/AccountComboBox.qml +++ b/src/mainview/components/AccountComboBox.qml @@ -1,4 +1,3 @@ - /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> @@ -16,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ + import QtQuick 2.14 import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 @@ -37,13 +37,6 @@ ComboBox { needToBackToWelcomePage() } - // Refresh every item in accountListModel. - function updateAccountListModel() { - accountListModel.dataChanged(accountListModel.index(0, 0), - accountListModel.index( - accountListModel.rowCount() - 1, 0)) - } - // Reset accountListModel. function resetAccountListModel() { accountListModel.reset() @@ -72,41 +65,24 @@ ComboBox { } mipmap: true - Rectangle { - id: presenseRect + AccountPresenceCycle { + id: currentAccountPresenseCycle anchors.right: userImageRoot.right anchors.rightMargin: -2 anchors.bottom: userImageRoot.bottom anchors.bottomMargin: -2 - width: 12 - height: 12 - - // Visible when account is registered, enum REGISTERED == 5. + // Visible when account is registered. visible: { if (currentIndex !== -1) return accountListModel.data( accountListModel.index( - accountComboBox.currentIndex, 0), 261) === 5 + accountComboBox.currentIndex, 0), 261) + === Account.Status.REGISTERED else return visible } - - Rectangle { - id: presenseCycle - - anchors.centerIn: presenseRect - - width: 10 - height: 10 - - radius: 30 - color: JamiTheme.presenceGreen - } - - radius: 30 - color: JamiTheme.backgroundColor } } diff --git a/src/mainview/components/AccountComboBoxPopup.qml b/src/mainview/components/AccountComboBoxPopup.qml index 2e3120d188b156e94e1fa52631535a85e81c43be..813cb8e775f89fa8ece613ae4d9eb1fb9db2882f 100644 --- a/src/mainview/components/AccountComboBoxPopup.qml +++ b/src/mainview/components/AccountComboBoxPopup.qml @@ -57,7 +57,6 @@ Popup { model: accountListModel implicitHeight: contentHeight delegate: ItemDelegate { - Image { id: userImage @@ -66,7 +65,7 @@ Popup { anchors.verticalCenter: parent.verticalCenter width: 30 - height: parent.height + height: 30 fillMode: Image.PreserveAspectFit mipmap: true @@ -81,6 +80,22 @@ Popup { } return "data:image/png;base64," + data } + + AccountPresenceCycle { + id: accountPresenseCycle + + anchors.right: userImage.right + anchors.rightMargin: -2 + anchors.bottom: userImage.bottom + anchors.bottomMargin: -2 + + // Visible when account is registered. + visible: { + return accountListModel.data( + accountListModel.index(index, 0), 261) + === Account.Status.REGISTERED + } + } } Text { diff --git a/src/mainview/components/AccountPresenceCycle.qml b/src/mainview/components/AccountPresenceCycle.qml new file mode 100644 index 0000000000000000000000000000000000000000..9eb4458493a38eb59a6bc6b695503654bbd797ac --- /dev/null +++ b/src/mainview/components/AccountPresenceCycle.qml @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +import QtQuick 2.14 +import QtQuick.Controls 2.14 +import net.jami.Models 1.0 + +Rectangle { + id: root + + width: 12 + height: 12 + + Rectangle { + id: presenceCycle + + anchors.centerIn: root + + width: 10 + height: 10 + + radius: 30 + color: JamiTheme.presenceGreen + } + + radius: 30 + color: JamiTheme.backgroundColor +} diff --git a/src/mainview/components/ConversationSmartListUserImage.qml b/src/mainview/components/ConversationSmartListUserImage.qml index 6f3600b23a3fb0823bf16609ed576e181f7098b2..e8034fd3d9556b3e36be63391479b4c1ca5f0ba2 100644 --- a/src/mainview/components/ConversationSmartListUserImage.qml +++ b/src/mainview/components/ConversationSmartListUserImage.qml @@ -31,33 +31,14 @@ Image { source: "data:image/png;base64," + Picture mipmap: true - Rectangle { - id: presenseRect + AccountPresenceCycle { + id: conversationAccountPresenseCycle anchors.right: userImage.right - anchors.rightMargin: -2 anchors.bottom: userImage.bottom anchors.bottomMargin: -2 - width: 14 - height: 14 - visible: Presence - - Rectangle { - id: presenseCycle - - anchors.centerIn: presenseRect - - width: 10 - height: 10 - - radius: 30 - color: JamiTheme.presenceGreen - } - - radius: 30 - color: JamiTheme.backgroundColor } Rectangle {