diff --git a/group.cpp b/group.cpp index 1661db9fd..93fdd7254 100644 --- a/group.cpp +++ b/group.cpp @@ -16,6 +16,9 @@ Group::Group(int GroupId, QString Name) peerInfoTimer.setInterval(500); peerInfoTimer.setSingleShot(false); //peerInfoTimer.start(); + + //in groupchats, we only notify on messages containing your name + hasNewMessages = 0; } Group::~Group() diff --git a/group.h b/group.h index b064a5b96..f88cdf2bd 100644 --- a/group.h +++ b/group.h @@ -32,6 +32,7 @@ public: GroupChatForm* chatForm; bool hasPeerInfo; QTimer peerInfoTimer; + int hasNewMessages; }; #endif // GROUP_H diff --git a/widget/groupwidget.cpp b/widget/groupwidget.cpp index d2a3679fe..899edc1c2 100644 --- a/widget/groupwidget.cpp +++ b/widget/groupwidget.cpp @@ -18,6 +18,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name) textLayout.setMargin(0); avatar.setPixmap(QPixmap("img/contact list icons/group_2x.png")); + statusPic.setPixmap(QPixmap("img/status/dot_away.png")); name.setText(Name); QFont small; small.setPixelSize(10); @@ -41,6 +42,9 @@ GroupWidget::GroupWidget(int GroupId, QString Name) layout.addSpacing(5); layout.addLayout(&textLayout); layout.addStretch(); + layout.addSpacing(5); + layout.addWidget(&statusPic); + layout.addSpacing(5); isActiveWidget = 0; } @@ -72,9 +76,18 @@ void GroupWidget::mousePressEvent(QMouseEvent *event) { if ((event->buttons() & Qt::LeftButton) == Qt::LeftButton) { - QPalette pal; - pal.setColor(QPalette::Background, QColor(85,85,85,255)); - this->setPalette(pal); + if (isActiveWidget) + { + QPalette pal; + pal.setColor(QPalette::Background, QColor(250,250,250,255)); + this->setPalette(pal); + } + else + { + QPalette pal; + pal.setColor(QPalette::Background, QColor(85,85,85,255)); + this->setPalette(pal); + } } } diff --git a/widget/groupwidget.h b/widget/groupwidget.h index 19be90bfa..3aa5e9b46 100644 --- a/widget/groupwidget.h +++ b/widget/groupwidget.h @@ -25,7 +25,7 @@ signals: public: int groupId; - QLabel avatar, name, nusers; + QLabel avatar, name, nusers, statusPic; QHBoxLayout layout; QVBoxLayout textLayout; void setAsInactiveChatroom(); diff --git a/widget/widget.cpp b/widget/widget.cpp index 9563ee7f4..3c63e2490 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -423,6 +423,16 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons return; g->chatForm->addGroupMessage(message, friendgroupnumber); + + if (isGroupWidgetActive != 1 || (g->groupId != activeGroupWidget->groupId)) + { + if (message.contains(Settings::getInstance().getUsername(), Qt::CaseInsensitive)) + { + playMessageNotification(); + g->hasNewMessages = 1; + g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat_notification.png")); + } + } } void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Change) @@ -459,6 +469,12 @@ void Widget::onGroupWidgetClicked(GroupWidget* widget) widget->setAsActiveChatroom(); isFriendWidgetActive = 0; isGroupWidgetActive = 1; + + if (g->hasNewMessages != 0) + { + g->hasNewMessages = 0; + g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat.png")); + } } void Widget::removeGroup(int groupId)