diff --git a/src/apps/qml/qml/common/AvatarImage.qml b/src/apps/qml/qml/common/AvatarImage.qml index 02ddd55d..e98f4d32 100644 --- a/src/apps/qml/qml/common/AvatarImage.qml +++ b/src/apps/qml/qml/common/AvatarImage.qml @@ -1,138 +1,134 @@ /* * 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.Controls 2.5 as QQC2 import org.kde.kirigami 2.7 as Kirigami import QtQuick.Layouts 1.12 import "../js/message.js" as MessageScript; import QtQuick.Window 2.2 import QtGraphicalEffects 1.0 import Ruqola 1.0 Rectangle { id: avatarRect property string avatarurl property string aliasname property string username readonly property int defaultWidth: compactViewMode ? Kirigami.Units.fontMetrics.height :Kirigami.Units.iconSizes.medium signal showUserInfo() - Layout.alignment: Qt.AlignTop | Qt.AlignCenter - Layout.fillHeight: false //Customize it. implicitWidth: defaultWidth implicitHeight: implicitWidth radius: 3 - anchors.rightMargin: 2*Kirigami.Units.smallSpacing - color: avatarurl !== "" ? "transparent" : MessageScript.stringToColour(username) Image { id: avatarImage anchors.fill: parent visible: avatarurl !== "" smooth: true source: avatarurl fillMode: Image.PreserveAspectFit asynchronous: true layer.enabled: true layer.effect: OpacityMask { maskSource: avatarImageMask } MouseArea { anchors.fill: parent onClicked: { avatarRect.showUserInfo(); } } onStatusChanged: { if (avatarImage.status === Image.Error) { console.log(RuqolaDebugCategorySingleton.category, "An error occurred when we try to load image"); } } Rectangle { id: avatarImageMask width: parent.width height: parent.height radius: avatarRect.radius visible: false } } QQC2.Label { id: avatarText visible: avatarurl == "" anchors.fill: parent anchors.margins: Kirigami.Units.smallSpacing renderType: Text.QtRendering color: Kirigami.Theme.backgroundColor font { weight: Font.Bold pointSize: 40 } fontSizeMode: Text.Fit horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: { //TODO verify if it works with non latin char. if (aliasname.length > 0) { var match = aliasname.match(/([a-zA-Z0-9])([a-zA-Z0-9])/); var abbrev = match[1].toUpperCase(); if (match.length > 2) { abbrev += match[2].toLowerCase(); } return abbrev; } return ""; } } Connections { target: appid.rocketChatAccount onFileDownloaded: { //console.log(" filePath " + filePath + " username: " + username) if (filePath === "/avatar/" + username) { avatarurl = cacheImageUrl } } } MouseArea { // HACK: Remove me, just for demonstration anchors.fill: parent onClicked: { activeChat.compactViewMode = !activeChat.compactViewMode // toggle console.log("compactViewMode: " + activeChat.compactViewMode); } } } diff --git a/src/apps/qml/qml/messages/JitsiVideoMessage.qml b/src/apps/qml/qml/messages/JitsiVideoMessage.qml index 31f37a1f..3fc7d35b 100644 --- a/src/apps/qml/qml/messages/JitsiVideoMessage.qml +++ b/src/apps/qml/qml/messages/JitsiVideoMessage.qml @@ -1,97 +1,99 @@ /* * 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.Controls 2.5 as QQC2 import org.kde.kirigami 2.7 as Kirigami import QtQuick.Layouts 1.12 import "../js/message.js" as MessageScript; import "../common" MessageBase { id: root implicitHeight: rowLayout.height RowLayout { id: rowLayout width: parent.width AvatarImage { id: avatarRect + + Layout.alignment: Qt.AlignTop avatarurl: i_avatar aliasname: i_aliasname username: i_username onShowUserInfo: { //TODO } } Item { Layout.fillWidth: true } Rectangle { Layout.alignment: Qt.AlignCenter width: textLabel.implicitWidth + 6*Kirigami.Units.smallSpacing height: textLabel.height color: Kirigami.Theme.disabledTextColor radius: 4*Kirigami.Units.smallSpacing QQC2.Label { id: textLabel color: Kirigami.Theme.textColor opacity: 1 anchors.centerIn: parent anchors.leftMargin: Kirigami.Units.smallSpacing anchors.rightMargin: Kirigami.Units.smallSpacing width: Math.min(implicitWidth, parent.width - Kirigami.Units.largeSpacing) text: i18n("Click To Join to Video") wrapMode: QQC2.Label.Wrap MouseArea { anchors.fill: parent onClicked: { messageMain.jitsiCallConfActivated() } } } } Item { Layout.fillWidth: true } TimestampText { id: timestampText timestamp: i_timestamp } } } diff --git a/src/apps/qml/qml/messages/UserMessage.qml b/src/apps/qml/qml/messages/UserMessage.qml index 044d9ef0..0164f726 100644 --- a/src/apps/qml/qml/messages/UserMessage.qml +++ b/src/apps/qml/qml/messages/UserMessage.qml @@ -1,281 +1,283 @@ /* * Copyright 2016 Riccardo Iaconelli * 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 org.kde.kirigami 2.7 as Kirigami import QtQuick.Controls 2.5 as QQC2 import QtQuick.Layouts 1.12 import Ruqola 1.0 import "../common" MessageBase { id: root property alias attachments: attachmentsLayout.children implicitHeight: rowLayout.height Loader { id: messageMenuLoader active: false property var posX property var posY sourceComponent: MessageMenu { id: menu x: messageMenuLoader.posX y: messageMenuLoader.posY can_edit_message: i_can_edit_message user_ignored : i_user_ignored starred: i_starred pinned_message: i_pinned showTranslatedMessage: i_showTranslatedMessage Component.onCompleted: { open() } onAboutToHide: { messageMenuLoader.active = false; } } } RowLayout { id: rowLayout width: parent.width AvatarImage { id: avatarRect + + Layout.alignment: Qt.AlignTop avatarurl: i_avatar aliasname: i_aliasname username: i_username onShowUserInfo: { messageMain.showUserInfo(i_own_username) } visible: !i_groupable } ColumnLayout { spacing: Kirigami.Units.smallSpacing / 2 // reduce spacing a little GridLayout { rowSpacing: 0 columnSpacing: Kirigami.Units.smallSpacing columns: compactViewMode ? -1 : 1 // user name label + roles info in one row RowLayout { Layout.alignment: Qt.AlignLeft | Qt.AlignTop Layout.rightMargin: Kirigami.Units.smallSpacing QQC2.Label { id: usernameLabel font.bold: true text: i_aliasname !== "" ? i_aliasname + ' @' + i_username : '@' + i_username MouseArea { anchors.fill: parent enabled: i_username !== appid.rocketChatAccount.userName hoverEnabled: true cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { if (mouse.button === Qt.RightButton) { if (i_useMenuMessage) { messageMenuLoader.posX = mouse.x messageMenuLoader.posY = mouse.y if (messageMenuLoader.active) messageMenuLoader.active = false else messageMenuLoader.active = true } } else { messageMain.linkActivated("ruqola:/user/" + i_username) } } } visible: !i_groupable } Kirigami.Icon { id: rolesInfo source: "documentinfo" width: height height: 18 visible: i_roles.length > 0 opacity: rolesInfoMA.containsMouse ? 1.0 : 0.6 MouseArea { id: rolesInfoMA hoverEnabled: true anchors.fill: parent } QQC2.ToolTip.visible: rolesInfoMA.containsMouse QQC2.ToolTip.text: i_roles } Kirigami.Icon { id: editedInfo source: "document-edit" width: height height: 18 visible: i_editedByUserName !== "" opacity: editedInfoMA.containsMouse ? 1.0 : 0.6 MouseArea { id: editedInfoMA hoverEnabled: true anchors.fill: parent } QQC2.ToolTip.visible: editedInfoMA.containsMouse QQC2.ToolTip.text: visible ? i18n("Edited by %1", i_editedByUserName) : "" } } QQC2.Label { id: threadPreview // TODO: I think the whole thread preview item needs to be visually redesigned... /// no eliding possible with rich text, cf. QTBUG-16567, fake it /// not ideal, see: https://stackoverflow.com/a/29923358 function elidedText(s, length) { var elidedText = s.substring(0, length) if (s.length > length) elidedText += "..." return elidedText } Layout.fillWidth: !compactViewMode Layout.alignment: Qt.AlignLeft | Qt.AlignTop visible: i_threadPreview.length > 0 textFormat: Text.RichText color: "red" //Convert to kirigami color font.pointSize: textLabel.font.pointSize - 1 text: compactViewMode ? elidedText(i_threadPreview, 30) : i_threadPreview wrapMode: compactViewMode ? Text.NoWrap : Text.Wrap MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton | Qt.LeftButton onClicked: { //console.log("open thread " + i_tmid) messageMain.openThread(i_tmid, i_threadPreview) } } } QQC2.Label { id: textLabel Layout.fillWidth: true textFormat: Text.RichText text: i_messageText wrapMode: QQC2.Label.Wrap onLinkActivated: messageMain.linkActivated(link) MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { if (i_useMenuMessage) { if (mouse.button === Qt.RightButton) { messageMenuLoader.posX = mouse.x messageMenuLoader.posY = mouse.y if (messageMenuLoader.active) messageMenuLoader.active = false else messageMenuLoader.active = true } } } } } ColumnLayout { id: urlColumn Layout.fillWidth: true //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 // textFormat: Text.RichText // onLinkActivated: messageMain.linkActivated(link) // } // } RowLayout { Layout.fillWidth: true RepeaterReactions { id: repearterReactions model: i_reactions onAddReaction: { messageMain.addReaction(i_messageID, emoji) } onDeleteReaction: { messageMain.deleteReaction(i_messageID, emoji) } } } } } ColumnLayout { id: attachmentsLayout Layout.fillWidth: true } ThreadLabel { Layout.fillWidth: true onOpenThread: { console.log(RuqolaDebugCategorySingleton.category, " OPen thread " + i_messageID) messageMain.openThread(i_messageID, i_messageText) } } } ReactionsPopup { visible: i_useMenuMessage showIcon: root.hovered onInsertReaction: { messageMain.addReaction(i_messageID, emoji) } } TimestampText { id: timestampText timestamp: i_timestamp visible: !i_groupable } } }