summary refs log tree commit diff
path: root/src/CommunitiesListItem.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-14 12:08:16 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-14 12:08:16 +0300
commit73dbd3c8dd78b41c8d93392eac74231e5b4a20d5 (patch)
tree8f48775d63a917faacfff03a55b1767bfb75477a /src/CommunitiesListItem.cc
parentProperly display the bottom border on the TopRoomBar (diff)
downloadnheko-73dbd3c8dd78b41c8d93392eac74231e5b4a20d5.tar.xz
Re-enable groups
Diffstat (limited to 'src/CommunitiesListItem.cc')
-rw-r--r--src/CommunitiesListItem.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/CommunitiesListItem.cc b/src/CommunitiesListItem.cc

index e5127050..df6c5393 100644 --- a/src/CommunitiesListItem.cc +++ b/src/CommunitiesListItem.cc
@@ -4,12 +4,9 @@ #include "RippleOverlay.h" #include "Utils.h" -CommunitiesListItem::CommunitiesListItem(QSharedPointer<Community> community, - QString community_id, - QWidget *parent) +CommunitiesListItem::CommunitiesListItem(QString group_id, QWidget *parent) : QWidget(parent) - , community_(community) - , communityId_(community_id) + , groupId_(group_id) { setMouseTracking(true); setAttribute(Qt::WA_Hover); @@ -20,8 +17,8 @@ CommunitiesListItem::CommunitiesListItem(QSharedPointer<Community> community, rippleOverlay_->setClipPath(path); rippleOverlay_->setClipping(true); - if (communityId_ == "world") - communityAvatar_ = QPixmap(":/icons/icons/ui/world.svg"); + if (groupId_ == "world") + avatar_ = QPixmap(":/icons/icons/ui/world.svg"); } void @@ -41,7 +38,7 @@ CommunitiesListItem::mousePressEvent(QMouseEvent *event) return; } - emit clicked(communityId_); + emit clicked(groupId_); setPressedState(true); @@ -70,12 +67,12 @@ CommunitiesListItem::paintEvent(QPaintEvent *) else p.fillRect(rect(), backgroundColor_); - if (communityAvatar_.isNull()) { + if (avatar_.isNull()) { QFont font; font.setPixelSize(conf::roomlist::fonts::communityBubble); p.setFont(font); - p.drawLetterAvatar(utils::firstChar(community_->getName()), + p.drawLetterAvatar(utils::firstChar(resolveName()), avatarFgColor_, avatarBgColor_, width(), @@ -84,7 +81,7 @@ CommunitiesListItem::paintEvent(QPaintEvent *) } else { p.save(); - p.drawAvatar(communityAvatar_, width(), height(), IconSize); + p.drawAvatar(avatar_, width(), height(), IconSize); p.restore(); } } @@ -92,6 +89,20 @@ CommunitiesListItem::paintEvent(QPaintEvent *) void CommunitiesListItem::setAvatar(const QImage &img) { - communityAvatar_ = utils::scaleImageToPixmap(img, IconSize); + avatar_ = utils::scaleImageToPixmap(img, IconSize); update(); } + +QString +CommunitiesListItem::resolveName() const +{ + if (!name_.isEmpty()) + return name_; + + if (!groupId_.startsWith("+")) + return QString("Group"); // Group with no name or id. + + // Extract the localpart of the group. + auto firstPart = groupId_.split(':').at(0); + return firstPart.right(firstPart.size() - 1); +}