diff --git a/qml.qrc b/qml.qrc index 79b1f5204ecdfd91acf4663838a7ed6192079d64..e9cc0f52780d23522ac956bf1405ca85e10668bb 100644 --- a/qml.qrc +++ b/qml.qrc @@ -126,7 +126,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> <file>src/commoncomponents/Scaffold.qml</file> <file>src/constant/JamiQmlUtils.qml</file> <file>src/wizardview/components/AccountCreationStepIndicator.qml</file> @@ -137,5 +136,6 @@ <file>src/commoncomponents/ModalPopup.qml</file> <file>src/commoncomponents/SimpleMessageDialog.qml</file> <file>src/commoncomponents/ResponsiveImage.qml</file> + <file>src/commoncomponents/PresenceIndicator.qml</file> </qresource> </RCC> diff --git a/src/mainview/components/AccountPresenceCycle.qml b/src/commoncomponents/PresenceIndicator.qml similarity index 54% rename from src/mainview/components/AccountPresenceCycle.qml rename to src/commoncomponents/PresenceIndicator.qml index 7883677e03a80c48a1da3bdf7001c96a2b4b2b0d..1bc69bb2899a61032749567911476c08488d44fb 100644 --- a/src/mainview/components/AccountPresenceCycle.qml +++ b/src/commoncomponents/PresenceIndicator.qml @@ -1,51 +1,47 @@ -/* - * 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 - - property int accountStatus: 5 - - width: 12 - height: 12 - - Rectangle { - id: presenceCycle - - anchors.centerIn: root - - width: 10 - height: 10 - - radius: 30 - color: { - if (accountStatus === Account.Status.REGISTERED) - return JamiTheme.presenceGreen - else if (accountStatus === Account.Status.TRYING) - return JamiTheme.unPresenceOrange - return JamiTheme.notificationRed - } - } - - radius: 30 - color: JamiTheme.backgroundColor -} +/* + * 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 + +// Serves as either account or contact presence indicator. +// TODO: this should be part of an avatar component at some point. +Rectangle { + id: root + + // This is set to REGISTERED for contact presence + // as status is not currently tracked for contact items. + property int status: Account.Status.REGISTERED + property int size: 12 + + width: size + height: size + radius: size * 0.5 + border { + color: JamiTheme.backgroundColor + width: 2 + } + color: { + if (status === Account.Status.REGISTERED) + return JamiTheme.presenceGreen + else if (status === Account.Status.TRYING) + return JamiTheme.unPresenceOrange + return JamiTheme.notificationRed + } +} diff --git a/src/mainview/components/AccountComboBox.qml b/src/mainview/components/AccountComboBox.qml index 75564f18576831398171188685e38d86d6519e22..53f4dff949ff20c4999a44ecab5826c242c619a4 100644 --- a/src/mainview/components/AccountComboBox.qml +++ b/src/mainview/components/AccountComboBox.qml @@ -41,7 +41,7 @@ ComboBox { function onModelReset() { userImageRoot.source = "data:image/png;base64," + accountListModel.data( accountListModel.index(0, 0), AccountListModel.Picture) - currentAccountPresenseCycle.accountStatus = + currentAccountPresenceIndicator.status = accountListModel.data(accountListModel.index(0, 0), AccountListModel.Status) textMetricsUserAliasRoot.text = accountListModel.data(accountListModel.index(0,0), AccountListModel.Alias) @@ -67,15 +67,15 @@ ComboBox { accountListModel.index(0, 0), AccountListModel.Picture) mipmap: true - AccountPresenceCycle { - id: currentAccountPresenseCycle + PresenceIndicator { + id: currentAccountPresenceIndicator anchors.right: userImageRoot.right anchors.rightMargin: -2 anchors.bottom: userImageRoot.bottom anchors.bottomMargin: -2 - accountStatus: accountListModel.data(accountListModel.index(0, 0), + status: accountListModel.data(accountListModel.index(0, 0), AccountListModel.Status) } } diff --git a/src/mainview/components/AccountComboBoxPopup.qml b/src/mainview/components/AccountComboBoxPopup.qml index 8b616b1a6f2cfd2081c5dafe9e0ee4a0f765540b..38a43c05eee9bac72293409e5527fbdb52e0b911 100644 --- a/src/mainview/components/AccountComboBoxPopup.qml +++ b/src/mainview/components/AccountComboBoxPopup.qml @@ -74,15 +74,13 @@ Popup { return "data:image/png;base64," + data } - AccountPresenceCycle { - id: accountPresenseCycle - + PresenceIndicator { anchors.right: userImage.right anchors.rightMargin: -2 anchors.bottom: userImage.bottom anchors.bottomMargin: -2 - accountStatus: Status + status: Status } } diff --git a/src/mainview/components/ConversationSmartListUserImage.qml b/src/mainview/components/ConversationSmartListUserImage.qml index 2358e165ef47d224f95c4afa99e9e9d007533814..7728161227537823f3c2e266ed93a7c287fd7ce9 100644 --- a/src/mainview/components/ConversationSmartListUserImage.qml +++ b/src/mainview/components/ConversationSmartListUserImage.qml @@ -1,4 +1,3 @@ - /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> @@ -16,10 +15,12 @@ * 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 import net.jami.Models 1.0 +import "../../commoncomponents" Image { id: userImage @@ -31,12 +32,9 @@ Image { source: "data:image/png;base64," + Picture mipmap: true - AccountPresenceCycle { - id: conversationAccountPresenseCycle - + PresenceIndicator { anchors.right: userImage.right anchors.bottom: userImage.bottom - anchors.bottomMargin: -2 visible: Presence === undefined ? false : Presence }