Commit 23fd3fa9 authored by Edric Milaret's avatar Edric Milaret Committed by Alexandre Lision

im: add bubble for unread message

Also set all read when on im page or when displaying it

Change-Id: I71fde714cdd4888e483e724fd3757a5adf540fb0
Tuleap: #232
parent 645e4c37
......@@ -609,6 +609,7 @@ CallWidget::on_contactMethodComboBox_currentIndexChanged(const QString& number)
this,
SLOT(slotAccountMessageReceived(QMap<QString,QString>,ContactMethod*,Media::Media::Direction)));
ui->listMessageView->scrollToBottom();
txtRecording->setAllRead();
}
}
......@@ -618,10 +619,10 @@ CallWidget::slotAccountMessageReceived(const QMap<QString,QString> message,
Media::Media::Direction dir)
{
Q_UNUSED(message)
Q_UNUSED(cm)
Q_UNUSED(dir)
ui->listMessageView->scrollToBottom();
cm->textRecording()->setAllRead();
}
void
......
......@@ -39,6 +39,8 @@ SmartListDelegate::paint(QPainter* painter
, const QModelIndex& index
) const
{
painter->setRenderHint(QPainter::Antialiasing);
QStyleOptionViewItem opt(option);
painter->setRenderHint(QPainter::Antialiasing);
......@@ -63,15 +65,44 @@ SmartListDelegate::paint(QPainter* painter
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);
......
......@@ -40,11 +40,13 @@ private:
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;
......
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