Changeset 14205


Ignore:
Timestamp:
Sep 14, 2013, 10:50:25 PM (9 years ago)
Author:
jordan
Message:

(trunk, qt) #5487 'Qt client crash when using Open URL action' -- fixed.

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r14177 r14205  
    1515
    1616#include <QtGui>
     17#include <QCheckBox>
    1718#include <QProxyStyle>
    1819#include <QLabel>
     
    107108  myStatsDialog (new StatsDialog (session, this)),
    108109  myDetailsDialog (0),
    109   myFileDialogOptionsCheck (0),
    110110  myFilterModel (prefs),
    111111  myTorrentDelegate (new TorrentDelegate (this)),
     
    11551155***/
    11561156
     1157#define SHOW_OPTIONS_CHECKBOX_NAME "show-options-checkbox"
     1158
    11571159void
    11581160TrMainWindow :: newTorrent ()
     
    11651167TrMainWindow :: openTorrent ()
    11661168{
    1167   QFileDialog * myFileDialog;
    1168   myFileDialog = new QFileDialog (this,
    1169                                   tr ("Open Torrent"),
    1170                                   myPrefs.getString (Prefs::OPEN_DIALOG_FOLDER),
    1171                                   tr ("Torrent Files (*.torrent);;All Files (*.*)"));
    1172   myFileDialog->setFileMode (QFileDialog::ExistingFiles);
    1173   myFileDialog->setAttribute (Qt::WA_DeleteOnClose);
    1174 
    1175   QCheckBox * button = new QCheckBox (tr ("Show &options dialog"));
    1176   button->setChecked (myPrefs.getBool (Prefs::OPTIONS_PROMPT));
    1177   QGridLayout * layout = dynamic_cast<QGridLayout*> (myFileDialog->layout ());
    1178   layout->addWidget (button, layout->rowCount (), 0, 1, -1, Qt::AlignLeft);
    1179   myFileDialogOptionsCheck = button;
    1180 
    1181   connect (myFileDialog, SIGNAL (filesSelected (const QStringList&)),
     1169  QFileDialog * d;
     1170  d = new QFileDialog (this,
     1171                       tr ("Open Torrent"),
     1172                       myPrefs.getString (Prefs::OPEN_DIALOG_FOLDER),
     1173                       tr ("Torrent Files (*.torrent);;All Files (*.*)"));
     1174  d->setFileMode (QFileDialog::ExistingFiles);
     1175  d->setAttribute (Qt::WA_DeleteOnClose);
     1176
     1177  QCheckBox * b = new QCheckBox (tr ("Show &options dialog"));
     1178  b->setChecked (myPrefs.getBool (Prefs::OPTIONS_PROMPT));
     1179  b->setObjectName (SHOW_OPTIONS_CHECKBOX_NAME);
     1180  QGridLayout * l = dynamic_cast<QGridLayout*> (d->layout ());
     1181  l->addWidget (b, l->rowCount (), 0, 1, -1, Qt::AlignLeft);
     1182
     1183  connect (d, SIGNAL (filesSelected (const QStringList&)),
    11821184           this, SLOT (addTorrents (const QStringList&)));
    11831185
    1184   myFileDialog->show ();
     1186  d->show ();
    11851187}
    11861188
     
    11961198    str.clear ();
    11971199
    1198   addTorrent (str);
     1200  addTorrent (str, true);
    11991201}
    12001202
     
    12021204TrMainWindow :: addTorrents (const QStringList& filenames)
    12031205{
     1206  bool showOptions = myPrefs.getBool (Prefs::OPTIONS_PROMPT);
     1207
     1208  const QFileDialog * const fileDialog = qobject_cast<const QFileDialog*> (sender ());
     1209  if (fileDialog != NULL)
     1210    {
     1211      const QCheckBox * const b = fileDialog->findChild<const QCheckBox*> (SHOW_OPTIONS_CHECKBOX_NAME);
     1212      if (b != NULL)
     1213        showOptions = b->isChecked ();
     1214    }
     1215
    12041216  foreach (const QString& filename, filenames)
    1205     addTorrent (filename);
    1206 }
    1207 
    1208 void
    1209 TrMainWindow :: addTorrent (const AddData& addMe)
    1210 {
    1211   bool show_options_dialog;
    1212 
    1213   if (myFileDialogOptionsCheck)
    1214     show_options_dialog = myFileDialogOptionsCheck->isChecked ();
    1215   else
    1216     show_options_dialog = myPrefs.getBool (Prefs::OPTIONS_PROMPT);
    1217 
    1218   if (show_options_dialog)
     1217    addTorrent (filename, showOptions);
     1218}
     1219
     1220void
     1221TrMainWindow :: addTorrent (const AddData& addMe, bool showOptions)
     1222{
     1223  if (showOptions)
    12191224    {
    12201225      Options * o = new Options (mySession, myPrefs, addMe, this);
  • trunk/qt/mainwin.h

    r14176 r14205  
    1515
    1616#include <ctime>
    17 #include <QCheckBox>
    1817#include <QLineEdit>
    1918#include <QIcon>
     
    6564    QDialog * myStatsDialog;
    6665    Details * myDetailsDialog;
    67     QCheckBox * myFileDialogOptionsCheck;
    6866    QSystemTrayIcon myTrayIcon;
    6967    TorrentFilter myFilterModel;
     
    173171    void queueMoveBottom ();
    174172    void reannounceSelected ();
    175     void addTorrent (const AddData& addMe);
    176173    void onNetworkTimer ();
    177174
    178175  private:
    179176    void clearSelection ();
     177    void addTorrent (const AddData& addMe, bool showOptions);
    180178
    181179  public slots:
Note: See TracChangeset for help on using the changeset viewer.