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.setInterval(500);
|
||||||
peerInfoTimer.setSingleShot(false);
|
peerInfoTimer.setSingleShot(false);
|
||||||
//peerInfoTimer.start();
|
//peerInfoTimer.start();
|
||||||
|
|
||||||
|
//in groupchats, we only notify on messages containing your name
|
||||||
|
hasNewMessages = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Group::~Group()
|
Group::~Group()
|
||||||
|
|
1
group.h
1
group.h
|
@ -32,6 +32,7 @@ public:
|
||||||
GroupChatForm* chatForm;
|
GroupChatForm* chatForm;
|
||||||
bool hasPeerInfo;
|
bool hasPeerInfo;
|
||||||
QTimer peerInfoTimer;
|
QTimer peerInfoTimer;
|
||||||
|
int hasNewMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GROUP_H
|
#endif // GROUP_H
|
||||||
|
|
|
@ -18,6 +18,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
||||||
textLayout.setMargin(0);
|
textLayout.setMargin(0);
|
||||||
|
|
||||||
avatar.setPixmap(QPixmap("img/contact list icons/group_2x.png"));
|
avatar.setPixmap(QPixmap("img/contact list icons/group_2x.png"));
|
||||||
|
statusPic.setPixmap(QPixmap("img/status/dot_away.png"));
|
||||||
name.setText(Name);
|
name.setText(Name);
|
||||||
QFont small;
|
QFont small;
|
||||||
small.setPixelSize(10);
|
small.setPixelSize(10);
|
||||||
|
@ -41,6 +42,9 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
||||||
layout.addSpacing(5);
|
layout.addSpacing(5);
|
||||||
layout.addLayout(&textLayout);
|
layout.addLayout(&textLayout);
|
||||||
layout.addStretch();
|
layout.addStretch();
|
||||||
|
layout.addSpacing(5);
|
||||||
|
layout.addWidget(&statusPic);
|
||||||
|
layout.addSpacing(5);
|
||||||
|
|
||||||
isActiveWidget = 0;
|
isActiveWidget = 0;
|
||||||
}
|
}
|
||||||
|
@ -71,11 +75,20 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
void GroupWidget::mousePressEvent(QMouseEvent *event)
|
void GroupWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if ((event->buttons() & Qt::LeftButton) == Qt::LeftButton)
|
if ((event->buttons() & Qt::LeftButton) == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
if (isActiveWidget)
|
||||||
|
{
|
||||||
|
QPalette pal;
|
||||||
|
pal.setColor(QPalette::Background, QColor(250,250,250,255));
|
||||||
|
this->setPalette(pal);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
||||||
this->setPalette(pal);
|
this->setPalette(pal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::enterEvent(QEvent*)
|
void GroupWidget::enterEvent(QEvent*)
|
||||||
|
|
|
@ -25,7 +25,7 @@ signals:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int groupId;
|
int groupId;
|
||||||
QLabel avatar, name, nusers;
|
QLabel avatar, name, nusers, statusPic;
|
||||||
QHBoxLayout layout;
|
QHBoxLayout layout;
|
||||||
QVBoxLayout textLayout;
|
QVBoxLayout textLayout;
|
||||||
void setAsInactiveChatroom();
|
void setAsInactiveChatroom();
|
||||||
|
|
|
@ -423,6 +423,16 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g->chatForm->addGroupMessage(message, friendgroupnumber);
|
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)
|
void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Change)
|
||||||
|
@ -459,6 +469,12 @@ void Widget::onGroupWidgetClicked(GroupWidget* widget)
|
||||||
widget->setAsActiveChatroom();
|
widget->setAsActiveChatroom();
|
||||||
isFriendWidgetActive = 0;
|
isFriendWidgetActive = 0;
|
||||||
isGroupWidgetActive = 1;
|
isGroupWidgetActive = 1;
|
||||||
|
|
||||||
|
if (g->hasNewMessages != 0)
|
||||||
|
{
|
||||||
|
g->hasNewMessages = 0;
|
||||||
|
g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat.png"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::removeGroup(int groupId)
|
void Widget::removeGroup(int groupId)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user