From cc93a6da1a61a02ff3df49856ffa827736c02e6e Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 29 Mar 2023 20:46:41 +0200 Subject: [PATCH] using orange color for unread comment bubble in channel post widget, and fixed the color update when new comment arrives --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 12 ++++ .../gui/gxschannels/GxsChannelPostsModel.h | 1 + .../GxsChannelPostsWidgetWithModel.cpp | 65 +++++++++++-------- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 6063d4d64..7d22208d5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -801,6 +801,16 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); } +void RsGxsChannelPostsModel::updatePostWithNewComment(const RsGxsMessageId& msg_id) +{ + for(uint32_t i=0;i 0) + { + QPainter p(&pixmap); + QFontMetricsF fm(option.font); - if(post.mUnreadCommentCount) - { - QPainter p(&pixmap); - QFontMetricsF fm(option.font); - - p.drawPixmap(QPoint(pixmap.width(),0.0)+mZoom*QPoint(-2.9*fm.height(),0.4*fm.height()), - FilesDefs::getPixmapFromQtResourcePath(COMMENT_OVERLAY_IMAGE).scaled(mZoom*3*fm.height(),mZoom*3*fm.height(), - Qt::KeepAspectRatio,Qt::SmoothTransformation)); - } + p.drawPixmap(QPoint(pixmap.width(),0.0)+mZoom*QPoint(-2.9*fm.height(),0.4*fm.height()), + FilesDefs::getPixmapFromQtResourcePath(UNREAD_COMMENT_OVERLAY_IMAGE).scaled(mZoom*3*fm.height(),mZoom*3*fm.height(), + Qt::KeepAspectRatio,Qt::SmoothTransformation)); + } + else if(post.mCommentCount > 0) + { + QPainter p(&pixmap); + QFontMetricsF fm(option.font); + p.drawPixmap(QPoint(pixmap.width(),0.0)+mZoom*QPoint(-2.9*fm.height(),0.4*fm.height()), + FilesDefs::getPixmapFromQtResourcePath(COMMENT_OVERLAY_IMAGE).scaled(mZoom*3*fm.height(),mZoom*3*fm.height(), + Qt::KeepAspectRatio,Qt::SmoothTransformation)); } painter->drawPixmap(option.rect.topLeft(), - pixmap.scaled(option.rect.width(),option.rect.width()*pixmap.height()/(float)pixmap.width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); + pixmap.scaled(option.rect.width(),option.rect.width()*pixmap.height()/(float)pixmap.width(), + Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); } else { @@ -833,7 +840,11 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptrmChannelGroupId == groupId() && e->mChannelThreadId != ui->commentsDialog->messageId()) + mChannelPostsModel->updatePostWithNewComment(e->mChannelThreadId); [[fallthrough]]; + case RsChannelEventCode::NEW_VOTE: if(e->mChannelGroupId == groupId() && e->mChannelThreadId == ui->commentsDialog->messageId()) @@ -922,7 +933,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() // Now also set the post as read - if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) + if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus) || post.mUnreadCommentCount > 0) { mChannelPostsModel->setMsgReadStatus(index,true);