2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 QtQuick.Layouts 1.14
|
|
|
|
import net.jami.Models 1.0
|
2020-09-23 12:54:48 +02:00
|
|
|
import net.jami.Adapters 1.0
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
import "../../commoncomponents"
|
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: comboBoxPopup
|
|
|
|
|
|
|
|
property bool toogleUpdatePopupHeight: false
|
|
|
|
|
|
|
|
y: accountComboBox.height - 1
|
|
|
|
implicitWidth: accountComboBox.width - 1
|
|
|
|
|
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
// Hack - limite the accounts that can be shown.
|
2020-08-03 13:27:42 -04:00
|
|
|
implicitHeight: {
|
|
|
|
comboBoxPopup.visible
|
2020-08-10 12:33:34 +02:00
|
|
|
return Math.min(accountComboBox.height *
|
|
|
|
Math.min(5, accountListModel.rowCount() + 1),
|
|
|
|
mainViewSidePanelRect.height)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
padding: 0
|
|
|
|
|
|
|
|
contentItem: ListView {
|
|
|
|
id: comboBoxPopupListView
|
|
|
|
|
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
// In list view, index is an interger.
|
2020-08-03 13:27:42 -04:00
|
|
|
clip: true
|
|
|
|
model: accountListModel
|
|
|
|
implicitHeight: contentHeight
|
|
|
|
delegate: ItemDelegate {
|
|
|
|
Image {
|
|
|
|
id: userImage
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
2020-07-30 13:38:57 +02:00
|
|
|
anchors.leftMargin: 10
|
2020-08-03 13:27:42 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
width: 30
|
2020-08-31 14:54:11 -04:00
|
|
|
height: 30
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
mipmap: true
|
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
// Role::Picture
|
2020-08-04 20:54:02 -04:00
|
|
|
source: {
|
2020-09-21 18:36:56 +02:00
|
|
|
var data = accountListModel.data(accountListModel.index(index, 0),
|
|
|
|
AccountListModel.Picture)
|
2020-08-04 20:54:02 -04:00
|
|
|
if (data === undefined) {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return "data:image/png;base64," + data
|
|
|
|
}
|
2020-08-31 14:54:11 -04:00
|
|
|
|
|
|
|
AccountPresenceCycle {
|
|
|
|
id: accountPresenseCycle
|
|
|
|
|
|
|
|
anchors.right: userImage.right
|
|
|
|
anchors.rightMargin: -2
|
|
|
|
anchors.bottom: userImage.bottom
|
|
|
|
anchors.bottomMargin: -2
|
|
|
|
|
2020-08-17 22:38:19 -04:00
|
|
|
accountStatus: Status
|
2020-08-31 14:54:11 -04:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: textUserAliasPopup
|
|
|
|
|
|
|
|
anchors.left: userImage.right
|
|
|
|
anchors.leftMargin: 10
|
|
|
|
anchors.top: itemCoboBackground.top
|
2020-07-30 13:38:57 +02:00
|
|
|
anchors.topMargin: 15
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
text: textMetricsUserAliasPopup.elidedText
|
|
|
|
font.pointSize: JamiTheme.textFontSize
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: textUsernamePopup
|
|
|
|
|
|
|
|
anchors.left: userImage.right
|
|
|
|
anchors.leftMargin: 10
|
|
|
|
anchors.top: textUserAliasPopup.bottom
|
|
|
|
|
|
|
|
text: textMetricsUsernamePopup.elidedText
|
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-07-30 13:38:57 +02:00
|
|
|
color: JamiTheme.faddedLastInteractionFontColor
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TextMetrics {
|
|
|
|
id: textMetricsUserAliasPopup
|
2020-07-30 13:38:57 +02:00
|
|
|
elide: Text.ElideRight
|
2020-08-03 13:27:42 -04:00
|
|
|
elideWidth: accountComboBox.width - userImage.width - settingsButton.width - 30
|
|
|
|
text: Alias
|
|
|
|
}
|
|
|
|
|
|
|
|
TextMetrics {
|
|
|
|
id: textMetricsUsernamePopup
|
2020-07-30 13:38:57 +02:00
|
|
|
elide: Text.ElideRight
|
2020-08-03 13:27:42 -04:00
|
|
|
elideWidth: accountComboBox.width - userImage.width - settingsButton.width - 30
|
|
|
|
text: Username
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
id: itemCoboBackground
|
2020-07-30 13:38:57 +02:00
|
|
|
color: JamiTheme.backgroundColor
|
2020-08-03 13:27:42 -04:00
|
|
|
implicitWidth: accountComboBox.width
|
|
|
|
implicitHeight: accountComboBox.height
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onPressed: {
|
|
|
|
itemCoboBackground.color = JamiTheme.pressColor
|
|
|
|
}
|
|
|
|
onReleased: {
|
|
|
|
itemCoboBackground.color = JamiTheme.releaseColor
|
|
|
|
currentIndex = index
|
|
|
|
comboBoxPopup.close()
|
2020-09-23 12:54:48 +02:00
|
|
|
AccountAdapter.accountChanged(index)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
onEntered: {
|
|
|
|
itemCoboBackground.color = JamiTheme.hoverColor
|
|
|
|
}
|
|
|
|
onExited: {
|
2020-07-30 13:38:57 +02:00
|
|
|
itemCoboBackground.color = JamiTheme.backgroundColor
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
footer: Button {
|
2020-08-03 13:27:42 -04:00
|
|
|
id: comboBoxFooterItem
|
|
|
|
|
|
|
|
implicitWidth: accountComboBox.width
|
|
|
|
implicitHeight: accountComboBox.height
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
background: Rectangle {
|
|
|
|
color: comboBoxFooterItem.hovered? JamiTheme.releaseColor : JamiTheme.backgroundColor
|
|
|
|
}
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
text: qsTr("Add Account") + "+"
|
2020-09-17 14:06:05 -04:00
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
comboBoxPopup.close()
|
2020-09-23 12:54:48 +02:00
|
|
|
mainViewWindow.startWizard()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator {}
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
|
|
|
id: accountComboBoxPopup
|
2020-07-30 13:38:57 +02:00
|
|
|
color: JamiTheme.backgroundColor
|
2020-08-03 13:27:42 -04:00
|
|
|
CustomBorder {
|
|
|
|
commonBorder: false
|
2020-07-30 13:38:57 +02:00
|
|
|
lBorderwidth: 1
|
2020-08-03 13:27:42 -04:00
|
|
|
rBorderwidth: 1
|
2020-07-30 13:38:57 +02:00
|
|
|
tBorderwidth: 1
|
2020-08-03 13:27:42 -04:00
|
|
|
bBorderwidth: 1
|
|
|
|
borderColor: JamiTheme.tabbarBorderColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|