Set dialog properties at the caller site

Redundant `setModal(true)` are removed since the dialog is already opened via `open()`.
This commit is contained in:
Chocobo1 2022-06-02 19:51:26 +08:00
parent ab0c82965c
commit 3fd0241abb
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
11 changed files with 30 additions and 32 deletions

View file

@ -47,7 +47,6 @@ AboutDialog::AboutDialog(QWidget *parent)
, m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs))
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Title // Title
m_ui->labelName->setText(QStringLiteral("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8)); m_ui->labelName->setText(QStringLiteral("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8));
@ -114,7 +113,6 @@ AboutDialog::AboutDialog(QWidget *parent)
m_ui->labelDBIP->setText(DBIPText); m_ui->labelDBIP->setText(DBIPText);
resize(m_storeDialogSize); resize(m_storeDialogSize);
show();
} }
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()

View file

@ -183,7 +183,6 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
{ {
// TODO: set dialog file properties using m_torrentParams.filePriorities // TODO: set dialog file properties using m_torrentParams.filePriorities
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
m_ui->lblMetaLoading->setVisible(false); m_ui->lblMetaLoading->setVisible(false);
m_ui->progMetaLoading->setVisible(false); m_ui->progMetaLoading->setVisible(false);
@ -352,6 +351,7 @@ void AddNewTorrentDialog::saveState()
void AddNewTorrentDialog::show(const QString &source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent) void AddNewTorrentDialog::show(const QString &source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
{ {
auto *dlg = new AddNewTorrentDialog(inParams, parent); auto *dlg = new AddNewTorrentDialog(inParams, parent);
dlg->setAttribute(Qt::WA_DeleteOnClose);
if (Net::DownloadManager::hasSupportedScheme(source)) if (Net::DownloadManager::hasSupportedScheme(source))
{ {

View file

@ -64,8 +64,6 @@ DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent)
, m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs))
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setModal(true);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Download")); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Download"));
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &DownloadFromURLDialog::downloadButtonClicked); connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &DownloadFromURLDialog::downloadButtonClicked);
@ -95,7 +93,6 @@ DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent)
m_ui->textUrls->moveCursor(QTextCursor::End); m_ui->textUrls->moveCursor(QTextCursor::End);
resize(m_storeDialogSize); resize(m_storeDialogSize);
show();
} }
DownloadFromURLDialog::~DownloadFromURLDialog() DownloadFromURLDialog::~DownloadFromURLDialog()

View file

@ -1124,17 +1124,29 @@ void MainWindow::on_actionAbout_triggered()
{ {
// About dialog // About dialog
if (m_aboutDlg) if (m_aboutDlg)
{
m_aboutDlg->activateWindow(); m_aboutDlg->activateWindow();
}
else else
{
m_aboutDlg = new AboutDialog(this); m_aboutDlg = new AboutDialog(this);
m_aboutDlg->setAttribute(Qt::WA_DeleteOnClose);
m_aboutDlg->show();
}
} }
void MainWindow::on_actionStatistics_triggered() void MainWindow::on_actionStatistics_triggered()
{ {
if (m_statsDlg) if (m_statsDlg)
{
m_statsDlg->activateWindow(); m_statsDlg->activateWindow();
}
else else
{
m_statsDlg = new StatsDialog(this); m_statsDlg = new StatsDialog(this);
m_statsDlg->setAttribute(Qt::WA_DeleteOnClose);
m_statsDlg->show();
}
} }
void MainWindow::showEvent(QShowEvent *e) void MainWindow::showEvent(QShowEvent *e)
@ -1279,6 +1291,8 @@ void MainWindow::createTorrentTriggered(const Path &path)
else else
{ {
m_createTorrentDlg = new TorrentCreatorDialog(this, path); m_createTorrentDlg = new TorrentCreatorDialog(this, path);
m_createTorrentDlg->setAttribute(Qt::WA_DeleteOnClose);
m_createTorrentDlg->show();
} }
} }
@ -1814,9 +1828,15 @@ PropertiesWidget *MainWindow::propertiesWidget() const
void MainWindow::on_actionOptions_triggered() void MainWindow::on_actionOptions_triggered()
{ {
if (m_options) if (m_options)
{
m_options->activateWindow(); m_options->activateWindow();
}
else else
{
m_options = new OptionsDialog(this); m_options = new OptionsDialog(this);
m_options->setAttribute(Qt::WA_DeleteOnClose);
m_options->open();
}
} }
void MainWindow::on_actionTopToolBar_triggered() void MainWindow::on_actionTopToolBar_triggered()
@ -1923,7 +1943,9 @@ void MainWindow::on_actionDownloadFromURL_triggered()
if (!m_downloadFromURLDialog) if (!m_downloadFromURLDialog)
{ {
m_downloadFromURLDialog = new DownloadFromURLDialog(this); m_downloadFromURLDialog = new DownloadFromURLDialog(this);
m_downloadFromURLDialog->setAttribute(Qt::WA_DeleteOnClose);
connect(m_downloadFromURLDialog.data(), &DownloadFromURLDialog::urlsReadyToBeDownloaded, this, &MainWindow::downloadFromURLList); connect(m_downloadFromURLDialog.data(), &DownloadFromURLDialog::urlsReadyToBeDownloaded, this, &MainWindow::downloadFromURLList);
m_downloadFromURLDialog->open();
} }
} }

