| 
									
										
										
										
											2019-12-19 07:46:16 -04:00
										 |  |  | // SPDX-License-Identifier: LGPL-3.0-or-later
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-18 03:27:00 -04:00
										 |  |  | import QtQuick 2.12 | 
					
						
							|  |  |  | import QtQuick.Layouts 1.12 | 
					
						
							|  |  |  | import "../Base" | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  | import "../Base/HTile" | 
					
						
							| 
									
										
										
										
											2019-08-18 03:27:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-13 07:37:39 -04:00
										 |  |  | HTileDelegate { | 
					
						
							| 
									
										
										
										
											2019-12-02 16:29:29 -04:00
										 |  |  |     id: account | 
					
						
							| 
									
										
										
										
											2020-05-13 08:24:53 -04:00
										 |  |  |     backgroundColor: theme.mainPane.listView.account.background | 
					
						
							| 
									
										
										
										
											2020-05-13 07:37:39 -04:00
										 |  |  |     leftPadding: theme.spacing | 
					
						
							| 
									
										
										
										
											2020-05-13 14:16:37 -04:00
										 |  |  |     rightPadding: 0  // the right buttons have padding
 | 
					
						
							| 
									
										
										
										
											2019-08-18 03:27:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |     contentItem: ContentRow { | 
					
						
							|  |  |  |         tile: account | 
					
						
							| 
									
										
										
										
											2020-05-13 14:16:37 -04:00
										 |  |  |         spacing: 0 | 
					
						
							|  |  |  |         opacity: collapsed ? theme.mainPane.listView.account.collapsedOpacity : 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Behavior on opacity { HNumberAnimation {} } | 
					
						
							| 
									
										
										
										
											2019-08-23 10:53:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |         HUserAvatar { | 
					
						
							|  |  |  |             id: avatar | 
					
						
							| 
									
										
										
										
											2020-05-12 06:09:07 -04:00
										 |  |  |             userId: model.id | 
					
						
							|  |  |  |             displayName: model.display_name | 
					
						
							|  |  |  |             mxc: model.avatar_url | 
					
						
							| 
									
										
										
										
											2020-05-13 08:24:53 -04:00
										 |  |  |             radius: theme.mainPane.listView.account.avatarRadius | 
					
						
							| 
									
										
										
										
											2020-05-01 01:22:08 -04:00
										 |  |  |             compact: account.compact | 
					
						
							| 
									
										
										
										
											2019-12-02 16:29:29 -04:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-08-19 10:28:49 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |         TitleLabel { | 
					
						
							| 
									
										
										
										
											2020-05-12 06:09:07 -04:00
										 |  |  |             text: model.display_name || model.id | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |             color: | 
					
						
							|  |  |  |                 hovered ? | 
					
						
							| 
									
										
										
										
											2020-04-29 14:00:02 -04:00
										 |  |  |                 utils.nameColor( | 
					
						
							| 
									
										
										
										
											2020-05-12 06:09:07 -04:00
										 |  |  |                     model.display_name || model.id.substring(1), | 
					
						
							| 
									
										
										
										
											2020-04-29 14:00:02 -04:00
										 |  |  |                 ) : | 
					
						
							| 
									
										
										
										
											2020-05-13 08:24:53 -04:00
										 |  |  |                 theme.mainPane.listView.account.name | 
					
						
							| 
									
										
										
										
											2019-08-19 10:28:49 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |             Behavior on color { HColorAnimation {} } | 
					
						
							| 
									
										
										
										
											2020-05-13 14:16:37 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |             Layout.leftMargin: theme.spacing | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-02-13 06:58:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 22:16:33 -04:00
										 |  |  |         HButton { | 
					
						
							|  |  |  |             id: addChat | 
					
						
							|  |  |  |             iconItem.small: true | 
					
						
							|  |  |  |             icon.name: "add-chat" | 
					
						
							|  |  |  |             backgroundColor: "transparent" | 
					
						
							|  |  |  |             toolTip.text: qsTr("Add new chat") | 
					
						
							|  |  |  |             onClicked: pageLoader.showPage( | 
					
						
							| 
									
										
										
										
											2020-05-12 06:09:07 -04:00
										 |  |  |                 "AddChat/AddChat", {userId: model.id}, | 
					
						
							| 
									
										
										
										
											2020-03-12 22:16:33 -04:00
										 |  |  |             ) | 
					
						
							| 
									
										
										
										
											2019-11-07 06:44:53 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-13 14:16:37 -04:00
										 |  |  |             leftPadding: theme.spacing | 
					
						
							|  |  |  |             rightPadding: theme.spacing / 1.75 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 22:16:33 -04:00
										 |  |  |             Layout.fillHeight: true | 
					
						
							|  |  |  |             Layout.maximumWidth: | 
					
						
							|  |  |  |                 account.width >= 100 * theme.uiScale ?  implicitWidth : 0 | 
					
						
							| 
									
										
										
										
											2019-11-07 06:44:53 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-26 14:20:45 -04:00
										 |  |  |             HShortcut { | 
					
						
							|  |  |  |                 enabled: isCurrent | 
					
						
							|  |  |  |                 sequences: window.settings.keys.addNewChat | 
					
						
							|  |  |  |                 onActivated: addChat.clicked() | 
					
						
							| 
									
										
										
										
											2020-03-12 22:16:33 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-05-13 14:16:37 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         HButton { | 
					
						
							|  |  |  |             id: expand | 
					
						
							|  |  |  |             iconItem.small: true | 
					
						
							|  |  |  |             icon.name: "expand" | 
					
						
							|  |  |  |             backgroundColor: "transparent" | 
					
						
							|  |  |  |             toolTip.text: collapsed ? qsTr("Expand") : qsTr("Collapse") | 
					
						
							|  |  |  |             onClicked: account.toggleCollapse() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             leftPadding: theme.spacing / 1.75 | 
					
						
							|  |  |  |             rightPadding: theme.spacing | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             visible: Layout.maximumWidth > 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Layout.fillHeight: true | 
					
						
							|  |  |  |             Layout.maximumWidth: | 
					
						
							|  |  |  |                 ! filterActive && account.width >= 120 * theme.uiScale ? | 
					
						
							|  |  |  |                 implicitWidth : | 
					
						
							|  |  |  |                 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             iconItem.transform: Rotation { | 
					
						
							|  |  |  |                 origin.x: expand.iconItem.width / 2 | 
					
						
							|  |  |  |                 origin.y: expand.iconItem.height / 2 | 
					
						
							|  |  |  |                 angle: expand.loading ? 0 : collapsed ? 180 : 90 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 Behavior on angle { HNumberAnimation {} } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Behavior on Layout.maximumWidth { HNumberAnimation {} } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-08-18 03:27:00 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-12 06:09:07 -04:00
										 |  |  |     contextMenu: AccountContextMenu { userId: model.id } | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-26 14:20:45 -04:00
										 |  |  |     onLeftClicked: { | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |         pageLoader.showPage( | 
					
						
							| 
									
										
										
										
											2020-05-12 06:09:07 -04:00
										 |  |  |             "AccountSettings/AccountSettings", { "userId": model.id } | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  |         ) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-26 14:20:45 -04:00
										 |  |  |     property bool isCurrent: false | 
					
						
							| 
									
										
										
										
											2020-05-13 14:16:37 -04:00
										 |  |  |     property bool filterActive: false | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     readonly property bool collapsed: | 
					
						
							|  |  |  |         (window.uiState.collapseAccounts[model.id] || false) && | 
					
						
							|  |  |  |         ! filterActive | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function setCollapse(collapse) { | 
					
						
							|  |  |  |         window.uiState.collapseAccounts[model.id] = collapse | 
					
						
							|  |  |  |         window.uiStateChanged() | 
					
						
							| 
									
										
										
										
											2020-05-13 20:22:48 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         py.callCoro("set_account_collapse", [model.id, collapse]) | 
					
						
							| 
									
										
										
										
											2020-05-13 14:16:37 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function toggleCollapse() { | 
					
						
							|  |  |  |         setCollapse(! collapsed) | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-03-30 15:03:35 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-26 14:20:45 -04:00
										 |  |  |     HShortcut { | 
					
						
							|  |  |  |         enabled: isCurrent | 
					
						
							|  |  |  |         sequences: window.settings.keys.accountSettings | 
					
						
							|  |  |  |         onActivated: leftClicked() | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-18 03:27:00 -04:00
										 |  |  | } |