mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-24 20:18:53 +03:00
Get rid of redundant constructions and make room implicit
This commit is contained in:
parent
466d3cd52c
commit
718a58d388
6 changed files with 28 additions and 10 deletions
|
@ -65,7 +65,7 @@ Item {
|
||||||
width: chat.delegateMaxWidth
|
width: chat.delegateMaxWidth
|
||||||
height: Math.max((section.item?.height ?? 0) + gridContainer.implicitHeight, 10)
|
height: Math.max((section.item?.height ?? 0) + gridContainer.implicitHeight, 10)
|
||||||
anchors.horizontalCenter: ListView.view.contentItem.horizontalCenter
|
anchors.horizontalCenter: ListView.view.contentItem.horizontalCenter
|
||||||
room: chatRoot.roommodel
|
//room: chatRoot.roommodel
|
||||||
|
|
||||||
required property var day
|
required property var day
|
||||||
required property bool isSender
|
required property bool isSender
|
||||||
|
@ -203,7 +203,7 @@ Item {
|
||||||
|
|
||||||
color: type == MtxEvent.NoticeMessage ? palette.buttonText : palette.text
|
color: type == MtxEvent.NoticeMessage ? palette.buttonText : palette.text
|
||||||
font.italic: type == MtxEvent.NoticeMessage
|
font.italic: type == MtxEvent.NoticeMessage
|
||||||
formatted: formattedBody
|
formatted: formattedBody + "a"
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
//Layout.maximumWidth: implicitWidth
|
//Layout.maximumWidth: implicitWidth
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.15
|
import QtQuick
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts
|
||||||
import im.nheko 1.0
|
import im.nheko
|
||||||
|
|
||||||
Control {
|
Control {
|
||||||
id: msgRoot
|
id: msgRoot
|
||||||
|
@ -14,6 +14,7 @@ Control {
|
||||||
property bool fitsMetadata: false //parent.width - redactedLayout.width > metadataWidth + 4
|
property bool fitsMetadata: false //parent.width - redactedLayout.width > metadataWidth + 4
|
||||||
|
|
||||||
required property string eventId
|
required property string eventId
|
||||||
|
required property Room room
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
id: redactedLayout
|
id: redactedLayout
|
||||||
|
|
|
@ -84,7 +84,8 @@ void
|
||||||
EventDelegateChooser::componentComplete()
|
EventDelegateChooser::componentComplete()
|
||||||
{
|
{
|
||||||
QQuickItem::componentComplete();
|
QQuickItem::componentComplete();
|
||||||
// eventIncubator.reset(eventIndex);
|
eventIncubator.reset(eventId_);
|
||||||
|
replyIncubator.reset(replyId);
|
||||||
// eventIncubator.forceCompletion();
|
// eventIncubator.forceCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +227,9 @@ EventDelegateChooser::DelegateIncubator::reset(QString id)
|
||||||
for (const auto choice : qAsConst(chooser.choices_)) {
|
for (const auto choice : qAsConst(chooser.choices_)) {
|
||||||
const auto &choiceValue = choice->roleValues();
|
const auto &choiceValue = choice->roleValues();
|
||||||
if (choiceValue.contains(role) || choiceValue.empty()) {
|
if (choiceValue.contains(role) || choiceValue.empty()) {
|
||||||
|
nhlog::ui()->debug(
|
||||||
|
"Instantiating type: {}, c {}", (int)role, choiceValue.contains(role));
|
||||||
|
|
||||||
if (auto child = qobject_cast<QQuickItem *>(object())) {
|
if (auto child = qobject_cast<QQuickItem *>(object())) {
|
||||||
child->setParentItem(nullptr);
|
child->setParentItem(nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,9 @@ public:
|
||||||
Q_PROPERTY(QQmlListProperty<EventDelegateChoice> choices READ choices CONSTANT FINAL)
|
Q_PROPERTY(QQmlListProperty<EventDelegateChoice> choices READ choices CONSTANT FINAL)
|
||||||
Q_PROPERTY(QQuickItem *main READ main NOTIFY mainChanged FINAL)
|
Q_PROPERTY(QQuickItem *main READ main NOTIFY mainChanged FINAL)
|
||||||
Q_PROPERTY(QQuickItem *reply READ reply NOTIFY replyChanged FINAL)
|
Q_PROPERTY(QQuickItem *reply READ reply NOTIFY replyChanged FINAL)
|
||||||
Q_PROPERTY(TimelineModel *room READ room WRITE setRoom NOTIFY roomChanged REQUIRED FINAL)
|
|
||||||
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged REQUIRED FINAL)
|
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged REQUIRED FINAL)
|
||||||
Q_PROPERTY(QString replyTo READ replyTo WRITE setReplyTo NOTIFY replyToChanged REQUIRED FINAL)
|
Q_PROPERTY(QString replyTo READ replyTo WRITE setReplyTo NOTIFY replyToChanged REQUIRED FINAL)
|
||||||
|
Q_PROPERTY(TimelineModel *room READ room WRITE setRoom NOTIFY roomChanged REQUIRED FINAL)
|
||||||
|
|
||||||
QQmlListProperty<EventDelegateChoice> choices();
|
QQmlListProperty<EventDelegateChoice> choices();
|
||||||
|
|
||||||
|
@ -74,9 +74,12 @@ public:
|
||||||
{
|
{
|
||||||
if (m != room_) {
|
if (m != room_) {
|
||||||
room_ = m;
|
room_ = m;
|
||||||
eventIncubator.reset(eventId_);
|
|
||||||
replyIncubator.reset(replyId);
|
|
||||||
emit roomChanged();
|
emit roomChanged();
|
||||||
|
|
||||||
|
if (isComponentComplete()) {
|
||||||
|
eventIncubator.reset(eventId_);
|
||||||
|
replyIncubator.reset(replyId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[[nodiscard]] TimelineModel *room() { return room_; }
|
[[nodiscard]] TimelineModel *room() { return room_; }
|
||||||
|
@ -85,12 +88,18 @@ public:
|
||||||
{
|
{
|
||||||
eventId_ = idx;
|
eventId_ = idx;
|
||||||
emit eventIdChanged();
|
emit eventIdChanged();
|
||||||
|
|
||||||
|
if (isComponentComplete())
|
||||||
|
eventIncubator.reset(eventId_);
|
||||||
}
|
}
|
||||||
[[nodiscard]] QString eventId() const { return eventId_; }
|
[[nodiscard]] QString eventId() const { return eventId_; }
|
||||||
void setReplyTo(QString id)
|
void setReplyTo(QString id)
|
||||||
{
|
{
|
||||||
replyId = id;
|
replyId = id;
|
||||||
emit replyToChanged();
|
emit replyToChanged();
|
||||||
|
|
||||||
|
if (isComponentComplete())
|
||||||
|
replyIncubator.reset(replyId);
|
||||||
}
|
}
|
||||||
[[nodiscard]] QString replyTo() const { return replyId; }
|
[[nodiscard]] QString replyTo() const { return replyId; }
|
||||||
|
|
||||||
|
|
|
@ -561,6 +561,7 @@ TimelineModel::roleNames() const
|
||||||
{ReplyTo, "replyTo"},
|
{ReplyTo, "replyTo"},
|
||||||
{ThreadId, "threadId"},
|
{ThreadId, "threadId"},
|
||||||
{Reactions, "reactions"},
|
{Reactions, "reactions"},
|
||||||
|
{Room, "room"},
|
||||||
{RoomId, "roomId"},
|
{RoomId, "roomId"},
|
||||||
{RoomName, "roomName"},
|
{RoomName, "roomName"},
|
||||||
{RoomTopic, "roomTopic"},
|
{RoomTopic, "roomTopic"},
|
||||||
|
@ -899,6 +900,8 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
|
||||||
auto id = relations(event).replaces().value_or(event_id(event));
|
auto id = relations(event).replaces().value_or(event_id(event));
|
||||||
return QVariant::fromValue(events.reactions(id));
|
return QVariant::fromValue(events.reactions(id));
|
||||||
}
|
}
|
||||||
|
case Room:
|
||||||
|
return QVariant::fromValue(this);
|
||||||
case RoomId:
|
case RoomId:
|
||||||
return QVariant(room_id_);
|
return QVariant(room_id_);
|
||||||
case RoomName:
|
case RoomName:
|
||||||
|
|
|
@ -267,6 +267,7 @@ public:
|
||||||
ReplyTo,
|
ReplyTo,
|
||||||
ThreadId,
|
ThreadId,
|
||||||
Reactions,
|
Reactions,
|
||||||
|
Room,
|
||||||
RoomId,
|
RoomId,
|
||||||
RoomName,
|
RoomName,
|
||||||
RoomTopic,
|
RoomTopic,
|
||||||
|
|
Loading…
Reference in a new issue