diff --git a/src/qml/messages/AttachmentMessageAudio.qml b/src/qml/messages/AttachmentMessageAudio.qml index 478d43ee..cad40b65 100644 --- a/src/qml/messages/AttachmentMessageAudio.qml +++ b/src/qml/messages/AttachmentMessageAudio.qml @@ -1,146 +1,161 @@ /* 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 QtMultimedia 5.8 import QtQuick.Controls 2.2 as QQC2 import org.kde.kirigami 2.1 as Kirigami import QtQuick.Layouts 1.1 import KDE.Ruqola.DebugCategory 1.0 import "../js/convert.js" as ConvertScript; import "../common" MessageBase { id: attachmentAudio RowLayout { AvatarImage { id: avatarRect avatarurl: i_avatar aliasname: i_aliasname username: i_username } Repeater { id: repearterAttachments model: i_attachments MediaPlayer { id: audioPlayer autoPlay: false onPaused: { playerButton.source = "media-playback-start" } onPlaying: { playerButton.source = "media-playback-pause" } onStopped: { playerButton.source = "media-playback-start" playerSlider.value=0 } onPositionChanged: { playerSlider.sync = true playerSlider.value = audioPlayer.position / audioPlayer.duration playerSlider.sync = false timeLabel.text = ConvertScript.convertTimeString(audioPlayer.position) + "/" + ConvertScript.convertTimeString(audioPlayer.duration) } source: rcAccount.attachmentUrl(model.modelData.link) } ColumnLayout { Layout.fillWidth: true QQC2.Label { //TODO remove duplicate code text: model.modelData.title === "" ? "" : i18n("File Uploaded: %1", model.modelData.title) visible: model.modelData.title !== "" wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } RowLayout { Kirigami.Icon { id: playerButton source: "media-playback-start" width: 24 height: 24 MouseArea { anchors.fill: parent onClicked: { console.log(RuqolaDebugCategorySingleton.category, "Click on download audio file"); if (repearterAttachments.audioPlayer.source !== "") { if (repearterAttachments.audioPlayer.playbackState === MediaPlayer.PlayingState) { repearterAttachments.audioPlayer.pause() } else { repearterAttachments.audioPlayer.play() } } else { console.log(RuqolaDebugCategorySingleton.category, "Audio file no found"); } } } } QQC2.Slider { id: playerSlider Layout.fillWidth: true property bool sync: false onValueChanged: { if (!sync) { audioPlayer.seek(value * audioPlayer.duration) } } } QQC2.Label { id: timeLabel text: "00:00/00:00" } DownloadButton { id: download onDownloadButtonClicked: { //TODO messageMain.downloadAttachment(model.modelData.link) } } } QQC2.Label { text: model.modelData.description visible: model.modelData.description !== "" wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } } } + Repeater { + id: repearterReactions + model: i_reactions + Row { + QQC2.Label { + id: numberOfReact + renderType: Text.NativeRendering + textFormat: Text.RichText + text: model.modelData.convertedReactionName + wrapMode: QQC2.Label.Wrap + anchors.leftMargin: Kirigami.Units.smallSpacing + anchors.rightMargin: Kirigami.Units.smallSpacing + } + } + } TimestampText { id: timestampText timestamp: i_timestamp } } } diff --git a/src/qml/messages/AttachmentMessageImage.qml b/src/qml/messages/AttachmentMessageImage.qml index 2e0a7c01..bb92171d 100644 --- a/src/qml/messages/AttachmentMessageImage.qml +++ b/src/qml/messages/AttachmentMessageImage.qml @@ -1,188 +1,204 @@ /* 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 2.2 as QQC2 import org.kde.kirigami 2.1 as Kirigami import KDE.Ruqola.DebugCategory 1.0 import QtQuick.Layouts 1.1 import "../common" MessageBase { id: messageMain 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 } Repeater { id: repearterAttachments model: i_attachments Row { Column { QQC2.Label { id: imageTitle text: model.modelData.title === "" ? "" : model.modelData.imageTitle visible: model.modelData.title !== "" wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing renderType: Text.NativeRendering textFormat: Text.RichText onLinkActivated: { messageMain.displayImage(imageUrl.source, model.modelData.title, model.modelData.isAnimatedImage) } MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { if (mouse.button === Qt.RightButton) { menu.x = mouse.x menu.y = mouse.y menu.open(); } } } } Image { id: imageUrl visible: model.modelData.isAnimatedImage readonly property int imageHeight: model.modelData.imageHeight === -1 ? 200 : model.modelData.imageHeight source: rcAccount.attachmentUrl(model.modelData.link) asynchronous: true fillMode: Image.PreserveAspectFit //TODO customize it. width: model.modelData.imageWidth === -1 ? 200 : model.modelData.imageWidth height: 0 sourceSize.width: 200 sourceSize.height: 200 onStatusChanged: { if(status == Image.Error){ console.log(RuqolaDebugCategorySingleton.category, "Image load error! Trying to reload. " + source) } } MouseArea { anchors.fill: parent onClicked: { if(status === Image.Error) { console.log(RuqolaDebugCategorySingleton.category, "Image not loaded."); } else { messageMain.displayImage(imageUrl.source, imageTitle.text, model.modelData.isAnimatedImage) } } } } AnimatedImage { id: imageAnimatedUrl visible: model.modelData.isAnimatedImage readonly property int imageHeight: model.modelData.imageHeight === -1 ? 200 : model.modelData.imageHeight source: rcAccount.attachmentUrl(model.modelData.link) asynchronous: true fillMode: Image.PreserveAspectFit width: model.modelData.imageWidth === -1 ? 200 : model.modelData.imageWidth height: 0 //sourceSize.width: 200 //sourceSize.height: 200 onStatusChanged: { if(status == Image.Error){ console.log(RuqolaDebugCategorySingleton.category, "Image load error! Trying to reload. " + source) } } MouseArea { anchors.fill: parent onClicked: { if(status === Image.Error) { console.log(RuqolaDebugCategorySingleton.category, "Image not loaded."); } else { messageMain.displayImage(imageAnimatedUrl.source, imageTitle.text, model.modelData.isAnimatedImage) } } } } QQC2.Label { text: model.modelData.description wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing visible: model.modelData.description !== "" MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { if (mouse.button === Qt.RightButton) { menu.x = mouse.x menu.y = mouse.y menu.open(); } } } } } ShowHideButton { targetAnimation: model.modelData.isAnimatedImage ? imageAnimatedUrl : imageUrl defaultHeight: model.modelData.isAnimatedImage ? imageAnimatedUrl.imageHeight : Url.imageHeight } DownloadButton { id: download onDownloadButtonClicked: { messageMain.downloadAttachment(model.modelData.link) } } Connections { target: rcAccount onFileDownloaded: { //console.log(RuqolaDebugCategorySingleton.category, " IMAGE SUPPORT: " + filePath + " cacheImageUrl :" + cacheImageUrl + " model.modelData.link: " + model.modelData.link) if (filePath === model.modelData.link) { console.log(RuqolaDebugCategorySingleton.category, "Image updated: " + cacheImageUrl) imageUrl.source = cacheImageUrl; imageAnimatedUrl.source = cacheImageUrl; } } } } } + Repeater { + id: repearterReactions + model: i_reactions + Row { + QQC2.Label { + id: numberOfReact + renderType: Text.NativeRendering + textFormat: Text.RichText + text: model.modelData.convertedReactionName + wrapMode: QQC2.Label.Wrap + anchors.leftMargin: Kirigami.Units.smallSpacing + anchors.rightMargin: Kirigami.Units.smallSpacing + } + } + } + Item { Layout.fillWidth: true } TimestampText { id: timestampText timestamp: i_timestamp } } } diff --git a/src/qml/messages/AttachmentMessageVideo.qml b/src/qml/messages/AttachmentMessageVideo.qml index db373193..d832fe74 100644 --- a/src/qml/messages/AttachmentMessageVideo.qml +++ b/src/qml/messages/AttachmentMessageVideo.qml @@ -1,162 +1,177 @@ /* 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 2.2 as QQC2 import org.kde.kirigami 2.1 as Kirigami import QtMultimedia 5.8 import QtQuick.Layouts 1.1 import "../js/convert.js" as ConvertScript; import "../common" import KDE.Ruqola.DebugCategory 1.0 MessageBase { id: attachmentVideo MediaPlayer { id: videoPlayer autoPlay: false onPaused: { playerButton.source = "media-playback-start" } onPlaying: { playerButton.source = "media-playback-pause" } onStopped: { playerButton.source = "media-playback-start" playerSlider.value=0 } onPositionChanged: { playerSlider.sync = true playerSlider.value = videoPlayer.position / videoPlayer.duration playerSlider.sync = false timeLabel.text = ConvertScript.convertTimeString(videoPlayer.position) + "/" + ConvertScript.convertTimeString(videoPlayer.duration) } source: rcAccount.attachmentUrl(model.modelData.link) } RowLayout { AvatarImage { id: avatarRect avatarurl: i_avatar aliasname: i_aliasname username: i_username } Repeater { id: repearterAttachments model: i_attachments RowLayout { ColumnLayout { Layout.fillWidth: true QQC2.Label { //TODO remove duplicate code text: model.modelData.title === "" ? "" : i18n("File Uploaded: %1", model.modelData.title) visible: model.modelData.title !== "" wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } VideoOutput { id: videoOutput property int videoHeight: 100 Layout.fillWidth: true source: attachmentVideo.videoPlayer width: 100 height: 0 } RowLayout { //Verify position. //Add video media Kirigami.Icon { id: playerButton source: "media-playback-start" width: 24 height: 24 MouseArea { anchors.fill: parent onClicked: { console.log(RuqolaDebugCategorySingleton.category, "Click on video file!"); if (repearterAttachments.videoPlayer.source !== "") { if (repearterAttachments.videoPlayer.playbackState === MediaPlayer.PlayingState) { repearterAttachments.videoPlayer.pause() } else { repearterAttachments.videoPlayer.play() } } else { console.log(RuqolaDebugCategorySingleton.category, "Video file no found"); } } } } QQC2.Slider { id: playerSlider Layout.fillWidth: true property bool sync: false onValueChanged: { if (!sync) { videoPlayer.seek(value * videoPlayer.duration) } } } QQC2.Label { id: timeLabel text: "00:00/00:00" } DownloadButton { id: download onDownloadButtonClicked: { //TODO messageMain.downloadAttachment(model.modelData.link) } } ShowHideButton { targetAnimation: videoOutput defaultHeight: videoOutput.videoHeight } } QQC2.Label { text: model.modelData.description visible: model.modelData.description !== "" wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } } } } + Repeater { + id: repearterReactions + model: i_reactions + Row { + QQC2.Label { + id: numberOfReact + renderType: Text.NativeRendering + textFormat: Text.RichText + text: model.modelData.convertedReactionName + wrapMode: QQC2.Label.Wrap + anchors.leftMargin: Kirigami.Units.smallSpacing + anchors.rightMargin: Kirigami.Units.smallSpacing + } + } + } TimestampText { id: timestampText timestamp: i_timestamp } } }