forked from blue/squawk
fix: Pop up windows: About, Accounts, Account, Settings - opening on
centr of parent
This commit is contained in:
parent
ea7dcc5f18
commit
1af20e27f2
@ -96,7 +96,7 @@ Squawk::~Squawk() {
|
||||
void Squawk::onAccounts()
|
||||
{
|
||||
if (accounts == nullptr) {
|
||||
accounts = new Accounts(rosterModel.accountsModel);
|
||||
accounts = new Accounts(rosterModel.accountsModel, this);
|
||||
accounts->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(accounts, &Accounts::destroyed, this, &Squawk::onAccountsClosed);
|
||||
connect(accounts, &Accounts::newAccount, this, &Squawk::newAccountRequest);
|
||||
@ -104,30 +104,24 @@ void Squawk::onAccounts()
|
||||
connect(accounts, &Accounts::connectAccount, this, &Squawk::connectAccount);
|
||||
connect(accounts, &Accounts::disconnectAccount, this, &Squawk::disconnectAccount);
|
||||
connect(accounts, &Accounts::removeAccount, this, &Squawk::removeAccountRequest);
|
||||
|
||||
accounts->show();
|
||||
} else {
|
||||
}
|
||||
accounts->show();
|
||||
accounts->raise();
|
||||
accounts->activateWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void Squawk::onPreferences()
|
||||
{
|
||||
if (preferences == nullptr) {
|
||||
preferences = new Settings();
|
||||
preferences = new Settings(this);
|
||||
preferences->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(preferences, &Settings::destroyed, this, &Squawk::onPreferencesClosed);
|
||||
connect(preferences, &Settings::changeDownloadsPath, this, &Squawk::changeDownloadsPath);
|
||||
|
||||
preferences->show();
|
||||
} else {
|
||||
}
|
||||
preferences->show();
|
||||
preferences->raise();
|
||||
preferences->activateWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Squawk::onAccountsSizeChanged(unsigned int size)
|
||||
|
@ -38,10 +38,9 @@ About::About(QWidget* parent):
|
||||
m_ui->qxmppBuiltAgainstVersion->setText(tr("(built against %1)").arg(QXMPP_VERSION_STRING));
|
||||
|
||||
setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||
move(
|
||||
parent->window()->frameGeometry().topLeft() +
|
||||
parent->window()->rect().center() - rect().center()
|
||||
);
|
||||
if (parent)
|
||||
move(parent->window()->frameGeometry().topLeft() +
|
||||
parent->window()->rect().center() - rect().center());
|
||||
|
||||
connect(m_ui->licenceLink, &QLabel::linkActivated, this, &About::onLicenseActivated);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "account.h"
|
||||
#include "ui_account.h"
|
||||
|
||||
Account::Account():
|
||||
QDialog(),
|
||||
Account::Account(QWidget *parent):
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::Account)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
@ -38,6 +38,10 @@ Account::Account():
|
||||
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet));
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
|
||||
}
|
||||
|
||||
if (parent)
|
||||
move(parent->window()->frameGeometry().topLeft() +
|
||||
parent->window()->rect().center() - rect().center());
|
||||
}
|
||||
|
||||
Account::~Account()
|
||||
|
@ -38,7 +38,7 @@ class Account : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Account();
|
||||
Account(QWidget *parent = nullptr);
|
||||
~Account();
|
||||
|
||||
QMap<QString, QVariant> value() const;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::Accounts),
|
||||
model(p_model),
|
||||
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(p_model, &Models::Accounts::changed, this, &Accounts::updateConnectButton);
|
||||
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;
|
||||
|
||||
void Accounts::onAddButton()
|
||||
{
|
||||
Account* acc = new Account();
|
||||
Account* acc = new Account(this);
|
||||
connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted);
|
||||
connect(acc, &Account::rejected, this, &Accounts::onAccountRejected);
|
||||
acc->exec();
|
||||
@ -74,7 +78,7 @@ void Accounts::onAccountRejected()
|
||||
|
||||
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());
|
||||
acc->setData({
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef ACCOUNTS_H
|
||||
#define ACCOUNTS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
#include <QItemSelection>
|
||||
|
||||
@ -31,7 +31,7 @@ namespace Ui
|
||||
class Accounts;
|
||||
}
|
||||
|
||||
class Accounts : public QWidget
|
||||
class Accounts : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "ui_settings.h"
|
||||
|
||||
Settings::Settings(QWidget* parent):
|
||||
QWidget(parent),
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::Settings()),
|
||||
modifiedSettings()
|
||||
{
|
||||
@ -34,6 +34,10 @@ Settings::Settings(QWidget* parent):
|
||||
connect(m_ui->applyButton, &QPushButton::clicked, this, &Settings::apply);
|
||||
connect(m_ui->okButton, &QPushButton::clicked, this, &Settings::confirm);
|
||||
connect(m_ui->cancelButton, &QPushButton::clicked, this, &Settings::close);
|
||||
|
||||
if (parent)
|
||||
move(parent->window()->frameGeometry().topLeft() +
|
||||
parent->window()->rect().center() - rect().center());
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDialog>
|
||||
#include <QListWidgetItem>
|
||||
#include <QScopedPointer>
|
||||
#include <QSettings>
|
||||
@ -36,7 +36,7 @@ class Settings;
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class Settings : public QWidget
|
||||
class Settings : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user