UI Improvements

Removed Clutter Single Party Conversation
Added Name ti Multiparty
Changed Default Icon in Conversation List
This commit is contained in:
Ashvin Nihalani 2020-06-27 11:37:59 -05:00 committed by Nicolas Fella
parent 1315d9b9eb
commit 74c6b71e04
3 changed files with 29 additions and 7 deletions

View file

@ -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

View file

@ -123,6 +123,7 @@ Kirigami.ScrollablePage
messageBody: model.display
sentByMe: model.fromMe
dateTime: new Date(model.date)
multiTarget: isMultitarget
width: viewport.width

View file

@ -28,6 +28,7 @@
#include <QString>
#include <QStandardPaths>
#include <QHash>
#include <QtDebug>
#include <KPeople/PersonData>
#include <KPeople/PersonsModel>
@ -292,12 +293,21 @@ QIcon SmsHelper::getIconForAddresses(const QList<ConversationAddress>& addresses
QList<QPixmap> 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<QImage>()) {
avatar = QPixmap::fromImage(pic.value<QImage>());
}
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);
}
}