Verified Commit 8ca86e26 authored by Jonah Brüchert's avatar Jonah Brüchert Committed by Linus Jahn

Replace fallback avatar with text avatar with user color

parent 8f1bad3b
Pipeline #376 failed with stages
in 2 minutes and 30 seconds
......@@ -15,6 +15,7 @@ Copyright: 2016-2019, Linus Jahn <lnj@kaidan.im>
2018, Marco Martin <notmart@gmail.com>
2017, probonopd <probonopd@users.noreply.github.com>
2016, Marzanna <MRZA-MRZA@users.noreply.github.com>
2017-2018, Eike Hein <hein@kde.org>
License: GPL-3+ with OpenSSL exception
Files: i18n/*
......@@ -66,10 +67,8 @@ Comment:
Files: misc/kaidan.svg
misc/kaidan-small-margin.svg
misc/kaidan-128x128.png
data/images/fallback-avatar.svg
data/images/banner.png
Copyright: 2016-2017, Ilya Bizyaev <bizyaev@zoho.com>
2017, LNJ <git@lnj.li>
2016, MBB <mbb-mail@gmx.de>
License: CC-BY-SA-4.0
......
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
<defs>
<clipPath id="a">
<path fill="#338000" d="M0 0h256v256H0z"/>
</clipPath>
</defs>
<path fill="#338000" d="M0 0h256v256H0z"/>
<path d="M99.3 130.8l57-84.8 113.5 113.5-9.2 132.6z" clip-path="url(#a)" fill="#000007" opacity=".3"/>
<path d="M173 88.4a45 54.4 0 0 1-45 54.5 45 54.4 0 0 1-45-55 45 54.4 0 0 1 45-54 45 54.4 0 0 1 45 54.3zm61 107.2a106 45 0 0 1-106 45 106 45 0 0 1-106-45 106 45 0 0 1 106-45 106 45 0 0 1 106 45z" fill="#55d400"/>
<path d="M22 195.3h212V256H22z" fill="#55d400"/>
</svg>
......@@ -23,6 +23,7 @@
<file alias="qml/elements/MediaPreviewImage.qml">src/qml/elements/MediaPreviewImage.qml</file>
<file alias="qml/elements/MediaPreviewOther.qml">src/qml/elements/MediaPreviewOther.qml</file>
<file alias="qml/elements/EmojiPicker.qml">src/qml/elements/EmojiPicker.qml</file>
<file alias="qml/elements/TextAvatar.qml">src/qml/elements/TextAvatar.qml</file>
<file alias="qtquickcontrols2.conf">misc/qtquickcontrols2.conf</file>
</qresource>
......
......@@ -131,11 +131,8 @@ Kirigami.ScrollablePage {
messageBody: model.message
dateTime: new Date(model.timestamp)
isRead: model.isDelivered
recipientAvatarUrl: {
kaidan.avatarStorage.getHashOfJid(author) !== "" ?
kaidan.avatarStorage.getAvatarUrl(author) :
kaidan.getResourcePath("images/fallback-avatar.svg")
}
recipientAvatarUrl: kaidan.avatarStorage.getAvatarUrl(author)
name: chatName
mediaType: model.type
mediaGetUrl: model.mediaUrl
mediaLocation: model.mediaLocation
......
......@@ -72,9 +72,7 @@ Kirigami.ScrollablePage {
presenceType: kaidan.presenceCache.getPresenceType(model.jid)
statusMsg: kaidan.presenceCache.getStatusText(model.jid)
unreadMessages: model.unreadMessages
avatarImagePath: kaidan.avatarStorage.getHashOfJid(model.jid) !== "" ?
kaidan.avatarStorage.getAvatarUrl(model.jid) :
kaidan.getResourcePath("images/fallback-avatar.svg")
avatarImagePath: kaidan.avatarStorage.getAvatarUrl(model.jid)
backgroundColor: {
if (!Kirigami.Settings.isMobile && kaidan.chatPartner == model.jid) {
Kirigami.Theme.highlightColor
......
......@@ -51,6 +51,7 @@ RowLayout {
property bool isLastMessage
property bool edited
property bool isLoading: kaidan.transferCache.hasUpload(msgId)
property string name
property var upload: {
if (mediaType !== Enums.MessageText &&
kaidan.transferCache.hasUpload(msgId)) {
......@@ -70,7 +71,7 @@ RowLayout {
RoundImage {
id: avatar
visible: !sentByMe
visible: !sentByMe && recipientAvatarUrl !== ""
source: recipientAvatarUrl
fillMode: Image.PreserveAspectFit
mipmap: true
......@@ -82,6 +83,15 @@ RowLayout {
sourceSize.width: Kirigami.Units.gridUnit * 2.2
}
TextAvatar {
id: textAvatar
visible: !sentByMe && recipientAvatarUrl == ""
name: root.name
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
Layout.preferredHeight: Kirigami.Units.gridUnit * 2.2
Layout.preferredWidth: Kirigami.Units.gridUnit * 2.2
}
// message bubble/box
Item {
Layout.preferredWidth: content.width + 13
......
......@@ -58,20 +58,29 @@ Kirigami.SwipeListItem {
Layout.preferredHeight: parent.height
Layout.preferredWidth: parent.height
Controls.ToolTip {
visible: hovered && !Kirigami.Settings.isMobile
delay: Qt.styleHints.mousePressAndHoldInterval
text: generateToolTipText(listItem.name, listItem.jid,
listItem.presenceType, listItem.statusMsg)
}
RoundImage {
id: avatar
visible: avatarImagePath !== ""
anchors.fill: parent
source: avatarImagePath
width: height
fillMode: Image.PreserveAspectFit
mipmap: true
}
Controls.ToolTip {
visible: hovered && !Kirigami.Settings.isMobile
delay: Qt.styleHints.mousePressAndHoldInterval
text: generateToolTipText(listItem.name, listItem.jid,
listItem.presenceType, listItem.statusMsg)
}
TextAvatar {
visible: avatarImagePath == ""
anchors.fill: parent
width: height
id: textAvatar
name: listItem.name
}
Rectangle {
......
/*
* 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 <http://www.gnu.org/licenses/>.
*/
import org.kde.kirigami 2.2 as Kirigami
import QtQuick 2.7
import QtQuick.Layouts 1.2
Rectangle {
id: avatar
property string name
color: Qt.lighter(kaidan.getUserColor(name))
radius: width * 0.5
Text {
id: text
anchors.fill: parent
anchors.margins: Kirigami.Units.devicePixelRatio * 5
property var model
renderType: Text.QtRendering
color: Kirigami.Theme.textColor
font.weight: Font.Bold
font.pointSize: 100
minimumPointSize: Kirigami.Theme.defaultFont.pointSize
fontSizeMode: Text.Fit
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: {
// WIPQTQUICK HACK TODO Probably doesn't work with non-latin1.
var match = name.match(/([a-zA-Z0-9])([a-zA-Z0-9])/);
var abbrev = match[1].toUpperCase();
if (match.length > 2) {
abbrev += match[2].toLowerCase();
}
return abbrev;
}
}
}
......@@ -259,7 +259,10 @@ def main():
copyrightTargets = [
CopyrightTarget(
directories = ["src", "utils", "misc"],
licenseName = "GPL-3+ with OpenSSL exception"
licenseName = "GPL-3+ with OpenSSL exception",
additionalAuthors = {
"Eike Hein <hein@kde.org>": CopyrightAuthor(years = "2017-2018")
}
),
CopyrightTarget(
directories = ["i18n"],
......@@ -300,12 +303,11 @@ def main():
CopyrightTarget(
files = [
"misc/kaidan.svg", "misc/kaidan-small-margin.svg", "misc/kaidan-128x128.png",
"data/images/fallback-avatar.svg", "data/images/banner.png"
"data/images/banner.png"
],
licenseName = "CC-BY-SA-4.0",
authorList = {
"Ilya Bizyaev <bizyaev@zoho.com>": CopyrightAuthor(years = "2016-2017"),
"LNJ <git@lnj.li>": CopyrightAuthor(years = "2017"),
"MBB <mbb-mail@gmx.de>": CopyrightAuthor(years = "2016"),
}
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment