Compare commits

...

3 Commits

10 changed files with 44 additions and 36 deletions

View File

@ -29,6 +29,7 @@ Application::Application(Core::Squawk* p_core):
destroyingSquawk(false), destroyingSquawk(false),
storage() storage()
{ {
squawk = new Squawk(roster);
connect(&roster, &Models::Roster::unnoticedMessage, this, &Application::notify); connect(&roster, &Models::Roster::unnoticedMessage, this, &Application::notify);
connect(&roster, &Models::Roster::unreadMessagesCountChanged, this, &Application::unreadMessagesCountChanged); connect(&roster, &Models::Roster::unreadMessagesCountChanged, this, &Application::unreadMessagesCountChanged);
@ -53,7 +54,7 @@ Application::Application(Core::Squawk* p_core):
connect(&roster, &Models::Roster::localPathInvalid, core, &Core::Squawk::onLocalPathInvalid); connect(&roster, &Models::Roster::localPathInvalid, core, &Core::Squawk::onLocalPathInvalid);
//coonecting backend to myself //connecting backend to myself
connect(core, &Core::Squawk::stateChanged, this, &Application::stateChanged); connect(core, &Core::Squawk::stateChanged, this, &Application::stateChanged);
connect(core, &Core::Squawk::accountMessage, &roster, &Models::Roster::addMessage); connect(core, &Core::Squawk::accountMessage, &roster, &Models::Roster::addMessage);
@ -147,8 +148,7 @@ void Application::checkForTheLastWindow()
void Application::createMainWindow() void Application::createMainWindow()
{ {
if (squawk == nullptr) { if (squawk) {
squawk = new Squawk(roster);
connect(squawk, &Squawk::notify, this, &Application::notify); connect(squawk, &Squawk::notify, this, &Application::notify);
connect(squawk, &Squawk::changeSubscription, this, &Application::changeSubscription); connect(squawk, &Squawk::changeSubscription, this, &Application::changeSubscription);

View File

@ -96,7 +96,7 @@ Squawk::~Squawk() {
void Squawk::onAccounts() void Squawk::onAccounts()
{ {
if (accounts == nullptr) { if (accounts == nullptr) {
accounts = new Accounts(rosterModel.accountsModel); accounts = new Accounts(rosterModel.accountsModel, this);
accounts->setAttribute(Qt::WA_DeleteOnClose); accounts->setAttribute(Qt::WA_DeleteOnClose);
connect(accounts, &Accounts::destroyed, this, &Squawk::onAccountsClosed); connect(accounts, &Accounts::destroyed, this, &Squawk::onAccountsClosed);
connect(accounts, &Accounts::newAccount, this, &Squawk::newAccountRequest); connect(accounts, &Accounts::newAccount, this, &Squawk::newAccountRequest);
@ -104,29 +104,23 @@ void Squawk::onAccounts()
connect(accounts, &Accounts::connectAccount, this, &Squawk::connectAccount); connect(accounts, &Accounts::connectAccount, this, &Squawk::connectAccount);
connect(accounts, &Accounts::disconnectAccount, this, &Squawk::disconnectAccount); connect(accounts, &Accounts::disconnectAccount, this, &Squawk::disconnectAccount);
connect(accounts, &Accounts::removeAccount, this, &Squawk::removeAccountRequest); connect(accounts, &Accounts::removeAccount, this, &Squawk::removeAccountRequest);
accounts->show();
} else {
accounts->show();
accounts->raise();
accounts->activateWindow();
} }
accounts->show();
accounts->raise();
accounts->activateWindow();
} }
void Squawk::onPreferences() void Squawk::onPreferences()
{ {
if (preferences == nullptr) { if (preferences == nullptr) {
preferences = new Settings(); preferences = new Settings(this);
preferences->setAttribute(Qt::WA_DeleteOnClose); preferences->setAttribute(Qt::WA_DeleteOnClose);
connect(preferences, &Settings::destroyed, this, &Squawk::onPreferencesClosed); connect(preferences, &Settings::destroyed, this, &Squawk::onPreferencesClosed);
connect(preferences, &Settings::changeDownloadsPath, this, &Squawk::changeDownloadsPath); connect(preferences, &Settings::changeDownloadsPath, this, &Squawk::changeDownloadsPath);
preferences->show();
} else {
preferences->show();
preferences->raise();
preferences->activateWindow();
} }
preferences->show();
preferences->raise();
preferences->activateWindow();
} }
@ -637,14 +631,13 @@ void Squawk::onContextAboutToHide()
void Squawk::onAboutSquawkCalled() void Squawk::onAboutSquawkCalled()
{ {
if (about == nullptr) { if (about == nullptr) {
about = new About(); about = new About(this);
about->setAttribute(Qt::WA_DeleteOnClose); about->setAttribute(Qt::WA_DeleteOnClose);
connect(about, &Settings::destroyed, this, &Squawk::onAboutSquawkClosed); connect(about, &Settings::destroyed, this, &Squawk::onAboutSquawkClosed);
} else {
about->raise();
about->activateWindow();
} }
about->show(); about->show();
about->raise();
about->activateWindow();
} }
Models::Roster::ElId Squawk::currentConversationId() const Models::Roster::ElId Squawk::currentConversationId() const

View File

@ -25,7 +25,7 @@ static const std::string QXMPP_VERSION_MAJOR(std::to_string(QXMPP_VERSION >> 16)
static const QString QXMPP_VERSION_STRING = QString::fromStdString(QXMPP_VERSION_MAJOR + "." + QXMPP_VERSION_MINOR + "." + QXMPP_VERSION_PATCH); static const QString QXMPP_VERSION_STRING = QString::fromStdString(QXMPP_VERSION_MAJOR + "." + QXMPP_VERSION_MINOR + "." + QXMPP_VERSION_PATCH);
About::About(QWidget* parent): About::About(QWidget* parent):
QWidget(parent), QDialog(parent),
m_ui(new Ui::About), m_ui(new Ui::About),
license(nullptr) license(nullptr)
{ {
@ -37,7 +37,10 @@ About::About(QWidget* parent):
m_ui->qxmppVersionValue->setText(QXmppVersion()); m_ui->qxmppVersionValue->setText(QXmppVersion());
m_ui->qxmppBuiltAgainstVersion->setText(tr("(built against %1)").arg(QXMPP_VERSION_STRING)); m_ui->qxmppBuiltAgainstVersion->setText(tr("(built against %1)").arg(QXMPP_VERSION_STRING));
setWindowFlag(Qt::Tool); setWindowFlag(Qt::WindowStaysOnTopHint);
if (parent)
move(parent->window()->frameGeometry().topLeft() +
parent->window()->rect().center() - rect().center());
connect(m_ui->licenceLink, &QLabel::linkActivated, this, &About::onLicenseActivated); connect(m_ui->licenceLink, &QLabel::linkActivated, this, &About::onLicenseActivated);
} }

View File

@ -17,7 +17,7 @@
#ifndef ABOUT_H #ifndef ABOUT_H
#define ABOUT_H #define ABOUT_H
#include <QWidget> #include <QDialog>
#include <QScopedPointer> #include <QScopedPointer>
#include <QApplication> #include <QApplication>
#include <QFile> #include <QFile>
@ -32,7 +32,7 @@ class About;
/** /**
* @todo write docs * @todo write docs
*/ */
class About : public QWidget class About : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -19,8 +19,8 @@
#include "account.h" #include "account.h"
#include "ui_account.h" #include "ui_account.h"
Account::Account(): Account::Account(QWidget *parent):
QDialog(), QDialog(parent),
m_ui(new Ui::Account) m_ui(new Ui::Account)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -38,6 +38,10 @@ Account::Account():
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet)); QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet));
item->setFlags(item->flags() & ~Qt::ItemIsEnabled); item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
} }
if (parent)
move(parent->window()->frameGeometry().topLeft() +
parent->window()->rect().center() - rect().center());
} }
Account::~Account() Account::~Account()

