author | schurig <schurig> | 2003-06-05 15:01:01 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-05 15:01:01 (UTC) |
commit | 33dbbfe57cb0a5a7de5600ea052e19b7bb5cb674 (patch) (side-by-side diff) | |
tree | cf70229935166b4e9d46ff1a1b828e73b80f7e4a /core/settings/light-and-power/light.cpp | |
parent | 9fe856c57c5df5a74f9276f500070f2d90cfe091 (diff) | |
download | opie-33dbbfe57cb0a5a7de5600ea052e19b7bb5cb674.zip opie-33dbbfe57cb0a5a7de5600ea052e19b7bb5cb674.tar.gz opie-33dbbfe57cb0a5a7de5600ea052e19b7bb5cb674.tar.bz2 |
initial contrast support. You won't see anything unless
ODevice::displayContrastResulution() returns != 0.
Diffstat (limited to 'core/settings/light-and-power/light.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/settings/light-and-power/light.cpp | 103 |
1 files changed, 76 insertions, 27 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index 21377b7..a58b1c1 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp @@ -43,2 +43,3 @@ #include <qpushbutton.h> +#include <qgroupbox.h> @@ -53,3 +54,4 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) { - m_res = ODevice::inst ( )-> displayBrightnessResolution ( ); + m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); + m_cres = ODevice::inst ( )-> displayContrastResolution ( ); @@ -58,4 +60,10 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) CalibrateLightSensor-> hide ( ); - auto_brightness_ac_3-> hide ( ); - CalibrateLightSensorAC-> hide ( ); + auto_brightness_ac-> hide ( ); + CalibrateLightSensor_ac-> hide ( ); + } + if (m_cres) { + GroupLight->setTitle(tr("Backlight & Contrast")); + } else { + contrast->hide(); + contrast_ac->hide(); } @@ -74,7 +82,16 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) int bright = config. readNumEntry ( "Brightness", 127 ); - brightness-> setMaxValue ( m_res - 1 ); - brightness-> setTickInterval ( QMAX( 1, m_res / 16 )); - brightness-> setLineStep ( QMAX( 1, m_res / 16 )); - brightness-> setPageStep ( QMAX( 1, m_res / 16 )); - brightness-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); + int contr = config. readNumEntry ( "Contrast", 127 ); + brightness-> setMaxValue ( m_bres - 1 ); + brightness-> setTickInterval ( QMAX( 1, m_bres / 16 )); + brightness-> setLineStep ( QMAX( 1, m_bres / 16 )); + brightness-> setPageStep ( QMAX( 1, m_bres / 16 )); + brightness-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); + + if (m_cres) { + contrast-> setMaxValue ( m_cres - 1 ); + contrast-> setTickInterval ( QMAX( 1, m_cres / 16 )); + contrast-> setLineStep ( QMAX( 1, m_cres / 16 )); + contrast-> setPageStep ( QMAX( 1, m_cres / 16 )); + contrast-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); + } @@ -87,18 +104,27 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) // ac spinboxes - interval_dim_ac_3-> setValue ( config. readNumEntry ( "Dim", 60 )); - interval_lightoff_ac_3-> setValue ( config. readNumEntry ( "LightOff", 120 )); - interval_suspend_ac_3-> setValue ( config. readNumEntry ( "Suspend", 0 )); + interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); + interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); + interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); // ac check and slider - LcdOffOnly_2_3-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); + LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); bright = config. readNumEntry ( "Brightness", 255 ); - brightness_ac_3-> setMaxValue ( m_res - 1 ); - brightness_ac_3-> setTickInterval ( QMAX( 1, m_res / 16 )); - brightness_ac_3-> setLineStep ( QMAX( 1, m_res / 16 )); - brightness_ac_3-> setPageStep ( QMAX( 1, m_res / 16 )); - brightness_ac_3-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); + brightness_ac-> setMaxValue ( m_bres - 1 ); + brightness_ac-> setTickInterval ( QMAX( 1, m_bres / 16 )); + brightness_ac-> setLineStep ( QMAX( 1, m_bres / 16 )); + brightness_ac-> setPageStep ( QMAX( 1, m_bres / 16 )); + brightness_ac-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); + + if (m_cres) { + contr = config. readNumEntry ( "Contrast", 127); + contrast_ac-> setMaxValue ( m_cres - 1 ); + contrast_ac-> setTickInterval ( QMAX( 1, m_cres / 16 )); + contrast_ac-> setLineStep ( QMAX( 1, m_cres / 16 )); + contrast_ac-> setPageStep ( QMAX( 1, m_cres / 16 )); + contrast_ac-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); + } // light sensor - auto_brightness_ac_3-> setChecked ( config. readBoolEntry ( "LightSensor", false )); + auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); @@ -122,3 +148,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); - connect ( brightness_ac_3, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); + connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); + if (m_havecontrast) { + connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); + connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); + } } @@ -150,3 +180,3 @@ void LightSettings::setBacklight ( int bright ) if ( bright >= 0 ) - bright = bright * 255 / ( m_res - 1 ); + bright = bright * 255 / ( m_bres - 1 ); @@ -161,2 +191,16 @@ void LightSettings::setBacklight ( int bright ) +void LightSettings::setContrast ( int contr ) +{ + if ( contr >= 0 ) + contr = contr * 255 / ( m_cres - 1 ); + + QCopEnvelope e ( "QPE/System", "setContrast(int)" ); + e << contr; + + if ( contr != -1 ) { + m_resettimer-> stop ( ); + m_resettimer-> start ( 2000, true ); + } +} + void LightSettings::resetBacklight ( ) @@ -164,2 +208,3 @@ void LightSettings::resetBacklight ( ) setBacklight ( -1 ); + setContrast ( -1 ); } @@ -176,3 +221,5 @@ void LightSettings::accept ( ) config. writeEntry ( "Suspend", interval_suspend-> value ( )); - config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_res - 1 ) ); + config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_bres - 1 ) ); + if (m_cres) + config. writeEntry ( "Contrast", contrast-> value ( ) * 255 / ( m_cres - 1 ) ); @@ -180,7 +227,9 @@ void LightSettings::accept ( ) config. setGroup ( "AC" ); - 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 / ( m_res - 1 )); + config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); + config. writeEntry ( "Dim", interval_dim_ac-> value ( )); + config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); + config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); + config. writeEntry ( "Brightness", brightness_ac-> value ( ) * 255 / ( m_bres - 1 )); + if (m_cres) + config. writeEntry ( "Contrast", contrast_ac-> value ( ) * 255 / ( m_cres - 1 )); @@ -192,3 +241,3 @@ void LightSettings::accept ( ) config. setGroup ( "AC" ); - config. writeEntry ( "LightSensor", auto_brightness_ac_3->isChecked() ); + config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); |