blob: d8197e1f78d4d36604eebdbe2fae84a4bcf11097 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001
2/*
3 * Copyright (C) 2020 by Savoir-faire Linux
4 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19import QtQuick 2.14
20import QtQuick.Controls 2.14
21import QtQuick.Layouts 1.14
22import net.jami.Models 1.0
23
24TabBar {
25 id: tabBar
26
27 property alias converstationTabDown: pageOne.down
28 property alias invitationTabDown: pageTwo.down
29 property alias converstationTabWidth: pageOne.width
30 property alias invitationTabWidth: pageTwo.width
31 property alias converstationTabHeight: pageOne.height
32 property alias invitationTabHeight: pageTwo.height
33
34 visible: tabBarVisible
35
36 currentIndex: 0
37
38 TabButton {
39 id: pageOne
40
41 width: tabBar.width / 2 - tabButtonShrinkSize
42 height: textConvElement.height + 10
43
44 down: true
45
46 Rectangle {
47 id: totalUnreadMessagesCountRect
48
49 anchors.right: pageOne.right
50 anchors.rightMargin: 5
51 anchors.bottom: pageOne.bottom
52 anchors.bottomMargin: pageOne.height - totalUnreadMessagesCountRect.height / 2
53
54 width: 14
55 height: 14
56
57 visible: totalUnreadMessagesCount > 0
58
59 Text {
60 id: totalUnreadMessagesCountText
61
62 anchors.centerIn: totalUnreadMessagesCountRect
63
64 text: totalUnreadMessagesCount > 9 ? "···" : totalUnreadMessagesCount
65 color: "white"
66 }
67
68 radius: 30
69 color: JamiTheme.notificationRed
70 }
71
72 background: Rectangle {
73 id: buttonRectOne
74
75 radius: 10
76 width: pageOne.width + 2
77 color: pageOne.down ? "white" : JamiTheme.releaseColor
78 border.color: JamiTheme.tabbarBorderColor
79
80 Text {
81 id: textConvElement
82
83 anchors.centerIn: buttonRectOne
84
85 horizontalAlignment: Text.AlignHCenter
86 verticalAlignment: Text.AlignVCenter
87
88 text: qsTr("Converstation")
89 font.pointSize: JamiTheme.textFontSize
90 opacity: enabled ? 1.0 : 0.3
91 }
92
93 MouseArea {
94 anchors.fill: parent
95 hoverEnabled: true
96 onPressed: {
97 buttonRectOne.color = JamiTheme.pressColor
98 ConversationsAdapter.setConversationFilter("")
99 contactSearchBar.setPlaceholderString(
100 JamiTheme.contactSearchBarPlaceHolderConversationText)
101 pageOne.down = true
102 pageTwo.down = false
103 setCurrentUidSmartListModelIndex()
104 forceReselectConversationSmartListCurrentIndex()
105 }
106 onReleased: {
107 buttonRectOne.color = JamiTheme.releaseColor
108 }
109 onEntered: {
110 buttonRectOne.color = JamiTheme.hoverColor
111 }
112 onExited: {
113 buttonRectOne.color = Qt.binding(function () {
114 return pageOne.down ? "white" : JamiTheme.releaseColor
115 })
116 }
117 }
118 }
119 }
120
121 TabButton {
122 id: pageTwo
123
124 width: tabBar.width / 2 - tabButtonShrinkSize
125 height: textInvElement.height + 10
126
127 Rectangle {
128 id: pendingRequestCountRect
129
130 anchors.right: pageTwo.right
131 anchors.rightMargin: 5
132 anchors.bottom: pageTwo.bottom
133 anchors.bottomMargin: pageTwo.height - pendingRequestCountRect.height / 2
134
135 width: 14
136 height: 14
137
138 visible: pendingRequestCount > 0
139
140 Text {
141 id: pendingRequestCountText
142
143 anchors.centerIn: pendingRequestCountRect
144
145 text: pendingRequestCount > 9 ? "···" : pendingRequestCount
146 color: "white"
147 }
148
149 radius: 30
150 color: JamiTheme.notificationRed
151 }
152
153 background: Rectangle {
154 id: buttonRectTwo
155
156 radius: 10
157 color: pageTwo.down ? "white" : JamiTheme.releaseColor
158 border.color: JamiTheme.tabbarBorderColor
159
160 Text {
161 id: textInvElement
162
163 anchors.centerIn: buttonRectTwo
164
165 horizontalAlignment: Text.AlignHCenter
166 verticalAlignment: Text.AlignVCenter
167
168 font.pointSize: JamiTheme.textFontSize
169
170 text: qsTr("Invitation")
171 opacity: enabled ? 1.0 : 0.3
172 }
173
174 MouseArea {
175 anchors.fill: parent
176 hoverEnabled: true
177 onPressed: {
178 buttonRectTwo.color = JamiTheme.pressColor
179 ConversationsAdapter.setConversationFilter("PENDING")
180 contactSearchBar.setPlaceholderString(
181 JamiTheme.contactSearchBarPlaceHolderInivitionText)
182 pageTwo.down = true
183 pageOne.down = false
184 }
185 onReleased: {
186 buttonRectTwo.color = JamiTheme.releaseColor
187 }
188 onEntered: {
189 buttonRectTwo.color = JamiTheme.hoverColor
190 }
191 onExited: {
192 buttonRectTwo.color = Qt.binding(function () {
193 return pageTwo.down ? "white" : JamiTheme.releaseColor
194 })
195 }
196 }
197 }
198 }
199}