im: add bubble for unread message
Also set all read when on im page or when displaying it
Change-Id: I71fde714cdd4888e483e724fd3757a5adf540fb0
Tuleap: #232
diff --git a/callwidget.cpp b/callwidget.cpp
index 7bc345c..08bb4bf 100644
--- a/callwidget.cpp
+++ b/callwidget.cpp
@@ -609,6 +609,7 @@
this,
SLOT(slotAccountMessageReceived(QMap<QString,QString>,ContactMethod*,Media::Media::Direction)));
ui->listMessageView->scrollToBottom();
+ txtRecording->setAllRead();
}
}
@@ -618,10 +619,10 @@
Media::Media::Direction dir)
{
Q_UNUSED(message)
- Q_UNUSED(cm)
Q_UNUSED(dir)
ui->listMessageView->scrollToBottom();
+ cm->textRecording()->setAllRead();
}
void
diff --git a/smartlistdelegate.cpp b/smartlistdelegate.cpp
index 755c261..ffa8bee 100644
--- a/smartlistdelegate.cpp
+++ b/smartlistdelegate.cpp
@@ -39,6 +39,8 @@
, const QModelIndex& index
) const
{
+ painter->setRenderHint(QPainter::Antialiasing);
+
QStyleOptionViewItem opt(option);
painter->setRenderHint(QPainter::Antialiasing);
@@ -63,15 +65,44 @@
drawDecoration(painter, opt, rectAvatar,
QPixmap::fromImage(index.data(Qt::DecorationRole).value<QImage>()));
- const int currentRow = index.row();
- if (currentRow == rowHighlighted_)
- emit rowSelected(opt.rect);
-
QFont font(painter->font());
+
+ if (auto messageCount = index.data(static_cast<int>(Ring::Role::UnreadTextMessageCount)).toInt()) {
+
+ font.setPointSize(8);
+ QFontMetrics textFontMetrics(font);
+ QString messageCountText = QString::number(messageCount);
+
+ QRect pastilleRect;
+ QRect(rectAvatar.right() - 7, rectAvatar.bottom() - 7, pinSize_, pinSize_);
+ pastilleRect = textFontMetrics.boundingRect(QRect(rectAvatar.left() + sizeImage_/3,
+ rectAvatar.bottom() - 6, sizeImage_, 0),
+ Qt::AlignCenter, messageCountText);
+
+ painter->setOpacity(0.9);
+ QRect bubbleRect(pastilleRect.left(), pastilleRect.top(),
+ pastilleRect.width() + 3, pastilleRect.height());
+
+ QPainterPath path;
+ path.addRoundedRect(bubbleRect, 3, 3);
+ QPen pen(red_, 5);
+ painter->setPen(pen);
+ painter->fillPath(path, red_);
+ painter->drawPath(path);
+
+ painter->setPen(Qt::white);
+ painter->setOpacity(1);
+ painter->setFont(font);
+ painter->drawText(bubbleRect, Qt::AlignCenter, messageCountText);
+ }
font.setPointSize(fontSize_);
QPen pen(painter->pen());
+ const int currentRow = index.row();
+ if (currentRow == rowHighlighted_)
+ emit rowSelected(opt.rect);
+
if (not (opt.state & QStyle::State_Selected)) {
pen.setColor(lightGrey_);
painter->setPen(pen);
diff --git a/smartlistdelegate.h b/smartlistdelegate.h
index a3f0d7f..354577c 100644
--- a/smartlistdelegate.h
+++ b/smartlistdelegate.h
@@ -40,11 +40,13 @@
constexpr static int dy_ = 6;
constexpr static int dx_ = 12;
constexpr static int fontSize_ = 10;
+ constexpr static int pinSize_ = 12;
int rowHighlighted_ = -1;
const QColor lightGrey_ {242, 242, 242};
const QColor lightBlack_ {63, 63, 63};
const QColor grey_ {192, 192, 192};
+ const QColor red_ {251, 72, 71};
signals:
void rowSelected(const QRect& rect) const;