diff --git a/data/images/check-mark.svg b/data/images/check-mark.svg new file mode 100644 index 0000000..9105179 --- /dev/null +++ b/data/images/check-mark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/images/images.qrc b/data/images/images.qrc index 7b1723d..258142d 100644 --- a/data/images/images.qrc +++ b/data/images/images.qrc @@ -1,11 +1,11 @@ banner.png chat-page-background.svg - message_checkmark.svg + check-mark.svg kaidan.svg kaidan.svg diff --git a/data/images/message_checkmark.svg b/data/images/message_checkmark.svg deleted file mode 100644 index 04467a9..0000000 --- a/data/images/message_checkmark.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/qml/elements/ChatMessage.qml b/src/qml/elements/ChatMessage.qml index 31426ee..ff90bee 100644 --- a/src/qml/elements/ChatMessage.qml +++ b/src/qml/elements/ChatMessage.qml @@ -1,330 +1,329 @@ /* * Kaidan - A user-friendly XMPP client for every device! * * Copyright (C) 2016-2019 Kaidan developers and contributors * (see the LICENSE file for a full list of copyright authors) * * Kaidan 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 3 of the License, or * (at your option) any later version. * * In addition, as a special exception, the author of Kaidan gives * permission to link the code of its release with the OpenSSL * project's "OpenSSL" library (or with modified versions of it that * use the same license as the "OpenSSL" library), and distribute the * linked executables. You must obey the GNU General Public License in * all respects for all of the code used other than "OpenSSL". If you * modify this file, you may extend this exception to your version of * the file, but you are not obligated to do so. If you do not wish to * do so, delete this exception statement from your version. * * Kaidan 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 Kaidan. If not, see . */ import QtQuick 2.7 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.3 as Controls import QtGraphicalEffects 1.0 import org.kde.kirigami 2.0 as Kirigami import im.kaidan.kaidan 1.0 import MediaUtils 0.1 RowLayout { id: root property string msgId property string sender property bool sentByMe: true property string messageBody property date dateTime property bool isDelivered: false property int mediaType property string mediaGetUrl property string mediaLocation property bool edited property bool isLoading: kaidan.transferCache.hasUpload(msgId) property string name property TransferJob upload: { if (mediaType !== Enums.MessageType.MessageText && isLoading) { return kaidan.transferCache.jobByMessageId(model.id) } return null } property bool isSpoiler property string spoilerHint property bool isShowingSpoiler: false property string avatarUrl: kaidan.avatarStorage.getAvatarUrl(sender) signal messageEditRequested(string id, string body) // Own messages are on the right, others on the left side. layoutDirection: sentByMe ? Qt.RightToLeft : Qt.LeftToRight spacing: 8 width: ListView.view.width // placeholder Item { Layout.preferredWidth: root.layoutDirection === Qt.LeftToRight ? 5 : 10 } Avatar { id: avatar visible: !sentByMe avatarUrl: root.avatarUrl Layout.alignment: Qt.AlignHCenter | Qt.AlignTop name: root.name Layout.preferredHeight: Kirigami.Units.gridUnit * 2.2 Layout.preferredWidth: Kirigami.Units.gridUnit * 2.2 } // message bubble Item { Layout.preferredWidth: content.width + 16 Layout.preferredHeight: content.height + 16 // glow effect around the inner area of the message bubble RectangularGlow { anchors.fill: messageBubble glowRadius: 0.8 spread: 0.3 cornerRadius: messageBubble.radius + glowRadius color: Qt.darker(messageBubble.color, 1.2) } // inner area of the message bubble Rectangle { id: messageBubble anchors.fill: parent radius: roundedCornersRadius color: sentByMe ? rightMessageBubbleColor : leftMessageBubbleColor MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { if (mouse.button === Qt.RightButton) contextMenu.popup() } onPressAndHold: { contextMenu.popup() } } Controls.Menu { id: contextMenu Controls.MenuItem { text: qsTr("Copy Message") enabled: bodyLabel.visible onTriggered: { if (!isSpoiler || isShowingSpoiler) Utils.copyToClipboard(messageBody); else Utils.copyToClipboard(spoilerHint); } } Controls.MenuItem { text: qsTr("Edit Message") enabled: kaidan.messageModel.canCorrectMessage(msgId) onTriggered: root.messageEditRequested(msgId, messageBody) } Controls.MenuItem { text: qsTr("Copy download URL") enabled: mediaGetUrl onTriggered: Utils.copyToClipboard(mediaGetUrl) } } } ColumnLayout { id: content spacing: 5 anchors.centerIn: parent RowLayout { id: spoilerHintRow visible: isSpoiler Controls.Label { text: spoilerHint == "" ? qsTr("Spoiler") : spoilerHint color: Kirigami.Theme.textColor font.pixelSize: Kirigami.Units.gridUnit * 0.8 MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { if (mouse.button === Qt.LeftButton) { isShowingSpoiler = !isShowingSpoiler } } } } Item { Layout.fillWidth: true height: 1 } Kirigami.Icon { height: 28 width: 28 source: isShowingSpoiler ? "password-show-off" : "password-show-on" color: Kirigami.Theme.textColor } } Kirigami.Separator { visible: isSpoiler Layout.fillWidth: true color: { var bgColor = Kirigami.Theme.backgroundColor var textColor = Kirigami.Theme.textColor return Qt.tint(textColor, Qt.rgba(bgColor.r, bgColor.g, bgColor.b, 0.7)) } } ColumnLayout { visible: isSpoiler && isShowingSpoiler || !isSpoiler Controls.ToolButton { visible: { switch (root.mediaType) { case Enums.MessageType.MessageUnknown: case Enums.MessageType.MessageText: case Enums.MessageType.MessageGeoLocation: break case Enums.MessageType.MessageImage: case Enums.MessageType.MessageAudio: case Enums.MessageType.MessageVideo: case Enums.MessageType.MessageFile: case Enums.MessageType.MessageDocument: return !root.isLoading && root.mediaGetUrl !== "" && (root.mediaLocation === "" || !MediaUtilsInstance.localFileAvailable(media.mediaSource)) } return false } text: qsTr("Download") onClicked: { print("Downloading " + mediaGetUrl + "...") kaidan.downloadMedia(msgId, mediaGetUrl) } } MediaPreviewLoader { id: media mediaSource: { switch (root.mediaType) { case Enums.MessageType.MessageUnknown: case Enums.MessageType.MessageText: break case Enums.MessageType.MessageGeoLocation: return root.mediaLocation case Enums.MessageType.MessageImage: case Enums.MessageType.MessageAudio: case Enums.MessageType.MessageVideo: case Enums.MessageType.MessageFile: case Enums.MessageType.MessageDocument: const localFile = root.mediaLocation !== '' ? MediaUtilsInstance.fromLocalFile(root.mediaLocation) : '' return MediaUtilsInstance.localFileAvailable(localFile) ? localFile : root.mediaGetUrl } return '' } mediaSourceType: root.mediaType showOpenButton: true message: root } // message body Controls.Label { id: bodyLabel visible: (root.mediaType === Enums.MessageType.MessageText || messageBody !== mediaGetUrl) && messageBody !== "" text: Utils.formatMessage(messageBody) textFormat: Text.StyledText wrapMode: Text.Wrap color: Kirigami.Theme.textColor onLinkActivated: Qt.openUrlExternally(link) Layout.maximumWidth: media.enabled ? media.width : root.width - Kirigami.Units.gridUnit * 6 } Kirigami.Separator { visible: isSpoiler && isShowingSpoiler Layout.fillWidth: true color: { var bgColor = Kirigami.Theme.backgroundColor var textColor = Kirigami.Theme.textColor return Qt.tint(textColor, Qt.rgba(bgColor.r, bgColor.g, bgColor.b, 0.7)) } } } // message meta data: date, isDelivered RowLayout { Layout.bottomMargin: -4 Controls.Label { id: dateLabel text: Qt.formatDateTime(dateTime, "dd. MMM yyyy, hh:mm") color: Kirigami.Theme.disabledTextColor font.pixelSize: Kirigami.Units.gridUnit * 0.8 } Image { id: checkmark visible: (sentByMe && isDelivered) - source: Utils.getResourcePath("images/message_checkmark.svg") Layout.preferredHeight: Kirigami.Units.gridUnit * 0.65 Layout.preferredWidth: Kirigami.Units.gridUnit * 0.65 sourceSize.height: Kirigami.Units.gridUnit * 0.65 sourceSize.width: Kirigami.Units.gridUnit * 0.65 } Kirigami.Icon { source: "edit-symbolic" visible: edited Layout.preferredHeight: Kirigami.Units.gridUnit * 0.65 Layout.preferredWidth: Kirigami.Units.gridUnit * 0.65 } } // progress bar for upload/download status Controls.ProgressBar { visible: isLoading value: upload ? upload.progress : 0 Layout.fillWidth: true Layout.maximumWidth: Kirigami.Units.gridUnit * 14 } } } // placeholder Item { Layout.fillWidth: true } function updateIsLoading() { isLoading = kaidan.transferCache.hasUpload(msgId) } Component.onCompleted: { kaidan.transferCache.jobsChanged.connect(updateIsLoading) } Component.onDestruction: { kaidan.transferCache.jobsChanged.disconnect(updateIsLoading) } } diff --git a/utils/generate-license.py b/utils/generate-license.py index 0c70545..02cb9a8 100755 --- a/utils/generate-license.py +++ b/utils/generate-license.py @@ -1,387 +1,386 @@ #!/usr/bin/env python3 # # Copyright (C) 2018-2019 Linus Jahn # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # """ This script generates a debian-formatted, machine-readable copyright file for Kaidan. It uses git to get a list of contributors for the source code and the translations. """ import git import datetime # These user ids will be replaced for the LICENSE file # If you want to be added to this list, please open an issue or pull request! REPLACE_USER_IDS = [ ("Ellenjott [LNJ] ", "Linus Jahn "), ("LNJ ", "Linus Jahn "), ("Linus Jahn ", "Linus Jahn "), ("JBBgameich ", "Jonah Brüchert "), ("JBBgameich ", "Jonah Brüchert "), ("JBBgameich ", "Jonah Brüchert "), ("JBB ", "Jonah Brüchert "), ("Jonah Brüchert ", "Jonah Brüchert "), ("Jonah Brüchert ", "Jonah Brüchert "), ("Georg ", "geobra "), ("Muhammad Nur Hidayat Yasuyoshi (MNH48.com) ", "Muhammad Nur Hidayat Yasuyoshi "), ("Joeke de Graaf ", "Joeke de Graaf "), ("X advocatux ", "advocatux "), ("ZatroxDE ", "Robert Maerkisch "), ("X oiseauroch ", "oiseauroch "), ("X ssantos ", "ssantos "), ("X Txaume ", "Txaume ") ] # These user ids will be excluded from any targets EXCLUDE_USER_IDS = [ "Weblate ", "Hosted Weblate ", "anonymous <>", "anonymous <> ", "Kaidan Translations ", "Kaidan translations ", "Hosted Weblate " ] GPL3_OPENSSL_LICENSE = """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 3 of the License, or (at your option) any later version. In addition, as a special exception, the author of this program gives permission to link the code of its release with the OpenSSL project's "OpenSSL" library (or with modified versions of it that use the same license as the "OpenSSL" library), and distribute the linked executables. You must obey the GNU General Public License in all respects for all of the code used other than "OpenSSL". If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your 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 package. If not, see . On Debian systems, the full text of the GNU General Public License version 3 can be found in the file `/usr/share/common-licenses/GPL-3'.""" GPL3_LICENSE = """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 3 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 package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA On Debian systems, the full text of the GNU General Public License version 3 can be found in the file `/usr/share/common-licenses/GPL-3'.""" MIT_LICENSE = """Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.""" MIT_APPLE_LICENSE = """Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.""" APACHE2_LICENSE = """Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.""" class CopyrightAuthor: def __init__(self, score = 0, dates = None, years = "", uid = ""): self.dates = dates or list([]); self.score = score; self.years = years; self.uid = uid; def addTimestamp(self, x): self.dates.append(x); def createField(name, contentList, fullIndent = True): retvar = "{}: {}\n".format(name, contentList[0]); if len(contentList) < 2: return retvar; indent = len(name) * " "; for i in range(1, len(contentList)): retvar += "{} {}\n".format(indent, contentList[i]); return retvar; def createLongField(name, heading, content): retvar = "{}: {}\n".format(name, heading); if not content: return retvar; for line in content.split('\n'): if not line.strip(): # if line is empty line = "."; retvar += " {}\n".format(line); return retvar; class CopyrightTarget: def __init__(self, directories = None, files = None, licenseName = "", licenseContent = "", replaceUids = None, excludeUids = None, authorList = None, additionalAuthors = None, comment = ""): self.repo = git.Repo("."); self.files = files or list([]); self.directories = directories or list([]); self.licenseName = licenseName; self.licenseContent = licenseContent self.authorList = authorList or dict({}); self.comment = comment self.replaceUids = replaceUids or list([]); self.excludeUids = excludeUids or list([]); self.replaceUids.extend(REPLACE_USER_IDS); self.excludeUids.extend(EXCLUDE_USER_IDS); self.authorList = authorList or self.getAuthorList(); if additionalAuthors: self.authorList.update(additionalAuthors) def replaceUid(self, uid): for pair in self.replaceUids: if uid == pair[0]: uid = pair[1]; return uid; def getAuthorList(self): paths = list(self.files); paths.extend(self.directories); commitList = self.repo.iter_commits(paths=paths); authorList = {}; for commit in commitList: # create user id and check replacements and excludes uid = "{} <{}>".format(commit.author.name, commit.author.email); uid = self.replaceUid(uid); if uid in self.excludeUids: continue; if not uid in authorList.keys(): authorList[uid] = CopyrightAuthor(uid = uid); authorList[uid].addTimestamp(commit.authored_date); for uid in authorList: minT = min(int(t) for t in authorList[uid].dates); maxT = max(int(t) for t in authorList[uid].dates); authorList[uid].score = maxT - minT; minYear = datetime.datetime.fromtimestamp(minT).year; maxYear = datetime.datetime.fromtimestamp(maxT).year; if minYear == maxYear: authorList[uid].years = str(minYear); else: authorList[uid].years = "{}-{}".format(minYear, maxYear); authorList[uid].dates = []; return authorList; def toDebianCopyright(self): # Create copyright list copyrights = []; for item in sorted(self.authorList.items(), key=lambda x: x[1].score, reverse=True): copyrights.append("{}, {}".format(item[1].years, item[0])); files = list(self.files); for directory in self.directories: files.append(directory + "/*"); retvar = createField("Files", files); retvar += createField("Copyright", copyrights); retvar += createLongField("License", self.licenseName, self.licenseContent); if self.comment: retvar += createLongField("Comment", "", self.comment); return retvar; class LicenseTarget: def __init__(self, name = "", content = ""): self.name = name; self.content = content; def toDebianCopyright(self): return createLongField("License", self.name, self.content); def main(): copyrightTargets = [ CopyrightTarget( directories = ["src", "utils", "misc"], licenseName = "GPL-3+ with OpenSSL exception", additionalAuthors = { "Eike Hein ": CopyrightAuthor(years = "2017-2018") } ), CopyrightTarget( directories = ["i18n"], licenseName = "GPL-3+ with OpenSSL exception" ), CopyrightTarget( files = ["src/StatusBar.cpp", "src/StatusBar.h", "src/singleapp/*", "src/hsluv-c/*", "utils/generate-license.py"], licenseName = "MIT", authorList = { "J-P Nurmi ": CopyrightAuthor(years = "2016"), "Linus Jahn ": CopyrightAuthor(years = "2018-2019"), "Itay Grudev ": CopyrightAuthor(years = "2015-2018"), "Alexei Boronine ": CopyrightAuthor(years = "2015"), "Roger Tallada ": CopyrightAuthor(years = "2015"), "Martin Mitas ": CopyrightAuthor(years = "2017"), } ), CopyrightTarget( files = ["src/EmojiModel.cpp", "src/EmojiModel.h", "qml/elements/EmojiPicker.qml"], licenseName = "GPL-3+", authorList = { "Konstantinos Sideris ": CopyrightAuthor(years = "2017"), }, ), CopyrightTarget( files = ["src/QrCodeVideoFrame.h", "src/QrCodeVideoFrame.cpp"], licenseName = "apache-2.0", authorList = { "QZXing authors": CopyrightAuthor(years = "2017"), }, ), CopyrightTarget( - files = ["data/images/message_checkmark.svg"], - licenseName = "GPL-3+", + files = ["data/images/check-mark.svg"], + licenseName = "CC-BY-SA-4.0", authorList = { - "Michael Kurz ": CopyrightAuthor(years = "2014"), + "Melvin Keskin ": CopyrightAuthor(years = "2019"), }, - comment = "message_checkmark.svg: Originally from conversations, optimized using SVGO by LNJ " ), CopyrightTarget( files = [ "misc/kaidan.svg", "misc/kaidan-small-margin.svg", "misc/kaidan-128x128.png", "data/images/banner.png" ], licenseName = "CC-BY-SA-4.0", authorList = { "Ilya Bizyaev ": CopyrightAuthor(years = "2016-2017"), "MBB ": CopyrightAuthor(years = "2016"), } ), CopyrightTarget( files = ["data/images/chat-page-background.svg"], licenseName = "CC-BY-SA-4.0", authorList = { "Mathis Brüchert ": CopyrightAuthor(years = "2019"), "Melvin Keskin ": CopyrightAuthor(years = "2019") }, comment = "Inspired by graphic from https://www.toptal.com/designers/subtlepatterns/" ), CopyrightTarget( files = ["utils/convert-prl-libs-to-cmake.pl"], licenseName = "MIT-Apple", authorList = { "Konstantin Tokarev ": CopyrightAuthor(years = "2016") } ), LicenseTarget( name = "GPL-3+ with OpenSSL exception", content = GPL3_OPENSSL_LICENSE ), LicenseTarget( name = "GPL-3+", content = GPL3_LICENSE ), LicenseTarget( name = "MIT", content = MIT_LICENSE ), LicenseTarget( name = "MIT-Apple", content = MIT_APPLE_LICENSE ), LicenseTarget( name = "apache-2.0", content = APACHE2_LICENSE ) ]; print("Upstream-Name: kaidan") print("Source: https://invent.kde.org/kde/kaidan/") print("Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/") print() for target in copyrightTargets: print(target.toDebianCopyright()); if __name__ == "__main__": main();