Skip to content
Snippets Groups Projects
Commit e5a75ad7 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Sébastien Blin
Browse files

mainview: add account presence cycle to account combo box delegates

Make account presence cycle a component, and remove redundant
update function

Gitlab: #23
Change-Id: I93cb37f2886da2e8e5e41d4c97ce054497e4e399
parent ac503776
No related branches found
No related tags found
No related merge requests found
...@@ -105,5 +105,6 @@ ...@@ -105,5 +105,6 @@
<file>src/mainview/components/SipInputPanel.qml</file> <file>src/mainview/components/SipInputPanel.qml</file>
<file>src/commoncomponents/js/contextmenugenerator.js</file> <file>src/commoncomponents/js/contextmenugenerator.js</file>
<file>src/commoncomponents/BaseContextMenu.qml</file> <file>src/commoncomponents/BaseContextMenu.qml</file>
<file>src/mainview/components/AccountPresenceCycle.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -304,7 +304,7 @@ Window { ...@@ -304,7 +304,7 @@ Window {
} }
function onAccountStatusChanged() { function onAccountStatusChanged() {
accountComboBox.updateAccountListModel() accountComboBox.resetAccountListModel()
} }
} }
......
/* /*
* Copyright (C) 2020 by Savoir-faire Linux * Copyright (C) 2020 by Savoir-faire Linux
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
...@@ -16,6 +15,7 @@ ...@@ -16,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
...@@ -37,13 +37,6 @@ ComboBox { ...@@ -37,13 +37,6 @@ ComboBox {
needToBackToWelcomePage() needToBackToWelcomePage()
} }
// 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() { function resetAccountListModel() {
accountListModel.reset() accountListModel.reset()
...@@ -72,41 +65,24 @@ ComboBox { ...@@ -72,41 +65,24 @@ ComboBox {
} }
mipmap: true mipmap: true
Rectangle { AccountPresenceCycle {
id: presenseRect id: currentAccountPresenseCycle
anchors.right: userImageRoot.right anchors.right: userImageRoot.right
anchors.rightMargin: -2 anchors.rightMargin: -2
anchors.bottom: userImageRoot.bottom anchors.bottom: userImageRoot.bottom
anchors.bottomMargin: -2 anchors.bottomMargin: -2
width: 12 // Visible when account is registered.
height: 12
// Visible when account is registered, enum REGISTERED == 5.
visible: { visible: {
if (currentIndex !== -1) if (currentIndex !== -1)
return accountListModel.data( return accountListModel.data(
accountListModel.index( accountListModel.index(
accountComboBox.currentIndex, 0), 261) === 5 accountComboBox.currentIndex, 0), 261)
=== Account.Status.REGISTERED
else else
return visible return visible
} }
Rectangle {
id: presenseCycle
anchors.centerIn: presenseRect
width: 10
height: 10
radius: 30
color: JamiTheme.presenceGreen
}
radius: 30
color: JamiTheme.backgroundColor
} }
} }
......
...@@ -57,7 +57,6 @@ Popup { ...@@ -57,7 +57,6 @@ Popup {
model: accountListModel model: accountListModel
implicitHeight: contentHeight implicitHeight: contentHeight
delegate: ItemDelegate { delegate: ItemDelegate {
Image { Image {
id: userImage id: userImage
...@@ -66,7 +65,7 @@ Popup { ...@@ -66,7 +65,7 @@ Popup {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 30 width: 30
height: parent.height height: 30
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
mipmap: true mipmap: true
...@@ -81,6 +80,22 @@ Popup { ...@@ -81,6 +80,22 @@ Popup {
} }
return "data:image/png;base64," + data 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 { Text {
......
/*
* 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
}
...@@ -31,33 +31,14 @@ Image { ...@@ -31,33 +31,14 @@ Image {
source: "data:image/png;base64," + Picture source: "data:image/png;base64," + Picture
mipmap: true mipmap: true
Rectangle { AccountPresenceCycle {
id: presenseRect id: conversationAccountPresenseCycle
anchors.right: userImage.right anchors.right: userImage.right
anchors.rightMargin: -2
anchors.bottom: userImage.bottom anchors.bottom: userImage.bottom
anchors.bottomMargin: -2 anchors.bottomMargin: -2
width: 14
height: 14
visible: Presence visible: Presence
Rectangle {
id: presenseCycle
anchors.centerIn: presenseRect
width: 10
height: 10
radius: 30
color: JamiTheme.presenceGreen
}
radius: 30
color: JamiTheme.backgroundColor
} }
Rectangle { Rectangle {
......
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