diff --git a/src/qml/messages/UserMessage.qml b/src/qml/messages/UserMessage.qml index a0bc2564..a61f6177 100644 --- a/src/qml/messages/UserMessage.qml +++ b/src/qml/messages/UserMessage.qml @@ -1,208 +1,208 @@ /* * Copyright 2016 Riccardo Iaconelli * Copyright (c) 2017-2018 Montel Laurent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ import QtQuick 2.9 import org.kde.kirigami 2.1 as Kirigami import QtQuick.Controls 2.2 as QQC2 import QtQuick.Layouts 1.1 import KDE.Ruqola.RuqolaUtils 1.0 import KDE.Ruqola.ExtraColors 1.0 import KDE.Ruqola.DebugCategory 1.0 import "../js/message.js" as MessageScript; import "../common" MessageBase { property string i_messageID property var i_urls property var i_attachments property string i_own_username id: messageMain Layout.alignment: Qt.AlignTop MessageMenu { id: menu can_editing_message: i_can_editing_message starred: i_starred } RowLayout { AvatarImage { id: avatarRect avatarurl: i_avatar aliasname: i_aliasname username: i_username } ColumnLayout { Layout.fillHeight: true Kirigami.Heading { id: usernameLabel level: 5 Layout.alignment: Qt.AlignLeft font.bold: true text: i_aliasname + ' ' + i_usernameurl + (i_editedByUserName === "" ? "" : " " + i18n("(edited by %1)", i_editedByUserName)) height: avatarRect.height onLinkActivated: messageMain.linkActivated(link) MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { if (mouse.button === Qt.RightButton) { menu.x = mouse.x menu.y = mouse.y menu.open(); } } } } Column { id: fullTextColumn Layout.fillWidth: true QQC2.Label { width: parent.width id: textLabel renderType: Text.NativeRendering textFormat: Text.RichText text: i_messageText wrapMode: QQC2.Label.Wrap onLinkActivated: messageMain.linkActivated(link) MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { if (mouse.button === Qt.RightButton) { menu.x = mouse.x menu.y = mouse.y menu.open(); } } } } Column { id: urlColumn width: parent.width //TODO //Reactivate when we have a parsed url ! //see info about bugs // Repeater { // id: repeaterUrl // model: i_urls // Text { // //Display it only if url != text otherwise it's not necessary // visible: model.modelData.url !== i_originalMessage // width: urlColumn.width // text: model.modelData.description === "" ? // RuqolaUtils.markdownToRichText(model.modelData.url) : // RuqolaUtils.markdownToRichText(model.modelData.description) // wrapMode: QQC2.Label.Wrap // renderType: Text.NativeRendering // textFormat: Text.RichText // onLinkActivated: messageMain.linkActivated(link) // } // } Repeater { id: repearterReactions model: i_reactions Row { QQC2.Label { id: numberOfReact renderType: Text.NativeRendering textFormat: Text.RichText - text: model.modelData.reactionName + text: model.modelData.convertedReactionName wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } } } Repeater { id: repearterAttachments model: i_attachments Column { Text { visible: model.modelData.authorName !== "" width: urlColumn.width text: model.modelData.authorName wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } Row { QQC2.Label { id: attachmentTitle renderType: Text.NativeRendering textFormat: Text.RichText visible: model.modelData.title !== "" width: urlColumn.width text: model.modelData.displayTitle wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing onLinkActivated: { messageMain.linkActivated(link) } } DownloadButton { id: downloadButton visible: model.modelData.canDownloadAttachment onDownloadButtonClicked: { messageMain.downloadAttachment(model.modelData.link) } } Item { Layout.fillWidth: true } } QQC2.Label { visible: model.modelData.description !== "" width: urlColumn.width text: model.modelData.description wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } } } } } } TimestampText { id: timestampText timestamp: i_timestamp } } } diff --git a/src/reaction.cpp b/src/reaction.cpp index 0c579663..0d74de13 100644 --- a/src/reaction.cpp +++ b/src/reaction.cpp @@ -1,61 +1,69 @@ /* Copyright (C) 2018 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "reaction.h" - +#include Reaction::Reaction() { } +QString Reaction::convertedReactionName() const +{ + QString str = mReactionName; + const KTextToHTML::Options convertFlags = KTextToHTML::PreserveSpaces | KTextToHTML::HighlightText | KTextToHTML::ReplaceSmileys; + str = KTextToHTML::convertToHtml(str, convertFlags); + return str; +} + QString Reaction::reactionName() const { return mReactionName; } void Reaction::setReactionName(const QString &reactionName) { mReactionName = reactionName; } QStringList Reaction::userNames() const { return mUserNames; } void Reaction::setUserNames(const QStringList &userNames) { mUserNames = userNames; } int Reaction::count() const { return mUserNames.count(); } bool Reaction::operator ==(const Reaction &other) const { return (mUserNames == other.userNames()) && (mReactionName == other.reactionName()); } QDebug operator <<(QDebug d, const Reaction &t) { d << "ReactionName " << t.reactionName(); d << "UserNames " << t.userNames(); return d; } diff --git a/src/reaction.h b/src/reaction.h index e204dbc5..fa864391 100644 --- a/src/reaction.h +++ b/src/reaction.h @@ -1,50 +1,52 @@ /* Copyright (C) 2018 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef REACTION_H #define REACTION_H #include "libruqola_private_export.h" #include class LIBRUQOLACORE_TESTS_EXPORT Reaction { Q_GADGET Q_PROPERTY(int count READ count CONSTANT) Q_PROPERTY(QString reactionName READ reactionName CONSTANT) + Q_PROPERTY(QString convertedReactionName READ convertedReactionName CONSTANT) public: Reaction(); Q_REQUIRED_RESULT QString reactionName() const; void setReactionName(const QString &reactionName); Q_REQUIRED_RESULT QStringList userNames() const; void setUserNames(const QStringList &userNames); Q_REQUIRED_RESULT int count() const; Q_REQUIRED_RESULT bool operator ==(const Reaction &other) const; + Q_REQUIRED_RESULT QString convertedReactionName() const; private: QString mReactionName; QStringList mUserNames; }; Q_DECLARE_METATYPE(Reaction) Q_DECLARE_TYPEINFO(Reaction, Q_MOVABLE_TYPE); LIBRUQOLACORE_EXPORT QDebug operator <<(QDebug d, const Reaction &t); #endif // REACTION_H