moment/src/qml/Base/HTile.qml

88 lines
2.1 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.12
HButton {
id: tile
2019-09-15 08:52:43 +10:00
signal leftClicked()
signal rightClicked()
default property var additionalItems: []
readonly property alias title: title
readonly property alias additionalInfo: additionalInfo
readonly property alias rightInfo: rightInfo
readonly property alias subtitle: subtitle
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
2019-09-15 07:39:17 +10:00
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
2019-09-15 07:39:17 +10:00
color: theme.colors.dimText
visible: Layout.maximumHeight > 0
Layout.maximumHeight: text ? implicitWidth : 0
Layout.fillWidth: true
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}
contentItem: HRowLayout {
spacing: tile.spacing
children: [image, details].concat(additionalItems)
}
2019-09-15 08:52:43 +10:00
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: leftClicked()
}
TapHandler {
acceptedButtons: Qt.RightButton
2019-09-15 08:52:43 +10:00
onTapped: {
rightClicked()
if (contextMenu.count > 0) contextMenu.popup()
}
}
}