2020-10-06 13:58:44 +02:00
|
|
|
|
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/>.
|
|
|
|
*/
|
2020-09-14 16:15:28 +02:00
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
2020-10-06 13:58:44 +02:00
|
|
|
import QtGraphicalEffects 1.14
|
2020-08-03 13:27:42 -04:00
|
|
|
import net.jami.Models 1.0
|
2020-09-14 16:15:28 +02:00
|
|
|
import net.jami.Adapters 1.0
|
2020-12-05 14:05:57 +01:00
|
|
|
import net.jami.Constants 1.0
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
import "../../commoncomponents"
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
TabBar {
|
|
|
|
id: tabBar
|
|
|
|
|
2020-09-14 16:15:28 +02:00
|
|
|
enum TabIndex {
|
|
|
|
Conversations,
|
|
|
|
Requests
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: ConversationsAdapter
|
|
|
|
|
|
|
|
function onCurrentTypeFilterChanged() {
|
|
|
|
pageOne.down = ConversationsAdapter.currentTypeFilter !== Profile.Type.PENDING
|
|
|
|
pageTwo.down = ConversationsAdapter.currentTypeFilter === Profile.Type.PENDING
|
|
|
|
setCurrentUidSmartListModelIndex()
|
|
|
|
forceReselectConversationSmartListCurrentIndex()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectTab(tabIndex) {
|
|
|
|
ConversationsAdapter.currentTypeFilter = tabIndex ===
|
|
|
|
SidePanelTabBar.Conversations ? AccountAdapter.getCurrentAccountType() :
|
|
|
|
Profile.Type.PENDING
|
|
|
|
}
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
property alias converstationTabWidth: pageOne.width
|
|
|
|
property alias invitationTabWidth: pageTwo.width
|
|
|
|
property alias converstationTabHeight: pageOne.height
|
|
|
|
property alias invitationTabHeight: pageTwo.height
|
2020-07-30 13:38:57 +02:00
|
|
|
property real opacityDegree: 0.5
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
visible: tabBarVisible
|
|
|
|
|
|
|
|
currentIndex: 0
|
|
|
|
|
|
|
|
TabButton {
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
id: pageOne
|
2020-08-03 13:27:42 -04:00
|
|
|
down: true
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: totalUnreadMessagesCountRect
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
anchors.centerIn: buttonRectOne
|
|
|
|
anchors.verticalCenterOffset : -20
|
|
|
|
anchors.horizontalCenterOffset : 15
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
width: 16
|
|
|
|
height: 16
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
visible: totalUnreadMessagesCount > 0
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: totalUnreadMessagesCountText
|
|
|
|
|
|
|
|
anchors.centerIn: totalUnreadMessagesCountRect
|
|
|
|
|
|
|
|
text: totalUnreadMessagesCount > 9 ? "···" : totalUnreadMessagesCount
|
|
|
|
color: "white"
|
2020-07-30 13:38:57 +02:00
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
radius: 30
|
|
|
|
color: JamiTheme.notificationRed
|
2020-07-30 13:38:57 +02:00
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
2020-07-30 13:38:57 +02:00
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
id: buttonRectOne
|
2020-07-30 13:38:57 +02:00
|
|
|
width: tabBar.width / 2 + 1
|
|
|
|
height: tabBar.height
|
|
|
|
color: JamiTheme.backgroundColor
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgRectOne
|
|
|
|
anchors.horizontalCenter: buttonRectOne.horizontalCenter
|
|
|
|
anchors.top: buttonRectOne.top
|
|
|
|
anchors.topMargin: 12
|
|
|
|
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
mipmap: true
|
|
|
|
source: "qrc:/images/icons/baseline-people-24px.svg"
|
|
|
|
//opacity: enabled ? 0.8 : 0.3
|
|
|
|
opacity: pageOne.down == true ? 1.0 : opacityDegree
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: imgRectOne
|
|
|
|
source: imgRectOne
|
|
|
|
color: JamiTheme.blueLogo_
|
|
|
|
opacity: pageOne.down == true ? 1.0 : opacityDegree
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
Text {
|
|
|
|
id: textConvElement
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
anchors.horizontalCenter: buttonRectOne.horizontalCenter
|
|
|
|
anchors.bottom: buttonRectOne.bottom
|
|
|
|
anchors.bottomMargin: 12
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
2020-09-11 17:30:46 -04:00
|
|
|
text: JamiStrings.conversations
|
2020-08-03 13:27:42 -04:00
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-07-30 13:38:57 +02:00
|
|
|
opacity: pageOne.down == true ? 1.0 : opacityDegree
|
|
|
|
color: JamiTheme.blueLogo_
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: markerTabOne
|
|
|
|
width: buttonRectOne.width
|
|
|
|
anchors.bottom: buttonRectOne.bottom
|
|
|
|
height: 2
|
|
|
|
color: pageOne.down == true ? JamiTheme.blueLogo_ : "transparent"
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onPressed: {
|
2020-09-14 16:15:28 +02:00
|
|
|
selectTab(SidePanelTabBar.Conversations)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
onReleased: {
|
2020-12-09 10:51:33 -05:00
|
|
|
buttonRectOne.color = Qt.binding(function(){return JamiTheme.backgroundColor})
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
onEntered: {
|
2020-12-09 10:51:33 -05:00
|
|
|
buttonRectOne.color = Qt.binding(function(){return JamiTheme.hoverColor})
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
onExited: {
|
2020-12-09 10:51:33 -05:00
|
|
|
buttonRectOne.color = Qt.binding(function(){return JamiTheme.backgroundColor})
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
2020-08-13 13:05:17 -04:00
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+L"
|
|
|
|
context: Qt.ApplicationShortcut
|
|
|
|
enabled: buttonRectOne.visible
|
|
|
|
onActivated: {
|
2020-09-14 16:15:28 +02:00
|
|
|
selectTab(SidePanelTabBar.Conversations)
|
2020-08-13 13:05:17 -04:00
|
|
|
}
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TabButton {
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
id: pageTwo
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: pendingRequestCountRect
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
anchors.centerIn: buttonRectTwo
|
|
|
|
anchors.verticalCenterOffset : -20
|
|
|
|
anchors.horizontalCenterOffset : 15
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
width: 16
|
|
|
|
height: 16
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
visible: pendingRequestCount > 0
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: pendingRequestCountText
|
|
|
|
|
|
|
|
anchors.centerIn: pendingRequestCountRect
|
|
|
|
|
|
|
|
text: pendingRequestCount > 9 ? "···" : pendingRequestCount
|
2020-07-30 13:38:57 +02:00
|
|
|
color: JamiTheme.backgroundColor
|
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
radius: 30
|
|
|
|
color: JamiTheme.notificationRed
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
id: buttonRectTwo
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
width: tabBar.width / 2
|
|
|
|
height: tabBar.height
|
|
|
|
color: JamiTheme.backgroundColor
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgRectTwo
|
|
|
|
anchors.horizontalCenter: buttonRectTwo.horizontalCenter
|
|
|
|
anchors.top: buttonRectTwo.top
|
|
|
|
anchors.topMargin: 10
|
|
|
|
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
mipmap: true
|
|
|
|
source: "qrc:/images/icons/drafts-24px.svg"
|
|
|
|
//opacity: enabled ? 0.8 : 0.3
|
|
|
|
opacity: pageTwo.down == true ? 1.0 : opacityDegree
|
|
|
|
}
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: imgRectTwo
|
|
|
|
source: imgRectTwo
|
|
|
|
color: JamiTheme.blueLogo_
|
|
|
|
opacity: pageTwo.down == true ? 1.0 : opacityDegree
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
Text {
|
|
|
|
id: textInvElement
|
|
|
|
|
2020-07-30 13:38:57 +02:00
|
|
|
anchors.horizontalCenter: buttonRectTwo.horizontalCenter
|
|
|
|
anchors.bottom: buttonRectTwo.bottom
|
|
|
|
anchors.bottomMargin: 12
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
|
|
|
font.pointSize: JamiTheme.textFontSize
|
|
|
|
|
2020-09-11 17:30:46 -04:00
|
|
|
text: JamiStrings.invitations
|
2020-07-30 13:38:57 +02:00
|
|
|
//opacity: enabled ? 1.0 : 0.3
|
|
|
|
opacity: pageTwo.down == true ? 1.0 : opacityDegree
|
|
|
|
color: JamiTheme.blueLogo_
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: markerTabTwo
|
|
|
|
width: buttonRectTwo.width
|
|
|
|
anchors.bottom: buttonRectTwo.bottom
|
|
|
|
height: 2
|
|
|
|
color: pageTwo.down == true ? JamiTheme.blueLogo_ : "transparent"
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onPressed: {
|
2020-09-14 16:15:28 +02:00
|
|
|
selectTab(SidePanelTabBar.Requests)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
onReleased: {
|
2020-12-09 10:51:33 -05:00
|
|
|
buttonRectTwo.color = Qt.binding(function(){return JamiTheme.backgroundColor})
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
onEntered: {
|
2020-12-09 10:51:33 -05:00
|
|
|
buttonRectTwo.color = Qt.binding(function(){return JamiTheme.hoverColor})
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
onExited: {
|
2020-12-09 10:51:33 -05:00
|
|
|
buttonRectTwo.color = Qt.binding(function(){return JamiTheme.backgroundColor})
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
2020-08-13 13:05:17 -04:00
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+R"
|
|
|
|
context: Qt.ApplicationShortcut
|
|
|
|
enabled: buttonRectTwo.visible
|
|
|
|
onActivated: {
|
2020-09-14 16:15:28 +02:00
|
|
|
selectTab(SidePanelTabBar.Requests)
|
2020-08-13 13:05:17 -04:00
|
|
|
}
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|