From 74c6b71e04f22581eb38b9d263b4aa41949ed572 Mon Sep 17 00:00:00 2001 From: Ashvin Nihalani Date: Sat, 27 Jun 2020 11:37:59 -0500 Subject: [PATCH] UI Improvements Removed Clutter Single Party Conversation Added Name ti Multiparty Changed Default Icon in Conversation List --- smsapp/qml/ChatMessage.qml | 17 ++++++++++++++--- smsapp/qml/ConversationDisplay.qml | 1 + smsapp/smshelper.cpp | 18 ++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/smsapp/qml/ChatMessage.qml b/smsapp/qml/ChatMessage.qml index 8a29eba0a..3b02c10fe 100644 --- a/smsapp/qml/ChatMessage.qml +++ b/smsapp/qml/ChatMessage.qml @@ -34,14 +34,15 @@ Item { property string selectedText property date dateTime property string name + property bool multiTarget signal messageCopyRequested(string message) Kirigami.Avatar { id: avatar - width: Kirigami.Units.gridUnit * 2 + width: visible ? Kirigami.Units.gridUnit * 2 : 0 height: width - visible: !root.sentByMe + visible: !root.sentByMe && multiTarget name: root.name anchors.left: parent.left @@ -103,6 +104,16 @@ Item { height: childrenRect.height property int contentWidth: Math.max(messageLabel.implicitWidth, dateLabel.implicitWidth) + Label { + id: authorLabel + width: parent.width + text: root.name + leftPadding: Kirigami.Units.largeSpacing + topPadding: Kirigami.Units.smallSpacing + visible: multiTarget + color: Kirigami.Theme.disabledTextColor + horizontalAlignment: messageLabel.horizontalAlignment + } TextEdit { id: messageLabel @@ -110,7 +121,7 @@ Item { readOnly: true leftPadding: Kirigami.Units.largeSpacing rightPadding: Kirigami.Units.largeSpacing - topPadding: Kirigami.Units.largeSpacing + topPadding: authorLabel.visible ? 0 : Kirigami.Units.largeSpacing width: parent.width horizontalAlignment: root.sentByMe ? Text.AlignRight : Text.AlignLeft wrapMode: Text.Wrap diff --git a/smsapp/qml/ConversationDisplay.qml b/smsapp/qml/ConversationDisplay.qml index 6d1a53ab5..4229f6b13 100644 --- a/smsapp/qml/ConversationDisplay.qml +++ b/smsapp/qml/ConversationDisplay.qml @@ -123,6 +123,7 @@ Kirigami.ScrollablePage messageBody: model.display sentByMe: model.fromMe dateTime: new Date(model.date) + multiTarget: isMultitarget width: viewport.width diff --git a/smsapp/smshelper.cpp b/smsapp/smshelper.cpp index 7b0bca529..138be2adf 100644 --- a/smsapp/smshelper.cpp +++ b/smsapp/smshelper.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -292,12 +293,21 @@ QIcon SmsHelper::getIconForAddresses(const QList& addresses QList icons; for (const ConversationAddress& address : addresses) { const auto personData = SmsHelper::lookupPersonByAddress(address.address()); - + static const QIcon defaultIcon = QIcon::fromTheme(QStringLiteral("im-user")); + static const QPixmap defaultAvatar = defaultIcon.pixmap(defaultIcon.actualSize(QSize(32, 32))); + QPixmap avatar; if (personData) { - icons.append(personData->photo()); + const QVariant pic = personData->contactCustomProperty(QStringLiteral("picture")); + if (pic.canConvert()) { + avatar = QPixmap::fromImage(pic.value()); + } + if (avatar.isNull()) { + icons.append(defaultAvatar); + } else { + icons.append(avatar); + } } else { - static QString dummyAvatar = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kf5/kpeople/dummy_avatar.png")); - icons.append(QPixmap(dummyAvatar)); + icons.append(defaultAvatar); } }