2019-04-22 05:20:20 +10:00
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.4
|
2019-04-29 04:34:29 +10:00
|
|
|
import "../../Base" as Base
|
2019-04-22 05:20:20 +10:00
|
|
|
|
2019-04-29 01:01:38 +10:00
|
|
|
Base.HGlassRectangle {
|
2019-04-22 05:20:20 +10:00
|
|
|
id: banner
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 32
|
|
|
|
|
|
|
|
property alias avatarName: bannerAvatar.name
|
|
|
|
property alias avatarSource: bannerAvatar.imageSource
|
|
|
|
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
|
|
|
|
|
|
|
Base.HRowLayout {
|
|
|
|
id: bannerRow
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2019-04-29 01:21:19 +10:00
|
|
|
Base.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
|
|
|
}
|
|
|
|
|
|
|
|
Base.HLabel {
|
|
|
|
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
|
|
|
|
|
|
|
|
Layout.leftMargin: 10
|
|
|
|
Layout.rightMargin: Layout.leftMargin
|
|
|
|
}
|
|
|
|
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
|
|
|
|
Base.HRowLayout {
|
|
|
|
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: []
|
|
|
|
|
|
|
|
Base.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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|