| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import ".." |
| 6 |
import QtQuick |
| 7 |
import QtQuick.Layouts |
| 8 |
import im.nheko |
| 9 |
|
| 10 |
Rectangle { |
| 11 |
id: tile |
| 12 |
|
| 13 |
property color background: palette.window |
| 14 |
property color importantText: palette.text |
| 15 |
property color unimportantText: palette.buttonText |
| 16 |
property color bubbleBackground: palette.highlight |
| 17 |
property color bubbleText: palette.highlightedText |
| 18 |
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3) |
| 19 |
required property string avatarUrl |
| 20 |
required property string title |
| 21 |
required property string subtitle |
| 22 |
required property int index |
| 23 |
required property int selectedIndex |
| 24 |
property bool crop: true |
| 25 |
property alias roomid: avatar.roomid |
| 26 |
property alias userid: avatar.userid |
| 27 |
|
| 28 |
color: background |
| 29 |
height: avatarSize + 2 * Nheko.paddingMedium |
| 30 |
width: ListView.view.width |
| 31 |
state: "normal" |
| 32 |
states: [ |
| 33 |
State { |
| 34 |
name: "highlight" |
| 35 |
when: hovered.hovered && !(index == selectedIndex) |
| 36 |
|
| 37 |
PropertyChanges { |
| 38 |
tile { |
| 39 |
background: palette.dark |
| 40 |
importantText: palette.brightText |
| 41 |
unimportantText: palette.brightText |
| 42 |
bubbleBackground: palette.highlight |
| 43 |
bubbleText: palette.highlightedText |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
}, |
| 48 |
State { |
| 49 |
name: "selected" |
| 50 |
when: index == selectedIndex |
| 51 |
|
| 52 |
PropertyChanges { |
| 53 |
tile { |
| 54 |
background: palette.highlight |
| 55 |
importantText: palette.highlightedText |
| 56 |
unimportantText: palette.highlightedText |
| 57 |
bubbleBackground: palette.highlightedText |
| 58 |
bubbleText: palette.highlight |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
} |
| 63 |
] |
| 64 |
|
| 65 |
HoverHandler { |
| 66 |
id: hovered |
| 67 |
} |
| 68 |
|
| 69 |
RowLayout { |
| 70 |
spacing: Nheko.paddingMedium |
| 71 |
anchors.fill: parent |
| 72 |
anchors.margins: Nheko.paddingMedium |
| 73 |
|
| 74 |
Avatar { |
| 75 |
id: avatar |
| 76 |
|
| 77 |
enabled: false |
| 78 |
Layout.alignment: Qt.AlignVCenter |
| 79 |
implicitHeight: avatarSize |
| 80 |
implicitWidth: avatarSize |
| 81 |
url: tile.avatarUrl.replace("mxc://", "image://MxcImage/") |
| 82 |
displayName: title |
| 83 |
crop: tile.crop |
| 84 |
} |
| 85 |
|
| 86 |
ColumnLayout { |
| 87 |
id: textContent |
| 88 |
|
| 89 |
Layout.alignment: Qt.AlignLeft |
| 90 |
Layout.fillWidth: true |
| 91 |
Layout.minimumWidth: 100 |
| 92 |
Layout.preferredWidth: parent.width - avatar.width |
| 93 |
spacing: Nheko.paddingSmall |
| 94 |
|
| 95 |
RowLayout { |
| 96 |
Layout.fillWidth: true |
| 97 |
spacing: 0 |
| 98 |
|
| 99 |
ElidedLabel { |
| 100 |
Layout.alignment: Qt.AlignBottom |
| 101 |
color: tile.importantText |
| 102 |
elideWidth: textContent.width - Nheko.paddingMedium |
| 103 |
fullText: title |
| 104 |
textFormat: Text.PlainText |
| 105 |
} |
| 106 |
|
| 107 |
Item { |
| 108 |
Layout.fillWidth: true |
| 109 |
} |
| 110 |
|
| 111 |
} |
| 112 |
|
| 113 |
RowLayout { |
| 114 |
Layout.fillWidth: true |
| 115 |
spacing: 0 |
| 116 |
|
| 117 |
ElidedLabel { |
| 118 |
color: tile.unimportantText |
| 119 |
font.pixelSize: fontMetrics.font.pixelSize * 0.9 |
| 120 |
elideWidth: textContent.width - Nheko.paddingSmall |
| 121 |
fullText: subtitle |
| 122 |
textFormat: Text.PlainText |
| 123 |
} |
| 124 |
|
| 125 |
Item { |
| 126 |
Layout.fillWidth: true |
| 127 |
} |
| 128 |
|
| 129 |
} |
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
} |