mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #248 from apprb/chat_widget
FriendWidget and GroupWidget improvements
This commit is contained in:
commit
bedc995659
6
qtox.pro
6
qtox.pro
|
@ -100,7 +100,8 @@ HEADERS += widget/form/addfriendform.h \
|
|||
style.h \
|
||||
widget/adjustingscrollarea.h \
|
||||
widget/croppinglabel.h \
|
||||
widget/friendlistwidget.h
|
||||
widget/friendlistwidget.h \
|
||||
widget/genericchatroomwidget.h
|
||||
|
||||
SOURCES += \
|
||||
widget/form/addfriendform.cpp \
|
||||
|
@ -132,4 +133,5 @@ SOURCES += \
|
|||
widget/adjustingscrollarea.cpp \
|
||||
widget/croppinglabel.cpp \
|
||||
widget/friendlistwidget.cpp \
|
||||
coreav.cpp
|
||||
coreav.cpp \
|
||||
widget/genericchatroomwidget.cpp
|
||||
|
|
|
@ -76,11 +76,6 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
updateGeometry();
|
||||
}
|
||||
|
||||
void FriendWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
{
|
||||
emit friendWidgetClicked(this);
|
||||
}
|
||||
|
||||
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||
{
|
||||
QPoint pos = event->globalPos();
|
||||
|
@ -122,47 +117,6 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
}
|
||||
}
|
||||
|
||||
void FriendWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
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;
|
||||
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FriendWidget::enterEvent(QEvent*)
|
||||
{
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(75,75,75,255));
|
||||
lastColor = this->palette().background().color();
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void FriendWidget::leaveEvent(QEvent*)
|
||||
{
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, lastColor);
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FriendWidget::setAsActiveChatroom()
|
||||
{
|
||||
isActiveWidget = 1;
|
||||
|
@ -201,11 +155,6 @@ void FriendWidget::setAsInactiveChatroom()
|
|||
avatar.setPixmap(QPixmap(":img/contact.png"));
|
||||
}
|
||||
|
||||
int FriendWidget::isActive()
|
||||
{
|
||||
return isActiveWidget;
|
||||
}
|
||||
|
||||
void FriendWidget::updateStatusLight()
|
||||
{
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
|
@ -228,3 +177,15 @@ void FriendWidget::updateStatusLight()
|
|||
else if (status == Status::Offline && f->hasNewEvents == 1)
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.png"));
|
||||
}
|
||||
|
||||
void FriendWidget::setChatForm(Ui::MainWindow &ui)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
f->chatForm->show(ui);
|
||||
}
|
||||
|
||||
void FriendWidget::resetEventFlags()
|
||||
{
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
f->hasNewEvents = 0;
|
||||
}
|
||||
|
|
|
@ -22,22 +22,20 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "genericchatroomwidget.h"
|
||||
#include "croppinglabel.h"
|
||||
|
||||
struct FriendWidget : public QWidget
|
||||
struct FriendWidget : public GenericChatroomWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FriendWidget(int FriendId, QString id);
|
||||
void mouseReleaseEvent (QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent * event);
|
||||
void enterEvent(QEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
void setAsActiveChatroom();
|
||||
void setAsInactiveChatroom();
|
||||
int isActive();
|
||||
void updateStatusLight();
|
||||
void setChatForm(Ui::MainWindow &);
|
||||
void resetEventFlags();
|
||||
|
||||
signals:
|
||||
void friendWidgetClicked(FriendWidget* widget);
|
||||
|
@ -48,12 +46,6 @@ public:
|
|||
int friendId;
|
||||
QLabel avatar, statusPic;
|
||||
CroppingLabel name, statusMessage;
|
||||
QHBoxLayout layout;
|
||||
QVBoxLayout textLayout;
|
||||
|
||||
private:
|
||||
QColor lastColor;
|
||||
int isActiveWidget;
|
||||
};
|
||||
|
||||
#endif // FRIENDWIDGET_H
|
||||
|
|
73
widget/genericchatroomwidget.cpp
Normal file
73
widget/genericchatroomwidget.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "genericchatroomwidget.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
int GenericChatroomWidget::isActive()
|
||||
{
|
||||
return isActiveWidget;
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if ((event->buttons() & Qt::LeftButton) == Qt::LeftButton)
|
||||
{
|
||||
if (isActive())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::leaveEvent(QEvent *)
|
||||
{
|
||||
if (isActive() != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, lastColor);
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::enterEvent(QEvent *)
|
||||
{
|
||||
if (isActive() != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(75,75,75,255));
|
||||
lastColor = this->palette().background().color();
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent*)
|
||||
{
|
||||
emit chatroomWidgetClicked(this);
|
||||
}
|
58
widget/genericchatroomwidget.h
Normal file
58
widget/genericchatroomwidget.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GENERICCHATROOMWIDGET_H
|
||||
#define GENERICCHATROOMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class GenericChatroomWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GenericChatroomWidget(QWidget *parent = 0);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent (QMouseEvent* event);
|
||||
void leaveEvent(QEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
|
||||
virtual void setAsActiveChatroom(){;}
|
||||
virtual void setAsInactiveChatroom(){;}
|
||||
virtual void updateStatusLight(){;}
|
||||
virtual void setChatForm(Ui::MainWindow &){;}
|
||||
virtual void resetEventFlags(){;}
|
||||
|
||||
int isActive();
|
||||
|
||||
signals:
|
||||
void chatroomWidgetClicked(GenericChatroomWidget* widget);
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
int isActiveWidget;
|
||||
QColor lastColor;
|
||||
QHBoxLayout layout;
|
||||
QVBoxLayout textLayout;
|
||||
};
|
||||
|
||||
#endif // GENERICCHATROOMWIDGET_H
|
|
@ -17,10 +17,14 @@
|
|||
#include "groupwidget.h"
|
||||
#include "grouplist.h"
|
||||
#include "group.h"
|
||||
#include "settings.h"
|
||||
#include "widget/form/groupchatform.h"
|
||||
#include <QPalette>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
GroupWidget::GroupWidget(int GroupId, QString Name)
|
||||
: groupId{GroupId}
|
||||
{
|
||||
|
@ -72,11 +76,6 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
isActiveWidget = 0;
|
||||
}
|
||||
|
||||
void GroupWidget::mouseReleaseEvent (QMouseEvent*)
|
||||
{
|
||||
emit groupWidgetClicked(this);
|
||||
}
|
||||
|
||||
void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||
{
|
||||
QPoint pos = event->globalPos();
|
||||
|
@ -94,46 +93,6 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
}
|
||||
}
|
||||
|
||||
void GroupWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
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;
|
||||
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::enterEvent(QEvent*)
|
||||
{
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(75,75,75,255));
|
||||
lastColor = this->palette().background().color();
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::leaveEvent(QEvent*)
|
||||
{
|
||||
if (isActiveWidget != 1)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, lastColor);
|
||||
this->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::onUserListChanged()
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
|
@ -180,3 +139,40 @@ void GroupWidget::setAsInactiveChatroom()
|
|||
this->setPalette(pal3);
|
||||
avatar.setPixmap(QPixmap(":img/group.png"));
|
||||
}
|
||||
|
||||
void GroupWidget::updateStatusLight()
|
||||
{
|
||||
Group *g = GroupList::findGroup(groupId);
|
||||
|
||||
if (Settings::getInstance().getUseNativeDecoration())
|
||||
{
|
||||
if (g->hasNewMessages == 0)
|
||||
{
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||
} else {
|
||||
if (g->userWasMentioned == 0) statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||
else statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||
}
|
||||
} else {
|
||||
if (g->hasNewMessages == 0)
|
||||
{
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||
} else {
|
||||
if (g->userWasMentioned == 0) statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_newmessages.png"));
|
||||
else statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_notification.png"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::setChatForm(Ui::MainWindow &ui)
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->chatForm->show(ui);
|
||||
}
|
||||
|
||||
void GroupWidget::resetEventFlags()
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->hasNewMessages = 0;
|
||||
g->userWasMentioned = 0;
|
||||
}
|
||||
|
|
|
@ -19,22 +19,20 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include "genericchatroomwidget.h"
|
||||
|
||||
class GroupWidget : public QWidget
|
||||
class GroupWidget : public GenericChatroomWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GroupWidget(int GroupId, QString Name);
|
||||
void onUserListChanged();
|
||||
void mouseReleaseEvent (QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent * event);
|
||||
void enterEvent(QEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
void setAsInactiveChatroom();
|
||||
void setAsActiveChatroom();
|
||||
void updateStatusLight();
|
||||
void setChatForm(Ui::MainWindow &);
|
||||
void resetEventFlags();
|
||||
|
||||
signals:
|
||||
void groupWidgetClicked(GroupWidget* widget);
|
||||
|
@ -43,12 +41,6 @@ signals:
|
|||
public:
|
||||
int groupId;
|
||||
QLabel avatar, name, nusers, statusPic;
|
||||
QHBoxLayout layout;
|
||||
QVBoxLayout textLayout;
|
||||
|
||||
private:
|
||||
QColor lastColor;
|
||||
int isActiveWidget;
|
||||
};
|
||||
|
||||
#endif // GROUPWIDGET_H
|
||||
|
|
|
@ -43,8 +43,7 @@ Widget *Widget::instance{nullptr};
|
|||
Widget::Widget(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
activeFriendWidget{nullptr},
|
||||
activeGroupWidget{nullptr}
|
||||
activeChatroomWidget{nullptr}
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -326,16 +325,14 @@ void Widget::onTransferClicked()
|
|||
{
|
||||
hideMainForms();
|
||||
filesForm.show(*ui);
|
||||
activeFriendWidget = nullptr;
|
||||
activeGroupWidget = nullptr;
|
||||
activeChatroomWidget = nullptr;
|
||||
}
|
||||
|
||||
void Widget::onSettingsClicked()
|
||||
{
|
||||
hideMainForms();
|
||||
settingsForm.show(*ui);
|
||||
activeFriendWidget = nullptr;
|
||||
activeGroupWidget = nullptr;
|
||||
activeChatroomWidget = nullptr;
|
||||
}
|
||||
|
||||
void Widget::hideMainForms()
|
||||
|
@ -346,17 +343,9 @@ void Widget::hideMainForms()
|
|||
while ((item = ui->mainContent->layout()->takeAt(0)) != 0)
|
||||
item->widget()->hide();
|
||||
|
||||
if (activeFriendWidget != nullptr)
|
||||
if (activeChatroomWidget != nullptr)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(activeFriendWidget->friendId);
|
||||
if (f != nullptr)
|
||||
activeFriendWidget->setAsInactiveChatroom();
|
||||
}
|
||||
if (activeGroupWidget != nullptr)
|
||||
{
|
||||
Group* g = GroupList::findGroup(activeGroupWidget->groupId);
|
||||
if (g != nullptr)
|
||||
activeGroupWidget->setAsInactiveChatroom();
|
||||
activeChatroomWidget->setAsInactiveChatroom();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,7 +403,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
Friend* newfriend = FriendList::addFriend(friendId, userId);
|
||||
QLayout* layout = contactListWidget->getFriendLayout(Status::Offline);
|
||||
layout->addWidget(newfriend->widget);
|
||||
connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*)));
|
||||
connect(newfriend->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
||||
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
||||
connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
|
||||
connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
|
||||
|
@ -495,26 +484,18 @@ void Widget::onFriendUsernameLoaded(int friendId, const QString& username)
|
|||
f->setName(username);
|
||||
}
|
||||
|
||||
void Widget::onFriendWidgetClicked(FriendWidget *widget)
|
||||
void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(widget->friendId);
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
hideMainForms();
|
||||
f->chatForm->show(*ui);
|
||||
if (activeFriendWidget != nullptr)
|
||||
widget->setChatForm(*ui);
|
||||
if (activeChatroomWidget != nullptr)
|
||||
{
|
||||
activeFriendWidget->setAsInactiveChatroom();
|
||||
activeChatroomWidget->setAsInactiveChatroom();
|
||||
}
|
||||
activeFriendWidget = widget;
|
||||
activeChatroomWidget = widget;
|
||||
widget->setAsActiveChatroom();
|
||||
activeGroupWidget = nullptr;
|
||||
|
||||
if (f->hasNewEvents != 0)
|
||||
f->hasNewEvents = 0;
|
||||
|
||||
f->widget->updateStatusLight();
|
||||
widget->resetEventFlags();
|
||||
widget->updateStatusLight();
|
||||
}
|
||||
|
||||
void Widget::onFriendMessageReceived(int friendId, const QString& message)
|
||||
|
@ -525,10 +506,9 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message)
|
|||
|
||||
f->chatForm->addFriendMessage(message);
|
||||
|
||||
if (activeFriendWidget != nullptr)
|
||||
if (activeChatroomWidget != nullptr)
|
||||
{
|
||||
Friend* f2 = FriendList::findFriend(activeFriendWidget->friendId);
|
||||
if ((f->friendId != f2->friendId) || isWindowMinimized || !isActiveWindow())
|
||||
if ((static_cast<GenericChatroomWidget*>(f->widget) != activeChatroomWidget) || isWindowMinimized || !isActiveWindow())
|
||||
{
|
||||
f->hasNewEvents = 1;
|
||||
newMessageAlert();
|
||||
|
@ -575,8 +555,8 @@ void Widget::removeFriend(int friendId)
|
|||
{
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
f->widget->setAsInactiveChatroom();
|
||||
if (f->widget == activeFriendWidget)
|
||||
activeFriendWidget = nullptr;
|
||||
if (static_cast<GenericChatroomWidget*>(f->widget) == activeChatroomWidget)
|
||||
activeChatroomWidget = nullptr;
|
||||
FriendList::removeFriend(friendId);
|
||||
core->removeFriend(friendId);
|
||||
delete f;
|
||||
|
@ -612,27 +592,15 @@ void Widget::onGroupMessageReceived(int groupnumber, int friendgroupnumber, cons
|
|||
|
||||
g->chatForm->addGroupMessage(message, friendgroupnumber);
|
||||
|
||||
if (((activeGroupWidget && g->groupId != activeGroupWidget->groupId)) || isWindowMinimized || !isActiveWindow())
|
||||
if ((static_cast<GenericChatroomWidget*>(g->widget) != activeChatroomWidget) || isWindowMinimized || !isActiveWindow())
|
||||
{
|
||||
g->hasNewMessages = 1;
|
||||
if (message.contains(core->getUsername(), Qt::CaseInsensitive))
|
||||
{
|
||||
newMessageAlert();
|
||||
g->hasNewMessages = 1;
|
||||
g->userWasMentioned = 1;
|
||||
if (Settings::getInstance().getUseNativeDecoration())
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||
else
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_notification.png"));
|
||||
}
|
||||
else
|
||||
if (g->hasNewMessages == 0)
|
||||
{
|
||||
g->hasNewMessages = 1;
|
||||
if (Settings::getInstance().getUseNativeDecoration())
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
|
||||
else
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat_newmessages.png"));
|
||||
}
|
||||
g->widget->updateStatusLight();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -654,39 +622,12 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
|
|||
g->updatePeer(peernumber,core->getGroupPeerName(groupnumber, peernumber));
|
||||
}
|
||||
|
||||
void Widget::onGroupWidgetClicked(GroupWidget* widget)
|
||||
{
|
||||
Group* g = GroupList::findGroup(widget->groupId);
|
||||
if (!g)
|
||||
return;
|
||||
|
||||
hideMainForms();
|
||||
g->chatForm->show(*ui);
|
||||
if (activeGroupWidget != nullptr)
|
||||
{
|
||||
activeGroupWidget->setAsInactiveChatroom();
|
||||
}
|
||||
activeGroupWidget = widget;
|
||||
widget->setAsActiveChatroom();
|
||||
activeFriendWidget = nullptr;
|
||||
|
||||
if (g->hasNewMessages != 0)
|
||||
{
|
||||
g->hasNewMessages = 0;
|
||||
g->userWasMentioned = 0;
|
||||
if (Settings::getInstance().getUseNativeDecoration())
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||
else
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::removeGroup(int groupId)
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->widget->setAsInactiveChatroom();
|
||||
if (g->widget == activeGroupWidget)
|
||||
activeGroupWidget = nullptr;
|
||||
if (static_cast<GenericChatroomWidget*>(g->widget) == activeChatroomWidget)
|
||||
activeChatroomWidget = nullptr;
|
||||
GroupList::removeGroup(groupId);
|
||||
core->removeGroup(groupId);
|
||||
delete g;
|
||||
|
@ -712,10 +653,9 @@ Group *Widget::createGroup(int groupId)
|
|||
Group* newgroup = GroupList::addGroup(groupId, groupName);
|
||||
QLayout* layout = contactListWidget->getGroupLayout();
|
||||
layout->addWidget(newgroup->widget);
|
||||
if (!Settings::getInstance().getUseNativeDecoration())
|
||||
newgroup->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||
newgroup->widget->updateStatusLight();
|
||||
|
||||
connect(newgroup->widget, SIGNAL(groupWidgetClicked(GroupWidget*)), this, SLOT(onGroupWidgetClicked(GroupWidget*)));
|
||||
connect(newgroup->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
|
||||
connect(newgroup->widget, SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
||||
connect(newgroup->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
|
||||
return newgroup;
|
||||
|
@ -735,15 +675,11 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
|||
{
|
||||
if (!f)
|
||||
return false;
|
||||
if (activeFriendWidget != nullptr)
|
||||
{
|
||||
Friend* f2 = FriendList::findFriend(activeFriendWidget->friendId);
|
||||
if (f->friendId != f2->friendId)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChatroomWidget == static_cast<GenericChatroomWidget*>(f->widget))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Widget::event(QEvent * e)
|
||||
|
@ -764,21 +700,10 @@ bool Widget::event(QEvent * e)
|
|||
this->style()->polish(this);
|
||||
}
|
||||
isWindowMinimized = 0;
|
||||
if (activeFriendWidget != nullptr)
|
||||
if (activeChatroomWidget != nullptr)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(activeFriendWidget->friendId);
|
||||
f->hasNewEvents = 0;
|
||||
f->widget->updateStatusLight();
|
||||
}
|
||||
else if (activeGroupWidget != nullptr)
|
||||
{
|
||||
Group* g = GroupList::findGroup(activeGroupWidget->groupId);
|
||||
g->hasNewMessages = 0;
|
||||
g->userWasMentioned = 0;
|
||||
if (Settings::getInstance().getUseNativeDecoration())
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||
else
|
||||
g->widget->statusPic.setPixmap(QPixmap(":img/status/dot_groupchat.png"));
|
||||
activeChatroomWidget->resetEventFlags();
|
||||
activeChatroomWidget->updateStatusLight();
|
||||
}
|
||||
}
|
||||
else if (e->type() == QEvent::WindowDeactivate && !Settings::getInstance().getUseNativeDecoration())
|
||||
|
|
|
@ -35,8 +35,7 @@ namespace Ui {
|
|||
class MainWindow;
|
||||
}
|
||||
|
||||
class GroupWidget;
|
||||
struct FriendWidget;
|
||||
class GenericChatroomWidget;
|
||||
class Group;
|
||||
struct Friend;
|
||||
|
||||
|
@ -95,14 +94,13 @@ private slots:
|
|||
void onFriendUsernameChanged(int friendId, const QString& username);
|
||||
void onFriendStatusMessageLoaded(int friendId, const QString& message);
|
||||
void onFriendUsernameLoaded(int friendId, const QString& username);
|
||||
void onFriendWidgetClicked(FriendWidget* widget);
|
||||
void onChatroomWidgetClicked(GenericChatroomWidget *);
|
||||
void onFriendMessageReceived(int friendId, const QString& message);
|
||||
void onFriendRequestReceived(const QString& userId, const QString& message);
|
||||
void onEmptyGroupCreated(int groupId);
|
||||
void onGroupInviteReceived(int32_t friendId, const uint8_t *publicKey);
|
||||
void onGroupMessageReceived(int groupnumber, int friendgroupnumber, const QString& message);
|
||||
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||
void onGroupWidgetClicked(GroupWidget* widget);
|
||||
void removeFriend(int friendId);
|
||||
void copyFriendIdToClipboard(int friendId);
|
||||
void removeGroup(int groupId);
|
||||
|
@ -142,8 +140,7 @@ private:
|
|||
SettingsForm settingsForm;
|
||||
FilesForm filesForm;
|
||||
static Widget* instance;
|
||||
FriendWidget* activeFriendWidget;
|
||||
GroupWidget* activeGroupWidget;
|
||||
GenericChatroomWidget* activeChatroomWidget;
|
||||
FriendListWidget* contactListWidget;
|
||||
SelfCamView* camview;
|
||||
Camera* camera;
|
||||
|
|
Loading…
Reference in New Issue
Block a user