some further thinking of info widget
This commit is contained in:
parent
e4a2728ef8
commit
ec362cef55
@ -187,7 +187,7 @@ void Core::VCardHandler::onOwnVCardReceived(const QXmppVCardIq& card) {
|
|||||||
|
|
||||||
ownVCardRequestInProgress = false;
|
ownVCardRequestInProgress = false;
|
||||||
|
|
||||||
Shared::Info info(acc->getBareJid(), Shared::EntryType::contact, true);
|
Shared::Info info(acc->getBareJid(), Shared::EntryType::ownAccount, true);
|
||||||
initializeVCard(info.vcard, card);
|
initializeVCard(info.vcard, card);
|
||||||
|
|
||||||
if (avatarType.size() > 0) {
|
if (avatarType.size() > 0) {
|
||||||
@ -203,7 +203,7 @@ void Core::VCardHandler::onOwnVCardReceived(const QXmppVCardIq& card) {
|
|||||||
void Core::VCardHandler::handleOffline() {
|
void Core::VCardHandler::handleOffline() {
|
||||||
pendingVCardRequests.clear();
|
pendingVCardRequests.clear();
|
||||||
for (const QString& jid : pendingVCardRequests) {
|
for (const QString& jid : pendingVCardRequests) {
|
||||||
Shared::Info info(jid, Shared::EntryType::contact);
|
Shared::Info info(jid, Shared::EntryType::none);
|
||||||
emit acc->infoReady(info); //need to show it better in the future, like with an error
|
emit acc->infoReady(info); //need to show it better in the future, like with an error
|
||||||
}
|
}
|
||||||
pendingVCardRequests.clear();
|
pendingVCardRequests.clear();
|
||||||
|
@ -119,6 +119,8 @@ static const AccountPassword AccountPasswordHighest = AccountPassword::kwallet;
|
|||||||
static const AccountPassword AccountPasswordLowest = AccountPassword::plain;
|
static const AccountPassword AccountPasswordLowest = AccountPassword::plain;
|
||||||
|
|
||||||
enum class EntryType {
|
enum class EntryType {
|
||||||
|
none,
|
||||||
|
ownAccount,
|
||||||
contact,
|
contact,
|
||||||
conference,
|
conference,
|
||||||
presence,
|
presence,
|
||||||
@ -126,7 +128,7 @@ enum class EntryType {
|
|||||||
};
|
};
|
||||||
Q_ENUM_NS(EntryType)
|
Q_ENUM_NS(EntryType)
|
||||||
static const EntryType EntryTypeHighest = EntryType::participant;
|
static const EntryType EntryTypeHighest = EntryType::participant;
|
||||||
static const EntryType EntryTypeLowest = EntryType::contact;
|
static const EntryType EntryTypeLowest = EntryType::none;
|
||||||
|
|
||||||
enum class Support {
|
enum class Support {
|
||||||
unknown,
|
unknown,
|
||||||
|
@ -422,7 +422,7 @@ void Squawk::responseInfo(const Shared::Info& info) {
|
|||||||
void Squawk::onInfoClosed() {
|
void Squawk::onInfoClosed() {
|
||||||
UI::Info* info = static_cast<UI::Info*>(sender());
|
UI::Info* info = static_cast<UI::Info*>(sender());
|
||||||
|
|
||||||
std::map<QString, UI::Info*>::const_iterator itr = infoWidgets.find(info->jid);
|
std::map<QString, UI::Info*>::const_iterator itr = infoWidgets.find(info->getJid());
|
||||||
if (itr == infoWidgets.end()) {
|
if (itr == infoWidgets.end()) {
|
||||||
qDebug() << "Info widget has been closed but can not be found among other opened vCards, application is most probably going to crash";
|
qDebug() << "Info widget has been closed but can not be found among other opened vCards, application is most probably going to crash";
|
||||||
return;
|
return;
|
||||||
@ -437,12 +437,7 @@ void Squawk::onActivateInfo(const QString& account, const QString& jid) {
|
|||||||
info = itr->second;
|
info = itr->second;
|
||||||
} else {
|
} else {
|
||||||
info = new UI::Info(jid);
|
info = new UI::Info(jid);
|
||||||
// TODO need to handle it somewhere else
|
info->setWindowTitle(tr("Information about %1").arg(jid));
|
||||||
// if (edition) {
|
|
||||||
// card->setWindowTitle(tr("%1 account card").arg(account));
|
|
||||||
// } else {
|
|
||||||
// card->setWindowTitle(tr("%1 contact card").arg(jid));
|
|
||||||
// }
|
|
||||||
info->setAttribute(Qt::WA_DeleteOnClose);
|
info->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
infoWidgets.insert(std::make_pair(jid, info));
|
infoWidgets.insert(std::make_pair(jid, info));
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
UI::Info::Info(const QString& p_jid, QWidget* parent):
|
UI::Info::Info(const QString& p_jid, QWidget* parent):
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
jid(p_jid),
|
jid(p_jid),
|
||||||
|
type(Shared::EntryType::none),
|
||||||
m_ui(new Ui::Info()),
|
m_ui(new Ui::Info()),
|
||||||
contactGeneral(nullptr),
|
contactGeneral(nullptr),
|
||||||
contactContacts(nullptr),
|
contactContacts(nullptr),
|
||||||
@ -30,36 +31,39 @@ UI::Info::Info(const QString& p_jid, QWidget* parent):
|
|||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->buttonBox->hide();
|
m_ui->buttonBox->hide();
|
||||||
|
m_ui->title->setText(tr("%1 info").arg(p_jid));
|
||||||
|
m_ui->receivingTimeLabel->hide();
|
||||||
|
|
||||||
initializeOverlay();
|
initializeOverlay();
|
||||||
initializeButtonBox();
|
initializeButtonBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
UI::Info::~Info() {
|
UI::Info::~Info() {
|
||||||
if (contactGeneral != nullptr)
|
clear();
|
||||||
contactGeneral->deleteLater();
|
|
||||||
|
|
||||||
if (contactContacts != nullptr)
|
|
||||||
contactContacts->deleteLater();
|
|
||||||
|
|
||||||
if (description != nullptr)
|
|
||||||
description->deleteLater();
|
|
||||||
|
|
||||||
overlay->deleteLater();
|
overlay->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::Info::setData(const Shared::Info& info) {
|
void UI::Info::setData(const Shared::Info& info) {
|
||||||
|
bool editable = false;
|
||||||
switch (info.type) {
|
switch (info.type) {
|
||||||
case Shared::EntryType::contact:
|
case Shared::EntryType::ownAccount:
|
||||||
initializeContactGeneral(info);
|
editable = true;
|
||||||
initializeContactContacts(info);
|
case Shared::EntryType::contact: {
|
||||||
initializeDescription(info);
|
QDateTime receivingTime = info.vcard.getReceivingTime();
|
||||||
|
m_ui->receivingTimeLabel->show();
|
||||||
|
m_ui->receivingTimeLabel->setText(tr("Received %1 at %2").arg(receivingTime.date().toString()).arg(receivingTime.time().toString()));
|
||||||
|
initializeContactGeneral(jid, info.vcard, editable);
|
||||||
|
initializeContactContacts(jid, info.vcard, editable);
|
||||||
|
initializeDescription(info.vcard.getDescription(), editable);
|
||||||
|
type = info.type;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info.editable)
|
if (!editable)
|
||||||
m_ui->buttonBox->hide();
|
m_ui->buttonBox->hide();
|
||||||
else
|
else
|
||||||
m_ui->buttonBox->show();
|
m_ui->buttonBox->show();
|
||||||
@ -77,10 +81,7 @@ void UI::Info::initializeOverlay() {
|
|||||||
overlay->setAutoFillBackground(true);
|
overlay->setAutoFillBackground(true);
|
||||||
overlay->setGraphicsEffect(opacity);
|
overlay->setGraphicsEffect(opacity);
|
||||||
progressLabel->setAlignment(Qt::AlignCenter);
|
progressLabel->setAlignment(Qt::AlignCenter);
|
||||||
QFont pf = progressLabel->font();
|
progressLabel->setFont(Shared::Global::getInstance()->titleFont);
|
||||||
pf.setBold(true);
|
|
||||||
pf.setPointSize(26);
|
|
||||||
progressLabel->setFont(pf);
|
|
||||||
progressLabel->setWordWrap(true);
|
progressLabel->setWordWrap(true);
|
||||||
nl->addStretch();
|
nl->addStretch();
|
||||||
nl->addWidget(progress);
|
nl->addWidget(progress);
|
||||||
@ -97,17 +98,14 @@ void UI::Info::initializeButtonBox() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UI::Info::onButtonBoxAccepted() {
|
void UI::Info::onButtonBoxAccepted() {
|
||||||
//TODO this is not good, since I don't exactly know what am I editing it's bad to assume there even going to be a vcard
|
if (type == Shared::EntryType::ownAccount) {
|
||||||
Shared::Info info;
|
Shared::Info info;
|
||||||
if (contactGeneral != nullptr)
|
|
||||||
contactGeneral->fillVCard(info.vcard);
|
contactGeneral->fillVCard(info.vcard);
|
||||||
if (contactContacts != nullptr)
|
|
||||||
contactContacts->fillVCard(info.vcard);
|
contactContacts->fillVCard(info.vcard);
|
||||||
if (description != nullptr)
|
|
||||||
info.vcard.setDescription(description->description());
|
info.vcard.setDescription(description->description());
|
||||||
|
|
||||||
emit saveInfo(info);
|
emit saveInfo(info);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UI::Info::showProgress(const QString& line) {
|
void UI::Info::showProgress(const QString& line) {
|
||||||
if (line.size() > 0)
|
if (line.size() > 0)
|
||||||
@ -124,30 +122,49 @@ void UI::Info::hideProgress() {
|
|||||||
progress->stop();
|
progress->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::Info::initializeContactGeneral(const Shared::Info& info) {
|
void UI::Info::initializeContactGeneral(const QString& jid, const Shared::VCard& card, bool editable) {
|
||||||
if (contactGeneral == nullptr) {
|
if (contactGeneral == nullptr) {
|
||||||
contactGeneral = new ContactGeneral;
|
contactGeneral = new ContactGeneral;
|
||||||
m_ui->tabWidget->addTab(contactGeneral, contactGeneral->title());
|
m_ui->tabWidget->addTab(contactGeneral, contactGeneral->title());
|
||||||
}
|
}
|
||||||
contactGeneral->setVCard(info.jid, info.vcard, info.editable);
|
contactGeneral->setVCard(jid, card, editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::Info::initializeContactContacts(const Shared::Info& info) {
|
void UI::Info::initializeContactContacts(const QString& jid, const Shared::VCard& card, bool editable) {
|
||||||
if (contactContacts == nullptr) {
|
if (contactContacts == nullptr) {
|
||||||
contactContacts = new ContactContacts;
|
contactContacts = new ContactContacts;
|
||||||
m_ui->tabWidget->addTab(contactContacts, contactContacts->title());
|
m_ui->tabWidget->addTab(contactContacts, contactContacts->title());
|
||||||
}
|
}
|
||||||
contactContacts->setVCard(info.jid, info.vcard, info.editable);
|
contactContacts->setVCard(jid, card, editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI::Info::initializeDescription(const Shared::Info& info) {
|
void UI::Info::initializeDescription(const QString& descr, bool editable) {
|
||||||
if (description == nullptr) {
|
if (description == nullptr) {
|
||||||
description = new Description;
|
description = new Description;
|
||||||
m_ui->tabWidget->addTab(description, description->title());
|
m_ui->tabWidget->addTab(description, description->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
description->setDescription(info.vcard.getDescription());
|
description->setDescription(descr);
|
||||||
description->setEditable(info.editable);
|
description->setEditable(editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString UI::Info::getJid() const {
|
||||||
|
return jid;}
|
||||||
|
|
||||||
|
void UI::Info::clear() {
|
||||||
|
if (contactGeneral != nullptr) {
|
||||||
|
contactGeneral->deleteLater();
|
||||||
|
contactGeneral = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contactContacts != nullptr) {
|
||||||
|
contactContacts->deleteLater();
|
||||||
|
contactContacts = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (description != nullptr) {
|
||||||
|
description->deleteLater();
|
||||||
|
description = nullptr;
|
||||||
|
}
|
||||||
|
type = Shared::EntryType::none;
|
||||||
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include <shared/info.h>
|
#include <shared/info.h>
|
||||||
|
#include <shared/global.h>
|
||||||
|
|
||||||
#include "ui/utils/progress.h"
|
#include "ui/utils/progress.h"
|
||||||
|
|
||||||
@ -42,13 +43,11 @@ public:
|
|||||||
Info(const QString& jid, QWidget* parent = nullptr);
|
Info(const QString& jid, QWidget* parent = nullptr);
|
||||||
~Info();
|
~Info();
|
||||||
|
|
||||||
|
QString getJid() const;
|
||||||
void setData(const Shared::Info& info);
|
void setData(const Shared::Info& info);
|
||||||
void showProgress(const QString& = "");
|
void showProgress(const QString& = "");
|
||||||
void hideProgress();
|
void hideProgress();
|
||||||
|
|
||||||
public:
|
|
||||||
QString jid;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void saveInfo(const Shared::Info& info);
|
void saveInfo(const Shared::Info& info);
|
||||||
|
|
||||||
@ -56,13 +55,16 @@ private slots:
|
|||||||
void onButtonBoxAccepted();
|
void onButtonBoxAccepted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeContactGeneral(const Shared::Info& info);
|
void initializeContactGeneral(const QString& jid, const Shared::VCard& card, bool editable);
|
||||||
void initializeContactContacts(const Shared::Info& info);
|
void initializeContactContacts(const QString& jid, const Shared::VCard& card, bool editable);
|
||||||
void initializeDescription(const Shared::Info& info);
|
void initializeDescription(const QString& description, bool editable);
|
||||||
void initializeOverlay();
|
void initializeOverlay();
|
||||||
void initializeButtonBox();
|
void initializeButtonBox();
|
||||||
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString jid;
|
||||||
|
Shared::EntryType type;
|
||||||
QScopedPointer<Ui::Info> m_ui;
|
QScopedPointer<Ui::Info> m_ui;
|
||||||
ContactGeneral* contactGeneral;
|
ContactGeneral* contactGeneral;
|
||||||
ContactContacts* contactContacts;
|
ContactContacts* contactContacts;
|
||||||
|
Loading…
Reference in New Issue
Block a user