Diffstat (limited to 'core/settings/light-and-power/light.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/light-and-power/light.cpp | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index c0ba60b..21377b7 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp @@ -28,3 +28,3 @@ -#include "settings.h" +#include "light.h" @@ -40,2 +40,3 @@ #include <qslider.h> +#include <qtimer.h> #include <qspinbox.h> @@ -50,3 +51,3 @@ using namespace Opie; LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) - : LightSettingsBase( parent, name, true, WStyle_ContextHelp ) + : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) { @@ -65,4 +66,4 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) // battery spinboxes - interval_dim-> setValue ( config. readNumEntry ( "Dim", 20 )); - interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 30 )); + interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); + interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); @@ -72,3 +73,3 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) - int bright = config. readNumEntry ( "Brightness", 255 ); + int bright = config. readNumEntry ( "Brightness", 127 ); brightness-> setMaxValue ( m_res - 1 ); @@ -86,5 +87,5 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) // 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 )); + 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 )); @@ -110,4 +111,6 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) + m_resettimer = new QTimer ( this ); + connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); + if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { - connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); tabs-> setCurrentPage ( 0 ); @@ -115,5 +118,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) else { - connect ( brightness_ac_3, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); tabs-> setCurrentPage ( 1 ); } + + connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); + connect ( brightness_ac_3, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); } @@ -124,3 +129,2 @@ LightSettings::~LightSettings ( ) - void LightSettings::calibrateSensor ( ) @@ -128,2 +132,3 @@ void LightSettings::calibrateSensor ( ) Sensor *s = new Sensor ( m_sensordata, this ); + connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); s-> showMaximized ( ); @@ -136,2 +141,3 @@ void LightSettings::calibrateSensorAC ( ) Sensor *s = new Sensor ( m_sensordata_ac, this ); + connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); s-> showMaximized ( ); @@ -143,14 +149,17 @@ void LightSettings::setBacklight ( int bright ) { - bright = bright * 255 / ( m_res - 1 ); + if ( bright >= 0 ) + bright = bright * 255 / ( m_res - 1 ); + QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); e << bright; + + if ( bright != -1 ) { + m_resettimer-> stop ( ); + m_resettimer-> start ( 2000, true ); + } } -void LightSettings::reject ( ) +void LightSettings::resetBacklight ( ) { - { - QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); - e << -1; - } - QDialog::reject ( ); + setBacklight ( -1 ); } @@ -202,8 +211,3 @@ void LightSettings::accept ( ) } - { - QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); - e << -1; - } - - QDialog::accept ( ); + LightSettingsBase::accept ( ); } @@ -212,3 +216,6 @@ void LightSettings::done ( int r ) { - QDialog::done ( r ); + m_resettimer-> stop ( ); + resetBacklight ( ); + + LightSettingsBase::done ( r ); close ( ); |