Browse Source

Merge pull request #13 from F1ynn/master

Added groupchat notifications when your name is mentioned
pull/19/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
68a50b995b
  1. 4
      group.cpp
  2. 1
      group.h
  3. BIN
      img/status/dot_groupchat.png
  4. BIN
      img/status/dot_groupchat_newmessages.png
  5. BIN
      img/status/dot_groupchat_notification.png
  6. 19
      widget/groupwidget.cpp
  7. 2
      widget/groupwidget.h
  8. 24
      widget/widget.cpp

4
group.cpp

@ -16,6 +16,10 @@ Group::Group(int GroupId, QString Name) @@ -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()

1
group.h

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

BIN
img/status/dot_groupchat.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

BIN
img/status/dot_groupchat_newmessages.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

BIN
img/status/dot_groupchat_notification.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

19
widget/groupwidget.cpp

@ -18,6 +18,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name) @@ -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) @@ -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) @@ -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);
}
}
}

2
widget/groupwidget.h

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

24
widget/widget.cpp

@ -422,6 +422,23 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons @@ -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) @@ -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)

Loading…
Cancel
Save