(trunk qt) #2050 "properties dialog changes seem to undo themselves" -- better fix

This commit is contained in:
Charles Kerr 2010-08-02 16:30:24 +00:00
parent 5aa04d83ef
commit 6f864ed3fc
3 changed files with 20 additions and 13 deletions

View File

@ -2,4 +2,4 @@
export G_SLICE=always-malloc export G_SLICE=always-malloc
export G_DEBUG=gc-friendly export G_DEBUG=gc-friendly
export GLIBCXX_FORCE_NEW=1 export GLIBCXX_FORCE_NEW=1
valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=64 --log-file=x-valgrind --show-reachable=yes ./qtr valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=32 --log-file=x-valgrind --show-reachable=yes ./transmission-qt

View File

@ -57,7 +57,7 @@ void
PrefsDialog :: checkBoxToggled( bool checked ) PrefsDialog :: checkBoxToggled( bool checked )
{ {
const int key( sender( )->property( PREF_KEY ).toInt( ) ); const int key( sender( )->property( PREF_KEY ).toInt( ) );
myPrefs.set( key, checked ); setPref( key, checked );
} }
QCheckBox * QCheckBox *
@ -86,9 +86,9 @@ PrefsDialog :: spinBoxChangedIdle( )
const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin ); const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin );
if( d != 0 ) if( d != 0 )
myPrefs.set( key, d->value( ) ); setPref( key, d->value( ) );
else else
myPrefs.set( key, qobject_cast<const QSpinBox*>(spin)->value( ) ); setPref( key, qobject_cast<const QSpinBox*>(spin)->value( ) );
} }
void void
@ -152,7 +152,7 @@ PrefsDialog :: timeChanged( const QTime& time )
{ {
const int key( sender()->property( PREF_KEY ).toInt( ) ); const int key( sender()->property( PREF_KEY ).toInt( ) );
const int seconds( QTime().secsTo( time ) ); const int seconds( QTime().secsTo( time ) );
myPrefs.set( key, seconds / 60 ); setPref( key, seconds / 60 );
} }
QTimeEdit* QTimeEdit*
@ -172,7 +172,7 @@ void
PrefsDialog :: textChanged( const QString& text ) PrefsDialog :: textChanged( const QString& text )
{ {
const int key( sender()->property( PREF_KEY ).toInt( ) ); const int key( sender()->property( PREF_KEY ).toInt( ) );
myPrefs.set( key, text ); setPref( key, text );
} }
QLineEdit* QLineEdit*
@ -255,7 +255,7 @@ void
PrefsDialog :: altSpeedDaysEdited( int i ) PrefsDialog :: altSpeedDaysEdited( int i )
{ {
const int value = qobject_cast<QComboBox*>(sender())->itemData(i).toInt(); const int value = qobject_cast<QComboBox*>(sender())->itemData(i).toInt();
myPrefs.set( Prefs::ALT_SPEED_LIMIT_TIME_DAY, value ); setPref( Prefs::ALT_SPEED_LIMIT_TIME_DAY, value );
} }
@ -458,7 +458,7 @@ void
PrefsDialog :: encryptionEdited( int i ) PrefsDialog :: encryptionEdited( int i )
{ {
const int value( qobject_cast<QComboBox*>(sender())->itemData(i).toInt( ) ); const int value( qobject_cast<QComboBox*>(sender())->itemData(i).toInt( ) );
myPrefs.set( Prefs::ENCRYPTION, value ); setPref( Prefs::ENCRYPTION, value );
} }
QWidget * QWidget *
@ -552,8 +552,7 @@ PrefsDialog :: onDestinationClicked( void )
void void
PrefsDialog :: onLocationSelected( const QString& path, int key ) PrefsDialog :: onLocationSelected( const QString& path, int key )
{ {
myPrefs.set( key, path ); setPref( key, path );
updatePref( key );
} }
QWidget * QWidget *
@ -668,7 +667,7 @@ PrefsDialog :: PrefsDialog( Session& session, Prefs& prefs, QWidget * parent ):
<< Prefs :: INCOMPLETE_DIR << Prefs :: INCOMPLETE_DIR
<< Prefs :: INCOMPLETE_DIR_ENABLED; << Prefs :: INCOMPLETE_DIR_ENABLED;
foreach( int key, keys ) foreach( int key, keys )
updatePref( key ); refreshPref( key );
// if it's a remote session, disable the preferences // if it's a remote session, disable the preferences
// that don't work in remote sessions // that don't work in remote sessions
@ -684,6 +683,13 @@ PrefsDialog :: ~PrefsDialog( )
{ {
} }
void
PrefsDialog :: setPref( int key, const QVariant& v )
{
myPrefs.set( key, v );
refreshPref( key );
}
/*** /***
**** ****
***/ ***/
@ -706,7 +712,7 @@ PrefsDialog :: updateBlocklistCheckBox( )
} }
void void
PrefsDialog :: updatePref( int key ) PrefsDialog :: refreshPref( int key )
{ {
switch( key ) switch( key )
{ {

View File

@ -46,7 +46,7 @@ class PrefsDialog: public QDialog
void spinBoxChangedIdle( ); void spinBoxChangedIdle( );
void timeChanged( const QTime& ); void timeChanged( const QTime& );
void textChanged( const QString& ); void textChanged( const QString& );
void updatePref( int key ); void refreshPref( int key );
void encryptionEdited( int ); void encryptionEdited( int );
void altSpeedDaysEdited( int ); void altSpeedDaysEdited( int );
void sessionUpdated( ); void sessionUpdated( );
@ -77,6 +77,7 @@ class PrefsDialog: public QDialog
~PrefsDialog( ); ~PrefsDialog( );
private: private:
void setPref( int key, const QVariant& v );
bool isAllowed( int key ) const; bool isAllowed( int key ) const;
QWidget * createTorrentsTab( ); QWidget * createTorrentsTab( );
QWidget * createSpeedTab( ); QWidget * createSpeedTab( );