From 87c754364415ac12b981a92ed2a5323d4ddb02df Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Thu, 8 Oct 2020 14:56:16 -0400 Subject: [PATCH] presence: cosmetic changes / simplify component Gitlab: #138 Change-Id: I552c26583dda87c71491a87655a91273c59d851f --- qml.qrc | 2 +- .../PresenceIndicator.qml} | 98 +++++++++---------- src/mainview/components/AccountComboBox.qml | 8 +- .../components/AccountComboBoxPopup.qml | 6 +- .../ConversationSmartListUserImage.qml | 8 +- 5 files changed, 57 insertions(+), 65 deletions(-) rename src/{mainview/components/AccountPresenceCycle.qml => commoncomponents/PresenceIndicator.qml} (54%) diff --git a/qml.qrc b/qml.qrc index 79b1f5204..e9cc0f527 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 7883677e0..1bc69bb28 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 75564f185..53f4dff94 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 8b616b1a6..38a43c05e 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 2358e165e..772816122 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 } -- GitLab