Split HTileDelegate into HTile and HTileDelegate
This commit is contained in:
parent
fe087ba724
commit
784cb3b19c
8
TODO.md
8
TODO.md
@ -11,6 +11,11 @@
|
||||
- GIF thumbnails: load the real animated image
|
||||
- Copy thumbnail URL in context menu?
|
||||
|
||||
- Refactor EventContent
|
||||
- No background/padding around medias
|
||||
|
||||
- Copy to X11 selection with new CppUtils class
|
||||
|
||||
- RoomMessageNotice
|
||||
|
||||
- Refactoring
|
||||
@ -53,8 +58,6 @@
|
||||
- Indeterminate progress bar
|
||||
- `smartVerticalFlick()` gradual acceleration
|
||||
|
||||
- Message selection
|
||||
- Copy to X11 selection
|
||||
- Link previews
|
||||
- Support showing images at the place they should be instead of always
|
||||
at the end of the message
|
||||
@ -182,7 +185,6 @@
|
||||
- When inviting someone to direct chat, room is "Empty room" until accepted,
|
||||
it should be the peer's display name instead.
|
||||
- Animate RoomEventDelegate DayBreak apparition
|
||||
- Room subtitle: show things like "*Image*" instead of blank, etc
|
||||
- Live-reloading accounts.json
|
||||
|
||||
- nio
|
||||
|
75
src/qml/Base/HTile.qml
Normal file
75
src/qml/Base/HTile.qml
Normal file
@ -0,0 +1,75 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
HButton {
|
||||
id: tile
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: if (contextMenu.count > 0) contextMenu.popup()
|
||||
}
|
||||
}
|
@ -1,82 +1,20 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
HButton {
|
||||
HTile {
|
||||
id: tile
|
||||
onActivated: view.currentIndex = model.index
|
||||
|
||||
|
||||
signal activated()
|
||||
|
||||
property HListView view: ListView.view
|
||||
property bool shouldBeCurrent: false
|
||||
|
||||
readonly property var delegateModel: model
|
||||
readonly property QtObject delegateModel: model
|
||||
|
||||
default property var additionalItems: []
|
||||
|
||||
readonly property alias title: title
|
||||
readonly property alias additionalInfo: additionalInfo
|
||||
readonly property alias rightInfo: rightInfo
|
||||
readonly property alias subtitle: subtitle
|
||||
readonly property alias setCurrentTimer: setCurrentTimer
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
onActivated: view.currentIndex = model.index
|
||||
|
||||
|
||||
Timer {
|
||||
id: setCurrentTimer
|
||||
@ -102,9 +40,4 @@ HButton {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: if (contextMenu.count > 0) contextMenu.popup()
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
// onLongPressed: if (contextMenu.count > 0) contextMenu.popup()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user