View file

@ -32,7 +32,6 @@
#include <limits> #include <limits>
#include <QApplication> #include <QApplication>
#include <QCloseEvent>
#include <QDebug> #include <QDebug>
#include <QDesktopServices> #include <QDesktopServices>
#include <QDialogButtonBox> #include <QDialogButtonBox>
@ -185,8 +184,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
{ {
qDebug("-> Constructing Options"); qDebug("-> Constructing Options");
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setModal(true);
#if (defined(Q_OS_UNIX)) #if (defined(Q_OS_UNIX))
setWindowTitle(tr("Preferences")); setWindowTitle(tr("Preferences"));
@ -576,7 +573,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->tabSelection->setCurrentRow(m_storeLastViewedPage); m_ui->tabSelection->setCurrentRow(m_storeLastViewedPage);
resize(m_storeDialogSize); resize(m_storeDialogSize);
show();
// Have to be called after show(), because splitter width needed // Have to be called after show(), because splitter width needed
loadSplitterState(); loadSplitterState();
} }
@ -1477,15 +1474,8 @@ void OptionsDialog::applySettings()
saveOptions(); saveOptions();
} }
void OptionsDialog::closeEvent(QCloseEvent *e)
{
setAttribute(Qt::WA_DeleteOnClose);
e->accept();
}
void OptionsDialog::on_buttonBox_rejected() void OptionsDialog::on_buttonBox_rejected()
{ {
setAttribute(Qt::WA_DeleteOnClose);
reject(); reject();
} }
@ -1667,7 +1657,6 @@ void OptionsDialog::on_addWatchedFolderButton_clicked()
return; return;
auto dialog = new WatchedFolderOptionsDialog({}, this); auto dialog = new WatchedFolderOptionsDialog({}, this);
dialog->setModal(true);
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
connect(dialog, &QDialog::accepted, this, [this, dialog, dir, pref]() connect(dialog, &QDialog::accepted, this, [this, dialog, dir, pref]()
{ {
@ -1723,7 +1712,6 @@ void OptionsDialog::editWatchedFolderOptions(const QModelIndex &index)
auto watchedFoldersModel = static_cast<WatchedFoldersModel *>(m_ui->scanFoldersView->model()); auto watchedFoldersModel = static_cast<WatchedFoldersModel *>(m_ui->scanFoldersView->model());
auto dialog = new WatchedFolderOptionsDialog(watchedFoldersModel->folderOptions(index.row()), this); auto dialog = new WatchedFolderOptionsDialog(watchedFoldersModel->folderOptions(index.row()), this);
dialog->setModal(true);
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
connect(dialog, &QDialog::accepted, this, [this, dialog, index, watchedFoldersModel]() connect(dialog, &QDialog::accepted, this, [this, dialog, index, watchedFoldersModel]()
{ {

View file

@ -33,7 +33,6 @@
#include "base/pathfwd.h" #include "base/pathfwd.h"
#include "base/settingvalue.h" #include "base/settingvalue.h"
class QCloseEvent;
class QListWidgetItem; class QListWidgetItem;
class AdvancedSettings; class AdvancedSettings;
@ -94,7 +93,6 @@ public slots:
private slots: private slots:
void enableProxy(int index); void enableProxy(int index);
void on_buttonBox_accepted(); void on_buttonBox_accepted();
void closeEvent(QCloseEvent *e) override;
void on_buttonBox_rejected(); void on_buttonBox_rejected();
void applySettings(); void applySettings();
void enableApplyButton(); void enableApplyButton();

View file

@ -66,7 +66,6 @@ PluginSelectDialog::PluginSelectDialog(SearchPluginManager *pluginManager, QWidg
, m_pluginManager(pluginManager) , m_pluginManager(pluginManager)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
m_ui->pluginsTree->setRootIsDecorated(false); m_ui->pluginsTree->setRootIsDecorated(false);
m_ui->pluginsTree->hideColumn(PLUGIN_ID); m_ui->pluginsTree->hideColumn(PLUGIN_ID);
@ -89,7 +88,6 @@ PluginSelectDialog::PluginSelectDialog(SearchPluginManager *pluginManager, QWidg
connect(m_pluginManager, &SearchPluginManager::checkForUpdatesFailed, this, &PluginSelectDialog::checkForUpdatesFailed); connect(m_pluginManager, &SearchPluginManager::checkForUpdatesFailed, this, &PluginSelectDialog::checkForUpdatesFailed);
resize(m_storeDialogSize); resize(m_storeDialogSize);
show();
} }
PluginSelectDialog::~PluginSelectDialog() PluginSelectDialog::~PluginSelectDialog()
@ -346,8 +344,10 @@ void PluginSelectDialog::finishPluginUpdate()
void PluginSelectDialog::on_installButton_clicked() void PluginSelectDialog::on_installButton_clicked()
{ {
auto *dlg = new PluginSourceDialog(this); auto *dlg = new PluginSourceDialog(this);
dlg->setAttribute(Qt::WA_DeleteOnClose);
connect(dlg, &PluginSourceDialog::askForLocalFile, this, &PluginSelectDialog::askForLocalPlugin); connect(dlg, &PluginSourceDialog::askForLocalFile, this, &PluginSelectDialog::askForLocalPlugin);
connect(dlg, &PluginSourceDialog::askForUrl, this, &PluginSelectDialog::askForPluginUrl); connect(dlg, &PluginSourceDialog::askForUrl, this, &PluginSelectDialog::askForPluginUrl);
dlg->show();
} }
void PluginSelectDialog::askForPluginUrl() void PluginSelectDialog::askForPluginUrl()

View file

@ -39,10 +39,8 @@ PluginSourceDialog::PluginSourceDialog(QWidget *parent)
, m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs))
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
resize(m_storeDialogSize); resize(m_storeDialogSize);
show();
} }
PluginSourceDialog::~PluginSourceDialog() PluginSourceDialog::~PluginSourceDialog()

View file

@ -286,7 +286,9 @@ void SearchWidget::toggleFocusBetweenLineEdits()
void SearchWidget::on_pluginsButton_clicked() void SearchWidget::on_pluginsButton_clicked()
{ {
new PluginSelectDialog(SearchPluginManager::instance(), this); auto *dlg = new PluginSelectDialog(SearchPluginManager::instance(), this);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
} }
void SearchWidget::searchTextEdited(const QString &) void SearchWidget::searchTextEdited(const QString &)

View file

@ -48,7 +48,7 @@ StatsDialog::StatsDialog(QWidget *parent)
, m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs))
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &StatsDialog::close); connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &StatsDialog::close);
update(); update();
@ -61,7 +61,6 @@ StatsDialog::StatsDialog(QWidget *parent)
#endif #endif
resize(m_storeDialogSize); resize(m_storeDialogSize);
show();
} }
StatsDialog::~StatsDialog() StatsDialog::~StatsDialog()

View file

@ -67,8 +67,6 @@ TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const Path &defaultP
, m_storeSource(SETTINGS_KEY(u"Source"_qs)) , m_storeSource(SETTINGS_KEY(u"Source"_qs))
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setModal(false);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Torrent")); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Torrent"));
@ -89,8 +87,6 @@ TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const Path &defaultP
#else #else
m_ui->widgetTorrentFormat->hide(); m_ui->widgetTorrentFormat->hide();
#endif #endif
show();
} }
TorrentCreatorDialog::~TorrentCreatorDialog() TorrentCreatorDialog::~TorrentCreatorDialog()