-rw-r--r-- | core/settings/light-and-power/light.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index aa36e06..572f8ea 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp @@ -49,75 +49,74 @@ #include <qdir.h> #if QT_VERSION >= 300 #include <qstylefactory.h> #endif #include <opie/odevice.h> using namespace Opie; LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) : LightSettingsBase( parent, name, TRUE, WStyle_ContextHelp ) { + int res = ODevice::inst ( )-> displayBrightnessResolution ( ); 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" ); // battery spinboxes 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.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 ); + + initbright = config. readNumEntry ( "Brightness", 255 ); + brightness-> setMaxValue ( res - 1 ); + brightness-> setTickInterval ( QMAX( 1, res / 16 )); + brightness-> setLineStep ( QMAX( 1, res / 16 )); + brightness-> setPageStep ( QMAX( 1, res / 16 )); + brightness-> setValue (( initbright * ( res - 1 ) + 127 ) / 255 ); // light sensor auto_brightness->setChecked( config.readNumEntry("LightSensor",0) != 0 ); - - config.setGroup( "AC" ); // ac spinboxes 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.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 ); + + initbright_ac = config. readNumEntry ( "Brightness", 255 ); + brightness_ac_3-> setMaxValue ( res - 1 ); + brightness_ac_3-> setTickInterval ( QMAX( 1, res / 16 )); + brightness_ac_3-> setLineStep ( QMAX( 1, res / 16 )); + brightness_ac_3-> setPageStep ( QMAX( 1, res / 16 )); + brightness_ac_3-> setValue (( initbright_ac * ( res - 1 ) + 127 ) / 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" ); @@ -129,25 +128,24 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) ); } LightSettings::~LightSettings() { } void LightSettings::slotSliderTicks( int steps ) { // LightMinValueSlider->setTickInterval( 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() { @@ -183,27 +181,27 @@ void LightSettings::accept() config.setGroup( "AC" ); config.writeEntry( "LcdOffOnly", LcdOffOnly_2_3->isChecked() ); config.writeEntry( "Dim", i_dim_ac ); config.writeEntry( "LightOff", i_lightoff_ac ); config.writeEntry( "Suspend", i_suspend_ac ); 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( "Battery" ); - config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); + config.writeEntry( "LightSensor", auto_brightness->isChecked() ); config.setGroup( "AC" ); - config.writeEntry( "LightSensor", (int)auto_brightness_ac_3->isChecked() ); + config.writeEntry( "LightSensor", 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() ); config.write(); |