View File

@ -38,7 +38,7 @@ class Account : public QDialog
Q_OBJECT Q_OBJECT
public: public:
Account(); Account(QWidget *parent = nullptr);
~Account(); ~Account();
QMap<QString, QVariant> value() const; QMap<QString, QVariant> value() const;

View File

@ -22,7 +22,7 @@
#include <QDebug> #include <QDebug>
Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) : Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
QWidget(parent), QDialog(parent),
m_ui(new Ui::Accounts), m_ui(new Ui::Accounts),
model(p_model), model(p_model),
editing(false), editing(false),
@ -38,13 +38,17 @@ Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
connect(m_ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Accounts::onSelectionChanged); connect(m_ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Accounts::onSelectionChanged);
connect(p_model, &Models::Accounts::changed, this, &Accounts::updateConnectButton); connect(p_model, &Models::Accounts::changed, this, &Accounts::updateConnectButton);
connect(m_ui->tableView, &QTableView::doubleClicked, this, &Accounts::onEditButton); connect(m_ui->tableView, &QTableView::doubleClicked, this, &Accounts::onEditButton);
if (parent)
move(parent->window()->frameGeometry().topLeft() +
parent->window()->rect().center() - rect().center());
} }
Accounts::~Accounts() = default; Accounts::~Accounts() = default;
void Accounts::onAddButton() void Accounts::onAddButton()
{ {
Account* acc = new Account(); Account* acc = new Account(this);
connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted); connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted);
connect(acc, &Account::rejected, this, &Accounts::onAccountRejected); connect(acc, &Account::rejected, this, &Accounts::onAccountRejected);
acc->exec(); acc->exec();
@ -74,7 +78,7 @@ void Accounts::onAccountRejected()
void Accounts::onEditButton() void Accounts::onEditButton()
{ {
Account* acc = new Account(); Account* acc = new Account(this);
const Models::Account* mAcc = model->getAccount(m_ui->tableView->selectionModel()->selectedRows().at(0).row()); const Models::Account* mAcc = model->getAccount(m_ui->tableView->selectionModel()->selectedRows().at(0).row());
acc->setData({ acc->setData({

View File

@ -19,7 +19,7 @@
#ifndef ACCOUNTS_H #ifndef ACCOUNTS_H
#define ACCOUNTS_H #define ACCOUNTS_H
#include <QWidget> #include <QDialog>
#include <QScopedPointer> #include <QScopedPointer>
#include <QItemSelection> #include <QItemSelection>
@ -31,7 +31,7 @@ namespace Ui
class Accounts; class Accounts;
} }
class Accounts : public QWidget class Accounts : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -20,7 +20,7 @@
#include "ui_settings.h" #include "ui_settings.h"
Settings::Settings(QWidget* parent): Settings::Settings(QWidget* parent):
QWidget(parent), QDialog(parent),
m_ui(new Ui::Settings()), m_ui(new Ui::Settings()),
modifiedSettings() modifiedSettings()
{ {
@ -34,6 +34,10 @@ Settings::Settings(QWidget* parent):
connect(m_ui->applyButton, &QPushButton::clicked, this, &Settings::apply); connect(m_ui->applyButton, &QPushButton::clicked, this, &Settings::apply);
connect(m_ui->okButton, &QPushButton::clicked, this, &Settings::confirm); connect(m_ui->okButton, &QPushButton::clicked, this, &Settings::confirm);
connect(m_ui->cancelButton, &QPushButton::clicked, this, &Settings::close); connect(m_ui->cancelButton, &QPushButton::clicked, this, &Settings::close);
if (parent)
move(parent->window()->frameGeometry().topLeft() +
parent->window()->rect().center() - rect().center());
} }
Settings::~Settings() Settings::~Settings()

View File

@ -19,7 +19,7 @@
#ifndef SETTINGS_H #ifndef SETTINGS_H
#define SETTINGS_H #define SETTINGS_H
#include <QWidget> #include <QDialog>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QScopedPointer> #include <QScopedPointer>
#include <QSettings> #include <QSettings>
@ -36,7 +36,7 @@ class Settings;
/** /**
* @todo write docs * @todo write docs
*/ */
class Settings : public QWidget class Settings : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public: