forked from blue/squawk
joining groups on opening them, leaving on closing
This commit is contained in:
parent
023494de0b
commit
a51907b810
14 changed files with 84 additions and 16 deletions
|
@ -247,6 +247,10 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
|
|||
} else if (room != 0) {
|
||||
created = true;
|
||||
conv = new Room(room);
|
||||
|
||||
if (!room->getJoined()) {
|
||||
emit setRoomJoined(id->account, id->name, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (conv != 0) {
|
||||
|
@ -283,11 +287,18 @@ void Squawk::onConversationShown()
|
|||
void Squawk::onConversationClosed(QObject* parent)
|
||||
{
|
||||
Conversation* conv = static_cast<Conversation*>(sender());
|
||||
Conversations::const_iterator itr = conversations.find({conv->getAccount(), conv->getJid()});
|
||||
Models::Roster::ElId id(conv->getAccount(), conv->getJid());
|
||||
Conversations::const_iterator itr = conversations.find(id);
|
||||
if (itr == conversations.end()) {
|
||||
qDebug() << "Conversation has been closed but can not be found among other opened conversations, application is most probably going to crash";
|
||||
return;
|
||||
}
|
||||
if (conv->isMuc) {
|
||||
Room* room = static_cast<Room*>(conv);
|
||||
if (room->autoJoined()) {
|
||||
emit setRoomJoined(id.account, id.name, false);
|
||||
}
|
||||
}
|
||||
conversations.erase(itr);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ signals:
|
|||
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
||||
void removeContactRequest(const QString& account, const QString& jid);
|
||||
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||
|
||||
public slots:
|
||||
void newAccount(const QMap<QString, QVariant>& account);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "chat.h"
|
||||
|
||||
Chat::Chat(Models::Contact* p_contact, QWidget* parent):
|
||||
Conversation(p_contact->getAccountJid(), p_contact->getAccountResource(), p_contact->getJid(), "", p_contact->getAccountName(), parent),
|
||||
Conversation(false, p_contact->getAccountJid(), p_contact->getAccountResource(), p_contact->getJid(), "", p_contact->getAccountName(), parent),
|
||||
contact(p_contact)
|
||||
{
|
||||
setName(p_contact->getContactName());
|
||||
|
|
|
@ -24,14 +24,15 @@
|
|||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QFileDialog>
|
||||
|
||||
Conversation::Conversation(const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent):
|
||||
Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent):
|
||||
QWidget(parent),
|
||||
isMuc(muc),
|
||||
myJid(mJid),
|
||||
myResource(mRes),
|
||||
palJid(pJid),
|
||||
activePalResource(pRes),
|
||||
account(acc),
|
||||
line(new MessageLine()),
|
||||
line(new MessageLine(muc)),
|
||||
m_ui(new Ui::Conversation()),
|
||||
ker(),
|
||||
thread(),
|
||||
|
|
|
@ -46,7 +46,7 @@ class Conversation : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Conversation(const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent = 0);
|
||||
Conversation(bool muc, const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent = 0);
|
||||
~Conversation();
|
||||
|
||||
QString getJid() const;
|
||||
|
@ -75,6 +75,9 @@ protected slots:
|
|||
void onAttach();
|
||||
void onFileSelected();
|
||||
|
||||
public:
|
||||
const bool isMuc;
|
||||
|
||||
protected:
|
||||
enum Scroll {
|
||||
nothing,
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
const QRegExp urlReg("^(?!<img\\ssrc=\")((?:https?|ftp)://\\S+)");
|
||||
const QRegExp imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
|
||||
|
||||
MessageLine::MessageLine(QWidget* parent):
|
||||
MessageLine::MessageLine(bool p_room, QWidget* parent):
|
||||
QWidget(parent),
|
||||
messageIndex(),
|
||||
messageOrder(),
|
||||
|
@ -31,7 +31,7 @@ MessageLine::MessageLine(QWidget* parent):
|
|||
myName(),
|
||||
palNames(),
|
||||
views(),
|
||||
room(false)
|
||||
room(p_room)
|
||||
{
|
||||
setLayout(layout);
|
||||
setBackgroundRole(QPalette::Base);
|
||||
|
@ -45,11 +45,6 @@ MessageLine::~MessageLine()
|
|||
}
|
||||
}
|
||||
|
||||
void MessageLine::setRoom(bool p_room)
|
||||
{
|
||||
room = p_room;
|
||||
}
|
||||
|
||||
MessageLine::Position MessageLine::message(const Shared::Message& msg)
|
||||
{
|
||||
QString id = msg.getId();
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
end,
|
||||
invalid
|
||||
};
|
||||
MessageLine(QWidget* parent = 0);
|
||||
MessageLine(bool p_room, QWidget* parent = 0);
|
||||
~MessageLine();
|
||||
|
||||
Position message(const Shared::Message& msg);
|
||||
|
@ -45,7 +45,6 @@ public:
|
|||
QString firstMessageId() const;
|
||||
void showBusyIndicator();
|
||||
void hideBusyIndicator();
|
||||
void setRoom(bool p_room);
|
||||
|
||||
signals:
|
||||
void resize(int amount);
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
#include "room.h"
|
||||
|
||||
Room::Room(Models::Room* p_room, QWidget* parent):
|
||||
Conversation(p_room->getAccountJid(), p_room->getAccountResource(), p_room->getJid(), "", p_room->getAccountName(), parent),
|
||||
Conversation(true, p_room->getAccountJid(), p_room->getAccountResource(), p_room->getJid(), "", p_room->getAccountName(), parent),
|
||||
room(p_room)
|
||||
{
|
||||
setName(p_room->getName());
|
||||
line->setMyName(room->getNick());
|
||||
line->setRoom(true);
|
||||
}
|
||||
|
||||
Room::~Room()
|
||||
|
@ -44,3 +43,8 @@ void Room::handleSendMessage(const QString& text)
|
|||
msg.setCurrentTime();
|
||||
emit sendMessage(msg);
|
||||
}
|
||||
|
||||
bool Room::autoJoined() const
|
||||
{
|
||||
return room->getAutoJoin();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
Room(Models::Room* p_room, QWidget* parent = 0);
|
||||
~Room();
|
||||
|
||||
bool autoJoined() const;
|
||||
|
||||
protected:
|
||||
void handleSendMessage(const QString & text) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue