2019-04-22 05:20:20 +10:00
|
|
|
import QtQuick 2.7
|
2019-04-29 05:45:42 +10:00
|
|
|
import QtQuick.Layouts 1.3
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../../Base"
|
2019-04-22 05:20:20 +10:00
|
|
|
|
2019-05-12 07:51:00 +10:00
|
|
|
HRectangle {
|
2019-04-22 05:20:20 +10:00
|
|
|
id: banner
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 32
|
|
|
|
|
2019-05-09 03:45:25 +10:00
|
|
|
property alias avatar: bannerAvatar
|
|
|
|
property alias icon: bannerIcon
|
2019-04-22 05:20:20 +10:00
|
|
|
property alias labelText: bannerLabel.text
|
|
|
|
property alias buttonModel: bannerRepeater.model
|
2019-04-29 04:20:30 +10:00
|
|
|
property var buttonCallbacks: []
|
2019-04-22 05:20:20 +10:00
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HRowLayout {
|
2019-04-22 05:20:20 +10:00
|
|
|
id: bannerRow
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HAvatar {
|
2019-04-22 05:20:20 +10:00
|
|
|
id: bannerAvatar
|
2019-04-29 01:32:02 +10:00
|
|
|
dimension: banner.Layout.preferredHeight
|
2019-04-22 05:20:20 +10:00
|
|
|
}
|
|
|
|
|
2019-05-09 03:45:25 +10:00
|
|
|
HIcon {
|
|
|
|
id: bannerIcon
|
|
|
|
dimension: bannerLabel.implicitHeight
|
|
|
|
visible: Boolean(svgName)
|
|
|
|
|
|
|
|
Layout.leftMargin: 5
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HLabel {
|
2019-04-22 05:20:20 +10:00
|
|
|
id: bannerLabel
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
maximumLineCount: 1
|
|
|
|
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-09 03:45:25 +10:00
|
|
|
Layout.leftMargin: 5
|
2019-04-22 05:20:20 +10:00
|
|
|
Layout.rightMargin: Layout.leftMargin
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:22:53 +10:00
|
|
|
HSpacer {}
|
2019-04-22 05:20:20 +10:00
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HRowLayout {
|
2019-04-22 05:20:20 +10: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-04-29 05:18:36 +10:00
|
|
|
HButton {
|
2019-04-29 04:20:30 +10:00
|
|
|
id: button
|
2019-04-22 05:20:20 +10:00
|
|
|
text: modelData.text
|
|
|
|
iconName: modelData.iconName
|
2019-04-29 04:20:30 +10:00
|
|
|
onClicked: buttonCallbacks[modelData.name](button)
|
2019-04-22 06:12:53 +10:00
|
|
|
|
2019-04-22 05:20:20 +10:00
|
|
|
Layout.maximumWidth: bannerButtons.compact ? height : -1
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|