diff --git a/qt/mainwin.cc b/qt/mainwin.cc index 26281a80c..82eac9086 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -106,7 +107,6 @@ TrMainWindow :: TrMainWindow (Session& session, Prefs& prefs, TorrentModel& mode myAboutDialog (new AboutDialog (this)), myStatsDialog (new StatsDialog (session, this)), myDetailsDialog (0), - myFileDialogOptionsCheck (0), myFilterModel (prefs), myTorrentDelegate (new TorrentDelegate (this)), myTorrentDelegateMin (new TorrentDelegateMin (this)), @@ -1154,6 +1154,8 @@ TrMainWindow :: refreshPref (int key) **** ***/ +#define SHOW_OPTIONS_CHECKBOX_NAME "show-options-checkbox" + void TrMainWindow :: newTorrent () { @@ -1164,24 +1166,24 @@ TrMainWindow :: newTorrent () void TrMainWindow :: openTorrent () { - QFileDialog * myFileDialog; - myFileDialog = new QFileDialog (this, - tr ("Open Torrent"), - myPrefs.getString (Prefs::OPEN_DIALOG_FOLDER), - tr ("Torrent Files (*.torrent);;All Files (*.*)")); - myFileDialog->setFileMode (QFileDialog::ExistingFiles); - myFileDialog->setAttribute (Qt::WA_DeleteOnClose); + QFileDialog * d; + d = new QFileDialog (this, + tr ("Open Torrent"), + myPrefs.getString (Prefs::OPEN_DIALOG_FOLDER), + tr ("Torrent Files (*.torrent);;All Files (*.*)")); + d->setFileMode (QFileDialog::ExistingFiles); + d->setAttribute (Qt::WA_DeleteOnClose); - QCheckBox * button = new QCheckBox (tr ("Show &options dialog")); - button->setChecked (myPrefs.getBool (Prefs::OPTIONS_PROMPT)); - QGridLayout * layout = dynamic_cast (myFileDialog->layout ()); - layout->addWidget (button, layout->rowCount (), 0, 1, -1, Qt::AlignLeft); - myFileDialogOptionsCheck = button; + QCheckBox * b = new QCheckBox (tr ("Show &options dialog")); + b->setChecked (myPrefs.getBool (Prefs::OPTIONS_PROMPT)); + b->setObjectName (SHOW_OPTIONS_CHECKBOX_NAME); + QGridLayout * l = dynamic_cast (d->layout ()); + l->addWidget (b, l->rowCount (), 0, 1, -1, Qt::AlignLeft); - connect (myFileDialog, SIGNAL (filesSelected (const QStringList&)), + connect (d, SIGNAL (filesSelected (const QStringList&)), this, SLOT (addTorrents (const QStringList&))); - myFileDialog->show (); + d->show (); } void @@ -1195,27 +1197,30 @@ TrMainWindow :: openURL () if (!AddData::isSupported (str)) str.clear (); - addTorrent (str); + addTorrent (str, true); } void TrMainWindow :: addTorrents (const QStringList& filenames) { + bool showOptions = myPrefs.getBool (Prefs::OPTIONS_PROMPT); + + const QFileDialog * const fileDialog = qobject_cast (sender ()); + if (fileDialog != NULL) + { + const QCheckBox * const b = fileDialog->findChild (SHOW_OPTIONS_CHECKBOX_NAME); + if (b != NULL) + showOptions = b->isChecked (); + } + foreach (const QString& filename, filenames) - addTorrent (filename); + addTorrent (filename, showOptions); } void -TrMainWindow :: addTorrent (const AddData& addMe) +TrMainWindow :: addTorrent (const AddData& addMe, bool showOptions) { - bool show_options_dialog; - - if (myFileDialogOptionsCheck) - show_options_dialog = myFileDialogOptionsCheck->isChecked (); - else - show_options_dialog = myPrefs.getBool (Prefs::OPTIONS_PROMPT); - - if (show_options_dialog) + if (showOptions) { Options * o = new Options (mySession, myPrefs, addMe, this); o->show (); diff --git a/qt/mainwin.h b/qt/mainwin.h index 7db35cae8..09279d69b 100644 --- a/qt/mainwin.h +++ b/qt/mainwin.h @@ -14,7 +14,6 @@ #define MAIN_WINDOW_H #include -#include #include #include #include @@ -64,7 +63,6 @@ class TrMainWindow: public QMainWindow QDialog * myAboutDialog; QDialog * myStatsDialog; Details * myDetailsDialog; - QCheckBox * myFileDialogOptionsCheck; QSystemTrayIcon myTrayIcon; TorrentFilter myFilterModel; TorrentDelegate * myTorrentDelegate; @@ -172,11 +170,11 @@ class TrMainWindow: public QMainWindow void queueMoveDown (); void queueMoveBottom (); void reannounceSelected (); - void addTorrent (const AddData& addMe); void onNetworkTimer (); private: void clearSelection (); + void addTorrent (const AddData& addMe, bool showOptions); public slots: void setToolbarVisible (bool);