Changeset 11452
- Timestamp:
- Dec 4, 2010, 12:19:52 AM (12 years ago)
- Location:
- trunk/qt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/details.cc
r11440 r11452 72 72 const int REFRESH_INTERVAL_MSEC = 4000; 73 73 74 const char * PREF_KEY( "pref-key" ); 75 74 76 enum // peer columns 75 77 { … … 897 899 } 898 900 void 899 Details :: onDownloadLimitChanged( int val ) 900 { 901 mySession.torrentSet( myIds, "downloadLimit", val ); 901 Details :: 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( ) ); 902 910 getNewData( ); 903 911 } 912 904 913 void 905 914 Details :: onUploadLimitedToggled( bool val ) 906 915 { 907 916 mySession.torrentSet( myIds, "uploadLimited", val ); 908 getNewData( );909 }910 void911 Details :: onUploadLimitChanged( int val )912 {913 mySession.torrentSet( myIds, "uploadLimit", val );914 917 getNewData( ); 915 918 } … … 924 927 925 928 void 926 Details :: onIdleLimitChanged( int val )927 {928 mySession.torrentSet( myIds, "seedIdleLimit", val );929 getNewData( );930 }931 932 void933 929 Details :: onRatioModeChanged( int index ) 934 930 { 935 931 const int val = myRatioCombo->itemData( index ).toInt( ); 936 932 mySession.torrentSet( myIds, "seedRatioMode", val ); 937 }938 939 void940 Details :: onRatioLimitChanged( double val )941 {942 mySession.torrentSet( myIds, "seedRatioLimit", val );943 getNewData( );944 }945 946 void947 Details :: onMaxPeersChanged( int val )948 {949 mySession.torrentSet( myIds, "peer-limit", val );950 getNewData( );951 933 } 952 934 … … 1090 1072 mySingleDownCheck = c; 1091 1073 s = new QSpinBox( ); 1074 s->setProperty( PREF_KEY, QString( "downloadLimit" ) ); 1092 1075 s->setSingleStep( 5 ); 1093 1076 s->setRange( 0, INT_MAX ); … … 1096 1079 enableWhenChecked( c, s ); 1097 1080 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())); 1099 1082 1100 1083 c = new QCheckBox( tr( "Limit &upload speed (%1):" ).arg( speed_K_str ) ); … … 1103 1086 s->setSingleStep( 5 ); 1104 1087 s->setRange( 0, INT_MAX ); 1088 s->setProperty( PREF_KEY, QString( "uploadLimit" ) ); 1105 1089 mySingleUpSpin = s; 1106 1090 hig->addRow( c, s ); 1107 1091 enableWhenChecked( c, s ); 1108 1092 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())); 1110 1094 1111 1095 m = new QComboBox; … … 1130 1114 ds = new QDoubleSpinBox( ); 1131 1115 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())); 1133 1118 h->addWidget( myRatioSpin = ds ); 1134 1119 hig->addRow( tr( "&Ratio:" ), h, m ); … … 1145 1130 s->setSingleStep( 5 ); 1146 1131 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())); 1148 1134 h->addWidget( myIdleSpin = s ); 1149 1135 hig->addRow( tr( "&Idle:" ), h, m ); … … 1156 1142 s->setSingleStep( 5 ); 1157 1143 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())); 1159 1146 myPeerLimitSpin = s; 1160 1147 hig->addRow( tr( "&Maximum peers:" ), s ); -
trunk/qt/details.h
r11234 r11452 143 143 void onHonorsSessionLimitsToggled( bool ); 144 144 void onDownloadLimitedToggled( bool ); 145 void on DownloadLimitChanged( int);145 void onSpinBoxEditingFinished( ); 146 146 void onUploadLimitedToggled( bool ); 147 void onUploadLimitChanged( int );148 147 void onRatioModeChanged( int ); 149 void onRatioLimitChanged( double );150 148 void onIdleModeChanged( int ); 151 void onIdleLimitChanged( int );152 149 void onShowTrackerScrapesToggled( bool ); 153 150 void onShowBackupTrackersToggled( bool ); … … 156 153 void onEditTrackerClicked( ); 157 154 void onRemoveTrackerClicked( ); 158 void onMaxPeersChanged( int );159 155 void refresh( ); 160 156 }; -
trunk/qt/prefs-dialog.cc
r11437 r11452 79 79 80 80 void 81 PrefsDialog :: spinBox ChangedIdle()82 { 83 const QObject * spin ( sender()->property( "SPIN" ).value<QObject*>( ));81 PrefsDialog :: spinBoxEditingFinished() 82 { 83 const QObject * spin = sender(); 84 84 const int key = spin->property( PREF_KEY ).toInt( ); 85 86 85 const QDoubleSpinBox * d = qobject_cast<const QDoubleSpinBox*>( spin ); 87 if( d != 0)86 if( d ) 88 87 setPref( key, d->value( ) ); 89 88 else 90 89 setPref( key, qobject_cast<const QSpinBox*>(spin)->value( ) ); 91 }92 93 void94 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 off102 // for a moment to kekep from flooding a bunch of prefs changes103 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 );113 90 } 114 91 … … 121 98 spin->setValue( myPrefs.getInt( key ) ); 122 99 spin->setProperty( PREF_KEY, key ); 123 connect( spin, SIGNAL( valueChanged(int)), this, SLOT(spinBoxChanged(int)));100 connect( spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished())); 124 101 myWidgets.insert( key, spin ); 125 102 return spin; 126 }127 128 void129 PrefsDialog :: doubleSpinBoxChanged( double value )130 {131 Q_UNUSED( value );132 133 spinBoxChanged( 0 );134 103 } 135 104 … … 143 112 spin->setValue( myPrefs.getDouble( key ) ); 144 113 spin->setProperty( PREF_KEY, key ); 145 connect( spin, SIGNAL( valueChanged(double)), this, SLOT(doubleSpinBoxChanged(double)));114 connect( spin, SIGNAL(editingFinished()), this, SLOT(spinBoxEditingFinished())); 146 115 myWidgets.insert( key, spin ); 147 116 return spin; … … 149 118 150 119 void 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 120 PrefsDialog :: 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 ) ); 128 std::cerr << "setPref to " << (seconds/60) << " minutes" << std::endl; 129 setPref( key, seconds / 60 ); 130 } 131 } 158 132 QTimeEdit* 159 133 PrefsDialog :: timeEditNew( int key ) … … 165 139 e->setTime( QTime().addSecs( minutes * 60 ) ); 166 140 myWidgets.insert( key, e ); 167 connect( e, SIGNAL( timeChanged(const QTime&)), this, SLOT(timeChanged(const QTime&)) );141 connect( e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished()) ); 168 142 return e; 169 143 } 170 144 171 145 void 172 PrefsDialog :: textChanged( const QString& text ) 173 { 174 const int key( sender()->property( PREF_KEY ).toInt( ) ); 175 setPref( key, text ); 176 } 177 146 PrefsDialog :: 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 } 178 156 QLineEdit* 179 157 PrefsDialog :: lineEditNew( int key, int echoMode ) … … 183 161 e->setEchoMode( QLineEdit::EchoMode( echoMode ) ); 184 162 myWidgets.insert( key, e ); 185 connect( e, SIGNAL( textChanged(const QString&)), this, SLOT(textChanged(const QString&)) );163 connect( e, SIGNAL(editingFinished()), this, SLOT(lineEditingFinished()) ); 186 164 return e; 187 165 } -
trunk/qt/prefs-dialog.h
r11379 r11452 42 42 private slots: 43 43 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( ); 49 47 void refreshPref( int key ); 50 48 void encryptionEdited( int );
Note: See TracChangeset
for help on using the changeset viewer.