Comment updates

This commit is contained in:
James Graham
2026-02-03 18:52:23 +00:00
parent 80047acf87
commit dff6ab66f1
15 changed files with 28 additions and 87 deletions

View File

@@ -8,7 +8,6 @@
#include <QQuickTextDocument>
#include <QTextCursor>
#include <QTextDocumentFragment>
#include <qquickitem.h>
#include "chatkeyhelper.h"
#include "chattextitemhelper.h"

View File

@@ -6,7 +6,6 @@
#include <QObject>
#include <QQuickItem>
#include <QTextCursor>
#include <qtextcursor.h>
#include "chatmarkdownhelper.h"
#include "chattextitemhelper.h"

View File

@@ -8,7 +8,6 @@
#include <QQuickTextDocument>
#include <QTextCursor>
#include <QTextDocumentFragment>
#include <qquickitem.h>
#include "chattextitemhelper.h"

View File

@@ -103,8 +103,14 @@ Item {
height: Kirigami.Units.iconSizes.smallMedium
icon.name: NeoChatConfig.sendMessageWith === 0 ? "arrow-up" : "arrow-down"
text: NeoChatConfig.sendMessageWith === 0 ? i18nc("@action:button", "Enter rich text mode") : i18nc("@action:button", "Exit rich text mode")
display: QQC2.AbstractButton.IconOnly
onClicked: NeoChatConfig.sendMessageWith = NeoChatConfig.sendMessageWith === 0 ? 1 : 0
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.text: text
}
LibNeoChat.DelegateSizeHelper {

View File

@@ -1,55 +0,0 @@
// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick
import QtCore
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import QtQuick.Dialogs
FormCard.FormCardDialog {
id: root
readonly property alias imagePath: imageField.path
title: i18nc("@title:window", "Insert Image")
standardButtons: QQC2.Dialog.Ok | QQC2.Dialog.Cancel
FileDialog {
id: fileDialog
title: i18nc("@title:window", "Select an image")
currentFolder: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
fileMode: FileDialog.OpenFile
nameFilters: [i18n("Image files (*.jpg *.jpeg *.png *.svg *.webp)"), i18n("All files (*)")]
onAccepted: imageField.path = selectedFile
}
FormCard.FormButtonDelegate {
id: imageField
property url path
text: i18nc("@label:textbox", "Image Location:")
description: path.toString().length > 0 ? path.toString().split('/').slice(-1)[0] : ''
onClicked: fileDialog.open()
}
Item {
visible: imageField.path.toString().length > 0
Layout.fillWidth: true
Layout.preferredHeight: 200
Layout.topMargin: Kirigami.Units.largeSpacing
Image {
anchors.fill: parent
source: imageField.path
fillMode: Image.PreserveAspectFit
horizontalAlignment: Image.AlignHCenter
}
}
}

View File

@@ -33,7 +33,7 @@ RowLayout {
visible: !root.contentModel.hasAttachment && (root.contentModel?.type ?? true) === LibNeoChat.ChatBarType.Room
icon.name: "mail-attachment"
text: i18n("Attach an image or file")
text: i18nc("@action:button", "Attach an image or file")
display: QQC2.AbstractButton.IconOnly
onClicked: {
@@ -48,8 +48,8 @@ RowLayout {
let warningDialog = Qt.createComponent('org.kde.kirigami', 'PromptDialog').createObject(QQC2.Overlay.overlay, {
dialogType: Kirigami.PromptDialog.Warning,
title: i18n("Attach an image or file?"),
subtitle: i18n("Attachments can only have plain text captions, all rich formatting will be removed"),
title: attachmentButton.text,
subtitle: i18nc("@Warning: that any rich text in the chat bar will be switched for the plain text equivalent.", "Attachments can only have plain text captions, all rich formatting will be removed"),
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
});
warningDialog.onAccepted.connect(() => {
@@ -87,7 +87,7 @@ RowLayout {
visible: (root.contentModel?.type ?? true) === LibNeoChat.ChatBarType.Room
icon.name: "globe"
property bool isBusy: false
text: i18n("Send a Location")
text: i18nc("@action:button", "Send a Location")
display: QQC2.AbstractButton.IconOnly
onClicked: {
@@ -122,7 +122,7 @@ RowLayout {
property bool isBusy: false
icon.name: "document-send"
text: i18n("Send message")
text: i18nc("@action:button", "Send message")
display: QQC2.AbstractButton.IconOnly
onClicked: root.contentModel.postMessage();

View File

@@ -6,7 +6,6 @@
#include "chattextitemhelper.h"
#include "clipboard.h"
#include "neochatroom.h"
#include <qnamespace.h>
ChatKeyHelper::ChatKeyHelper(QObject *parent)
: QObject(parent)

View File

@@ -156,7 +156,7 @@ void ChatTextItemHelper::initializeChars()
return;
}
QTextCursor cursor = QTextCursor(doc);
QTextCursor cursor(doc);
if (cursor.isNull()) {
return;
}

View File

@@ -5,7 +5,6 @@
#include <QObject>
#include <QQuickItem>
#include <qcontainerfwd.h>
#include "enums/chatbartype.h"
#include "enums/richformat.h"

View File

@@ -8,7 +8,7 @@
struct MessageComponent {
MessageComponentType::Type type = MessageComponentType::Other;
QString display;
QVariantMap attributes = {};
QVariantMap attributes;
bool operator==(const MessageComponent &right) const
{

View File

@@ -36,7 +36,7 @@ class CompletionModel : public QAbstractListModel
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
/**
* @brief The QQuickTextDocument that is being handled.
* @brief The ChatBarType::Type of the chat bar.
*/
Q_PROPERTY(ChatBarType::Type type READ type WRITE setType NOTIFY typeChanged)

View File

@@ -4,7 +4,6 @@
#include "chatbarmessagecontentmodel.h"
#include <QTextDocumentFragment>
#include <qlogging.h>
#include "chatbarcache.h"
#include "chatkeyhelper.h"
@@ -332,7 +331,7 @@ QModelIndex ChatBarMessageContentModel::indexForTextItem(ChatTextItemHelper *tex
bool ChatBarMessageContentModel::hasRichFormatting() const
{
for (const auto &component : m_components) {
return std::ranges::any_of(m_components, [this](const auto &component) {
if (component.type != MessageComponentType::Text) {
return true;
}
@@ -341,8 +340,8 @@ bool ChatBarMessageContentModel::hasRichFormatting() const
return true;
}
}
}
return false;
return false;
});
}
bool ChatBarMessageContentModel::hasAttachment() const

View File

@@ -18,7 +18,7 @@
/**
* @class ChatBarMessageContentModel
*
* Inherited from MessageContentModel this visulaises the content of a Quotient::RoomMessageEvent.
* Inherited from MessageContentModel this visualises the content of a Quotient::RoomMessageEvent.
*/
class ChatBarMessageContentModel : public MessageContentModel
{

View File

@@ -201,7 +201,7 @@ QVariant MessageContentModel::data(const QModelIndex &index, int role) const
}
return QVariant::fromValue<ChatBarCache *>(m_room->editCache());
}
if (role == Editable) {
if (role == EditableRole) {
return m_editableActive;
}
if (role == CurrentFocusRole) {
@@ -239,7 +239,7 @@ QHash<int, QByteArray> MessageContentModel::roleNamesStatic()
roles[MessageContentModel::ThreadRootRole] = "threadRoot";
roles[MessageContentModel::LinkPreviewerRole] = "linkPreviewer";
roles[MessageContentModel::ChatBarCacheRole] = "chatBarCache";
roles[MessageContentModel::Editable] = "editable";
roles[MessageContentModel::EditableRole] = "editable";
roles[MessageContentModel::CurrentFocusRole] = "currentFocus";
return roles;
}
@@ -254,14 +254,11 @@ bool MessageContentModel::hasComponentType(MessageComponentType::Type type) cons
!= m_components.cend();
}
bool MessageContentModel::hasComponentType(QList<MessageComponentType::Type> types) const
bool MessageContentModel::hasComponentType(const QList<MessageComponentType::Type> &types) const
{
for (const auto &type : types) {
if (hasComponentType(type)) {
return true;
}
}
return false;
return std::ranges::any_of(types, [this](const MessageComponentType::Type &type) {
return hasComponentType(type);
});
}
void MessageContentModel::forEachComponentOfType(MessageComponentType::Type type,
@@ -316,8 +313,7 @@ void MessageContentModel::updateReplyModel()
m_replyModel = new EventMessageContentModel(m_room, *eventId, true, false, this);
bool hasModel = hasComponentType(MessageComponentType::Reply);
if (!hasModel) {
if (!hasComponentType(MessageComponentType::Reply)) {
int insertRow = 0;
if (m_components.first().type == MessageComponentType::Author) {
insertRow = 1;

View File

@@ -67,7 +67,7 @@ public:
ThreadRootRole, /**< The thread root event ID for the event. */
LinkPreviewerRole, /**< The link preview details. */
ChatBarCacheRole, /**< The ChatBarCache to use. */
Editable, /**< Whether the component can be edited. */
EditableRole, /**< Whether the component can be edited. */
CurrentFocusRole, /**< Whteher the delegate should have focus. */
};
Q_ENUM(Roles)
@@ -138,7 +138,7 @@ Q_SIGNALS:
protected:
QPointer<NeoChatRoom> m_room;
QString m_eventId = {};
QString m_eventId;
/**
* @brief NeoChatDateTime for the message.
@@ -165,7 +165,7 @@ protected:
QList<MessageComponent> m_components;
bool hasComponentType(MessageComponentType::Type type) const;
bool hasComponentType(QList<MessageComponentType::Type> types) const;
bool hasComponentType(const QList<MessageComponentType::Type> &types) const;
void forEachComponentOfType(MessageComponentType::Type type, std::function<ComponentIt(ComponentIt)> function);
void forEachComponentOfType(QList<MessageComponentType::Type> types, std::function<ComponentIt(ComponentIt)> function);