1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +00:00

(trunk qt) #3772 "users' changes in the Preferences and Properties dialog get applied before they're done editing" -- fixed.

This commit is contained in:
Charles Kerr 2010-12-04 00:19:52 +00:00
parent e8ba22fc11
commit 3f9b6a3aaa
4 changed files with 50 additions and 91 deletions

View file

@ -71,6 +71,8 @@ namespace
{
const int REFRESH_INTERVAL_MSEC = 4000;
const char * PREF_KEY( "pref-key" );
enum // peer columns
{
COL_LOCK,
@ -896,23 +898,24 @@ Details :: onDownloadLimitedToggled( bool val )
getNewData( );
}
void
Details :: onDownloadLimitChanged( int val )
Details :: onSpinBoxEditingFinished( )
{
mySession.torrentSet( myIds, "downloadLimit", val );
const QObject * spin = sender();
const QString key = spin->property( PREF_KEY ).toString( );
const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin );
if( d )
mySession.torrentSet( myIds, key, d->value( ) );
else
mySession.torrentSet( myIds, key, qobject_cast<const QSpinBox*>(spin)->value( ) );
getNewData( );
}
void
Details :: onUploadLimitedToggled( bool val )
{
mySession.torrentSet( myIds, "uploadLimited", val );
getNewData( );
}
void
Details :: onUploadLimitChanged( int val )
{
mySession.torrentSet( myIds, "uploadLimit", val );
getNewData( );
}
void
Details :: onIdleModeChanged( int index )
@ -922,13 +925,6 @@ Details :: onIdleModeChanged( int index )
getNewData( );
}
void
Details :: onIdleLimitChanged( int val )
{
mySession.torrentSet( myIds, "seedIdleLimit", val );
getNewData( );
}
void
Details :: onRatioModeChanged( int index )
{
@ -936,20 +932,6 @@ Details :: onRatioModeChanged( int index )
mySession.torrentSet( myIds, "seedRatioMode", val );
}
void
Details :: onRatioLimitChanged( double val )
{
mySession.torrentSet( myIds, "seedRatioLimit", val );
getNewData( );
}
void
Details :: onMaxPeersChanged( int val )
{
mySession.torrentSet( myIds, "peer-limit", val );
getNewData( );
}
void
Details :: onBandwidthPriorityChanged( int index )
{
@ -1089,24 +1071,26 @@ Details :: createOptionsTab( )
c = new QCheckBox( tr( "Limit &download speed (%1):" ).arg( speed_K_str ) );
mySingleDownCheck = c;
s = new QSpinBox( );
s->setProperty( PREF_KEY, QString( "downloadLimit" ) );
s->setSingleStep( 5 );
s->setRange( 0, INT_MAX );
mySingleDownSpin = s;
hig->addRow( c, s );
enableWhenChecked( c, s );
connect( c, SIGNAL(clicked(bool)), this, SLOT(onDownloadLimitedToggled(bool)) );
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onDownloadLimitChanged(int)));
connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
c = new QCheckBox( tr( "Limit &upload speed (%1):" ).arg( speed_K_str ) );
mySingleUpCheck = c;
s = new QSpinBox( );
s->setSingleStep( 5 );
s->setRange( 0, INT_MAX );
s->setProperty( PREF_KEY, QString( "uploadLimit" ) );
mySingleUpSpin = s;
hig->addRow( c, s );
enableWhenChecked( c, s );
connect( c, SIGNAL(clicked(bool)), this, SLOT(onUploadLimitedToggled(bool)) );
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onUploadLimitChanged(int)));
connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
m = new QComboBox;
m->addItem( tr( "High" ), TR_PRI_HIGH );
@ -1129,7 +1113,8 @@ Details :: createOptionsTab( )
h->addWidget( myRatioCombo = m );
ds = new QDoubleSpinBox( );
ds->setRange( 0.5, INT_MAX );
connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onRatioLimitChanged(double)));
ds->setProperty( PREF_KEY, QString( "seedRatioLimit" ) );
connect( ds, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
h->addWidget( myRatioSpin = ds );
hig->addRow( tr( "&Ratio:" ), h, m );
@ -1144,7 +1129,8 @@ Details :: createOptionsTab( )
s = new QSpinBox( );
s->setSingleStep( 5 );
s->setRange( 1, 9999 );
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onIdleLimitChanged(int)));
s->setProperty( PREF_KEY, QString( "seedIdleLimit" ) );
connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
h->addWidget( myIdleSpin = s );
hig->addRow( tr( "&Idle:" ), h, m );
@ -1155,7 +1141,8 @@ Details :: createOptionsTab( )
s = new QSpinBox( );
s->setSingleStep( 5 );
s->setRange( 1, 300 );
connect( s, SIGNAL(valueChanged(int)), this, SLOT(onMaxPeersChanged(int)));
s->setProperty( PREF_KEY, QString( "peer-limit" ) );
connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
myPeerLimitSpin = s;
hig->addRow( tr( "&Maximum peers:" ), s );

View file

