1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #13 from F1ynn/master

Added groupchat notifications when your name is mentioned
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-06-28 01:50:00 +02:00
commit 68a50b995b
8 changed files with 46 additions and 4 deletions

View File

@ -16,6 +16,10 @@ 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;
userWasMentioned = 0;
}
Group::~Group()

View File

@ -32,6 +32,7 @@ public:
GroupChatForm* chatForm;
bool hasPeerInfo;
QTimer peerInfoTimer;
int hasNewMessages, userWasMentioned;
};
#endif // GROUP_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

View File

@ -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_groupchat.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);
}
}
}

View File

@ -25,7 +25,7 @@ signals:
public:
int groupId;
QLabel avatar, name, nusers;
QLabel avatar, name, nusers, statusPic;
QHBoxLayout layout;
QVBoxLayout textLayout;
void setAsInactiveChatroom();

View File

@ -422,6 +422,23 @@ 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->userWasMentioned = 1;
g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat_notification.png"));
}
else
if (g->hasNewMessages == 0)
{
g->hasNewMessages = 1;
g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat_newmessages.png"));
}
}
}
void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Change)
@ -458,6 +475,13 @@ void Widget::onGroupWidgetClicked(GroupWidget* widget)
widget->setAsActiveChatroom();
isFriendWidgetActive = 0;
isGroupWidgetActive = 1;
if (g->hasNewMessages != 0)
{
g->hasNewMessages = 0;
g->userWasMentioned = 0;
g->widget->statusPic.setPixmap(QPixmap("img/status/dot_groupchat.png"));
}
}
void Widget::removeGroup(int groupId)