Add "+" button to account delegates

This commit is contained in:
miruka
2019-11-07 06:44:53 -04:00
parent 83ff9bf61d
commit 45951554a5
3 changed files with 88 additions and 57 deletions

View File

@@ -1,5 +1,6 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../utils.js" as Utils
HButton {
id: tile
@@ -7,7 +8,7 @@ HButton {
signal leftClicked()
signal rightClicked()
default property var additionalItems: []
default property alias additionalData: contentItem.data
readonly property alias title: title
readonly property alias additionalInfo: additionalInfo
@@ -16,62 +17,71 @@ HButton {
property HMenu contextMenu: HMenu {}
property Item image
property Item details: HColumnLayout {
Layout.fillWidth: true
HRowLayout {
spacing: tile.spacing
HLabel {
id: title
text: "Missing title"
elide: Text.ElideRight
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
HRowLayout {
id: additionalInfo
visible: visibleChildren.length > 0
}
HLabel {
id: rightInfo
font.pixelSize: theme.fontSize.small
color: theme.colors.halfDimText
visible: Layout.maximumWidth > 0
Layout.maximumWidth:
text && tile.width >= 160 ? implicitWidth : 0
Behavior on Layout.maximumWidth { HNumberAnimation {} }
}
}
HRichLabel {
id: subtitle
textFormat: Text.StyledText
font.pixelSize: theme.fontSize.small
elide: Text.ElideRight
color: theme.colors.dimText
visible: Layout.maximumHeight > 0
Layout.maximumHeight: text ? implicitWidth : 0
Layout.fillWidth: true
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}
property Component image
contentItem: HRowLayout {
id: contentItem
spacing: tile.spacing
children: [image, details].concat(additionalItems)
HLoader {
sourceComponent: image
}
HColumnLayout {
Layout.fillWidth: true
HRowLayout {
spacing: tile.spacing
HLabel {
id: title
text: "Missing title"
elide: Text.ElideRight
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
HRowLayout {
id: additionalInfo
visible: visibleChildren.length > 0
}
HLabel {
id: rightInfo
font.pixelSize: theme.fontSize.small
color: theme.colors.halfDimText
visible: Layout.maximumWidth > 0
Layout.maximumWidth:
text && tile.width >= 160 ? implicitWidth : 0
Behavior on Layout.maximumWidth { HNumberAnimation {} }
}
}
HRichLabel {
id: subtitle
textFormat: Text.StyledText
font.pixelSize: theme.fontSize.small
elide: Text.ElideRight
color: theme.colors.dimText
visible: Layout.maximumHeight > 0
Layout.maximumHeight: text ? implicitWidth : 0
Layout.fillWidth: true
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}
}
// Binding { target: details; property: "parent"; value: contentItem }
// Binding { target: image; property: "parent"; value: contentItem }
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: leftClicked()