Release threads removing the feature flag.

This mr performs some final cleanup to make sure the threads are sized correctly and it all works with the new chatbar
This commit is contained in:
James Graham
2026-02-15 15:26:49 +00:00
committed by Joshua Goins
parent 85b731e9fb
commit 7e6b79d5d4
18 changed files with 60 additions and 93 deletions

View File

@@ -181,7 +181,7 @@ KirigamiComponents.ConvergentContextMenu {
Kirigami.Action {
id: replyThreadAction
visible: (root.messageComponentType !== MessageComponentType.Other || NeoChatConfig.relateAnyEvent) && NeoChatConfig.threads
visible: (root.messageComponentType !== MessageComponentType.Other || NeoChatConfig.relateAnyEvent)
text: i18nc("@action:inmenu", "Reply in Thread")
icon.name: "dialog-messages"
onTriggered: {

View File

@@ -87,7 +87,6 @@ void MessageDelegateBase::setIsThreaded(bool isThreaded)
return;
}
m_isThreaded = isThreaded;
setAlwaysFillWidth(m_isThreaded || m_compactMode);
setPercentageValues(m_isThreaded || m_compactMode);
updateAvatar();
Q_EMIT isThreadedChanged();
@@ -138,11 +137,8 @@ void MessageDelegateBase::setPercentageValues(bool fillWidth)
void MessageDelegateBase::setContentPadding()
{
qreal selectionOffset = (m_showSelection && m_selectionItem) ? m_selectionItem->implicitWidth() + (m_spacing * 2) : 0;
qreal avatarOffset = (leaveAvatarSpace() ? m_avatarSize + m_spacing : 0);
m_contentSizeHelper.setLeftPadding(m_sizeHelper.leftX() + selectionOffset + avatarOffset);
m_contentSizeHelper.setRightPadding(m_sizeHelper.rightPadding());
m_contentSizeHelper.setLeftPadding(m_sizeHelper.leftX());
m_contentSizeHelper.setRightPadding(m_compactMode ? m_sizeHelper.rightPadding() : 0);
}
qreal MessageDelegateBase::maxContentWidth() const
@@ -229,7 +225,7 @@ bool MessageDelegateBase::leaveAvatarSpace() const
bool MessageDelegateBase::showAvatar() const
{
return m_enableAvatars && m_showAuthor && !showMessageOnRight();
return m_enableAvatars && (m_showAuthor || m_isThreaded) && !showMessageOnRight();
}
void MessageDelegateBase::updateAvatar()
@@ -434,7 +430,7 @@ void MessageDelegateBase::setCompactMode(bool compactMode)
return;
}
m_compactMode = compactMode;
setAlwaysFillWidth(m_isThreaded || m_compactMode);
setAlwaysFillWidth(m_compactMode);
setPercentageValues(m_isThreaded || m_compactMode);
setBaseRightPadding();
@@ -669,7 +665,7 @@ void MessageDelegateBase::updateImplicitHeight()
bool MessageDelegateBase::showMessageOnRight() const
{
return m_showLocalMessagesOnRight && !m_alwaysFillWidth && m_author && m_author->isLocalMember();
return m_showLocalMessagesOnRight && !m_compactMode && !m_isThreaded && m_author && m_author->isLocalMember();
}
void MessageDelegateBase::resizeContent()
@@ -697,22 +693,25 @@ void MessageDelegateBase::resizeContent()
nextY += m_sectionItem->implicitHeight() + m_spacing;
}
qreal yAdd = 0.0;
qreal nextX = m_sizeHelper.leftX();
if (m_showSelection && m_selectionItem) {
m_selectionItem->setPosition(QPointF(m_sizeHelper.leftX(), nextY));
m_selectionItem->setPosition(QPointF(nextX, nextY));
m_selectionItem->setSize(QSizeF(m_selectionItem->implicitWidth(), m_selectionItem->implicitHeight()));
yAdd = m_selectionItem->implicitHeight();
nextX += m_selectionItem->implicitWidth() + m_spacing;
}
if (showAvatar() && m_avatarItem) {
m_avatarItem->setPosition(
QPointF(m_showSelection && m_selectionItem ? m_sizeHelper.leftX() + m_selectionItem->implicitWidth() + (m_spacing * 2) : m_sizeHelper.leftX(),
nextY));
m_avatarItem->setPosition(QPointF(nextX, nextY));
m_avatarItem->setSize(QSizeF(m_avatarItem->implicitWidth(), m_avatarItem->implicitHeight()));
yAdd = std::max(yAdd, m_avatarItem->implicitHeight());
nextX += m_avatarItem->implicitWidth() + m_spacing;
} else if (leaveAvatarSpace()) {
nextX += m_avatarSize + m_spacing;
}
if (m_contentItem) {
const auto contentItemWidth =
m_alwaysFillWidth ? m_contentSizeHelper.availableWidth() : std::min(m_contentItem->implicitWidth(), m_contentSizeHelper.availableWidth());
const auto contentX = showMessageOnRight() ? m_sizeHelper.rightX() - contentItemWidth - 1 : m_contentSizeHelper.leftPadding();
const auto contentItemWidth = m_compactMode || m_isThreaded ? m_contentSizeHelper.availableWidth() - nextX
: std::min(m_contentItem->implicitWidth(), m_contentSizeHelper.availableWidth());
const auto contentX = showMessageOnRight() ? m_sizeHelper.rightX() - contentItemWidth - 1 : nextX;
m_contentItem->setPosition(QPointF(contentX, nextY));
m_contentItem->setSize(QSizeF(contentItemWidth, m_contentItem->implicitHeight()));
yAdd = std::max(yAdd, m_contentItem->implicitHeight());

View File

@@ -27,7 +27,6 @@ using namespace Quotient;
std::function<bool(const Quotient::RoomEvent *)> MessageModel::m_hiddenFilter = [](const Quotient::RoomEvent *) -> bool {
return false;
};
bool MessageModel::m_threadsEnabled = false;
MessageModel::MessageModel(QObject *parent)
: QAbstractListModel(parent)
@@ -40,10 +39,6 @@ MessageModel::MessageModel(QObject *parent)
connect(this, &MessageModel::modelReset, this, [this]() {
m_resetting = false;
});
connect(this, &MessageModel::threadsEnabledChanged, this, [this]() {
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {DelegateTypeRole, ContentModelRole, IsThreadedRole, SpecialMarksRole});
});
}
NeoChatRoom *MessageModel::room() const
@@ -151,7 +146,7 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
}
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get());
if (m_threadsEnabled && roomMessageEvent && roomMessageEvent->isThreaded()) {
if (roomMessageEvent && roomMessageEvent->isThreaded()) {
return QVariant::fromValue<EventMessageContentModel *>(
ContentProvider::self().contentModelForEvent(eventRoom, roomMessageEvent->threadRootEventId()));
}
@@ -200,7 +195,7 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
}
auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get());
if (m_threadsEnabled && roomMessageEvent && (roomMessageEvent->isThreaded() || eventRoom->threads().contains(event.value().get().id()))) {
if (roomMessageEvent && (roomMessageEvent->isThreaded() || eventRoom->threads().contains(event.value().get().id()))) {
const auto &thread = eventRoom->threads().value(roomMessageEvent->isThreaded() ? roomMessageEvent->threadRootEventId() : event.value().get().id());
if (thread.latestEventId != event.value().get().id()) {
return EventStatus::Hidden;
@@ -231,9 +226,6 @@ QVariant MessageModel::data(const QModelIndex &idx, int role) const
}
if (role == IsThreadedRole) {
if (!m_threadsEnabled) {
return false;
}
if (auto roomMessageEvent = eventCast<const RoomMessageEvent>(&event.value().get())) {
return roomMessageEvent->isThreaded();
}
@@ -559,9 +551,4 @@ void MessageModel::setHiddenFilter(std::function<bool(const Quotient::RoomEvent
MessageModel::m_hiddenFilter = hiddenFilter;
}
void MessageModel::setThreadsEnabled(bool enableThreads)
{
MessageModel::m_threadsEnabled = enableThreads;
}
#include "moc_messagemodel.cpp"

View File

@@ -124,8 +124,6 @@ public:
static void setHiddenFilter(std::function<bool(const Quotient::RoomEvent *)> hiddenFilter);
static void setThreadsEnabled(bool enableThreads);
Q_SIGNALS:
/**
* @brief Emitted when the room is changed.
@@ -170,8 +168,6 @@ Q_SIGNALS:
*/
void newLocalUserEventAdded();
void threadsEnabledChanged();
protected:
QPointer<NeoChatRoom> m_room;
QPersistentModelIndex m_lastReadEventIndex;
@@ -200,5 +196,4 @@ private:
void createEventObjects(const Quotient::RoomEvent *event);
static std::function<bool(const Quotient::RoomEvent *)> m_hiddenFilter;
static bool m_threadsEnabled;
};

View File

@@ -16,8 +16,6 @@ TimelineModel::TimelineModel(QObject *parent)
addSourceModel(m_timelineMessageModel);
m_timelineEndModel = new TimelineEndModel(this);
addSourceModel(m_timelineEndModel);
connect(this, &TimelineModel::threadsEnabledChanged, m_timelineMessageModel, &TimelineMessageModel::threadsEnabledChanged);
}
NeoChatRoom *TimelineModel::room() const

View File

@@ -156,7 +156,6 @@ public:
Q_SIGNALS:
void roomChanged();
void threadsEnabledChanged();
private:
TimelineMessageModel *m_timelineMessageModel = nullptr;