author | sandman <sandman> | 2002-11-01 18:13:18 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-01 18:13:18 (UTC) |
commit | 2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba (patch) (side-by-side diff) | |
tree | f3e6bb8ee6c0d8f2671a63c240d1145e710da82d /core/settings/light-and-power/light.cpp | |
parent | 7b7b760ca3886d5b6562a88b5c2ef8e610b73eb8 (diff) | |
download | opie-2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba.zip opie-2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba.tar.gz opie-2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba.tar.bz2 |
- Completly reworked the backlight "preview":
every slider/control that relates to backlight levels, is now switching the
lcd to this level for 2 seconds - after that the backlight switches back to
the standard level (or light sensor control)
- Many bugfixes and usability improvements in light sensor calibration
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 | 55 |
1 files changed, 31 insertions, 24 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 @@ -25,9 +25,9 @@ Boston, MA 02111-1307, USA. */ -#include "settings.h" +#include "light.h" #include <qpe/config.h> #include <qpe/qpeapplication.h> #include <qpe/power.h> @@ -37,8 +37,9 @@ #include <qcheckbox.h> #include <qtabwidget.h> #include <qslider.h> +#include <qtimer.h> #include <qspinbox.h> #include <qpushbutton.h> #include <opie/odevice.h> @@ -47,9 +48,9 @@ using namespace Opie; LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) - : LightSettingsBase( parent, name, true, WStyle_ContextHelp ) + : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) { m_res = ODevice::inst ( )-> displayBrightnessResolution ( ); if ( !ODevice::inst ( )-> hasLightSensor ( )) { @@ -62,16 +63,16 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) Config config ( "apm" ); config. setGroup ( "Battery" ); // 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 )); // battery check and slider LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); - int bright = config. readNumEntry ( "Brightness", 255 ); + 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 )); @@ -83,11 +84,11 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 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 )); + 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 )); // ac check and slider LcdOffOnly_2_3-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); @@ -107,53 +108,61 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); + 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 ); } 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 ))); } LightSettings::~LightSettings ( ) { } - void LightSettings::calibrateSensor ( ) { Sensor *s = new Sensor ( m_sensordata, this ); + connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); s-> showMaximized ( ); s-> exec ( ); delete s; } void LightSettings::calibrateSensorAC ( ) { Sensor *s = new Sensor ( m_sensordata_ac, this ); + connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); s-> showMaximized ( ); s-> exec ( ); delete s; } void LightSettings::setBacklight ( int bright ) { + 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 ); } void LightSettings::accept ( ) { @@ -199,17 +208,15 @@ void LightSettings::accept ( ) { QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); e << -1; } - { - QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); - e << -1; - } - - QDialog::accept ( ); + LightSettingsBase::accept ( ); } void LightSettings::done ( int r ) { - QDialog::done ( r ); + m_resettimer-> stop ( ); + resetBacklight ( ); + + LightSettingsBase::done ( r ); close ( ); } |