From 6f5f661f303e44e99f6d9d992336b5b352522bd7 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sat, 9 Aug 2014 21:15:17 +0300 Subject: [PATCH] Show the loaded torrents in the transferlist when qBT is launched with a torrent/magnet and the AddNewTorrentDialog is showing. Closes #1564. Conflicts: src/mainwindow.cpp --- src/addnewtorrentdialog.cpp | 21 +++++++++++++-------- src/addnewtorrentdialog.h | 4 ++-- src/mainwindow.cpp | 16 ++++++++-------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/addnewtorrentdialog.cpp b/src/addnewtorrentdialog.cpp index 5cd42e7c0..f5cd60c35 100644 --- a/src/addnewtorrentdialog.cpp +++ b/src/addnewtorrentdialog.cpp @@ -61,6 +61,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : m_hasRenamedFile(false) { ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); ui->lblMetaLoading->setVisible(false); ui->progMetaLoading->setVisible(false); @@ -124,18 +125,22 @@ void AddNewTorrentDialog::saveState() settings.setValue("expanded", ui->adv_button->isChecked()); } -void AddNewTorrentDialog::showTorrent(const QString &torrent_path, const QString& from_url) +void AddNewTorrentDialog::showTorrent(const QString &torrent_path, const QString& from_url, QWidget *parent) { - AddNewTorrentDialog dlg; - if (dlg.loadTorrent(torrent_path, from_url)) - dlg.exec(); + AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent); + if (dlg->loadTorrent(torrent_path, from_url)) + dlg->open(); + else + delete dlg; } -void AddNewTorrentDialog::showMagnet(const QString& link) +void AddNewTorrentDialog::showMagnet(const QString& link, QWidget *parent) { - AddNewTorrentDialog dlg; - if (dlg.loadMagnet(link)) - dlg.exec(); + AddNewTorrentDialog *dlg = new AddNewTorrentDialog(parent); + if (dlg->loadMagnet(link)) + dlg->open(); + else + delete dlg; } void AddNewTorrentDialog::showEvent(QShowEvent *event) { diff --git a/src/addnewtorrentdialog.h b/src/addnewtorrentdialog.h index 1e1bfb2ae..ca351e5c5 100644 --- a/src/addnewtorrentdialog.h +++ b/src/addnewtorrentdialog.h @@ -53,8 +53,8 @@ class AddNewTorrentDialog : public QDialog public: ~AddNewTorrentDialog(); - static void showTorrent(const QString& torrent_path, const QString& from_url = QString()); - static void showMagnet(const QString& torrent_link); + static void showTorrent(const QString& torrent_path, const QString& from_url, QWidget *parent = 0); + static void showMagnet(const QString& torrent_link, QWidget *parent = 0); protected: void showEvent(QShowEvent *event); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7361e9ebf..eb068b8aa 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -901,13 +901,13 @@ void MainWindow::dropEvent(QDropEvent *event) { } if (file.startsWith("magnet:", Qt::CaseInsensitive)) { if (useTorrentAdditionDialog) - AddNewTorrentDialog::showMagnet(file); + AddNewTorrentDialog::showMagnet(file, this); else QBtSession::instance()->addMagnetUri(file); } else { // Local file if (useTorrentAdditionDialog) - AddNewTorrentDialog::showTorrent(file); + AddNewTorrentDialog::showTorrent(file, QString(), this); else QBtSession::instance()->addTorrent(file); } @@ -944,7 +944,7 @@ void MainWindow::on_actionOpen_triggered() { const uint listSize = pathsList.size(); for (uint i=0; iaddTorrent(pathsList.at(i)); } @@ -987,12 +987,12 @@ void MainWindow::processParams(const QStringList& params) { } if (param.startsWith("magnet:", Qt::CaseInsensitive)) { if (useTorrentAdditionDialog) - AddNewTorrentDialog::showMagnet(param); + AddNewTorrentDialog::showMagnet(param, this); else QBtSession::instance()->addMagnetUri(param); } else { if (useTorrentAdditionDialog) - AddNewTorrentDialog::showTorrent(param); + AddNewTorrentDialog::showTorrent(param, QString(), this); else QBtSession::instance()->addTorrent(param); } @@ -1007,7 +1007,7 @@ void MainWindow::addTorrent(QString path) { void MainWindow::processDownloadedFiles(QString path, QString url) { Preferences pref; if (pref.useAdditionDialog()) - AddNewTorrentDialog::showTorrent(path, url); + AddNewTorrentDialog::showTorrent(path, url, this); else QBtSession::instance()->addTorrent(path, false, url); } @@ -1015,7 +1015,7 @@ void MainWindow::processDownloadedFiles(QString path, QString url) { void MainWindow::processNewMagnetLink(const QString& link) { Preferences pref; if (pref.useAdditionDialog()) - AddNewTorrentDialog::showMagnet(link); + AddNewTorrentDialog::showMagnet(link, this); else QBtSession::instance()->addMagnetUri(link); } @@ -1210,7 +1210,7 @@ void MainWindow::downloadFromURLList(const QStringList& url_list) { } if (url.startsWith("magnet:", Qt::CaseInsensitive)) { if (useTorrentAdditionDialog) - AddNewTorrentDialog::showMagnet(url); + AddNewTorrentDialog::showMagnet(url, this); else QBtSession::instance()->addMagnetUri(url); }