@ -142,20 +142,16 @@ class Details: public QDialog
void onFileWantedChanged( const QSet<int>& fileIndices, bool );
void onHonorsSessionLimitsToggled( bool );
void onDownloadLimitedToggled( bool );
void onDownloadLimitChanged( int );
void onSpinBoxEditingFinished( );
void onUploadLimitedToggled( bool );
void onUploadLimitChanged( int );
void onRatioModeChanged( int );
void onRatioLimitChanged( double );
void onIdleModeChanged( int );
void onIdleLimitChanged( int );
void onShowTrackerScrapesToggled( bool );
void onShowBackupTrackersToggled( bool );
void onTrackerSelectionChanged( );
void onAddTrackerClicked( );
void onEditTrackerClicked( );
void onRemoveTrackerClicked( );
void onMaxPeersChanged( int );
void refresh( );
};

View file

@ -78,40 +78,17 @@ PrefsDialog :: enableBuddyWhenChecked( QCheckBox * box, QWidget * buddy )
}
void
PrefsDialog :: spinBoxChangedIdle( )
PrefsDialog :: spinBoxEditingFinished()
{
const QObject * spin( sender()->property( "SPIN" ).value<QObject*>( ) );
const QObject * spin = sender();
const int key = spin->property( PREF_KEY ).toInt( );
const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin );
if( d != 0 )
if( d )
setPref( key, d->value( ) );
else
setPref( key, qobject_cast<const QSpinBox*>(spin)->value( ) );
}
void
PrefsDialog :: spinBoxChanged( int value )
{
Q_UNUSED( value );
static const QString timerName( "TIMER_CHILD" );
QObject * o( sender( ) );
// user may be spinning through many values, so let's hold off
// for a moment to kekep from flooding a bunch of prefs changes
QTimer * timer( o->findChild<QTimer*>( timerName ) );
if( timer == 0 )
{
timer = new QTimer( o );
timer->setObjectName( timerName );
timer->setSingleShot( true );
timer->setProperty( "SPIN", qVariantFromValue( o ) );
connect( timer, SIGNAL(timeout()), this, SLOT(spinBoxChangedIdle()));
}
timer->start( 200 );
}
QSpinBox *
PrefsDialog :: spinBoxNew( int key, int low, int high, int step )
{
@ -120,19 +97,11 @@ PrefsDialog :: spinBoxNew( int key, int low, int high, int step )
spin->setSingleStep( step );
spin->setValue( myPrefs.getInt( key ) );
spin->setProperty( PREF_KEY, key );
connect( spin, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChanged(int)));
connect( spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished()));
myWidgets.insert( key, spin );
return spin;
}
void
PrefsDialog :: doubleSpinBoxChanged( double value )
{
Q_UNUSED( value );
spinBoxChanged( 0 );
}
QDoubleSpinBox *
PrefsDialog :: doubleSpinBoxNew( int key, double low, double high, double step, int decimals )
{
@ -142,19 +111,24 @@ PrefsDialog :: doubleSpinBoxNew( int key, double low, double high, double step,
spin->setDecimals( decimals );
spin->setValue( myPrefs.getDouble( key ) );
spin->setProperty( PREF_KEY, key );
connect( spin, SIGNAL(valueChanged(double)), this, SLOT(doubleSpinBoxChanged(double)));
connect( spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished()));
myWidgets.insert( key, spin );
return spin;
}
void
PrefsDialog :: timeChanged( const QTime& time )
PrefsDialog :: timeEditingFinished( )
{
const int key( sender()->property( PREF_KEY ).toInt( ) );
const int seconds( QTime().secsTo( time ) );
setPref( key, seconds / 60 );
QTimeEdit * e = qobject_cast<QTimeEdit*>(sender());
if( e )
{
const int key( e->property( PREF_KEY ).toInt( ) );
const QTime time( e->time( ) );
const int seconds( QTime().secsTo( time ) );
std::cerr << "setPref to " << (seconds/60) << " minutes" << std::endl;
setPref( key, seconds / 60 );
}
}
QTimeEdit*
PrefsDialog :: timeEditNew( int key )
{
@ -164,17 +138,21 @@ PrefsDialog :: timeEditNew( int key )
e->setProperty( PREF_KEY, key );
e->setTime( QTime().addSecs( minutes * 60 ) );
myWidgets.insert( key, e );
connect( e, SIGNAL(timeChanged(const QTime&)), this, SLOT(timeChanged(const QTime&)) );
connect( e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished()) );
return e;
}
void
PrefsDialog :: textChanged( const QString& text )
PrefsDialog :: lineEditingFinished( )
{
const int key( sender()->property( PREF_KEY ).toInt( ) );
setPref( key, text );
QLineEdit * e = qobject_cast<QLineEdit*>(sender());
if( e && e->isModified( ) )
{
const int key( e->property( PREF_KEY ).toInt( ) );
const QString text( e->text() );
setPref( key, text );
}
}
QLineEdit*
PrefsDialog :: lineEditNew( int key, int echoMode )
{
@ -182,7 +160,7 @@ PrefsDialog :: lineEditNew( int key, int echoMode )
e->setProperty( PREF_KEY, key );
e->setEchoMode( QLineEdit::EchoMode( echoMode ) );
myWidgets.insert( key, e );
connect( e, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)) );
connect( e, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()) );
return e;
}

View file

@ -41,11 +41,9 @@ class PrefsDialog: public QDialog
private slots:
void checkBoxToggled( bool checked );
void spinBoxChanged( int value );
void doubleSpinBoxChanged( double value );
void spinBoxChangedIdle( );
void timeChanged( const QTime& );
void textChanged( const QString& );
void spinBoxEditingFinished( );
void timeEditingFinished( );
void lineEditingFinished( );
void refreshPref( int key );
void encryptionEdited( int );
void altSpeedDaysEdited( int );