moment/src/qml/Base/HTile.qml

94 lines
2.3 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.12
2019-11-07 21:44:53 +11:00
import "../utils.js" as Utils
HButton {
id: tile
2019-09-15 08:52:43 +10:00
signal leftClicked()
signal rightClicked()
2019-11-07 21:44:53 +11:00
default property alias additionalData: contentItem.data
readonly property alias title: title
readonly property alias additionalInfo: additionalInfo
readonly property alias rightInfo: rightInfo
readonly property alias subtitle: subtitle
property HMenu contextMenu: HMenu {}
2019-11-07 21:44:53 +11:00
property Component image
2019-11-07 21:44:53 +11:00
contentItem: HRowLayout {
id: contentItem
spacing: tile.spacing
2019-11-07 21:44:53 +11:00
HLoader {
sourceComponent: image
}
2019-11-07 21:44:53 +11:00
HColumnLayout {
Layout.fillWidth: true
HRowLayout {
2019-11-07 21:44:53 +11:00
spacing: tile.spacing
2019-11-07 21:44:53 +11:00
HLabel {
id: title
text: "Missing title"
elide: Text.ElideRight
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
HRowLayout {
id: additionalInfo
visible: visibleChildren.length > 0
}
2019-11-07 21:44:53 +11:00
HLabel {
id: rightInfo
font.pixelSize: theme.fontSize.small
color: theme.colors.halfDimText
2019-11-07 21:44:53 +11:00
visible: Layout.maximumWidth > 0
Layout.maximumWidth:
text && tile.width >= 160 ? implicitWidth : 0
Behavior on Layout.maximumWidth { HNumberAnimation {} }
}
}
2019-11-07 21:44:53 +11:00
HRichLabel {
id: subtitle
textFormat: Text.StyledText
font.pixelSize: theme.fontSize.small
elide: Text.ElideRight
color: theme.colors.dimText
2019-11-07 21:44:53 +11:00
visible: Layout.maximumHeight > 0
Layout.maximumHeight: text ? implicitWidth : 0
Layout.fillWidth: true
2019-11-07 21:44:53 +11:00
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}
}
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()
}
}
}