diff --git a/src/apps/qml/qml/ChannelInfoDialog.qml b/src/apps/qml/qml/ChannelInfoDialog.qml index da60407d..60a9d5a9 100644 --- a/src/apps/qml/qml/ChannelInfoDialog.qml +++ b/src/apps/qml/qml/ChannelInfoDialog.qml @@ -1,218 +1,218 @@ /* Copyright (c) 2017-2020 Laurent Montel 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.12 import QtQuick.Controls 2.5 as QQC2 import QtQuick.Window 2.2 import org.kde.kirigami 2.5 as Kirigami import Ruqola 1.0 import "common" QQC2.Dialog { id: channelInfoDialog title: i18n("Info about this channel") standardButtons: QQC2.Dialog.Close modal: true focus: true width: parent.width * 9 / 10 height: parent.height * 9 / 10 anchors.centerIn: parent property string channelName: "" property QtObject roomInfo signal modifyChannelSetting(string roomId, int type, var newVal, string channelType) signal deleteRoom(string roomId) contentItem: Kirigami.FormLayout { QQC2.TextField { id: channelNameEdit visible: roomInfo.canBeModify text: roomInfo.name Kirigami.FormData.label: i18n("Name:") onTextChanged: newText => { if (newText != "") { if (roomInfo.name !== newText) { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Name, newText, roomInfo.channelType) } } else { //see https://doc.qt.io/qt-5/qml-qtqml-loggingcategory.html console.log(RuqolaDebugCategorySingleton.category, "New name is empty. We can't rename room name to empty name.") } } } QQC2.Label { visible: !channelNameEdit.visible text: roomInfo.name Kirigami.FormData.label: i18n("Name:") } QQC2.TextField { id: channelCommentEdit visible: roomInfo.canBeModify text: roomInfo.topic Kirigami.FormData.label: i18n("Comment:") onTextChanged: newText => { if (newText === roomInfo.topic) return channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Topic, newText, roomInfo.channelType) } } QQC2.Label { visible: !channelCommentEdit.visible text: roomInfo.topic Kirigami.FormData.label: i18n("Comment:") } QQC2.TextField { id: channelAnnouncementEdit visible: roomInfo.canBeModify text: roomInfo.announcement Kirigami.FormData.label: i18n("Announcement:") onTextChanged: newText => { if (newText === roomInfo.announcement) return channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Announcement, newText, roomInfo.channelType) } } QQC2.Label { visible: !channelAnnouncementEdit.visible text: roomInfo.announcement Kirigami.FormData.label: i18n("Announcement:") } QQC2.TextField { id: channelDescriptionEdit visible: roomInfo.canBeModify text: roomInfo.description Kirigami.FormData.label: i18n("Description:") onTextChanged: newText => { if (newText === roomInfo.description) return channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Description, newText, roomInfo.channelType) } } QQC2.Label { visible: !channelDescriptionEdit.visible text: roomInfo.description Kirigami.FormData.label: i18n("Description:") } PasswordLineEdit { id: password visible: roomInfo.canBeModify //Add i18n context ? placeholderText: roomInfo === null ? i18n("Add password") : (roomInfo.joinCodeRequired ? i18n("This Room has a password") : i18n("Add password")) Kirigami.FormData.label: i18n("Password:") } QQC2.Switch { id: readOnlyRoom visible: roomInfo.canBeModify checked: roomInfo.readOnly onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.ReadOnly, checked, roomInfo.channelType) } Kirigami.FormData.label: i18n("Read-Only:") } QQC2.Switch { id: broadcast visible: roomInfo.canBeModify checked: roomInfo.broadcast onClicked: { console.log(RuqolaDebugCategorySingleton.category, "Broadcast not implemented yet") //TODO } Kirigami.FormData.label: i18n("Broadcast:") } QQC2.Switch { id: archiveRoom visible: roomInfo.canBeModify checked: roomInfo.archived onClicked: { archiveRoomDialog.archive = checked archiveRoomDialog.open() } Kirigami.FormData.label: i18n("Archive:") } QQC2.Switch { id: roomType visible: roomInfo.canBeModify checked: roomInfo.channelType === "p" onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.RoomType, checked, roomInfo.channelType) } Kirigami.FormData.label: i18n("Private:") } QQC2.Switch { id: encrypted visible: roomInfo.canBeModify && roomInfo.encryptedEnabled checked: roomInfo.encrypted onClicked: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Encrypted, checked, roomInfo.channelType) } Kirigami.FormData.label: i18n("Encrypted:") } DeleteButton { id: deleteButton visible: roomInfo.canBeModify - onDeleteButtonClicked: { + onClicked: { deleteRoomDialog.rId = roomInfo.roomId deleteRoomDialog.open(); } Kirigami.FormData.label: i18n("Delete Room:") } } ArchiveRoomDialog { id: archiveRoomDialog onAccepted: { channelInfoDialog.modifyChannelSetting(channelName, RocketChatAccount.Archive, archiveRoomDialog.archive, roomInfo.channelType) } onRejected: { archiveRoom.checked = false } } DeleteRoomDialog { id: deleteRoomDialog rId: channelName onDeleteRoom: { channelInfoDialog.deleteRoom(roomId) channelInfoDialog.close() } } } diff --git a/src/apps/qml/qml/FileInRoom.qml b/src/apps/qml/qml/FileInRoom.qml index cde02186..0c9e3a70 100644 --- a/src/apps/qml/qml/FileInRoom.qml +++ b/src/apps/qml/qml/FileInRoom.qml @@ -1,91 +1,91 @@ /* * Copyright (C) 2019-2020 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 org.kde.kirigami 2.7 as Kirigami import QtQuick.Controls 2.5 as QQC2 import QtQuick.Layouts 1.12 import "common" Kirigami.BasicListItem { reserveSpaceForIcon: false reserveSpaceForLabel: false property string i_filename property string i_description property string i_username property string i_timestamp property string i_url property bool i_complete RowLayout { width: filesInRoomDelegateItem.width ColumnLayout { QQC2.Label { text: i_filename textFormat: Text.PlainText elide: Text.ElideRight wrapMode: QQC2.Label.Wrap Layout.fillWidth: true } QQC2.Label { text: i_description Layout.fillWidth: true visible: i_description !== "" wrapMode: QQC2.Label.Wrap elide: Text.ElideRight font.italic: true } QQC2.Label { text: i_username wrapMode: QQC2.Label.NoWrap elide: Text.ElideRight color: Kirigami.Theme.disabledTextColor Layout.fillWidth: true font.italic: true } QQC2.Label { text: i_timestamp textFormat: Text.PlainText wrapMode: QQC2.Label.NoWrap color: Kirigami.Theme.disabledTextColor Layout.fillWidth: true font.italic: true } } Item { Layout.fillWidth: true } DownloadButton { visible: i_complete - onDownloadButtonClicked: { + onClicked: { showFilesInRoomDialog.downloadFile(i_url) } } DeleteButton { visible: canbedeleted - onDeleteButtonClicked: { + onClicked: { deleteFileAttachmentDialog.fileId = fileid; deleteFileAttachmentDialog.open(); } } } } diff --git a/src/apps/qml/qml/common/DeleteButton.qml b/src/apps/qml/qml/common/Button.qml similarity index 72% copy from src/apps/qml/qml/common/DeleteButton.qml copy to src/apps/qml/qml/common/Button.qml index 291db9b9..441c3d76 100644 --- a/src/apps/qml/qml/common/DeleteButton.qml +++ b/src/apps/qml/qml/common/Button.qml @@ -1,41 +1,50 @@ /* - * Copyright (C) 2018-2020 Laurent Montel + * Copyright (C) 2020 Kevin Funk * * 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 2.5 as QQC2 import QtQuick.Layouts 1.12 import org.kde.kirigami 2.7 as Kirigami Kirigami.Icon { - id: deleteButton - source: "edit-delete-shred" - signal deleteButtonClicked() + id: button + + property string toolTipText + + signal clicked() width: height height: Kirigami.Units.iconSizes.small MouseArea { + id: mouseArea anchors.fill: parent + hoverEnabled: true + cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor onClicked: { - deleteButton.deleteButtonClicked(); + button.clicked(); } } + + QQC2.ToolTip.text: toolTipText + QQC2.ToolTip.visible: toolTipText !== "" && mouseArea.containsMouse } diff --git a/src/apps/qml/qml/common/DeleteButton.qml b/src/apps/qml/qml/common/DeleteButton.qml index 291db9b9..dcc1707f 100644 --- a/src/apps/qml/qml/common/DeleteButton.qml +++ b/src/apps/qml/qml/common/DeleteButton.qml @@ -1,41 +1,31 @@ /* * Copyright (C) 2018-2020 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.Layouts 1.12 import org.kde.kirigami 2.7 as Kirigami -Kirigami.Icon { +Button { id: deleteButton + toolTipText: i18n("Delete") source: "edit-delete-shred" - signal deleteButtonClicked() - - width: height - height: Kirigami.Units.iconSizes.small - - MouseArea { - anchors.fill: parent - onClicked: { - deleteButton.deleteButtonClicked(); - } - } } diff --git a/src/apps/qml/qml/common/DownloadButton.qml b/src/apps/qml/qml/common/DownloadButton.qml index e09a0f93..a09631da 100644 --- a/src/apps/qml/qml/common/DownloadButton.qml +++ b/src/apps/qml/qml/common/DownloadButton.qml @@ -1,40 +1,30 @@ /* * Copyright (C) 2017-2020 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.Layouts 1.12 import org.kde.kirigami 2.7 as Kirigami -Kirigami.Icon { + +Button { id: download + toolTipText: i18n("Download") source: "cloud-download" - signal downloadButtonClicked() - - width: height - height: Kirigami.Units.iconSizes.small - MouseArea { - anchors.fill: parent - onClicked: { - download.downloadButtonClicked(); - } - } } diff --git a/src/apps/qml/qml/messages/AttachmentMessageAudio.qml b/src/apps/qml/qml/messages/AttachmentMessageAudio.qml index c08eff0c..ebb24931 100644 --- a/src/apps/qml/qml/messages/AttachmentMessageAudio.qml +++ b/src/apps/qml/qml/messages/AttachmentMessageAudio.qml @@ -1,135 +1,135 @@ /* Copyright (c) 2017-2020 Laurent Montel 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.5 as QQC2 import org.kde.kirigami 2.7 as Kirigami import QtQuick.Layouts 1.12 import Ruqola 1.0 import "../js/convert.js" as ConvertScript; import "../common" UserMessage { id: root attachments: 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) textFormat: Text.PlainText 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: height height: Kirigami.Units.iconSizes.huge 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() playerButton.source = "media-playback-start" } else { repearterAttachments.audioPlayer.play() playerButton.source = "media-playback-pause" } } 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 //TODO display real value text: "00:00/00:00" } DownloadButton { id: download - onDownloadButtonClicked: { + onClicked: { 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 } } } } diff --git a/src/apps/qml/qml/messages/AttachmentMessageFile.qml b/src/apps/qml/qml/messages/AttachmentMessageFile.qml index 4e135a90..1a8eba09 100644 --- a/src/apps/qml/qml/messages/AttachmentMessageFile.qml +++ b/src/apps/qml/qml/messages/AttachmentMessageFile.qml @@ -1,85 +1,85 @@ /* Copyright (c) 2017-2020 Laurent Montel 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.5 as QQC2 import QtQuick.Layouts 1.12 import org.kde.kirigami 2.7 as Kirigami import Ruqola 1.0 import "../common" UserMessage { id: root attachments: Repeater { id: repearterAttachments model: i_attachments ColumnLayout { id: column QQC2.Label { visible: model.modelData.authorName !== "" Layout.fillWidth: true text: model.modelData.authorName wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } RowLayout { Layout.fillWidth: true QQC2.Label { id: attachmentTitle textFormat: Text.RichText visible: model.modelData.title !== "" text: model.modelData.displayTitle Layout.fillWidth: true 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: { + onClicked: { messageMain.downloadAttachment(model.modelData.link) } } Item { Layout.fillWidth: true } } QQC2.Label { visible: model.modelData.description !== "" Layout.fillWidth: true text: model.modelData.description wrapMode: QQC2.Label.Wrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing } } } } diff --git a/src/apps/qml/qml/messages/AttachmentMessageImage.qml b/src/apps/qml/qml/messages/AttachmentMessageImage.qml index b48821f4..19048539 100644 --- a/src/apps/qml/qml/messages/AttachmentMessageImage.qml +++ b/src/apps/qml/qml/messages/AttachmentMessageImage.qml @@ -1,168 +1,168 @@ /* Copyright (c) 2017-2020 Laurent Montel 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.5 as QQC2 import org.kde.kirigami 2.7 as Kirigami import Ruqola 1.0 import QtQuick.Layouts 1.12 import "../common" UserMessage { id: root attachments: Repeater { id: repearterAttachments model: i_attachments Row { Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing Column { ClickableLabel { id: imageTitle text: model.modelData.title === "" ? "" : model.modelData.imageTitle visible: model.modelData.title !== "" wrapMode: QQC2.Label.NoWrap anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing onLinkActivated: { messageMain.displayImage(imageUrl.source, model.modelData.title, model.modelData.isAnimatedImage) } onContextMenuRequested: { messageMenuLoader.posX = mouse.x messageMenuLoader.posY = mouse.y if (messageMenuLoader.active) messageMenuLoader.active = false else messageMenuLoader.active = true } } Image { id: imageUrl visible: model.modelData.isAnimatedImage readonly property int imageHeight: model.modelData.imageHeight === -1 ? 200 : Math.min(200, model.modelData.imageHeight) source: rcAccount.attachmentUrl(model.modelData.link) asynchronous: true fillMode: Image.PreserveAspectFit //Don't use really imageWidth otherwise it will be too big //width: 200 //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 : Math.min(200, model.modelData.imageHeight) source: rcAccount.attachmentUrl(model.modelData.link) asynchronous: true fillMode: Image.PreserveAspectFit //Don't use really imageWidth otherwise it will be too big //width: 200 //model.modelData.imageWidth === -1 ? 200 : model.modelData.imageWidth height: 0 onStatusChanged: { if(status == Image.Error){ console.log(RuqolaDebugCategorySingleton.category, "Image load error! Trying to reload. " + source) } } onHeightChanged: { playing = height > 0; } 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 onHiddenChanged: { messageMain.showDisplayAttachment(i_messageID, state) } } DownloadButton { id: download - onDownloadButtonClicked: { + onClicked: { 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; } } } } } } diff --git a/src/apps/qml/qml/messages/AttachmentMessageVideo.qml b/src/apps/qml/qml/messages/AttachmentMessageVideo.qml index f7479c4e..0b3f3ca6 100644 --- a/src/apps/qml/qml/messages/AttachmentMessageVideo.qml +++ b/src/apps/qml/qml/messages/AttachmentMessageVideo.qml @@ -1,153 +1,153 @@ /* Copyright (c) 2017-2020 Laurent Montel 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.5 as QQC2 import org.kde.kirigami 2.7 as Kirigami import QtMultimedia 5.8 import QtQuick.Layouts 1.12 import Ruqola 1.0 import "../js/convert.js" as ConvertScript; import "../common" UserMessage { id: attachmentVideo MediaPlayer { id: videoPlayer autoPlay: false //It doesn't work. Perhaps we need to remove it function preview() { if (status === MediaPlayer.Loaded && playbackState === MediaPlayer.StoppedState) { seek(duration/2) } } onStatusChanged: { preview(); } onPlaybackStateChanged: { preview(); } } attachments: 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: videoPlayer width: 100 height: 0 } RowLayout { //Add video media Kirigami.Icon { id: playerButton source: "media-playback-start" width: height height: Kirigami.Units.iconSizes.medium MouseArea { anchors.fill: parent readonly property url link: rcAccount.attachmentUrl(model.modelData.link) onLinkChanged: { videoPlayer.source = link } onClicked: { console.log(RuqolaDebugCategorySingleton.category, "Click on video file!"); if (videoPlayer.playbackState === MediaPlayer.PlayingState) { videoPlayer.pause() playerButton.source = "media-playback-start" } else { videoPlayer.play() playerButton.source = "media-playback-pause" } //TODO stop ? if (videoPlayer.error !== MediaPlayer.NoError) { console.log(RuqolaDebugCategorySingleton.category, "Video file no found"); } } } } QQC2.Slider { id: playerSlider enabled: videoPlayer.playbackState === MediaPlayer.PlayingState Layout.fillWidth: true from: 0 to: videoPlayer.duration value: videoPlayer.position onMoved: { videoPlayer.seek(value) } } QQC2.Label { id: timeLabel text: ConvertScript.convertTimeString(playerSlider.value) + "/" + ConvertScript.convertTimeString(playerSlider.to)//"00:00/00:00" } DownloadButton { id: download - onDownloadButtonClicked: { + onClicked: { messageMain.downloadAttachment(videoPlayer.source) } } 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 } } } } } diff --git a/src/apps/qml/qml/messages/ShowHideButton.qml b/src/apps/qml/qml/messages/ShowHideButton.qml index 518780ed..bc7618bf 100644 --- a/src/apps/qml/qml/messages/ShowHideButton.qml +++ b/src/apps/qml/qml/messages/ShowHideButton.qml @@ -1,71 +1,71 @@ /* * Copyright (C) 2018-2020 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 2.5 as QQC2 import org.kde.kirigami 2.7 as Kirigami import QtQuick.Layouts 1.12 -Kirigami.Icon { +import "../common" + +Button { id: showHideButtonId property QtObject targetAnimation property int defaultHeight: 200 property bool isHidden: true signal hiddenChanged(bool state); source: isHidden ? "hint" : "visibility" - width: height - height: Kirigami.Units.iconSizes.small - MouseArea { - anchors.fill: parent - onClicked: { - if (isHidden) { - isHidden = false - imageAnimationShow.running = true; - } else { - isHidden = true - imageAnimationHide.running = true; - } - showHideButtonId.hiddenChanged(!isHidden) + toolTipText: isHidden ? i18n("Show") : i18n("Hide") + + onClicked: { + if (isHidden) { + isHidden = false + imageAnimationShow.running = true; + } else { + isHidden = true + imageAnimationHide.running = true; } + showHideButtonId.hiddenChanged(!isHidden) } + NumberAnimation { id: imageAnimationHide target: targetAnimation property: "height" duration: 500 easing.type: Easing.InOutQuad from: defaultHeight to: 0 } NumberAnimation { id: imageAnimationShow target: targetAnimation property: "height" duration: 500 easing.type: Easing.InOutQuad from: 0 to: defaultHeight } } diff --git a/src/apps/qml/qml/qml.qrc b/src/apps/qml/qml/qml.qrc index c2dc4c47..a5668dfe 100644 --- a/src/apps/qml/qml/qml.qrc +++ b/src/apps/qml/qml/qml.qrc @@ -1,96 +1,97 @@ Desktop.qml FancyMessageDelegate.qml RoomsView.qml RoomDelegate.qml Login.qml UserInput.qml LoginPage.qml ExtraColors.qml ActiveChat.qml PersonsListView.qml CreateNewChannelDialog.qml OpenDirectChannelDialog.qml ChannelInfoDialog.qml DeleteMessageDialog.qml AddUserDialog.qml DeleteRoomDialog.qml TakeVideoMessageDialog.qml DebugCategory.qml ConfigureServerList.qml MainComponent.qml RoomsComponent.qml ArchiveRoomDialog.qml DownloadFileDialog.qml UploadFileDialog.qml DisplayImageDialog.qml EncryptedConversationDialog.qml SearchChannelDialog.qml ShowFilesInRoomDialog.qml MessageLine.qml ShowSearchMessageDialog.qml DeleteAccountDialog.qml OpenChannelDialog.qml PrivateChannelInfoDialog.qml PasswordLineEdit.qml NotificationOptionsDialog.qml LeaveChannelDialog.qml DeleteFileAttachmentDialog.qml UserInfoDialog.qml CreateNewAccountDialog.qml ChannelPasswordDialog.qml ServerInfoDialog.qml NotificationAlertCombobox.qml UserMenu.qml JobErrorMessageDialog.qml ReportMessageDialog.qml CreateDiscussionDialog.qml ShowDiscussionsInRoomDialog.qml ShowThreadsInRoomDialog.qml ShowThreadMessagesDialog.qml DiscussionMessageDelegate.qml DiscussionMessage.qml FilesInRoomDelegate.qml FileInRoom.qml SearchLabel.qml AutoTranslateLanguageCombobox.qml AutoTranslateConfigDialog.qml CustomUserStatusDialog.qml ListMessagesDialogBase.qml messages/SystemMessage.qml messages/UserMessage.qml messages/AttachmentMessageAudio.qml messages/AttachmentMessageFile.qml messages/AttachmentMessageImage.qml messages/AttachmentMessageVideo.qml messages/JitsiVideoMessage.qml messages/NewDateLabel.qml messages/MessageBase.qml messages/MessageMenu.qml messages/TimestampText.qml messages/ShowHideButton.qml messages/RepeaterReactions.qml messages/DiscussionLabel.qml messages/ThreadLabel.qml messages/ReactionsPopup.qml + common/Button.qml common/DownloadButton.qml common/AvatarImage.qml common/DeleteButton.qml common/EmoticonMenu.qml common/StatusCombobox.qml common/ClickableLabel.qml icons/systray.png icons/attach-button.jpg js/message.js js/convert.js