| 
									
										
										
										
											2019-07-07 23:52:41 -04:00
										 |  |  | // Copyright 2019 miruka
 | 
					
						
							|  |  |  | // This file is part of harmonyqml, licensed under LGPLv3.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-13 05:39:01 -04:00
										 |  |  | import QtQuick 2.12 | 
					
						
							|  |  |  | import QtQuick.Layouts 1.12 | 
					
						
							| 
									
										
										
										
											2019-04-28 15:18:36 -04:00
										 |  |  | import "../../Base" | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-11 17:51:00 -04:00
										 |  |  | HRectangle { | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |     id: banner | 
					
						
							|  |  |  |     Layout.fillWidth: true | 
					
						
							| 
									
										
										
										
											2019-07-06 17:50:55 -04:00
										 |  |  |     Layout.preferredHeight: theme.bottomElementsHeight | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 13:45:25 -04:00
										 |  |  |     property alias avatar: bannerAvatar | 
					
						
							|  |  |  |     property alias icon: bannerIcon | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |     property alias labelText: bannerLabel.text | 
					
						
							|  |  |  |     property alias buttonModel: bannerRepeater.model | 
					
						
							| 
									
										
										
										
											2019-04-28 14:20:30 -04:00
										 |  |  |     property var buttonCallbacks: [] | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-28 15:18:36 -04:00
										 |  |  |     HRowLayout { | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |         id: bannerRow | 
					
						
							|  |  |  |         anchors.fill: parent | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-07 00:24:23 -04:00
										 |  |  |         HUserAvatar { | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |             id: bannerAvatar | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 13:45:25 -04:00
										 |  |  |         HIcon { | 
					
						
							|  |  |  |             id: bannerIcon | 
					
						
							|  |  |  |             dimension: bannerLabel.implicitHeight | 
					
						
							|  |  |  |             visible: Boolean(svgName) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Layout.leftMargin: 5 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-28 15:18:36 -04:00
										 |  |  |         HLabel { | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |             id: bannerLabel | 
					
						
							|  |  |  |             textFormat: Text.StyledText | 
					
						
							|  |  |  |             elide: Text.ElideRight | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             visible: | 
					
						
							|  |  |  |                 bannerRow.width - bannerAvatar.width - bannerButtons.width > 30 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Layout.maximumWidth: | 
					
						
							|  |  |  |                 bannerRow.width - | 
					
						
							|  |  |  |                 bannerAvatar.width - bannerButtons.width - | 
					
						
							|  |  |  |                 Layout.leftMargin - Layout.rightMargin | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 13:45:25 -04:00
										 |  |  |             Layout.leftMargin: 5 | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |             Layout.rightMargin: Layout.leftMargin | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-28 15:22:53 -04:00
										 |  |  |         HSpacer {} | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-28 15:18:36 -04:00
										 |  |  |         HRowLayout { | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |             id: bannerButtons | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             function getButtonsWidth() { | 
					
						
							|  |  |  |                 var total = 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 for (var i = 0; i < bannerRepeater.count; i++) { | 
					
						
							|  |  |  |                     total += bannerRepeater.itemAt(i).implicitWidth | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 return total | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             property bool compact: | 
					
						
							|  |  |  |                 bannerRow.width < | 
					
						
							|  |  |  |                 bannerAvatar.width + | 
					
						
							|  |  |  |                 bannerLabel.implicitWidth + | 
					
						
							|  |  |  |                 bannerLabel.Layout.leftMargin + | 
					
						
							|  |  |  |                 bannerLabel.Layout.rightMargin + | 
					
						
							|  |  |  |                 getButtonsWidth() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Repeater { | 
					
						
							|  |  |  |                 id: bannerRepeater | 
					
						
							|  |  |  |                 model: [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-10 15:03:05 -04:00
										 |  |  |                 HUIButton { | 
					
						
							| 
									
										
										
										
											2019-04-28 14:20:30 -04:00
										 |  |  |                     id: button | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |                     text: modelData.text | 
					
						
							|  |  |  |                     iconName: modelData.iconName | 
					
						
							| 
									
										
										
										
											2019-04-28 14:20:30 -04:00
										 |  |  |                     onClicked: buttonCallbacks[modelData.name](button) | 
					
						
							| 
									
										
										
										
											2019-04-21 16:12:53 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-10 15:00:34 -04:00
										 |  |  |                     clip: true | 
					
						
							| 
									
										
										
										
											2019-04-21 15:20:20 -04:00
										 |  |  |                     Layout.maximumWidth: bannerButtons.compact ? height : -1 | 
					
						
							|  |  |  |                     Layout.fillHeight: true | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |