2019-09-15 06:05:57 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2019-11-07 21:44:53 +11:00
|
|
|
import "../utils.js" as Utils
|
2019-09-15 06:05:57 +10:00
|
|
|
|
|
|
|
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
|
2019-09-15 06:05:57 +10:00
|
|
|
|
|
|
|
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-09-15 06:05:57 +10:00
|
|
|
|
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
contentItem: HRowLayout {
|
|
|
|
id: contentItem
|
|
|
|
spacing: tile.spacing
|
2019-09-15 06:05:57 +10:00
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
HLoader {
|
|
|
|
sourceComponent: image
|
|
|
|
}
|
2019-09-15 06:05:57 +10:00
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
HColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
2019-09-15 06:05:57 +10:00
|
|
|
|
|
|
|
HRowLayout {
|
2019-11-07 21:44:53 +11:00
|
|
|
spacing: tile.spacing
|
2019-09-15 06:05:57 +10:00
|
|
|
|
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-09-15 06:05:57 +10:00
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
HLabel {
|
|
|
|
id: rightInfo
|
|
|
|
font.pixelSize: theme.fontSize.small
|
|
|
|
color: theme.colors.halfDimText
|
2019-09-15 06:05:57 +10:00
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
visible: Layout.maximumWidth > 0
|
|
|
|
Layout.maximumWidth:
|
2019-12-05 00:08:38 +11:00
|
|
|
text && tile.width >= 160 * theme.uiScale ?
|
|
|
|
implicitWidth : 0
|
2019-11-07 21:44:53 +11:00
|
|
|
|
|
|
|
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
|
|
|
}
|
2019-09-15 06:05:57 +10:00
|
|
|
}
|
|
|
|
|
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-09-15 06:05:57 +10:00
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
visible: Layout.maximumHeight > 0
|
|
|
|
Layout.maximumHeight: text ? implicitWidth : 0
|
|
|
|
Layout.fillWidth: true
|
2019-09-15 06:05:57 +10:00
|
|
|
|
2019-11-07 21:44:53 +11:00
|
|
|
Behavior on Layout.maximumHeight { HNumberAnimation {} }
|
|
|
|
}
|
2019-09-15 06:05:57 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-15 08:52:43 +10:00
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onTapped: leftClicked()
|
|
|
|
}
|
2019-09-15 06:05:57 +10:00
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.RightButton
|
2019-09-15 08:52:43 +10:00
|
|
|
onTapped: {
|
|
|
|
rightClicked()
|
|
|
|
if (contextMenu.count > 0) contextMenu.popup()
|
|
|
|
}
|
2019-09-15 06:05:57 +10:00
|
|
|
}
|
|
|
|
}
|