From cc3a6350a5fee1648bf0eaac5e3934ab53a18b5d Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 10 Mar 2010 20:21:56 +0000 Subject: [PATCH] Enabled modality for appropriate dialogs Make sure it is impossible to open more than one torrent addition from URL dialog --- src/GUI.cpp | 12 ++++++++---- src/GUI.h | 2 ++ src/console_imp.h | 1 + src/createtorrent_imp.cpp | 1 + src/downloadfromurldlg.h | 1 + src/options_imp.cpp | 2 ++ 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 2961a85ac..a9cc220b5 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -227,6 +227,8 @@ GUI::~GUI() { delete aboutDlg; if(options) delete options; + if(downloadFromURLDialog) + delete downloadFromURLDialog; if(rssWidget) delete rssWidget; delete searchEngine; @@ -633,8 +635,8 @@ void GUI::on_actionOpen_triggered() { // Open File Open Dialog // Note: it is possible to select more than one file const QStringList &pathsList = QFileDialog::getOpenFileNames(0, - tr("Open Torrent Files"), settings.value(QString::fromUtf8("MainWindowLastDir"), QDir::homePath()).toString(), - tr("Torrent Files")+QString::fromUtf8(" (*.torrent)")); + tr("Open Torrent Files"), settings.value(QString::fromUtf8("MainWindowLastDir"), QDir::homePath()).toString(), + tr("Torrent Files")+QString::fromUtf8(" (*.torrent)")); if(!pathsList.empty()) { const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool(); const uint listSize = pathsList.size(); @@ -960,7 +962,9 @@ void GUI::on_actionOptions_triggered() { // Display an input dialog to prompt user for // an url void GUI::on_actionDownload_from_URL_triggered() { - downloadFromURL *downloadFromURLDialog = new downloadFromURL(this); - connect(downloadFromURLDialog, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), this, SLOT(downloadFromURLList(const QStringList&))); + if(!downloadFromURLDialog) { + downloadFromURLDialog = new downloadFromURL(this); + connect(downloadFromURLDialog, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), this, SLOT(downloadFromURLList(const QStringList&))); + } } diff --git a/src/GUI.h b/src/GUI.h index 82ef0e86b..208157709 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -58,6 +58,7 @@ class StatusBar; class consoleDlg; class about; class createtorrent; +class downloadFromURL; class GUI : public QMainWindow, private Ui::MainWindow{ Q_OBJECT @@ -139,6 +140,7 @@ private: QPointer console; QPointer aboutDlg; QPointer createTorrentDlg; + QPointer downloadFromURLDialog; QPointer systrayIcon; QPointer systrayCreator; QMenu *myTrayIconMenu; diff --git a/src/console_imp.h b/src/console_imp.h index 0d70eae47..90a5cda2d 100644 --- a/src/console_imp.h +++ b/src/console_imp.h @@ -46,6 +46,7 @@ class consoleDlg : public QDialog, private Ui_ConsoleDlg{ consoleDlg(QWidget *parent, Bittorrent* _BTSession) : QDialog(parent) { setupUi(this); setAttribute(Qt::WA_DeleteOnClose); + setModal(true); BTSession = _BTSession; textConsole->setHtml(BTSession->getConsoleMessages().join("
")); textBannedPeers->setHtml(BTSession->getPeerBanMessages().join("
")); diff --git a/src/createtorrent_imp.cpp b/src/createtorrent_imp.cpp index abded9f7e..8e729863e 100644 --- a/src/createtorrent_imp.cpp +++ b/src/createtorrent_imp.cpp @@ -65,6 +65,7 @@ bool file_filter(boost::filesystem::path const& filename) createtorrent::createtorrent(QWidget *parent): QDialog(parent){ setupUi(this); setAttribute(Qt::WA_DeleteOnClose); + setModal(true); creatorThread = new torrentCreatorThread(this); connect(creatorThread, SIGNAL(creationSuccess(QString, const char*)), this, SLOT(handleCreationSuccess(QString, const char*))); connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString))); diff --git a/src/downloadfromurldlg.h b/src/downloadfromurldlg.h index 9006bf899..436620b71 100644 --- a/src/downloadfromurldlg.h +++ b/src/downloadfromurldlg.h @@ -47,6 +47,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ setupUi(this); setAttribute(Qt::WA_DeleteOnClose); icon_lbl->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/url.png"))); + setModal(true); show(); // Paste clipboard if there is an URL in it QString clip_txt = qApp->clipboard()->text(); diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 6c1166533..f6229d21b 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -52,6 +52,8 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ qDebug("-> Constructing Options"); setAttribute(Qt::WA_DeleteOnClose); + setModal(true); + QString savePath; setupUi(this); // Get apply button in button box