forked from blue/squawk
Shared namespace refactoring, enum class refactoring, going offline related crash fix
This commit is contained in:
parent
b309100f99
commit
ddfb3419cc
59 changed files with 1948 additions and 1695 deletions
|
@ -22,7 +22,7 @@ using namespace Models;
|
|||
|
||||
Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, const QMap<QString, QVariant>& data, Models::Item* parentItem):
|
||||
Item(p_type, data, parentItem),
|
||||
availability(Shared::offline),
|
||||
availability(Shared::Availability::offline),
|
||||
lastActivity(data.value("lastActivity").toDateTime()),
|
||||
status(data.value("status").toString())
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ QVariant Models::AbstractParticipant::data(int column) const
|
|||
case 1:
|
||||
return lastActivity;
|
||||
case 2:
|
||||
return availability;
|
||||
return QVariant::fromValue(availability);
|
||||
case 3:
|
||||
return status;
|
||||
default:
|
||||
|
@ -91,15 +91,9 @@ void Models::AbstractParticipant::setAvailability(Shared::Availability p_avail)
|
|||
|
||||
void Models::AbstractParticipant::setAvailability(unsigned int avail)
|
||||
{
|
||||
if (avail <= Shared::availabilityHighest) {
|
||||
Shared::Availability state = static_cast<Shared::Availability>(avail);
|
||||
setAvailability(state);
|
||||
} else {
|
||||
qDebug("An attempt to set wrong state to the contact");
|
||||
}
|
||||
setAvailability(Shared::Global::fromInt<Shared::Availability>(avail));
|
||||
}
|
||||
|
||||
|
||||
void Models::AbstractParticipant::setLastActivity(const QDateTime& p_time)
|
||||
{
|
||||
if (lastActivity != p_time) {
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
|
||||
|
||||
#include "item.h"
|
||||
#include "../../global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ Models::Account::Account(const QMap<QString, QVariant>& data, Models::Item* pare
|
|||
resource(data.value("resource").toString()),
|
||||
error(data.value("error").toString()),
|
||||
avatarPath(data.value("avatarPath").toString()),
|
||||
state(Shared::disconnected),
|
||||
availability(Shared::offline)
|
||||
state(Shared::ConnectionState::disconnected),
|
||||
availability(Shared::Availability::offline)
|
||||
{
|
||||
QMap<QString, QVariant>::const_iterator sItr = data.find("state");
|
||||
if (sItr != data.end()) {
|
||||
|
@ -49,7 +49,7 @@ void Models::Account::setState(Shared::ConnectionState p_state)
|
|||
if (state != p_state) {
|
||||
state = p_state;
|
||||
changed(2);
|
||||
if (state == Shared::disconnected) {
|
||||
if (state == Shared::ConnectionState::disconnected) {
|
||||
toOfflineState();
|
||||
}
|
||||
}
|
||||
|
@ -57,22 +57,12 @@ void Models::Account::setState(Shared::ConnectionState p_state)
|
|||
|
||||
void Models::Account::setAvailability(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::availabilityHighest) {
|
||||
Shared::Availability state = static_cast<Shared::Availability>(p_state);
|
||||
setAvailability(state);
|
||||
} else {
|
||||
qDebug() << "An attempt to set invalid availability " << p_state << " to the account " << name;
|
||||
}
|
||||
setAvailability(Shared::Global::fromInt<Shared::Availability>(p_state));
|
||||
}
|
||||
|
||||
void Models::Account::setState(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::subscriptionStateHighest) {
|
||||
Shared::ConnectionState state = static_cast<Shared::ConnectionState>(p_state);
|
||||
setState(state);
|
||||
} else {
|
||||
qDebug() << "An attempt to set invalid subscription state " << p_state << " to the account " << name;
|
||||
}
|
||||
setState(Shared::Global::fromInt<Shared::ConnectionState>(p_state));
|
||||
}
|
||||
|
||||
Shared::Availability Models::Account::getAvailability() const
|
||||
|
@ -90,10 +80,10 @@ void Models::Account::setAvailability(Shared::Availability p_avail)
|
|||
|
||||
QIcon Models::Account::getStatusIcon(bool big) const
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
return Shared::availabilityIcon(availability, big);
|
||||
} else if (state == Shared::disconnected) {
|
||||
return Shared::availabilityIcon(Shared::offline, big);
|
||||
} else if (state == Shared::ConnectionState::disconnected) {
|
||||
return Shared::availabilityIcon(Shared::Availability::offline, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(state);
|
||||
}
|
||||
|
@ -152,7 +142,7 @@ QVariant Models::Account::data(int column) const
|
|||
case 1:
|
||||
return server;
|
||||
case 2:
|
||||
return QCoreApplication::translate("Global", Shared::connectionStateNames[state].toLatin1());
|
||||
return Shared::Global::getName(state);
|
||||
case 3:
|
||||
return error;
|
||||
case 4:
|
||||
|
@ -160,7 +150,7 @@ QVariant Models::Account::data(int column) const
|
|||
case 5:
|
||||
return password;
|
||||
case 6:
|
||||
return QCoreApplication::translate("Global", Shared::availabilityNames[availability].toLatin1());
|
||||
return Shared::Global::getName(availability);
|
||||
case 7:
|
||||
return resource;
|
||||
case 8:
|
||||
|
@ -226,7 +216,7 @@ void Models::Account::setError(const QString& p_resource)
|
|||
|
||||
void Models::Account::toOfflineState()
|
||||
{
|
||||
setAvailability(Shared::offline);
|
||||
setAvailability(Shared::Availability::offline);
|
||||
Item::toOfflineState();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
#ifndef MODELS_ACCOUNT_H
|
||||
#define MODELS_ACCOUNT_H
|
||||
|
||||
#include "../../global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/utils.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
#include "item.h"
|
||||
#include <QVariant>
|
||||
#include <QIcon>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "accounts.h"
|
||||
#include "../../global.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
Models::Contact::Contact(const QString& p_jid ,const QMap<QString, QVariant> &data, Item *parentItem):
|
||||
Item(Item::contact, data, parentItem),
|
||||
jid(p_jid),
|
||||
availability(Shared::offline),
|
||||
state(Shared::none),
|
||||
availability(Shared::Availability::offline),
|
||||
state(Shared::SubscriptionState::none),
|
||||
avatarState(Shared::Avatar::empty),
|
||||
presences(),
|
||||
messages(),
|
||||
|
@ -66,22 +66,12 @@ void Models::Contact::setJid(const QString p_jid)
|
|||
|
||||
void Models::Contact::setAvailability(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::availabilityHighest) {
|
||||
Shared::Availability state = static_cast<Shared::Availability>(p_state);
|
||||
setAvailability(state);
|
||||
} else {
|
||||
qDebug() << "An attempt to set invalid availability " << p_state << " to the contact " << jid;
|
||||
}
|
||||
setAvailability(Shared::Global::fromInt<Shared::Availability>(p_state));
|
||||
}
|
||||
|
||||
void Models::Contact::setState(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::subscriptionStateHighest) {
|
||||
Shared::SubscriptionState state = static_cast<Shared::SubscriptionState>(p_state);
|
||||
setState(state);
|
||||
} else {
|
||||
qDebug() << "An attempt to set invalid subscription state " << p_state << " to the contact " << jid;
|
||||
}
|
||||
setState(Shared::Global::fromInt<Shared::SubscriptionState>(p_state));
|
||||
}
|
||||
|
||||
Shared::Availability Models::Contact::getAvailability() const
|
||||
|
@ -123,15 +113,15 @@ QVariant Models::Contact::data(int column) const
|
|||
case 1:
|
||||
return jid;
|
||||
case 2:
|
||||
return state;
|
||||
return QVariant::fromValue(state);
|
||||
case 3:
|
||||
return availability;
|
||||
return QVariant::fromValue(availability);
|
||||
case 4:
|
||||
return getMessagesCount();
|
||||
case 5:
|
||||
return getStatus();
|
||||
case 6:
|
||||
return static_cast<quint8>(getAvatarState());
|
||||
return QVariant::fromValue(getAvatarState());
|
||||
case 7:
|
||||
return getAvatarPath();
|
||||
default:
|
||||
|
@ -216,7 +206,7 @@ void Models::Contact::refresh()
|
|||
setAvailability(presence->getAvailability());
|
||||
setStatus(presence->getStatus());
|
||||
} else {
|
||||
setAvailability(Shared::offline);
|
||||
setAvailability(Shared::Availability::offline);
|
||||
setStatus("");
|
||||
}
|
||||
|
||||
|
@ -258,7 +248,7 @@ QIcon Models::Contact::getStatusIcon(bool big) const
|
|||
{
|
||||
if (getMessagesCount() > 0) {
|
||||
return Shared::icon("mail-message", big);
|
||||
} else if (state == Shared::both || state == Shared::to) {
|
||||
} else if (state == Shared::SubscriptionState::both || state == Shared::SubscriptionState::to) {
|
||||
return Shared::availabilityIcon(availability, big);;
|
||||
} else {
|
||||
return Shared::subscriptionStateIcon(state, big);
|
||||
|
@ -276,7 +266,7 @@ void Models::Contact::addMessage(const Shared::Message& data)
|
|||
// the only issue is to find out when the sender is gone offline
|
||||
Presence* pr = new Presence({});
|
||||
pr->setName(res);
|
||||
pr->setAvailability(Shared::invisible);
|
||||
pr->setAvailability(Shared::Availability::invisible);
|
||||
pr->setLastActivity(QDateTime::currentDateTimeUtc());
|
||||
presences.insert(res, pr);
|
||||
appendChild(pr);
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
|
||||
#include "item.h"
|
||||
#include "presence.h"
|
||||
#include "global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/message.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QIcon>
|
||||
#include <deque>
|
||||
|
|
|
@ -96,7 +96,7 @@ unsigned int Models::Group::getOnlineContacts() const
|
|||
|
||||
for (std::deque<Models::Item*>::const_iterator itr = childItems.begin(), end = childItems.end(); itr != end; ++itr) {
|
||||
Models::Contact* cnt = static_cast<Models::Contact*>(*itr);
|
||||
if (cnt->getAvailability() != Shared::offline) {
|
||||
if (cnt->getAvailability() != Shared::Availability::offline) {
|
||||
++amount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ Shared::Availability Models::Item::getAccountAvailability() const
|
|||
{
|
||||
const Account* acc = static_cast<const Account*>(getParentAccount());
|
||||
if (acc == 0) {
|
||||
return Shared::offline;
|
||||
return Shared::Availability::offline;
|
||||
}
|
||||
return acc->getAvailability();
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ Shared::ConnectionState Models::Item::getAccountConnectionState() const
|
|||
{
|
||||
const Account* acc = static_cast<const Account*>(getParentAccount());
|
||||
if (acc == 0) {
|
||||
return Shared::disconnected;
|
||||
return Shared::ConnectionState::disconnected;
|
||||
}
|
||||
return acc->getState();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <deque>
|
||||
|
||||
#include "../../global.h"
|
||||
#include "shared/enums.h"
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "presence.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem):
|
||||
AbstractParticipant(Item::presence, data, parentItem),
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
#define MODELS_PRESENCE_H
|
||||
|
||||
#include "abstractparticipant.h"
|
||||
#include "../../global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/message.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QIcon>
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
|
||||
#include "room.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -194,15 +196,15 @@ QIcon Models::Room::getStatusIcon(bool big) const
|
|||
} else {
|
||||
if (autoJoin) {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connected, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::connected, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::disconnected, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::disconnected, big);
|
||||
}
|
||||
} else {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connecting, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::connecting, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::error, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::error, big);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
|
||||
#include "item.h"
|
||||
#include "participant.h"
|
||||
#include "global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/message.h"
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
switch (item->type) {
|
||||
case Item::account: {
|
||||
Account* acc = static_cast<Account*>(item);
|
||||
result = QCoreApplication::translate("Global", Shared::availabilityNames[acc->getAvailability()].toLatin1());
|
||||
result = Shared::Global::getName(acc->getAvailability());
|
||||
}
|
||||
break;
|
||||
case Item::contact: {
|
||||
|
@ -193,18 +193,18 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
}
|
||||
str += tr("Jabber ID: ") + contact->getJid() + "\n";
|
||||
Shared::SubscriptionState ss = contact->getState();
|
||||
if (ss == Shared::both || ss == Shared::to) {
|
||||
if (ss == Shared::SubscriptionState::both || ss == Shared::SubscriptionState::to) {
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1());
|
||||
if (av != Shared::offline) {
|
||||
str += tr("Availability: ") + Shared::Global::getName(av);
|
||||
if (av != Shared::Availability::offline) {
|
||||
QString s = contact->getStatus();
|
||||
if (s.size() > 0) {
|
||||
str += "\n" + tr("Status: ") + s;
|
||||
}
|
||||
}
|
||||
str += "\n" + tr("Subscription: ") + QCoreApplication::translate("Global", Shared::subscriptionStateNames[ss].toLatin1());
|
||||
str += "\n" + tr("Subscription: ") + Shared::Global::getName(ss);
|
||||
} else {
|
||||
str += tr("Subscription: ") + QCoreApplication::translate("Global", Shared::subscriptionStateNames[ss].toLatin1());
|
||||
str += tr("Subscription: ") + Shared::Global::getName(ss);
|
||||
}
|
||||
|
||||
result = str;
|
||||
|
@ -218,7 +218,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
str += tr("New messages: ") + std::to_string(mc).c_str() + "\n";
|
||||
}
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1());
|
||||
str += tr("Availability: ") + Shared::Global::getName(av);
|
||||
QString s = contact->getStatus();
|
||||
if (s.size() > 0) {
|
||||
str += "\n" + tr("Status: ") + s;
|
||||
|
@ -231,18 +231,14 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||
Participant* p = static_cast<Participant*>(item);
|
||||
QString str("");
|
||||
Shared::Availability av = p->getAvailability();
|
||||
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()) + "\n";
|
||||
str += tr("Availability: ") + Shared::Global::getName(av) + "\n";
|
||||
QString s = p->getStatus();
|
||||
if (s.size() > 0) {
|
||||
str += tr("Status: ") + s + "\n";
|
||||
}
|
||||
|
||||
str += tr("Affiliation: ") +
|
||||
QCoreApplication::translate("Global",
|
||||
Shared::affiliationNames[static_cast<unsigned int>(p->getAffiliation())].toLatin1()) + "\n";
|
||||
str += tr("Role: ") +
|
||||
QCoreApplication::translate("Global",
|
||||
Shared::roleNames[static_cast<unsigned int>(p->getRole())].toLatin1());
|
||||
str += tr("Affiliation: ") + Shared::Global::getName(p->getAffiliation()) + "\n";
|
||||
str += tr("Role: ") + Shared::Global::getName(p->getRole());
|
||||
|
||||
result = str;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
#include <map>
|
||||
#include <QVector>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "shared/global.h"
|
||||
#include "accounts.h"
|
||||
#include "item.h"
|
||||
#include "account.h"
|
||||
|
|
|
@ -41,11 +41,11 @@ Squawk::Squawk(QWidget *parent) :
|
|||
m_ui->roster->header()->setStretchLastSection(false);
|
||||
m_ui->roster->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
for (unsigned int i = Shared::availabilityLowest; i < Shared::availabilityHighest + 1; ++i) {
|
||||
for (int i = static_cast<int>(Shared::availabilityLowest); i < static_cast<int>(Shared::availabilityHighest) + 1; ++i) {
|
||||
Shared::Availability av = static_cast<Shared::Availability>(i);
|
||||
m_ui->comboBox->addItem(Shared::availabilityIcon(av), QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()));
|
||||
m_ui->comboBox->addItem(Shared::availabilityIcon(av), Shared::Global::getName(av));
|
||||
}
|
||||
m_ui->comboBox->setCurrentIndex(Shared::offline);
|
||||
m_ui->comboBox->setCurrentIndex(static_cast<int>(Shared::Availability::offline));
|
||||
|
||||
connect(m_ui->actionAccounts, &QAction::triggered, this, &Squawk::onAccounts);
|
||||
connect(m_ui->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact);
|
||||
|
@ -173,25 +173,26 @@ void Squawk::newAccount(const QMap<QString, QVariant>& account)
|
|||
|
||||
void Squawk::onComboboxActivated(int index)
|
||||
{
|
||||
if (index != Shared::offline) {
|
||||
Shared::Availability av = Shared::Global::fromInt<Shared::Availability>(index);
|
||||
if (av != Shared::Availability::offline) {
|
||||
int size = rosterModel.accountsModel->rowCount(QModelIndex());
|
||||
if (size > 0) {
|
||||
emit changeState(index);
|
||||
emit changeState(av);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
Models::Account* acc = rosterModel.accountsModel->getAccount(i);
|
||||
if (acc->getState() == Shared::disconnected) {
|
||||
if (acc->getState() == Shared::ConnectionState::disconnected) {
|
||||
emit connectAccount(acc->getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_ui->comboBox->setCurrentIndex(Shared::offline);
|
||||
m_ui->comboBox->setCurrentIndex(static_cast<int>(Shared::Availability::offline));
|
||||
}
|
||||
} else {
|
||||
emit changeState(index);
|
||||
emit changeState(av);
|
||||
int size = rosterModel.accountsModel->rowCount(QModelIndex());
|
||||
for (int i = 0; i != size; ++i) {
|
||||
Models::Account* acc = rosterModel.accountsModel->getAccount(i);
|
||||
if (acc->getState() != Shared::disconnected) {
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
||||
emit disconnectAccount(acc->getName());
|
||||
}
|
||||
}
|
||||
|
@ -273,9 +274,9 @@ void Squawk::removePresence(const QString& account, const QString& jid, const QS
|
|||
rosterModel.removePresence(account, jid, name);
|
||||
}
|
||||
|
||||
void Squawk::stateChanged(int state)
|
||||
void Squawk::stateChanged(Shared::Availability state)
|
||||
{
|
||||
m_ui->comboBox->setCurrentIndex(state);
|
||||
m_ui->comboBox->setCurrentIndex(static_cast<int>(state));
|
||||
}
|
||||
|
||||
void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
|
||||
|
@ -600,14 +601,14 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
|
||||
contextMenu->clear();
|
||||
bool hasMenu = false;
|
||||
bool active = item->getAccountConnectionState() == Shared::connected;
|
||||
bool active = item->getAccountConnectionState() == Shared::ConnectionState::connected;
|
||||
switch (item->type) {
|
||||
case Models::Item::account: {
|
||||
Models::Account* acc = static_cast<Models::Account*>(item);
|
||||
hasMenu = true;
|
||||
QString name = acc->getName();
|
||||
|
||||
if (acc->getState() != Shared::disconnected) {
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
||||
QAction* con = contextMenu->addAction(Shared::icon("network-disconnect"), tr("Disconnect"));
|
||||
con->setEnabled(active);
|
||||
connect(con, &QAction::triggered, [this, name]() {
|
||||
|
@ -644,8 +645,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
|
||||
Shared::SubscriptionState state = cnt->getState();
|
||||
switch (state) {
|
||||
case Shared::both:
|
||||
case Shared::to: {
|
||||
case Shared::SubscriptionState::both:
|
||||
case Shared::SubscriptionState::to: {
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe"));
|
||||
unsub->setEnabled(active);
|
||||
connect(unsub, &QAction::triggered, [this, cnt]() {
|
||||
|
@ -653,9 +654,9 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||
});
|
||||
}
|
||||
break;
|
||||
case Shared::from:
|
||||
case Shared::unknown:
|
||||
case Shared::none: {
|
||||
case Shared::SubscriptionState::from:
|
||||
case Shared::SubscriptionState::unknown:
|
||||
case Shared::SubscriptionState::none: {
|
||||
QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
|
||||
sub->setEnabled(active);
|
||||
connect(sub, &QAction::triggered, [this, cnt]() {
|
||||
|
@ -882,7 +883,7 @@ void Squawk::readSettings()
|
|||
if (settings.contains("availability")) {
|
||||
int avail = settings.value("availability").toInt();
|
||||
m_ui->comboBox->setCurrentIndex(avail);
|
||||
emit stateChanged(avail);
|
||||
emit stateChanged(Shared::Global::fromInt<Shared::Availability>(avail));
|
||||
|
||||
int size = settings.beginReadArray("connectedAccounts");
|
||||
for (int i = 0; i < size; ++i) {
|
||||
|
@ -909,7 +910,7 @@ void Squawk::writeSettings()
|
|||
int size = rosterModel.accountsModel->rowCount(QModelIndex());
|
||||
for (int i = 0; i < size; ++i) {
|
||||
Models::Account* acc = rosterModel.accountsModel->getAccount(i);
|
||||
if (acc->getState() != Shared::disconnected) {
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue("name", acc->getName());
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "models/roster.h"
|
||||
#include "widgets/vcard/vcard.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "shared.h"
|
||||
|
||||
namespace Ui {
|
||||
class Squawk;
|
||||
|
@ -61,7 +61,7 @@ signals:
|
|||
void removeAccountRequest(const QString&);
|
||||
void connectAccount(const QString&);
|
||||
void disconnectAccount(const QString&);
|
||||
void changeState(int state);
|
||||
void changeState(Shared::Availability state);
|
||||
void sendMessage(const QString& account, const Shared::Message& data);
|
||||
void sendMessage(const QString& account, const Shared::Message& data, const QString& path);
|
||||
void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
|
||||
|
@ -93,7 +93,7 @@ public slots:
|
|||
void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data);
|
||||
void addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
|
||||
void removePresence(const QString& account, const QString& jid, const QString& name);
|
||||
void stateChanged(int state);
|
||||
void stateChanged(Shared::Availability state);
|
||||
void accountMessage(const QString& account, const Shared::Message& data);
|
||||
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
|
||||
void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "message.h"
|
||||
#include <QDebug>
|
||||
#include <QMimeDatabase>
|
||||
#include <QPixmap>
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
#include "message.h"
|
||||
|
||||
const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])("
|
||||
"(?:https?|ftp):\\/\\/"
|
||||
|
@ -346,7 +346,7 @@ void Message::setState()
|
|||
{
|
||||
Shared::Message::State state = msg.getState();
|
||||
QIcon q(Shared::icon(Shared::messageStateThemeIcons[static_cast<uint8_t>(state)]));
|
||||
QString tt = QCoreApplication::translate("Global", Shared::messageStateNames[static_cast<uint8_t>(state)].toLatin1());
|
||||
QString tt = Shared::Global::getName(state);
|
||||
if (state == Shared::Message::State::error) {
|
||||
QString errText = msg.getErrorText();
|
||||
if (errText.size() > 0) {
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
#include <QUrl>
|
||||
#include <QMap>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
#include "resizer.h"
|
||||
#include "image.h"
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "messageline.h"
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <cmath>
|
||||
|
||||
MessageLine::MessageLine(bool p_room, QWidget* parent):
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <QResizeEvent>
|
||||
#include <QIcon>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "message.h"
|
||||
#include "progress.h"
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include "progress.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
|
||||
Progress::Progress(quint16 p_size, QWidget* parent):
|
||||
QWidget(parent),
|
||||
pixmap(new QGraphicsPixmapItem(Shared::icon("view-refresh", true).pixmap(p_size))),
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include <QVariantAnimation>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "../../global.h"
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
|
|
|
@ -115,7 +115,7 @@ void Accounts::updateConnectButton()
|
|||
bool allConnected = true;
|
||||
for (int i = 0; i < selectionSize && allConnected; ++i) {
|
||||
const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row());
|
||||
allConnected = mAcc->getState() == Shared::connected;
|
||||
allConnected = mAcc->getState() == Shared::ConnectionState::connected;
|
||||
}
|
||||
if (allConnected) {
|
||||
toDisconnect = true;
|
||||
|
|
|
@ -58,7 +58,7 @@ void Chat::updateState()
|
|||
{
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
statusIcon->setPixmap(Shared::availabilityIcon(av, true).pixmap(40));
|
||||
statusIcon->setToolTip(QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()));
|
||||
statusIcon->setToolTip(Shared::Global::getName(av));
|
||||
}
|
||||
|
||||
void Chat::handleSendMessage(const QString& text)
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
#define CHAT_H
|
||||
|
||||
#include "conversation.h"
|
||||
#include "../models/contact.h"
|
||||
#include "ui/models/contact.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "conversation.h"
|
||||
#include "ui_conversation.h"
|
||||
#include "ui/utils/dropshadoweffect.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
|
@ -27,6 +28,7 @@
|
|||
#include <QMimeDatabase>
|
||||
#include <unistd.h>
|
||||
#include <QAbstractTextDocumentLayout>
|
||||
#include <QCoreApplication>
|
||||
|
||||
Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, const QString pRes, QWidget* parent):
|
||||
QWidget(parent),
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <QScopedPointer>
|
||||
#include <QMap>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "order.h"
|
||||
#include "ui/models/account.h"
|
||||
#include "ui/utils/messageline.h"
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
#include "emailsmodel.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
UI::VCard::EMailsModel::EMailsModel(bool p_edit, QObject* parent):
|
||||
QAbstractTableModel(parent),
|
||||
edit(p_edit),
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <deque>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/vcard.h"
|
||||
|
||||
namespace UI {
|
||||
namespace VCard {
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
|
||||
#include "phonesmodel.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
UI::VCard::PhonesModel::PhonesModel(bool p_edit, QObject* parent):
|
||||
QAbstractTableModel(parent),
|
||||
edit(p_edit),
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <QAbstractTableModel>
|
||||
#include <QIcon>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/vcard.h"
|
||||
|
||||
namespace UI {
|
||||
namespace VCard {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "vcard.h"
|
||||
#include "ui_vcard.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include <set>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/vcard.h"
|
||||
#include "emailsmodel.h"
|
||||
#include "phonesmodel.h"
|
||||
#include "ui/utils/progress.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue