-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 @@ -60,2 +60,3 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) { + int res = ODevice::inst ( )-> displayBrightnessResolution ( ); @@ -83,9 +84,9 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 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 ); @@ -94,4 +95,2 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) - - config.setGroup( "AC" ); @@ -104,9 +103,9 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 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 ); @@ -140,3 +139,2 @@ static void set_fl(int bright) { - qDebug ( QString( "Brightness" ).arg( bright ) ); QCopEnvelope e("QPE/System", "setBacklight(int)" ); @@ -194,5 +192,5 @@ void LightSettings::accept() 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() ); |