Changeset 11452


Ignore:
Timestamp:
Dec 4, 2010, 12:19:52 AM (12 years ago)
Author:
charles
Message:

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

Location:
trunk/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/details.cc

    r11440 r11452  
    7272    const int REFRESH_INTERVAL_MSEC = 4000;
    7373
     74    const char * PREF_KEY( "pref-key" );
     75
    7476    enum // peer columns
    7577    {
     
    897899}
    898900void
    899 Details :: onDownloadLimitChanged( int val )
    900 {
    901     mySession.torrentSet( myIds, "downloadLimit", val );
     901Details :: onSpinBoxEditingFinished( )
     902{
     903    const QObject * spin = sender();
     904    const QString key = spin->property( PREF_KEY ).toString( );
     905    const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin );
     906    if( d )
     907        mySession.torrentSet( myIds, key, d->value( ) );
     908    else
     909        mySession.torrentSet( myIds, key, qobject_cast<const QSpinBox*>(spin)->value( ) );
    902910    getNewData( );
    903911}
     912
    904913void
    905914Details :: onUploadLimitedToggled( bool val )
    906915{
    907916    mySession.torrentSet( myIds, "uploadLimited", val );
    908     getNewData( );
    909 }
    910 void
    911 Details :: onUploadLimitChanged( int val )
    912 {
    913     mySession.torrentSet( myIds, "uploadLimit", val );
    914917    getNewData( );
    915918}
     
    924927
    925928void
    926 Details :: onIdleLimitChanged( int val )
    927 {
    928     mySession.torrentSet( myIds, "seedIdleLimit", val );
    929     getNewData( );
    930 }
    931 
    932 void
    933929Details :: onRatioModeChanged( int index )
    934930{
    935931    const int val = myRatioCombo->itemData( index ).toInt( );
    936932    mySession.torrentSet( myIds, "seedRatioMode", val );
    937 }
    938 
    939 void
    940 Details :: onRatioLimitChanged( double val )
    941 {
    942     mySession.torrentSet( myIds, "seedRatioLimit", val );
    943     getNewData( );
    944 }
    945 
    946 void
    947 Details :: onMaxPeersChanged( int val )
    948 {
    949     mySession.torrentSet( myIds, "peer-limit", val );
    950     getNewData( );
    951933}
    952934
     
    10901072    mySingleDownCheck = c;
    10911073    s = new QSpinBox( );
     1074    s->setProperty( PREF_KEY, QString( "downloadLimit" ) );
    10921075    s->setSingleStep( 5 );
    10931076    s->setRange( 0, INT_MAX );
     
    10961079    enableWhenChecked( c, s );
    10971080    connect( c, SIGNAL(clicked(bool)), this, SLOT(onDownloadLimitedToggled(bool)) );
    1098     connect( s, SIGNAL(valueChanged(int)), this, SLOT(onDownloadLimitChanged(int)));
     1081    connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
    10991082
    11001083    c = new QCheckBox( tr( "Limit &upload speed (%1):" ).arg( speed_K_str ) );
     
    11031086    s->setSingleStep( 5 );
    11041087    s->setRange( 0, INT_MAX );
     1088    s->setProperty( PREF_KEY, QString( "uploadLimit" ) );
    11051089    mySingleUpSpin = s;
    11061090    hig->addRow( c, s );
    11071091    enableWhenChecked( c, s );
    11081092    connect( c, SIGNAL(clicked(bool)), this, SLOT(onUploadLimitedToggled(bool)) );
    1109     connect( s, SIGNAL(valueChanged(int)), this, SLOT(onUploadLimitChanged(int)));
     1093    connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
    11101094
    11111095    m = new QComboBox;
     
    11301114    ds = new QDoubleSpinBox( );
    11311115    ds->setRange( 0.5, INT_MAX );
    1132     connect( ds, SIGNAL(valueChanged(double)), this, SLOT(onRatioLimitChanged(double)));
     1116    ds->setProperty( PREF_KEY, QString( "seedRatioLimit" ) );
     1117    connect( ds, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
    11331118    h->addWidget( myRatioSpin = ds );
    11341119    hig->addRow( tr( "&Ratio:" ), h, m );
     
    11451130    s->setSingleStep( 5 );
    11461131    s->setRange( 1, 9999 );
    1147     connect( s, SIGNAL(valueChanged(int)), this, SLOT(onIdleLimitChanged(int)));
     1132    s->setProperty( PREF_KEY, QString( "seedIdleLimit" ) );
     1133    connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
    11481134    h->addWidget( myIdleSpin = s );
    11491135    hig->addRow( tr( "&Idle:" ), h, m );
     
    11561142    s->setSingleStep( 5 );
    11571143    s->setRange( 1, 300 );
    1158     connect( s, SIGNAL(valueChanged(int)), this, SLOT(onMaxPeersChanged(int)));
     1144    s->setProperty( PREF_KEY, QString( "peer-limit" ) );
     1145    connect( s, SIGNAL(editingFinished()), this, SLOT(onSpinBoxEditingFinished()));
    11591146    myPeerLimitSpin = s;
    11601147    hig->addRow( tr( "&Maximum peers:" ), s );
  • trunk/qt/details.h

    r11234 r11452  
    143143        void onHonorsSessionLimitsToggled( bool );
    144144        void onDownloadLimitedToggled( bool );
    145         void onDownloadLimitChanged( int );
     145        void onSpinBoxEditingFinished( );
    146146        void onUploadLimitedToggled( bool );
    147         void onUploadLimitChanged( int );
    148147        void onRatioModeChanged( int );
    149         void onRatioLimitChanged( double );
    150148        void onIdleModeChanged( int );
    151         void onIdleLimitChanged( int );
    152149        void onShowTrackerScrapesToggled( bool );
    153150        void onShowBackupTrackersToggled( bool );
     
    156153        void onEditTrackerClicked( );
    157154        void onRemoveTrackerClicked( );
    158         void onMaxPeersChanged( int );
    159155        void refresh( );
    160156};
  • trunk/qt/prefs-dialog.cc

    r11437 r11452  
    7979
    8080void
    81 PrefsDialog :: spinBoxChangedIdle( )
    82 {
    83     const QObject * spin( sender()->property( "SPIN" ).value<QObject*>( ) );
     81PrefsDialog :: spinBoxEditingFinished()
     82{
     83    const QObject * spin = sender();
    8484    const int key = spin->property( PREF_KEY ).toInt( );
    85 
    8685    const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin );
    87     if( d != 0 )
     86    if( d )
    8887        setPref( key, d->value( ) );
    8988    else
    9089        setPref( key, qobject_cast<const QSpinBox*>(spin)->value( ) );
    91 }
    92 
    93 void
    94 PrefsDialog :: spinBoxChanged( int value )
    95 {
    96     Q_UNUSED( value );
    97 
    98     static const QString timerName( "TIMER_CHILD" );
    99     QObject * o( sender( ) );
    100 
    101     // user may be spinning through many values, so let's hold off
    102     // for a moment to kekep from flooding a bunch of prefs changes
    103     QTimer * timer( o->findChild<QTimer*>( timerName ) );
    104     if( timer == 0 )
    105     {
    106         timer = new QTimer( o );
    107         timer->setObjectName( timerName );
    108         timer->setSingleShot( true );
    109         timer->setProperty( "SPIN", qVariantFromValue( o ) );
    110         connect( timer, SIGNAL(timeout()), this, SLOT(spinBoxChangedIdle()));
    111     }
    112     timer->start( 200 );
    11390}
    11491
     
    12198    spin->setValue( myPrefs.getInt( key ) );
    12299    spin->setProperty( PREF_KEY, key );
    123     connect( spin, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChanged(int)));
     100    connect( spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished()));
    124101    myWidgets.insert( key, spin );
    125102    return spin;
    126 }
    127 
    128 void
    129 PrefsDialog :: doubleSpinBoxChanged( double value )
    130 {
    131     Q_UNUSED( value );
    132 
    133     spinBoxChanged( 0 );
    134103}
    135104
     
    143112    spin->setValue( myPrefs.getDouble( key ) );
    144113    spin->setProperty( PREF_KEY, key );
    145     connect( spin, SIGNAL(valueChanged(double)), this, SLOT(doubleSpinBoxChanged(double)));
     114    connect( spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished()));
    146115    myWidgets.insert( key, spin );
    147116    return spin;
     
    149118
    150119void
    151 PrefsDialog :: timeChanged( const QTime& time )
    152 {
    153     const int key( sender()->property( PREF_KEY ).toInt( ) );
    154     const int seconds( QTime().secsTo( time ) );
    155     setPref( key, seconds / 60 );
    156 }
    157 
     120PrefsDialog :: timeEditingFinished( )
     121{
     122    QTimeEdit * e = qobject_cast<QTimeEdit*>(sender());
     123    if( e )
     124    {
     125        const int key( e->property( PREF_KEY ).toInt( ) );
     126        const QTime time( e->time( ) );
     127        const int seconds( QTime().secsTo( time ) );
     128std::cerr << "setPref to " << (seconds/60) << " minutes" << std::endl;
     129        setPref( key, seconds / 60 );
     130    }
     131}
    158132QTimeEdit*
    159133PrefsDialog :: timeEditNew( int key )
     
    165139    e->setTime( QTime().addSecs( minutes * 60 ) );
    166140    myWidgets.insert( key, e );
    167     connect( e, SIGNAL(timeChanged(const QTime&)), this, SLOT(timeChanged(const QTime&)) );
     141    connect( e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished()) );
    168142    return e;
    169143}
    170144
    171145void
    172 PrefsDialog :: textChanged( const QString& text )
    173 {
    174     const int key( sender()->property( PREF_KEY ).toInt( ) );
    175     setPref( key, text );
    176 }
    177 
     146PrefsDialog :: lineEditingFinished( )
     147{
     148    QLineEdit * e = qobject_cast<QLineEdit*>(sender());
     149    if( e && e->isModified( ) )
     150    {
     151        const int key( e->property( PREF_KEY ).toInt( ) );
     152        const QString text( e->text() );
     153        setPref( key, text );
     154    }
     155}
    178156QLineEdit*
    179157PrefsDialog :: lineEditNew( int key, int echoMode )
     
    183161    e->setEchoMode( QLineEdit::EchoMode( echoMode ) );
    184162    myWidgets.insert( key, e );
    185     connect( e, SIGNAL(textChanged(const QString&)), this, SLOT(textChanged(const QString&)) );
     163    connect( e, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()) );
    186164    return e;
    187165}
  • trunk/qt/prefs-dialog.h

    r11379 r11452  
    4242    private slots:
    4343        void checkBoxToggled( bool checked );
    44         void spinBoxChanged( int value );
    45         void doubleSpinBoxChanged( double value );
    46         void spinBoxChangedIdle( );
    47         void timeChanged( const QTime& );
    48         void textChanged( const QString& );
     44        void spinBoxEditingFinished( );
     45        void timeEditingFinished( );
     46        void lineEditingFinished( );
    4947        void refreshPref( int key );
    5048        void encryptionEdited( int );
Note: See TracChangeset for help on using the changeset viewer.