diff --git a/src/message.cpp b/src/message.cpp index 8d210f37..64bb16a2 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -1,540 +1,541 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "message.h" #include "ruqola_debug.h" #include #include #include Message::Message() { } void Message::parseMessage(const QJsonObject &o) { const QString roomId = o.value(QLatin1String("rid")).toString(); //t ? I can't find it. const QString type = o.value(QLatin1String("t")).toString(); mMessageId = o.value(QLatin1String("_id")).toString(); mRoomId = roomId; mText = o.value(QLatin1String("msg")).toString(); mTimeStamp = (qint64)o.value(QLatin1String("ts")).toObject().value(QLatin1String("$date")).toDouble(); mUsername = o.value(QLatin1String("u")).toObject().value(QLatin1String("username")).toString(); mUserId = o.value(QLatin1String("u")).toObject().value(QLatin1String("_id")).toString(); mUpdatedAt = o.value(QLatin1String("_updatedAt")).toObject().value(QLatin1String("$date")).toDouble(); mEditedAt = o.value(QLatin1String("editedAt")).toObject().value(QLatin1String("$date")).toDouble(); mEditedByUsername = o.value(QLatin1String("editedBy")).toObject().value(QLatin1String("username")).toString(); mEditedByUserId = o.value(QLatin1String("editedBy")).toObject().value(QLatin1String("userID")).toString(); mAlias = o.value(QLatin1String("alias")).toString(); mAvatar = o.value(QLatin1String("avatar")).toString(); mGroupable = o.value(QLatin1String("groupable")).toBool(); mParseUrls = o.value(QLatin1String("parseUrls")).toBool(); + mStarred = o.contains(QStringLiteral("starred")); //TODO add starred ! mMessageType = Message::MessageType::NormalText; if (!type.isEmpty()) { mSystemMessageType = type; mMessageType = System; } parseMentions(o.value(QLatin1String("mentions")).toArray()); parseAttachment(o.value(QLatin1String("attachments")).toArray()); parseUrls(o.value(QLatin1String("urls")).toArray()); } void Message::parseMentions(const QJsonArray &mentions) { mMentions.clear(); for (int i = 0; i < mentions.size(); i++) { const QJsonObject mention = mentions.at(i).toObject(); mMentions.insert(mention.value(QLatin1String("username")).toString(), mention.value(QLatin1String("_id")).toString()); } } void Message::parseUrls(const QJsonArray &urls) { mUrls.clear(); if (!urls.isEmpty()) { qCDebug(RUQOLA_LOG) << " void Message::urls(const QJsonObject &attachements)"< Message::mentions() const { return mMentions; } void Message::setMentions(const QMap &mentions) { mMentions = mentions; } void Message::parseAttachment(const QJsonArray &attachments) { mAttachements.clear(); if (!attachments.isEmpty()) { qCDebug(RUQOLA_LOG) << " void Message::parseAttachment(const QJsonObject &attachements)"< Message::attachements() const { return mAttachements; } void Message::setAttachements(const QVector &attachements) { mAttachements = attachements; } QVector Message::urls() const { return mUrls; } void Message::setUrls(const QVector &urls) { mUrls = urls; } QString Message::alias() const { return mAlias; } void Message::setAlias(const QString &alias) { mAlias = alias; } QString Message::editedByUserId() const { return mEditedByUserId; } void Message::setEditedByUserId(const QString &editedByUserId) { mEditedByUserId = editedByUserId; } QString Message::editedByUsername() const { return mEditedByUsername; } void Message::setEditedByUsername(const QString &editedByUsername) { mEditedByUsername = editedByUsername; } qint64 Message::editedAt() const { return mEditedAt; } void Message::setEditedAt(const qint64 &editedAt) { mEditedAt = editedAt; } qint64 Message::updatedAt() const { return mUpdatedAt; } void Message::setUpdatedAt(const qint64 &updatedAt) { mUpdatedAt = updatedAt; } QString Message::userId() const { return mUserId; } void Message::setUserId(const QString &userId) { mUserId = userId; } QString Message::username() const { return mUsername; } void Message::setUsername(const QString &username) { mUsername = username; } qint64 Message::timeStamp() const { return mTimeStamp; } void Message::setTimeStamp(const qint64 &timeStamp) { mTimeStamp = timeStamp; } QString Message::text() const { return mText; } void Message::setText(const QString &text) { mText = text; } QString Message::messageId() const { return mMessageId; } void Message::setMessageId(const QString &messageId) { mMessageId = messageId; } QString Message::roomId() const { return mRoomId; } void Message::setRoomId(const QString &roomId) { mRoomId = roomId; } QString Message::avatar() const { return mAvatar; } void Message::setAvatar(const QString &avatar) { mAvatar = avatar; } bool Message::parseUrls() const { return mParseUrls; } void Message::setParseUrls(bool parseUrls) { mParseUrls = parseUrls; } bool Message::groupable() const { return mGroupable; } void Message::setGroupable(bool groupable) { mGroupable = groupable; } Message Message::fromJSon(const QJsonObject &o) { Message message; message.mMessageId = o[QStringLiteral("messageID")].toString(); message.mRoomId = o[QStringLiteral("roomID")].toString(); message.mText = o[QStringLiteral("message")].toString(); message.mTimeStamp = (qint64)o[QStringLiteral("timestamp")].toDouble(); message.mUsername = o[QStringLiteral("username")].toString(); message.mUserId = o[QStringLiteral("userID")].toString(); message.mUpdatedAt = (qint64)o[QStringLiteral("updatedAt")].toDouble(); message.mEditedAt = (qint64)o[QStringLiteral("editedAt")].toDouble(); message.mEditedByUsername = o[QStringLiteral("editedByUsername")].toString(); message.mEditedByUserId = o[QStringLiteral("editedByUserID")].toString(); message.mAlias = o[QStringLiteral("alias")].toString(); message.mAvatar = o[QStringLiteral("avatar")].toString(); message.mGroupable = o[QStringLiteral("groupable")].toBool(); message.mParseUrls = o[QStringLiteral("parseUrls")].toBool(); message.mSystemMessageType = o[QStringLiteral("type")].toString(); message.mMessageType = o[QStringLiteral("messageType")].toVariant().value(); const QJsonArray attachmentsArray = o.value(QLatin1String("attachments")).toArray(); for (int i = 0; i < attachmentsArray.count(); ++i) { const QJsonObject attachment = attachmentsArray.at(i).toObject(); const MessageAttachment att = MessageAttachment::fromJSon(attachment); if (!att.isEmpty()) { message.mAttachements.append(att); } } const QJsonArray urlsArray = o.value(QLatin1String("urls")).toArray(); for (int i = 0; i < urlsArray.count(); ++i) { const QJsonObject urlObj = urlsArray.at(i).toObject(); const MessageUrl url = MessageUrl::fromJSon(urlObj); if (!url.isEmpty()) { message.mUrls.append(url); } } const QJsonArray mentionsArray = o.value(QLatin1String("mentions")).toArray(); for (int i = 0; i < mentionsArray.count(); ++i) { const QJsonObject mention = mentionsArray.at(i).toObject(); qCDebug(RUQOLA_LOG) << " mention"<(message.mMessageType)); //Attachments if (!message.mAttachements.isEmpty()) { QJsonArray array; const int nbAttachment{ message.mAttachements.count() }; for (int i = 0; i < nbAttachment; ++i) { array.append(MessageAttachment::serialize(message.mAttachements.at(i))); } o[QStringLiteral("attachments")] = array; } //Urls if (!message.mUrls.isEmpty()) { QJsonArray array; const int nbUrls{ message.mUrls.count() }; for (int i = 0; i < nbUrls; ++i) { array.append(MessageUrl::serialize(message.mUrls.at(i))); } o[QStringLiteral("urls")] = array; } d.setObject(o); return d.toBinaryData(); } QDebug operator <<(QDebug d, const Message &t) { d << "mMessageId : " << t.messageId(); d << "mText: " << t.text(); d << "mTimeStamp: " << t.timeStamp(); d << "mUsername: " << t.username(); d << "mUserId: " << t.userId(); d << "mUpdatedAt: " << t.updatedAt(); d << "mEditedAt: " << t.editedAt(); d << "mEditedByUsername: " << t.editedByUsername(); d << "mEditedByUserId: " << t.editedByUserId(); d << "mAlias: " << t.alias(); d << "mSystemMessageType: " << t.systemMessageType(); d << "mRoomId: " << t.roomId(); d << "mAvatar: " << t.avatar(); d << "mGroupable: " << t.groupable(); d << "mParseUrls: " << t.parseUrls(); d << "mStarred: " << t.starred(); for (int i = 0; i < t.attachements().count(); ++i) { d << "Attachment :" << t.attachements().at(i); } for (int i = 0; i < t.urls().count(); ++i) { d << "Urls :" << t.urls().at(i); } d << "Mentions :" << t.mentions(); d << "mMessageType: " << t.messageType(); return d; } diff --git a/src/qml/ActiveChat.qml b/src/qml/ActiveChat.qml index d5b8d14f..3d6b9dc1 100644 --- a/src/qml/ActiveChat.qml +++ b/src/qml/ActiveChat.qml @@ -1,100 +1,100 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 import org.kde.kirigami 2.1 as Kirigami ListView { id: activeChat signal openDirectChannel(string userName) signal jitsiCallConfActivated() signal deleteMessage(string messageId) signal downloadAttachment(string url) signal editMessage(string messageId) signal replyMessage(string messageId) - signal setFavoriteMessage(string messageId) + signal setFavoriteMessage(string messageId, bool starred) signal displayImage(url imageUrl, string title) property QtObject rcAccount property string roomId: "" spacing: Kirigami.Units.smallSpacing onCountChanged: { positionViewAtIndex(count - 1, ListView.Beginning) } Component.onCompleted: positionViewAtIndex(count - 1, ListView.End) visible: count > 0 onDragEnded : { if (roomId !== "") { rcAccount.loadHistory(roomId) } } delegate: FancyMessageDelegate { anchors.left: parent.left anchors.right: parent.right anchors.rightMargin: Kirigami.Units.largeSpacing anchors.leftMargin: Kirigami.Units.largeSpacing i_messageText: messageText i_username: username i_aliasname: alias i_systemMessageType: type i_timestamp: timestamp i_messageID: messageID i_messageType: messagetype i_avatar: avatar == "" ? rcAccount.avatarUrl(userID) : avatar i_urls: urls i_attachments: attachments i_date: date i_own_username: rcAccount.userName i_can_editing_message: canEditingMessage i_starred: starred onOpenDirectChannel: { activeChat.openDirectChannel(userName) } onJitsiCallConfActivated: { activeChat.jitsiCallConfActivated() } onDeleteMessage: { activeChat.deleteMessage(messageId) } onDownloadAttachment: { activeChat.downloadAttachment(url) } onEditMessage: { activeChat.editMessage(messageId) } onReplyMessage: { activeChat.replyMessage(messageId) } onSetFavoriteMessage: { - activeChat.setFavoriteMessage(messageId) + activeChat.setFavoriteMessage(messageId, starred) } onDisplayImage: { activeChat.displayImage(imageUrl, title) } } } diff --git a/src/qml/FancyMessageDelegate.qml b/src/qml/FancyMessageDelegate.qml index 1437cdc4..311051cb 100644 --- a/src/qml/FancyMessageDelegate.qml +++ b/src/qml/FancyMessageDelegate.qml @@ -1,210 +1,210 @@ /* * 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 KDE.Ruqola.RuqolaUtils 1.0 import KDE.Ruqola.Message 1.0 import QtQuick.Controls 2.2 import org.kde.kirigami 2.1 as Kirigami import KDE.Ruqola.ExtraColors 1.0 import QtQuick.Layouts 1.1 import KDE.Ruqola.RocketChatAccount 1.0 import KDE.Ruqola.DebugCategory 1.0 Rectangle { id: messageMain property string i_messageID property string i_messageText property string i_username property bool i_systemMessage property string i_systemMessageType property string i_avatar property string i_aliasname property var i_timestamp property var i_messageType property var i_urls property var i_attachments property string i_date property string i_own_username property bool i_can_editing_message property bool i_starred color: RuqolaSingleton.backgroundColor implicitHeight: 4*Kirigami.Units.smallSpacing + loaded.item.implicitHeight implicitWidth: 150 signal openDirectChannel(string userName) signal jitsiCallConfActivated() signal deleteMessage(string messageId) signal downloadAttachment(string url) signal editMessage(string messageId) signal replyMessage(string messageId) - signal setFavoriteMessage(string messageId) + signal setFavoriteMessage(string messageId, bool starred) signal displayImage(url imageUrl, string title) Loader { id: loaded anchors.fill: parent Component.onCompleted: { if (i_messageType === Message.System) { if (i_systemMessageType === "jitsi_call_started") { console.log(RuqolaDebugCategorySingleton.category, "Jitsi"); setSource("messages/JitsiVideoMessage.qml", { i_messageText: i_messageText, i_username: i_username, i_aliasname: i_aliasname, i_timestamp: i_timestamp, i_systemMessageType: i_systemMessageType, i_messageID: i_messageID, i_avatar: i_avatar, i_date: i_date, rcAccount: appid.rocketChatAccount } ) } else { console.log(RuqolaDebugCategorySingleton.category, "System Message"); setSource("messages/SystemMessage.qml", { i_messageText: i_messageText, i_username: i_username, i_aliasname: i_aliasname, i_timestamp: i_timestamp, i_systemMessageType: i_systemMessageType, i_messageID: i_messageID, i_date: i_date, rcAccount: appid.rocketChatAccount } ) } } else if (i_messageType === Message.NormalText || i_messageType === Message.File) { console.log(RuqolaDebugCategorySingleton.category, "User Message"); setSource("messages/UserMessage.qml", { i_messageText: i_messageText, i_username: i_username, i_aliasname: i_aliasname, i_timestamp: i_timestamp, i_messageID: i_messageID, i_avatar: i_avatar, i_urls: i_urls, i_attachments: i_attachments, i_date: i_date, i_own_username: i_own_username, rcAccount: appid.rocketChatAccount, i_can_editing_message: i_can_editing_message, i_starred: i_starred } ) } else if (i_messageType === Message.Audio) { console.log(RuqolaDebugCategorySingleton.category, "Audio"); setSource("messages/AttachmentMessageAudio.qml", { i_messageText: i_messageText, i_username: i_username, i_aliasname: i_aliasname, i_timestamp: i_timestamp, i_messageID: i_messageID, i_avatar: i_avatar, i_urls: i_urls, i_attachments: i_attachments, i_date: i_date, rcAccount: appid.rocketChatAccount }) } else if (i_messageType === Message.Video) { console.log(RuqolaDebugCategorySingleton.category, "Video"); setSource("messages/AttachmentMessageVideo.qml", { i_messageText: i_messageText, i_username: i_username, i_aliasname: i_aliasname, i_timestamp: i_timestamp, i_messageID: i_messageID, i_avatar: i_avatar, i_urls: i_urls, i_attachments: i_attachments, i_date: i_date, rcAccount: appid.rocketChatAccount }) } else if (i_messageType === Message.Image) { console.log(RuqolaDebugCategorySingleton.category, "Image"); setSource("messages/AttachmentMessageImage.qml", { i_messageText: i_messageText, i_username: i_username, i_aliasname: i_aliasname, i_timestamp: i_timestamp, i_messageID: i_messageID, i_avatar: i_avatar, i_urls: i_urls, i_attachments: i_attachments, i_date: i_date, rcAccount: appid.rocketChatAccount }) } else { console.log(RuqolaDebugCategorySingleton.category, "Unknown message type: " + i_messageType) } } } Connections { target: loaded.item onLinkActivated: { if (link.startsWith("ruqola:/room/")) { appid.rocketChatAccount.openChannel(RuqolaUtils.extractRoomUserFromUrl(link)); } else if (link.startsWith("ruqola:/user/")) { messageMain.openDirectChannel(RuqolaUtils.extractRoomUserFromUrl(link)) } else { RuqolaUtils.openUrl(link); } } onJitsiCallConfActivated: { messageMain.jitsiCallConfActivated() } onDeleteMessage: { messageMain.deleteMessage(messageId) } onDownloadAttachment: { messageMain.downloadAttachment(url) } onEditMessage: { messageMain.editMessage(messageId) } onReplyMessage: { messageMain.replyMessage(messageId) } onSetFavoriteMessage: { - messageMain.setFavoriteMessage(messageId) + messageMain.setFavoriteMessage(messageId, starred) } onDisplayImage: { messageMain.displayImage(imageUrl, title) } } } diff --git a/src/qml/MainComponent.qml b/src/qml/MainComponent.qml index 1cc920e9..7969cb4c 100644 --- a/src/qml/MainComponent.qml +++ b/src/qml/MainComponent.qml @@ -1,254 +1,254 @@ /* * Copyright 2016 Riccardo Iaconelli * Copyright (C) 2017-2018 Laurent Montel * * 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 QtQuick.Controls 1.4 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.2 as QQC2 import KDE.Ruqola.RuqolaUtils 1.0 import KDE.Ruqola.Ruqola 1.0 import KDE.Ruqola.DDPClient 1.0 import KDE.Ruqola.RoomFilterProxyModel 1.0 import org.kde.kirigami 2.1 as Kirigami import KDE.Ruqola.DebugCategory 1.0 Component { id: mainComponent Kirigami.ScrollablePage { id: mainWidget leftPadding: Kirigami.Units.smallSpacing rightPadding: Kirigami.Units.smallSpacing topPadding: Kirigami.Units.smallSpacing bottomPadding: Kirigami.Units.smallSpacing header: Column { RowLayout { anchors.left: parent.left anchors.right: parent.right anchors.leftMargin: 2*Kirigami.Units.smallSpacing visible: appid.selectedRoom ToolButton { iconName: "favorite" checkable: true Binding on checked { value: appid.selectedRoom && appid.selectedRoom.favorite } onCheckedChanged: { appid.rocketChatAccount.changeFavorite(appid.selectedRoomID, checked) } } Kirigami.Heading { text: "#" + (appid.selectedRoom ? appid.selectedRoom.name : "") level: 3 font.bold: true } Item { Layout.fillWidth: true } ToolButton { iconName: "settings-configure" onClicked: menu.open(); QQC2.Menu { id: menu y: parent.height QQC2.MenuItem { text: i18n("Create New Channel") onTriggered: { createNewChannelDialog.initializeAndOpen() } } RuqolaMenuSeparator { } QQC2.MenuItem { text: i18n("Channel Info") onTriggered: { channelInfoDialog.initializeAndOpen() } } RuqolaMenuSeparator { } QQC2.MenuItem { text: i18n("Video Chat") onTriggered: { if (appid.selectedRoom) { appid.rocketChatAccount.createJitsiConfCall(appid.selectedRoom); } } } RuqolaMenuSeparator { } QQC2.MenuItem { text: "Test add user !" onTriggered: { addUserDialog.initializeAndOpen() } } RuqolaMenuSeparator { } QQC2.MenuItem { text: i18n("Take a Video Message") onTriggered: { takeVideoMessage.open(); } } RuqolaMenuSeparator {} QQC2.MenuItem { text: i18n("Load Recent History") onTriggered: { appid.rocketChatAccount.loadHistory(appid.selectedRoomID); } } } } } QQC2.Label { visible: appid.selectedRoom && (appid.selectedRoom.topic !== "") text: appid.selectedRoom ? appid.selectedRoom.topic : "" font.italic: true anchors.right: parent.right anchors.left: parent.left anchors.margins: 2*Kirigami.Units.smallSpacing wrapMode: QQC2.Label.Wrap } QQC2.Label { visible: appid.selectedRoom && (appid.selectedRoom.announcement !== "") text: appid.selectedRoom ? appid.selectedRoom.announcement : "" anchors.right: parent.right anchors.left: parent.left anchors.margins: 2*Kirigami.Units.smallSpacing wrapMode: QQC2.Label.Wrap } Rectangle { color: Kirigami.Theme.textColor height:1 anchors.right: parent.right anchors.left: parent.left opacity: .5 visible: appid.selectedRoom } } ActiveChat { id: activeChat model: appid.model rcAccount: appid.rocketChatAccount roomId: appid.selectedRoomID onOpenDirectChannel: { openDirectChannelDialog.username = userName; openDirectChannelDialog.open() } onJitsiCallConfActivated: { appid.rocketChatAccount.joinJitsiConfCall(roomId) } onDeleteMessage: { deleteMessageDialog.msgId = messageId deleteMessageDialog.open() } onDownloadAttachment: { downloadFileDialog.fileToSaveUrl = url downloadFileDialog.open() } onEditMessage: { userInputMessage.messageId = messageId; //TODO show message text too console.log(RuqolaDebugCategorySingleton.category, "edit message : " + messageId) } onReplyMessage: { console.log(RuqolaDebugCategorySingleton.category, "reply message : " + messageId) } onSetFavoriteMessage: { - appid.rocketChatAccount.starMessage(messageId, roomId, true) + appid.rocketChatAccount.starMessage(messageId, roomId, starred) } onDisplayImage: { displayImageDialog.iUrl = imageUrl displayImageDialog.title = title displayImageDialog.open(); } OpenDirectChannelDialog { id: openDirectChannelDialog onOpenDirectChannel: { appid.rocketChatAccount.openDirectChannel(userName); } } DeleteMessageDialog { id: deleteMessageDialog onDeleteMessage: { appid.rocketChatAccount.deleteMessage(messageId) } } DownloadFileDialog { id: downloadFileDialog onAccepted: { if (fileUrl != "") { //console.log(RuqolaDebugCategorySingleton.category, "You chose: " + fileUrl) appid.rocketChatAccount.downloadFile(fileToSaveUrl, fileUrl) } else { console.log(RuqolaDebugCategorySingleton.category, "No file selected"); } } } DisplayImageDialog { id: displayImageDialog } UploadFileDialog { id: uploadFileDialog onUploadFile: { appid.rocketChatAccount.uploadFile(description, filename) } } } footer: UserInput { id: userInputMessage rcAccount: appid.rocketChatAccount visible: appid.selectedRoom && (appid.selectedRoom.readOnly === false) anchors.bottom: mainWidget.bottom messageLineText: rcAccount.getUserCurrentMessage(appid.selectedRoomID) onTextEditing: { rcAccount.textEditing(appid.selectedRoomID, str) appid.userInputMessageText = str; } onClearUnreadMessages: { rcAccount.clearUnreadMessages(appid.selectedRoomID) } onUploadFile: { uploadFileDialog.initializeAndOpen() } } }// mainWidget Item } diff --git a/src/qml/messages/MessageBase.qml b/src/qml/messages/MessageBase.qml index 490d5ad3..f018ce05 100644 --- a/src/qml/messages/MessageBase.qml +++ b/src/qml/messages/MessageBase.qml @@ -1,50 +1,50 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Layouts 1.1 ColumnLayout { signal linkActivated(string link) signal jitsiCallConfActivated() signal deleteMessage(string messageId) signal editMessage(string messageId) signal replyMessage(string messageId) - signal setFavoriteMessage(string messageId) + signal setFavoriteMessage(string messageId, bool starred) signal downloadAttachment(string url) signal displayImage(url imageUrl, string title) property string i_date property string i_username property string i_aliasname property string i_avatar property var i_timestamp property string i_messageText property var i_urls property var i_attachments property QtObject rcAccount NewDateLabel { id: newDateRect date: i_date } } diff --git a/src/qml/messages/MessageMenu.qml b/src/qml/messages/MessageMenu.qml index 6bb926d1..4a428a88 100644 --- a/src/qml/messages/MessageMenu.qml +++ b/src/qml/messages/MessageMenu.qml @@ -1,80 +1,80 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 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.DebugCategory 1.0 QQC2.Menu { id: menu property bool can_editing_message property bool starred function updateFavoriteLabelText() { return (i_starred === true) ? i18n("Remove as Favorite") : i18n("Set as Favorite") } QQC2.MenuItem { id: editMessageItem contentItem: QQC2.Label { text: i18n("Edit") } onTriggered: { messageMain.editMessage(i_messageID); console.log(RuqolaDebugCategorySingleton.category, "Edit", i_messageID, i_messageText); console.log(RuqolaDebugCategorySingleton.category, "User", i_own_username, i_username); } } QQC2.MenuItem { contentItem: QQC2.Label { text: i18n("Reply") } onTriggered: { console.log(RuqolaDebugCategorySingleton.category, "Reply to", i_messageID); messageMain.replyMessage(i_messageID); } } QQC2.MenuItem { contentItem: QQC2.Label { id: favoriteLabel text: updateFavoriteLabelText() } onTriggered: { console.log(RuqolaDebugCategorySingleton.category, "Set as favorite", i_messageID); - messageMain.setFavoriteMessage(i_messageID); + messageMain.setFavoriteMessage(i_messageID, !starred); } } QQC2.MenuItem { visible: i_username === i_own_username contentItem: QQC2.Label { text: i18n("Delete") } onTriggered: { messageMain.deleteMessage(i_messageID); } } onAboutToShow: { editMessageItem.visible = (i_username === i_own_username) && rcAccount.allowEditingMessages() && can_editing_message favoriteLabel.text = updateFavoriteLabelText() } }