mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Add groupchat notification support
This commit is contained in:
parent
20235b1c93
commit
ed741b6364
|
@ -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()
|
||||
|
|
1
group.h
1
group.h
|
@ -32,6 +32,7 @@ public:
|
|||
GroupChatForm* chatForm;
|
||||
bool hasPeerInfo;
|
||||
QTimer peerInfoTimer;
|
||||
int hasNewMessages;
|
||||
};
|
||||
|
||||
#endif // GROUP_H
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ signals:
|
|||
|
||||
public:
|
||||
int groupId;
|
||||
QLabel avatar, name, nusers;
|
||||
QLabel avatar, name, nusers, statusPic;
|
||||
QHBoxLayout layout;
|
||||
QVBoxLayout textLayout;
|
||||
void setAsInactiveChatroom();
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user