From edd14bd8d67a0e26c25fda17c1ff753d9443808e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 8 Dec 2010 16:23:21 +0000 Subject: [PATCH] (trunk qt) #2050 "properties dialog changes seem to undo themselves" -- fixed. --- qt/details.cc | 66 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/qt/details.cc b/qt/details.cc index a1403ae21..e084fe4c1 100644 --- a/qt/details.cc +++ b/qt/details.cc @@ -296,6 +296,38 @@ Details :: onTorrentChanged( ) } } +namespace +{ + void setIfIdle( QComboBox * box, int i ) + { + if( !box->hasFocus( ) ) + { + box->blockSignals( true ); + box->setCurrentIndex( i ); + box->blockSignals( false ); + } + } + + void setIfIdle( QDoubleSpinBox * spin, double value ) + { + if( !spin->hasFocus( ) ) + { + spin->blockSignals( true ); + spin->setValue( value ); + spin->blockSignals( false ); + } + } + + void setIfIdle( QSpinBox * spin, int value ) + { + if( !spin->hasFocus( ) ) + { + spin->blockSignals( true ); + spin->setValue( value ); + spin->blockSignals( false ); + } + } +} void Details :: refresh( ) @@ -680,21 +712,11 @@ Details :: refresh( ) i = myBandwidthPriorityCombo->findData( baselineInt ); else i = -1; - myBandwidthPriorityCombo->blockSignals( true ); - myBandwidthPriorityCombo->setCurrentIndex( i ); - myBandwidthPriorityCombo->blockSignals( false ); + setIfIdle( myBandwidthPriorityCombo, i ); - mySingleDownSpin->blockSignals( true ); - mySingleDownSpin->setValue( (int)tor->downloadLimit().KBps() ); - mySingleDownSpin->blockSignals( false ); - - mySingleUpSpin->blockSignals( true ); - mySingleUpSpin->setValue( (int)tor->uploadLimit().KBps() ); - mySingleUpSpin->blockSignals( false ); - - myPeerLimitSpin->blockSignals( true ); - myPeerLimitSpin->setValue( tor->peerLimit() ); - myPeerLimitSpin->blockSignals( false ); + setIfIdle( mySingleDownSpin, int(tor->downloadLimit().KBps()) ); + setIfIdle( mySingleUpSpin, int(tor->uploadLimit().KBps()) ); + setIfIdle( myPeerLimitSpin, tor->peerLimit() ); } if( !torrents.empty( ) ) @@ -706,28 +728,20 @@ Details :: refresh( ) int baselineInt = torrents[0]->seedRatioMode( ); foreach( tor, torrents ) if( baselineInt != tor->seedRatioMode( ) ) { uniform = false; break; } - myRatioCombo->blockSignals( true ); - myRatioCombo->setCurrentIndex( uniform ? myRatioCombo->findData( baselineInt ) : -1 ); + setIfIdle( myRatioCombo, uniform ? myRatioCombo->findData( baselineInt ) : -1 ); myRatioSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) ); - myRatioCombo->blockSignals( false ); - myRatioSpin->blockSignals( true ); - myRatioSpin->setValue( tor->seedRatioLimit( ) ); - myRatioSpin->blockSignals( false ); + setIfIdle( myRatioSpin, tor->seedRatioLimit( ) ); // idle uniform = true; baselineInt = torrents[0]->seedIdleMode( ); foreach( tor, torrents ) if( baselineInt != tor->seedIdleMode( ) ) { uniform = false; break; } - myIdleCombo->blockSignals( true ); - myIdleCombo->setCurrentIndex( uniform ? myIdleCombo->findData( baselineInt ) : -1 ); + setIfIdle( myIdleCombo, uniform ? myIdleCombo->findData( baselineInt ) : -1 ); myIdleSpin->setVisible( uniform && ( baselineInt == TR_RATIOLIMIT_SINGLE ) ); - myIdleCombo->blockSignals( false ); - myIdleSpin->blockSignals( true ); - myIdleSpin->setValue( tor->seedIdleLimit( ) ); - myIdleSpin->blockSignals( false ); + setIfIdle( myIdleSpin, tor->seedIdleLimit( ) ); } ///