Use controls.

This commit is contained in:
Black
2020-02-12 02:20:29 -08:00
parent d3b926bc8e
commit cd10a8474a
5 changed files with 90 additions and 109 deletions

View File

@@ -8,34 +8,16 @@ import Spectral.Dialog 2.0
import Spectral.Effect 2.0 import Spectral.Effect 2.0
import Spectral.Setting 0.1 import Spectral.Setting 0.1
Control { RowLayout {
id: root
padding: 8
contentItem: RowLayout {
id: row id: row
Control {
Layout.alignment: Qt.AlignTop
id: authorControl
padding: 4
background: Rectangle {
radius: height / 2
color: author.color
}
contentItem: RowLayout {
Avatar { Avatar {
Layout.preferredWidth: 24 Layout.preferredWidth: 24
Layout.preferredHeight: 24 Layout.preferredHeight: 24
hint: author.displayName hint: author.displayName
source: author.avatarMediaId source: author.avatarMediaId
color: Qt.darker(author.color, 1.1) color: author.color
Component { Component {
id: userDetailDialog id: userDetailDialog
@@ -57,18 +39,11 @@ Control {
text: author.displayName text: author.displayName
font.pixelSize: 13 font.pixelSize: 13
font.weight: Font.Medium font.bold: true
color: "white"
rightPadding: 8
}
}
} }
Label { Label {
Layout.fillWidth: true text: model.display
Layout.maximumWidth: messageListView.width - authorControl.width - row.spacing - (root.padding * 2)
text: display + " • " + Qt.formatTime(time)
color: MPalette.foreground color: MPalette.foreground
font.pixelSize: 13 font.pixelSize: 13
font.weight: Font.Medium font.weight: Font.Medium
@@ -77,4 +52,3 @@ Control {
onLinkActivated: Qt.openUrlExternally(link) onLinkActivated: Qt.openUrlExternally(link)
} }
} }
}

View File

@@ -2,7 +2,6 @@ import QtQuick 2.12
import org.kde.kirigami 2.4 as Kirigami import org.kde.kirigami 2.4 as Kirigami
TextEdit { TextEdit {
text: "<style>pre {white-space: pre-wrap} a{color: " + Kirigami.Theme.linkColor + ";} .user-pill{}</style>" + model.display text: "<style>pre {white-space: pre-wrap} a{color: " + Kirigami.Theme.linkColor + ";} .user-pill{}</style>" + model.display

View File

@@ -10,12 +10,14 @@ Controls.ItemDelegate {
horizontalPadding: Kirigami.Units.largeSpacing horizontalPadding: Kirigami.Units.largeSpacing
verticalPadding: Kirigami.Units.smallSpacing verticalPadding: Kirigami.Units.smallSpacing
contentItem: Column { contentItem: ColumnLayout {
id: column id: column
SectionDelegate { SectionDelegate {
anchors.horizontalCenter: parent.horizontalCenter // anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(implicitWidth, parent.width) // width: Math.min(implicitWidth, parent.width)
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
visible: showSection visible: showSection
} }

View File

@@ -104,28 +104,34 @@ Kirigami.ScrollablePage {
DelegateChoice { DelegateChoice {
roleValue: "state" roleValue: "state"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
StateDelegate {} innerObject: StateDelegate {
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
}
} }
} }
DelegateChoice { DelegateChoice {
roleValue: "emote" roleValue: "emote"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
innerObject: StateDelegate {} innerObject: StateDelegate {
Layout.maximumWidth: parent.width
Layout.alignment: Qt.AlignHCenter
}
} }
} }
DelegateChoice { DelegateChoice {
roleValue: "message" roleValue: "message"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
innerObject: MessageDelegate { innerObject: MessageDelegate {
width: parent.width Layout.fillWidth: true
innerObject: TextDelegate { innerObject: TextDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -137,10 +143,10 @@ Kirigami.ScrollablePage {
DelegateChoice { DelegateChoice {
roleValue: "notice" roleValue: "notice"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
innerObject: MessageDelegate { innerObject: MessageDelegate {
width: parent.width Layout.fillWidth: true
innerObject: TextDelegate { innerObject: TextDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -152,10 +158,10 @@ Kirigami.ScrollablePage {
DelegateChoice { DelegateChoice {
roleValue: "image" roleValue: "image"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
innerObject: MessageDelegate { innerObject: MessageDelegate {
width: parent.width Layout.fillWidth: true
innerObject: ImageDelegate { innerObject: ImageDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -168,10 +174,10 @@ Kirigami.ScrollablePage {
DelegateChoice { DelegateChoice {
roleValue: "audio" roleValue: "audio"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
innerObject: MessageDelegate { innerObject: MessageDelegate {
width: parent.width Layout.fillWidth: true
innerObject: AudioDelegate { innerObject: AudioDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -183,10 +189,10 @@ Kirigami.ScrollablePage {
DelegateChoice { DelegateChoice {
roleValue: "video" roleValue: "video"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
innerObject: MessageDelegate { innerObject: MessageDelegate {
width: parent.width Layout.fillWidth: true
innerObject: AudioDelegate { innerObject: AudioDelegate {
Layout.fillWidth: true Layout.fillWidth: true
@@ -198,10 +204,10 @@ Kirigami.ScrollablePage {
DelegateChoice { DelegateChoice {
roleValue: "file" roleValue: "file"
delegate: TimelineContainer { delegate: TimelineContainer {
width: page.width width: messageListView.width
innerObject: MessageDelegate { innerObject: MessageDelegate {
width: parent.width Layout.fillWidth: true
innerObject: FileDelegate { innerObject: FileDelegate {
Layout.fillWidth: true Layout.fillWidth: true

View File

@@ -459,7 +459,7 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
} }
if (role == ShowAuthorRole) { if (role == ShowAuthorRole) {
for (auto r = row + 1; r < 0; ++r) { for (auto r = row + 1; r < rowCount(); ++r) {
auto i = index(r); auto i = index(r);
if (data(i, SpecialMarksRole) != EventStatus::Hidden) { if (data(i, SpecialMarksRole) != EventStatus::Hidden) {
return data(i, AuthorRole) != data(idx, AuthorRole) || return data(i, AuthorRole) != data(idx, AuthorRole) ||