refactoring: UI squawk now belongs to a new class, it enables me doing trayed mode, when main window is destroyed

This commit is contained in:
Blue 2022-04-22 18:26:18 +03:00
parent 83cb220175
commit 721d3a1a89
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
16 changed files with 908 additions and 769 deletions

View file

@ -21,15 +21,13 @@
#include <QDebug>
#include <QIcon>
Squawk::Squawk(QWidget *parent) :
Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
QMainWindow(parent),
m_ui(new Ui::Squawk),
accounts(nullptr),
preferences(nullptr),
about(nullptr),
dialogueQueue(this),
rosterModel(*(Shared::Global::getInstance()->rosterModel)),
conversations(),
rosterModel(p_rosterModel),
contextMenu(new QMenu()),
vCards(),
currentConversation(nullptr),
@ -64,12 +62,8 @@ Squawk::Squawk(QWidget *parent) :
connect(m_ui->roster, &QTreeView::customContextMenuRequested, this, &Squawk::onRosterContextMenu);
connect(m_ui->roster, &QTreeView::collapsed, this, &Squawk::onItemCollepsed);
connect(m_ui->roster->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &Squawk::onRosterSelectionChanged);
connect(&rosterModel, &Models::Roster::unnoticedMessage, this, &Squawk::onUnnoticedMessage);
connect(rosterModel.accountsModel, &Models::Accounts::sizeChanged, this, &Squawk::onAccountsSizeChanged);
connect(&rosterModel, &Models::Roster::requestArchive, this, &Squawk::onRequestArchive);
connect(&rosterModel, &Models::Roster::fileDownloadRequest, this, &Squawk::fileDownloadRequest);
connect(&rosterModel, &Models::Roster::localPathInvalid, this, &Squawk::localPathInvalid);
connect(contextMenu, &QMenu::aboutToHide, this, &Squawk::onContextAboutToHide);
connect(m_ui->actionAboutSquawk, &QAction::triggered, this, &Squawk::onAboutSquawkCalled);
//m_ui->mainToolBar->addWidget(m_ui->comboBox);
@ -199,36 +193,25 @@ void Squawk::closeEvent(QCloseEvent* event)
about->close();
}
for (Conversations::const_iterator itr = conversations.begin(), end = conversations.end(); itr != end; ++itr) {
disconnect(itr->second, &Conversation::destroyed, this, &Squawk::onConversationClosed);
itr->second->close();
}
conversations.clear();
for (std::map<QString, VCard*>::const_iterator itr = vCards.begin(), end = vCards.end(); itr != end; ++itr) {
disconnect(itr->second, &VCard::destroyed, this, &Squawk::onVCardClosed);
itr->second->close();
}
vCards.clear();
writeSettings();
emit closing();;
QMainWindow::closeEvent(event);
}
void Squawk::onAccountsClosed() {
accounts = nullptr;}
void Squawk::onAccountsClosed()
{
accounts = nullptr;
}
void Squawk::onPreferencesClosed() {
preferences = nullptr;}
void Squawk::onPreferencesClosed()
{
preferences = nullptr;
}
void Squawk::newAccount(const QMap<QString, QVariant>& account)
{
rosterModel.addAccount(account);
}
void Squawk::onAboutSquawkClosed() {
about = nullptr;}
void Squawk::onComboboxActivated(int index)
{
@ -236,85 +219,11 @@ void Squawk::onComboboxActivated(int index)
emit changeState(av);
}
void Squawk::changeAccount(const QString& account, const QMap<QString, QVariant>& data)
{
for (QMap<QString, QVariant>::const_iterator itr = data.begin(), end = data.end(); itr != end; ++itr) {
QString attr = itr.key();
rosterModel.updateAccount(account, attr, *itr);
}
}
void Squawk::expand(const QModelIndex& index) {
m_ui->roster->expand(index);}
void Squawk::addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data)
{
rosterModel.addContact(account, jid, group, data);
QSettings settings;
settings.beginGroup("ui");
settings.beginGroup("roster");
settings.beginGroup(account);
if (settings.value("expanded", false).toBool()) {
QModelIndex ind = rosterModel.getAccountIndex(account);
m_ui->roster->expand(ind);
}
settings.endGroup();
settings.endGroup();
settings.endGroup();
}
void Squawk::addGroup(const QString& account, const QString& name)
{
rosterModel.addGroup(account, name);
QSettings settings;
settings.beginGroup("ui");
settings.beginGroup("roster");
settings.beginGroup(account);
if (settings.value("expanded", false).toBool()) {
QModelIndex ind = rosterModel.getAccountIndex(account);
m_ui->roster->expand(ind);
if (settings.value(name + "/expanded", false).toBool()) {
m_ui->roster->expand(rosterModel.getGroupIndex(account, name));
}
}
settings.endGroup();
settings.endGroup();
settings.endGroup();
}
void Squawk::removeGroup(const QString& account, const QString& name)
{
rosterModel.removeGroup(account, name);
}
void Squawk::changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data)
{
rosterModel.changeContact(account, jid, data);
}
void Squawk::removeContact(const QString& account, const QString& jid)
{
rosterModel.removeContact(account, jid);
}
void Squawk::removeContact(const QString& account, const QString& jid, const QString& group)
{
rosterModel.removeContact(account, jid, group);
}
void Squawk::addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data)
{
rosterModel.addPresence(account, jid, name, data);
}
void Squawk::removePresence(const QString& account, const QString& jid, const QString& name)
{
rosterModel.removePresence(account, jid, name);
}
void Squawk::stateChanged(Shared::Availability state)
{
m_ui->comboBox->setCurrentIndex(static_cast<int>(state));
}
void Squawk::stateChanged(Shared::Availability state) {
m_ui->comboBox->setCurrentIndex(static_cast<int>(state));}
void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
{
@ -325,186 +234,33 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
}
Models::Contact* contact = nullptr;
Models::Room* room = nullptr;
QString res;
Models::Roster::ElId* id = nullptr;
switch (node->type) {
case Models::Item::contact:
contact = static_cast<Models::Contact*>(node);
id = new Models::Roster::ElId(contact->getAccountName(), contact->getJid());
emit openConversation(Models::Roster::ElId(contact->getAccountName(), contact->getJid()));
break;
case Models::Item::presence:
contact = static_cast<Models::Contact*>(node->parentItem());
id = new Models::Roster::ElId(contact->getAccountName(), contact->getJid());
res = node->getName();
emit openConversation(Models::Roster::ElId(contact->getAccountName(), contact->getJid()), node->getName());
break;
case Models::Item::room:
room = static_cast<Models::Room*>(node);
id = new Models::Roster::ElId(room->getAccountName(), room->getJid());
emit openConversation(Models::Roster::ElId(room->getAccountName(), room->getJid()));
break;
default:
m_ui->roster->expand(item);
break;
}
if (id != nullptr) {
Conversations::const_iterator itr = conversations.find(*id);
Models::Account* acc = rosterModel.getAccount(id->account);
Conversation* conv = nullptr;
bool created = false;
if (itr != conversations.end()) {
conv = itr->second;
} else if (contact != nullptr) {
created = true;
conv = new Chat(acc, contact);
} else if (room != nullptr) {
created = true;
conv = new Room(acc, room);
if (!room->getJoined()) {
emit setRoomJoined(id->account, id->name, true);
}
}
if (conv != nullptr) {
if (created) {
conv->setAttribute(Qt::WA_DeleteOnClose);
subscribeConversation(conv);
conversations.insert(std::make_pair(*id, conv));
}
conv->show();
conv->raise();
conv->activateWindow();
if (res.size() > 0) {
conv->setPalResource(res);
}
}
delete id;
}
}
}
void Squawk::onConversationClosed(QObject* parent)
void Squawk::closeCurrentConversation()
{
Conversation* conv = static_cast<Conversation*>(sender());
Models::Roster::ElId id(conv->getAccount(), conv->getJid());
Conversations::const_iterator itr = conversations.find(id);
if (itr != conversations.end()) {
conversations.erase(itr);
}
if (conv->isMuc) {
Room* room = static_cast<Room*>(conv);
if (!room->autoJoined()) {
emit setRoomJoined(id.account, id.name, false);
}
}
}
void Squawk::fileProgress(const std::list<Shared::MessageInfo> msgs, qreal value, bool up)
{
rosterModel.fileProgress(msgs, value, up);
}
void Squawk::fileDownloadComplete(const std::list<Shared::MessageInfo> msgs, const QString& path)
{
rosterModel.fileComplete(msgs, false);
}
void Squawk::fileError(const std::list<Shared::MessageInfo> msgs, const QString& error, bool up)
{
rosterModel.fileError(msgs, error, up);
}
void Squawk::fileUploadComplete(const std::list<Shared::MessageInfo> msgs, const QString& url, const QString& path)
{
rosterModel.fileComplete(msgs, true);
}
void Squawk::accountMessage(const QString& account, const Shared::Message& data)
{
rosterModel.addMessage(account, data);
}
void Squawk::onUnnoticedMessage(const QString& account, const Shared::Message& msg)
{
notify(account, msg); //Telegram does this way - notifies even if the app is visible
QApplication::alert(this);
}
void Squawk::changeMessage(const QString& account, const QString& jid, const QString& id, const QMap<QString, QVariant>& data)
{
rosterModel.changeMessage(account, jid, id, data);
}
void Squawk::notify(const QString& account, const Shared::Message& msg)
{
Shared::Global::notify(account, msg);
}
void Squawk::onConversationMessage(const Shared::Message& msg)
{
Conversation* conv = static_cast<Conversation*>(sender());
QString acc = conv->getAccount();
rosterModel.addMessage(acc, msg);
emit sendMessage(acc, msg);
}
void Squawk::onConversationReplaceMessage(const QString& originalId, const Shared::Message& msg)
{
Conversation* conv = static_cast<Conversation*>(sender());
QString acc = conv->getAccount();
rosterModel.changeMessage(acc, msg.getPenPalJid(), originalId, {
{"state", static_cast<uint>(Shared::Message::State::pending)}
});
emit replaceMessage(acc, originalId, msg);
}
void Squawk::onConversationResend(const QString& id)
{
Conversation* conv = static_cast<Conversation*>(sender());
QString acc = conv->getAccount();
QString jid = conv->getJid();
emit resendMessage(acc, jid, id);
}
void Squawk::onRequestArchive(const QString& account, const QString& jid, const QString& before)
{
emit requestArchive(account, jid, 20, before); //TODO amount as a settings value
}
void Squawk::responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last)
{
rosterModel.responseArchive(account, jid, list, last);
}
void Squawk::removeAccount(const QString& account)
{
Conversations::const_iterator itr = conversations.begin();
while (itr != conversations.end()) {
if (itr->first.account == account) {
Conversations::const_iterator lItr = itr;
++itr;
Conversation* conv = lItr->second;
disconnect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed);
conv->close();
conversations.erase(lItr);
} else {
++itr;
}
}
if (currentConversation != nullptr && currentConversation->getAccount() == account) {
if (currentConversation != nullptr) {
currentConversation->deleteLater();
currentConversation = nullptr;
m_ui->filler->show();
}
rosterModel.removeAccount(account);
}
void Squawk::onRosterContextMenu(const QPoint& point)
@ -542,13 +298,13 @@ void Squawk::onRosterContextMenu(const QPoint& point)
break;
case Models::Item::contact: {
Models::Contact* cnt = static_cast<Models::Contact*>(item);
Models::Roster::ElId id(cnt->getAccountName(), cnt->getJid());
QString cntName = cnt->getName();
hasMenu = true;
QAction* dialog = contextMenu->addAction(Shared::icon("mail-message"), tr("Open dialog"));
dialog->setEnabled(active);
connect(dialog, &QAction::triggered, [this, index]() {
onRosterItemDoubleClicked(index);
});
connect(dialog, &QAction::triggered, std::bind(&Squawk::onRosterItemDoubleClicked, this, index));
Shared::SubscriptionState state = cnt->getState();
switch (state) {
@ -556,9 +312,7 @@ void Squawk::onRosterContextMenu(const QPoint& point)
case Shared::SubscriptionState::to: {
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe"));
unsub->setEnabled(active);
connect(unsub, &QAction::triggered, [this, cnt]() {
emit unsubscribeContact(cnt->getAccountName(), cnt->getJid(), "");
});
connect(unsub, &QAction::triggered, std::bind(&Squawk::changeSubscription, this, id, false));
}
break;
case Shared::SubscriptionState::from:
@ -566,75 +320,68 @@ void Squawk::onRosterContextMenu(const QPoint& point)
case Shared::SubscriptionState::none: {
QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
sub->setEnabled(active);
connect(sub, &QAction::triggered, [this, cnt]() {
emit subscribeContact(cnt->getAccountName(), cnt->getJid(), "");
});
connect(sub, &QAction::triggered, std::bind(&Squawk::changeSubscription, this, id, true));
}
}
QString accName = cnt->getAccountName();
QString cntJID = cnt->getJid();
QString cntName = cnt->getName();
QAction* rename = contextMenu->addAction(Shared::icon("edit-rename"), tr("Rename"));
rename->setEnabled(active);
connect(rename, &QAction::triggered, [this, cntName, accName, cntJID]() {
connect(rename, &QAction::triggered, [this, cntName, id]() {
QInputDialog* dialog = new QInputDialog(this);
connect(dialog, &QDialog::accepted, [this, dialog, cntName, accName, cntJID]() {
connect(dialog, &QDialog::accepted, [this, dialog, cntName, id]() {
QString newName = dialog->textValue();
if (newName != cntName) {
emit renameContactRequest(accName, cntJID, newName);
emit renameContactRequest(id.account, id.name, newName);
}
dialog->deleteLater();
});
connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater);
dialog->setInputMode(QInputDialog::TextInput);
dialog->setLabelText(tr("Input new name for %1\nor leave it empty for the contact \nto be displayed as %1").arg(cntJID));
dialog->setWindowTitle(tr("Renaming %1").arg(cntJID));
dialog->setLabelText(tr("Input new name for %1\nor leave it empty for the contact \nto be displayed as %1").arg(id.name));
dialog->setWindowTitle(tr("Renaming %1").arg(id.name));
dialog->setTextValue(cntName);
dialog->exec();
});
QMenu* groupsMenu = contextMenu->addMenu(Shared::icon("group"), tr("Groups"));
std::deque<QString> groupList = rosterModel.groupList(accName);
std::deque<QString> groupList = rosterModel.groupList(id.account);
for (QString groupName : groupList) {
QAction* gr = groupsMenu->addAction(groupName);
gr->setCheckable(true);
gr->setChecked(rosterModel.groupHasContact(accName, groupName, cntJID));
gr->setChecked(rosterModel.groupHasContact(id.account, groupName, id.name));
gr->setEnabled(active);
connect(gr, &QAction::toggled, [this, accName, groupName, cntJID](bool checked) {
connect(gr, &QAction::toggled, [this, groupName, id](bool checked) {
if (checked) {
emit addContactToGroupRequest(accName, cntJID, groupName);
emit addContactToGroupRequest(id.account, id.name, groupName);
} else {
emit removeContactFromGroupRequest(accName, cntJID, groupName);
emit removeContactFromGroupRequest(id.account, id.name, groupName);
}
});
}
QAction* newGroup = groupsMenu->addAction(Shared::icon("group-new"), tr("New group"));
newGroup->setEnabled(active);
connect(newGroup, &QAction::triggered, [this, accName, cntJID]() {
connect(newGroup, &QAction::triggered, [this, id]() {
QInputDialog* dialog = new QInputDialog(this);
connect(dialog, &QDialog::accepted, [this, dialog, accName, cntJID]() {
emit addContactToGroupRequest(accName, cntJID, dialog->textValue());
connect(dialog, &QDialog::accepted, [this, dialog, id]() {
emit addContactToGroupRequest(id.account, id.name, dialog->textValue());
dialog->deleteLater();
});
connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater);
dialog->setInputMode(QInputDialog::TextInput);
dialog->setLabelText(tr("New group name"));
dialog->setWindowTitle(tr("Add %1 to a new group").arg(cntJID));
dialog->setWindowTitle(tr("Add %1 to a new group").arg(id.name));
dialog->exec();
});
QAction* card = contextMenu->addAction(Shared::icon("user-properties"), tr("VCard"));
card->setEnabled(active);
connect(card, &QAction::triggered, std::bind(&Squawk::onActivateVCard, this, accName, cnt->getJid(), false));
connect(card, &QAction::triggered, std::bind(&Squawk::onActivateVCard, this, id.account, id.name, false));
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
remove->setEnabled(active);
connect(remove, &QAction::triggered, [this, cnt]() {
emit removeContactRequest(cnt->getAccountName(), cnt->getJid());
});
connect(remove, &QAction::triggered, std::bind(&Squawk::removeContactRequest, this, id.account, id.name));
}
break;
@ -653,32 +400,16 @@ void Squawk::onRosterContextMenu(const QPoint& point)
if (room->getAutoJoin()) {
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe"));
unsub->setEnabled(active);
connect(unsub, &QAction::triggered, [this, id]() {
emit setRoomAutoJoin(id.account, id.name, false);
if (conversations.find(id) == conversations.end()
&& (currentConversation == nullptr || currentConversation->getId() != id)
) { //to leave the room if it's not opened in a conversation window
emit setRoomJoined(id.account, id.name, false);
}
});
connect(unsub, &QAction::triggered, std::bind(&Squawk::changeSubscription, this, id, false));
} else {
QAction* unsub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
unsub->setEnabled(active);
connect(unsub, &QAction::triggered, [this, id]() {
emit setRoomAutoJoin(id.account, id.name, true);
if (conversations.find(id) == conversations.end()
&& (currentConversation == nullptr || currentConversation->getId() != id)
) { //to join the room if it's not already joined
emit setRoomJoined(id.account, id.name, true);
}
});
QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
sub->setEnabled(active);
connect(sub, &QAction::triggered, std::bind(&Squawk::changeSubscription, this, id, true));
}
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove"));
remove->setEnabled(active);
connect(remove, &QAction::triggered, [this, id]() {
emit removeRoomRequest(id.account, id.name);
});
connect(remove, &QAction::triggered, std::bind(&Squawk::removeRoomRequest, this, id.account, id.name));
}
break;
default:
@ -690,36 +421,6 @@ void Squawk::onRosterContextMenu(const QPoint& point)
}
}
void Squawk::addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data)
{
rosterModel.addRoom(account, jid, data);
}
void Squawk::changeRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data)
{
rosterModel.changeRoom(account, jid, data);
}
void Squawk::removeRoom(const QString& account, const QString jid)
{
rosterModel.removeRoom(account, jid);
}
void Squawk::addRoomParticipant(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data)
{
rosterModel.addRoomParticipant(account, jid, name, data);
}
void Squawk::changeRoomParticipant(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data)
{
rosterModel.changeRoomParticipant(account, jid, name, data);
}
void Squawk::removeRoomParticipant(const QString& account, const QString& jid, const QString& name)
{
rosterModel.removeRoomParticipant(account, jid, name);
}
void Squawk::responseVCard(const QString& jid, const Shared::VCard& card)
{
std::map<QString, VCard*>::const_iterator itr = vCards.find(jid);
@ -777,61 +478,40 @@ void Squawk::onVCardSave(const Shared::VCard& card, const QString& account)
widget->deleteLater();
}
void Squawk::readSettings()
{
QSettings settings;
settings.beginGroup("ui");
int avail;
if (settings.contains("availability")) {
avail = settings.value("availability").toInt();
} else {
avail = static_cast<int>(Shared::Availability::online);
}
settings.endGroup();
m_ui->comboBox->setCurrentIndex(avail);
emit changeState(Shared::Global::fromInt<Shared::Availability>(avail));
}
void Squawk::writeSettings()
{
QSettings settings;
settings.beginGroup("ui");
settings.beginGroup("window");
settings.setValue("geometry", saveGeometry());
settings.setValue("state", saveState());
settings.endGroup();
settings.setValue("splitter", m_ui->splitter->saveState());
settings.setValue("availability", m_ui->comboBox->currentIndex());
settings.remove("roster");
settings.beginGroup("roster");
int size = rosterModel.accountsModel->rowCount(QModelIndex());
for (int i = 0; i < size; ++i) {
QModelIndex acc = rosterModel.index(i, 0, QModelIndex());
Models::Account* account = rosterModel.accountsModel->getAccount(i);
QString accName = account->getName();
settings.beginGroup(accName);
settings.setValue("expanded", m_ui->roster->isExpanded(acc));
std::deque<QString> groups = rosterModel.groupList(accName);
for (const QString& groupName : groups) {
settings.beginGroup(groupName);
QModelIndex gIndex = rosterModel.getGroupIndex(accName, groupName);
settings.setValue("expanded", m_ui->roster->isExpanded(gIndex));
settings.endGroup();
}
settings.beginGroup("window");
settings.setValue("geometry", saveGeometry());
settings.setValue("state", saveState());
settings.endGroup();
settings.setValue("splitter", m_ui->splitter->saveState());
settings.remove("roster");
settings.beginGroup("roster");
int size = rosterModel.accountsModel->rowCount(QModelIndex());
for (int i = 0; i < size; ++i) {
QModelIndex acc = rosterModel.index(i, 0, QModelIndex());
Models::Account* account = rosterModel.accountsModel->getAccount(i);
QString accName = account->getName();
settings.beginGroup(accName);
settings.setValue("expanded", m_ui->roster->isExpanded(acc));
std::deque<QString> groups = rosterModel.groupList(accName);
for (const QString& groupName : groups) {
settings.beginGroup(groupName);
QModelIndex gIndex = rosterModel.getGroupIndex(accName, groupName);
settings.setValue("expanded", m_ui->roster->isExpanded(gIndex));
settings.endGroup();
}
settings.endGroup();
}
settings.endGroup();
}
settings.endGroup();
settings.endGroup();
settings.sync();
qDebug() << "Saved settings";
}
void Squawk::onItemCollepsed(const QModelIndex& index)
@ -853,24 +533,6 @@ void Squawk::onItemCollepsed(const QModelIndex& index)
}
}
void Squawk::requestPassword(const QString& account, bool authenticationError) {
if (authenticationError) {
dialogueQueue.addAction(account, DialogQueue::askCredentials);
} else {
dialogueQueue.addAction(account, DialogQueue::askPassword);
}
}
void Squawk::subscribeConversation(Conversation* conv)
{
connect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed);
connect(conv, &Conversation::sendMessage, this, &Squawk::onConversationMessage);
connect(conv, &Conversation::replaceMessage, this, &Squawk::onConversationReplaceMessage);
connect(conv, &Conversation::resendMessage, this, &Squawk::onConversationResend);
connect(conv, &Conversation::notifyableMessage, this, &Squawk::notify);
}
void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
{
if (restoreSelection.isValid() && restoreSelection == current) {
@ -942,16 +604,12 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
currentConversation = new Chat(acc, contact);
} else if (room != nullptr) {
currentConversation = new Room(acc, room);
if (!room->getJoined()) {
emit setRoomJoined(id->account, id->name, true);
}
}
if (!testAttribute(Qt::WA_TranslucentBackground)) {
currentConversation->setFeedFrames(true, false, true, true);
}
subscribeConversation(currentConversation);
emit openedConversation();
if (res.size() > 0) {
currentConversation->setPalResource(res);
@ -961,18 +619,10 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
delete id;
} else {
if (currentConversation != nullptr) {
currentConversation->deleteLater();
currentConversation = nullptr;
m_ui->filler->show();
}
closeCurrentConversation();
}
} else {
if (currentConversation != nullptr) {
currentConversation->deleteLater();
currentConversation = nullptr;
m_ui->filler->show();
}
closeCurrentConversation();
}
}
@ -997,7 +647,12 @@ void Squawk::onAboutSquawkCalled()
about->show();
}
void Squawk::onAboutSquawkClosed()
Models::Roster::ElId Squawk::currentConversationId() const
{
about = nullptr;
if (currentConversation == nullptr) {
return Models::Roster::ElId();
} else {
return Models::Roster::ElId(currentConversation->getAccount(), currentConversation->getJid());
}
}