diff --git a/qt/mainwin.cc b/qt/mainwin.cc index 2f333a7f0..6703c7aa6 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -86,7 +86,7 @@ namespace TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& model, bool minimized ): myLastFullUpdateTime( 0 ), mySessionDialog( new SessionDialog( session, prefs, this ) ), - myPrefsDialog( new PrefsDialog( session, prefs, this ) ), + myPrefsDialog( 0 ), myAboutDialog( new AboutDialog( this ) ), myStatsDialog( new StatsDialog( session, this ) ), myDetailsDialog( 0 ), @@ -159,7 +159,7 @@ TrMainWindow :: TrMainWindow( Session& session, Prefs& prefs, TorrentModel& mode connect( ui.action_AddFile, SIGNAL(triggered()), this, SLOT(openTorrent())); connect( ui.action_AddURL, SIGNAL(triggered()), this, SLOT(openURL())); connect( ui.action_New, SIGNAL(triggered()), this, SLOT(newTorrent())); - connect( ui.action_Preferences, SIGNAL(triggered()), myPrefsDialog, SLOT(show())); + connect( ui.action_Preferences, SIGNAL(triggered()), this, SLOT(openPreferences())); connect( ui.action_Statistics, SIGNAL(triggered()), myStatsDialog, SLOT(show())); connect( ui.action_About, SIGNAL(triggered()), myAboutDialog, SLOT(show())); connect( ui.action_Contents, SIGNAL(triggered()), this, SLOT(openHelp())); @@ -629,6 +629,23 @@ TrMainWindow :: setSortAscendingPref( bool b ) ***** ****/ +void +TrMainWindow :: onPrefsDestroyed( ) +{ + myPrefsDialog = 0; +} + +void +TrMainWindow :: openPreferences( ) +{ + if( myPrefsDialog == 0 ) { + myPrefsDialog = new PrefsDialog( mySession, myPrefs, this ); + connect( myPrefsDialog, SIGNAL(destroyed(QObject*)), this, SLOT(onPrefsDestroyed())); + } + + myPrefsDialog->show( ); +} + void TrMainWindow :: onDetailsDestroyed( ) { diff --git a/qt/mainwin.h b/qt/mainwin.h index 537145a4b..e18f66871 100644 --- a/qt/mainwin.h +++ b/qt/mainwin.h @@ -95,6 +95,8 @@ class TrMainWindow: public QMainWindow void openURL( QString ); private slots: + void onPrefsDestroyed( ); + void openPreferences( ); void onDetailsDestroyed( ); void onShowModeClicked( ); void showAll( ); diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index 68adf26b1..e4ba3659c 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -620,7 +620,7 @@ PrefsDialog :: PrefsDialog( Session& session, Prefs& prefs, QWidget * parent ): myLayout->addWidget( t ); QDialogButtonBox * buttons = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, this ); - connect( buttons, SIGNAL(rejected()), this, SLOT(hide()) ); // "close" triggers rejected + connect( buttons, SIGNAL(rejected()), this, SLOT(deleteLater()) ); // "close" triggers rejected myLayout->addWidget( buttons ); connect( &mySession, SIGNAL(sessionUpdated()), this, SLOT(sessionUpdated()));