author | sandman <sandman> | 2002-10-27 19:36:57 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-27 19:36:57 (UTC) |
commit | c1f70789d18145743fd71464c091612788cc5e3f (patch) (side-by-side diff) | |
tree | a2e90d73149f638d155d3e28990fe77ea83de96e | |
parent | 63894d36a26675655a4f74721ea1c19fb5e3e84c (diff) | |
download | opie-c1f70789d18145743fd71464c091612788cc5e3f.zip opie-c1f70789d18145743fd71464c091612788cc5e3f.tar.gz opie-c1f70789d18145743fd71464c091612788cc5e3f.tar.bz2 |
some cleanup regarding config:
replaced all the foo/foo_Interval configs with a single foo config (a 0
value means off)
-rw-r--r-- | core/settings/light-and-power/light.cpp | 86 |
1 files changed, 20 insertions, 66 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index bf94a21..c021ad4 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp @@ -53,116 +53,76 @@ #include <opie/odevice.h> using namespace Opie; LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) : LightSettingsBase( parent, name, TRUE, WStyle_ContextHelp ) { if ( ODevice::inst()->hasLightSensor() ) { // Not supported yet - hide until implemented CalibrateLightSensor->setEnabled( false ); CalibrateLightSensorAC->setEnabled( false ); } else { // if ipaq no need to show the sensor box auto_brightness->hide(); CalibrateLightSensor->hide(); auto_brightness_ac_3->hide(); CalibrateLightSensorAC->hide(); } Config config( "apm" ); config.setGroup( "Battery" ); - int interval; // battery spinboxes - interval = config.readNumEntry( "Interval_Dim", 20 ); - if ( config.readNumEntry("Dim",1) == 0 ) { - interval_dim->setValue( 0 ); - } else { - interval_dim->setValue( interval ); - } - - interval = config.readNumEntry( "Interval_LightOff", 30 ); - if ( config.readNumEntry("LightOff",1) == 0 ) { - interval_lightoff->setValue( 0 ); - } else { - interval_lightoff->setValue( interval ); - } - - interval = config.readNumEntry( "Interval", 60 ); - if ( interval > 3600 ) interval /= 1000; // compatibility (was millisecs) - - if ( config.readNumEntry("NoApm", 0 ) == 1 ) { - interval_suspend->setValue( 0 ); - } else { - interval_suspend->setValue( interval ); - } + interval_dim->setValue( config.readNumEntry( "Dim", 20 )); + interval_lightoff->setValue( config.readNumEntry( "LightOff", 30 )); + interval_suspend->setValue( config.readNumEntry( "Suspend", 60 )); // battery check and slider - LcdOffOnly->setChecked( config.readNumEntry("LcdOffOnly",0) != 0 ); + LcdOffOnly->setChecked( config.readBoolEntry("LcdOffOnly",false)); int maxbright = ODevice::inst ( )-> displayBrightnessResolution ( ); initbright = config.readNumEntry("Brightness",255); brightness->setMaxValue( maxbright ); brightness->setTickInterval( QMAX(1,maxbright/16) ); brightness->setLineStep( QMAX(1,maxbright/16) ); brightness->setPageStep( QMAX(1,maxbright/16) ); brightness->setValue( (maxbright*255 - initbright*maxbright)/255 ); // light sensor auto_brightness->setChecked( config.readNumEntry("LightSensor",0) != 0 ); config.setGroup( "AC" ); // ac spinboxes - interval = config.readNumEntry( "Interval_Dim", 20 ); - if ( config.readNumEntry("Dim",1) == 0 ) { - interval_dim_ac_3->setValue( 0 ); - } else { - interval_dim_ac_3->setValue( interval ); - } - - interval = config.readNumEntry( "Interval_LightOff", 30 ); - if ( config.readNumEntry("LightOff",1) == 0 ) { - interval_lightoff_ac_3->setValue( 0 ); - } else { - interval_lightoff_ac_3->setValue( interval ); - } - - interval = config.readNumEntry( "Interval", 60 ); - if ( interval > 3600 ) { - interval /= 1000; // compatibility (was millisecs) - } - if ( config.readNumEntry("NoApm", 1) == 1 ) { - interval_suspend_ac_3->setValue( 0 ); - } else { - interval_suspend_ac_3->setValue( interval ); - } + interval_dim_ac_3->setValue( config.readNumEntry( "Dim", 20 )); + interval_lightoff_ac_3->setValue( config.readNumEntry( "LightOff", 30 )); + interval_suspend_ac_3->setValue( config.readNumEntry( "Suspend", 60 )); // ac check and slider - LcdOffOnly_2_3->setChecked( config.readNumEntry("LcdOffOnly",0) != 0 ); + LcdOffOnly_2_3->setChecked( config.readBoolEntry("LcdOffOnly",false)); int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); initbright_ac = config.readNumEntry("Brightness",255); brightness_ac_3->setMaxValue( maxbright_ac ); brightness_ac_3->setTickInterval( QMAX(1,maxbright_ac/16) ); brightness_ac_3->setLineStep( QMAX(1,maxbright_ac/16) ); brightness_ac_3->setPageStep( QMAX(1,maxbright_ac/16) ); brightness_ac_3->setValue( (maxbright_ac*255 - initbright_ac*maxbright_ac)/255 ); // light sensor auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensor",0) != 0 ); //LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); //LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); //connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; //LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); // advanced settings config.setGroup( "Warnings" ); warnintervalBox->setValue( config.readNumEntry("checkinterval", 10000)/1000 ); lowSpinBox->setValue( config.readNumEntry("powerverylow", 10 ) ); criticalSpinBox->setValue( config.readNumEntry("powercritical", 5 ) ); connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) ); @@ -177,85 +137,79 @@ void LightSettings::slotSliderTicks( int steps ) { } static void set_fl(int bright) { qDebug ( QString( "Brightness" ).arg( bright ) ); QCopEnvelope e("QPE/System", "setBacklight(int)" ); e << bright; } void LightSettings::reject() { set_fl(initbright); QDialog::reject(); } void LightSettings::accept() { if ( qApp->focusWidget() ) { qApp->focusWidget()->clearFocus(); } applyBrightness(); // bat - int i_dim = ( !( interval_dim->specialValueText() == tr("never") ) ? interval_dim->value() : 0); - int i_lightoff = ( !( interval_lightoff->specialValueText() == tr("never") ) ? interval_lightoff->value() : 0); + int i_dim = interval_dim->value(); + int i_lightoff = interval_lightoff->value(); int i_suspend = interval_suspend->value(); QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); e << i_dim << i_lightoff << i_suspend; // ac - int i_dim_ac = ( !( interval_dim_ac_3->specialValueText() == tr("never") ) ? interval_dim_ac_3->value() : 0); - int i_lightoff_ac = ( !( interval_lightoff_ac_3->specialValueText() == tr("never") ) ? interval_lightoff_ac_3->value() : 0); + int i_dim_ac = interval_dim_ac_3->value(); + int i_lightoff_ac = interval_lightoff_ac_3->value(); int i_suspend_ac = interval_suspend_ac_3->value(); QCopEnvelope e_ac("QPE/System", "setScreenSaverIntervalsAC(int,int,int)" ); e << i_dim_ac << i_lightoff_ac << i_suspend_ac; Config config( "apm" ); config.setGroup( "Battery" ); // bat - config.writeEntry( "Dim", interval_dim->specialValueText() == tr("never") ); - config.writeEntry( "LightOff", interval_lightoff->specialValueText() == tr("never") ); - config.writeEntry( "LcdOffOnly", (int)LcdOffOnly->isChecked() ); - config.writeEntry( "NoAPm", interval_suspend->specialValueText() == tr("never") ); - config.writeEntry( "Interval_Dim", interval_dim->value() ); - config.writeEntry( "Interval_LightOff", interval_lightoff->value() ); - config.writeEntry( "Interval", interval_suspend->value() ); + config.writeEntry( "LcdOffOnly", LcdOffOnly->isChecked() ); + config.writeEntry( "Dim", interval_dim->value() ); + config.writeEntry( "LightOff", interval_lightoff->value() ); + config.writeEntry( "Suspend", interval_suspend->value() ); config.writeEntry( "Brightness", ( brightness->value() ) * 255 / brightness->maxValue() ); // ac config.setGroup( "AC" ); - config.writeEntry( "Dim", interval_dim_ac_3->specialValueText() == tr("never") ); - config.writeEntry( "LightOff", interval_lightoff_ac_3->specialValueText() == tr("never") ); - config.writeEntry( "LcdOffOnly", (int)LcdOffOnly_2_3->isChecked() ); - config.writeEntry( "NoAPm", interval_suspend_ac_3->specialValueText() == tr("never") ); - config.writeEntry( "Interval_Dim", interval_dim_ac_3->value() ); - config.writeEntry( "Interval_LightOff", interval_lightoff_ac_3->value() ); - config.writeEntry( "Interval", interval_suspend_ac_3->value() ); + config.writeEntry( "LcdOffOnly", LcdOffOnly_2_3->isChecked() ); + config.writeEntry( "Dim", interval_dim_ac_3->value() ); + config.writeEntry( "LightOff", interval_lightoff_ac_3->value() ); + config.writeEntry( "Suspend", interval_suspend_ac_3->value() ); config.writeEntry( "Brightness", ( brightness_ac_3->value()) * 255 / brightness_ac_3->maxValue() ); // only make light sensor stuff appear if the unit has a sensor if ( ODevice::inst()->hasLightSensor() ) { config.setGroup( "lightsensor" ); config.setGroup( "Battery" ); config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); config.setGroup( "AC" ); config.writeEntry( "LightSensor", (int)auto_brightness_ac_3->isChecked() ); //config.writeEntry( "Steps", LightStepSpin->value() ); //onfig.writeEntry( "MinValue", LightMinValueSlider->value() ); //config.writeEntry( "Shift", LightShiftSpin->value() ); } // advanced config.setGroup( "Warnings" ); config.writeEntry( "check_interval", warnintervalBox->value()*1000 ); config.writeEntry( "power_verylow", lowSpinBox->value() ); config.writeEntry( "power_critical", criticalSpinBox->value() ); QCopEnvelope e_warn("QPE/System", "reloadPowerWarnSettings()"); |