author | schurig <schurig> | 2003-06-05 15:01:01 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-05 15:01:01 (UTC) |
commit | 33dbbfe57cb0a5a7de5600ea052e19b7bb5cb674 (patch) (unidiff) | |
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) (ignore 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 | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <qtimer.h> | 41 | #include <qtimer.h> |
42 | #include <qspinbox.h> | 42 | #include <qspinbox.h> |
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qgroupbox.h> | ||
44 | 45 | ||
45 | #include <opie/odevice.h> | 46 | #include <opie/odevice.h> |
46 | 47 | ||
@@ -51,13 +52,20 @@ using namespace Opie; | |||
51 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | 52 | LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) |
52 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) | 53 | : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) |
53 | { | 54 | { |
54 | m_res = ODevice::inst ( )-> displayBrightnessResolution ( ); | 55 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); |
56 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); | ||
55 | 57 | ||
56 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { | 58 | if ( !ODevice::inst ( )-> hasLightSensor ( )) { |
57 | auto_brightness-> hide ( ); | 59 | auto_brightness-> hide ( ); |
58 | CalibrateLightSensor-> hide ( ); | 60 | CalibrateLightSensor-> hide ( ); |
59 | auto_brightness_ac_3-> hide ( ); | 61 | auto_brightness_ac-> hide ( ); |
60 | CalibrateLightSensorAC-> hide ( ); | 62 | CalibrateLightSensor_ac-> hide ( ); |
63 | } | ||
64 | if (m_cres) { | ||
65 | GroupLight->setTitle(tr("Backlight & Contrast")); | ||
66 | } else { | ||
67 | contrast->hide(); | ||
68 | contrast_ac->hide(); | ||
61 | } | 69 | } |
62 | 70 | ||
63 | Config config ( "apm" ); | 71 | Config config ( "apm" ); |
@@ -72,11 +80,20 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
72 | LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 80 | LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
73 | 81 | ||
74 | int bright = config. readNumEntry ( "Brightness", 127 ); | 82 | int bright = config. readNumEntry ( "Brightness", 127 ); |
75 | brightness-> setMaxValue ( m_res - 1 ); | 83 | int contr = config. readNumEntry ( "Contrast", 127 ); |
76 | brightness-> setTickInterval ( QMAX( 1, m_res / 16 )); | 84 | brightness-> setMaxValue ( m_bres - 1 ); |
77 | brightness-> setLineStep ( QMAX( 1, m_res / 16 )); | 85 | brightness-> setTickInterval ( QMAX( 1, m_bres / 16 )); |
78 | brightness-> setPageStep ( QMAX( 1, m_res / 16 )); | 86 | brightness-> setLineStep ( QMAX( 1, m_bres / 16 )); |
79 | brightness-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); | 87 | brightness-> setPageStep ( QMAX( 1, m_bres / 16 )); |
88 | brightness-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); | ||
89 | |||
90 | if (m_cres) { | ||
91 | contrast-> setMaxValue ( m_cres - 1 ); | ||
92 | contrast-> setTickInterval ( QMAX( 1, m_cres / 16 )); | ||
93 | contrast-> setLineStep ( QMAX( 1, m_cres / 16 )); | ||
94 | contrast-> setPageStep ( QMAX( 1, m_cres / 16 )); | ||
95 | contrast-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); | ||
96 | } | ||
80 | 97 | ||
81 | // light sensor | 98 | // light sensor |
82 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 99 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
@@ -85,22 +102,31 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
85 | config. setGroup ( "AC" ); | 102 | config. setGroup ( "AC" ); |
86 | 103 | ||
87 | // ac spinboxes | 104 | // ac spinboxes |
88 | interval_dim_ac_3-> setValue ( config. readNumEntry ( "Dim", 60 )); | 105 | interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); |
89 | interval_lightoff_ac_3-> setValue ( config. readNumEntry ( "LightOff", 120 )); | 106 | interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); |
90 | interval_suspend_ac_3-> setValue ( config. readNumEntry ( "Suspend", 0 )); | 107 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); |
91 | 108 | ||
92 | // ac check and slider | 109 | // ac check and slider |
93 | LcdOffOnly_2_3-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 110 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
94 | 111 | ||
95 | bright = config. readNumEntry ( "Brightness", 255 ); | 112 | bright = config. readNumEntry ( "Brightness", 255 ); |
96 | brightness_ac_3-> setMaxValue ( m_res - 1 ); | 113 | brightness_ac-> setMaxValue ( m_bres - 1 ); |
97 | brightness_ac_3-> setTickInterval ( QMAX( 1, m_res / 16 )); | 114 | brightness_ac-> setTickInterval ( QMAX( 1, m_bres / 16 )); |
98 | brightness_ac_3-> setLineStep ( QMAX( 1, m_res / 16 )); | 115 | brightness_ac-> setLineStep ( QMAX( 1, m_bres / 16 )); |
99 | brightness_ac_3-> setPageStep ( QMAX( 1, m_res / 16 )); | 116 | brightness_ac-> setPageStep ( QMAX( 1, m_bres / 16 )); |
100 | brightness_ac_3-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); | 117 | brightness_ac-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); |
118 | |||
119 | if (m_cres) { | ||
120 | contr = config. readNumEntry ( "Contrast", 127); | ||
121 | contrast_ac-> setMaxValue ( m_cres - 1 ); | ||
122 | contrast_ac-> setTickInterval ( QMAX( 1, m_cres / 16 )); | ||
123 | contrast_ac-> setLineStep ( QMAX( 1, m_cres / 16 )); | ||
124 | contrast_ac-> setPageStep ( QMAX( 1, m_cres / 16 )); | ||
125 | contrast_ac-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); | ||
126 | } | ||
101 | 127 | ||
102 | // light sensor | 128 | // light sensor |
103 | auto_brightness_ac_3-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 129 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
104 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); | 130 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); |
105 | 131 | ||
106 | // advanced settings | 132 | // advanced settings |
@@ -120,7 +146,11 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
120 | } | 146 | } |
121 | 147 | ||
122 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 148 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
123 | connect ( brightness_ac_3, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 149 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
150 | if (m_havecontrast) { | ||
151 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | ||
152 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | ||
153 | } | ||
124 | } | 154 | } |
125 | 155 | ||
126 | LightSettings::~LightSettings ( ) | 156 | LightSettings::~LightSettings ( ) |
@@ -148,7 +178,7 @@ void LightSettings::calibrateSensorAC ( ) | |||
148 | void LightSettings::setBacklight ( int bright ) | 178 | void LightSettings::setBacklight ( int bright ) |
149 | { | 179 | { |
150 | if ( bright >= 0 ) | 180 | if ( bright >= 0 ) |
151 | bright = bright * 255 / ( m_res - 1 ); | 181 | bright = bright * 255 / ( m_bres - 1 ); |
152 | 182 | ||
153 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); | 183 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); |
154 | e << bright; | 184 | e << bright; |
@@ -159,9 +189,24 @@ void LightSettings::setBacklight ( int bright ) | |||
159 | } | 189 | } |
160 | } | 190 | } |
161 | 191 | ||
192 | void LightSettings::setContrast ( int contr ) | ||
193 | { | ||
194 | if ( contr >= 0 ) | ||
195 | contr = contr * 255 / ( m_cres - 1 ); | ||
196 | |||
197 | QCopEnvelope e ( "QPE/System", "setContrast(int)" ); | ||
198 | e << contr; | ||
199 | |||
200 | if ( contr != -1 ) { | ||
201 | m_resettimer-> stop ( ); | ||
202 | m_resettimer-> start ( 2000, true ); | ||
203 | } | ||
204 | } | ||
205 | |||
162 | void LightSettings::resetBacklight ( ) | 206 | void LightSettings::resetBacklight ( ) |
163 | { | 207 | { |
164 | setBacklight ( -1 ); | 208 | setBacklight ( -1 ); |
209 | setContrast ( -1 ); | ||
165 | } | 210 | } |
166 | 211 | ||
167 | void LightSettings::accept ( ) | 212 | void LightSettings::accept ( ) |
@@ -174,15 +219,19 @@ void LightSettings::accept ( ) | |||
174 | config. writeEntry ( "Dim", interval_dim-> value ( )); | 219 | config. writeEntry ( "Dim", interval_dim-> value ( )); |
175 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); | 220 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); |
176 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); | 221 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); |
177 | config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_res - 1 ) ); | 222 | config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_bres - 1 ) ); |
223 | if (m_cres) | ||
224 | config. writeEntry ( "Contrast", contrast-> value ( ) * 255 / ( m_cres - 1 ) ); | ||
178 | 225 | ||
179 | // ac | 226 | // ac |
180 | config. setGroup ( "AC" ); | 227 | config. setGroup ( "AC" ); |
181 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_2_3-> isChecked ( )); | 228 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); |
182 | config. writeEntry ( "Dim", interval_dim_ac_3-> value ( )); | 229 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); |
183 | config. writeEntry ( "LightOff", interval_lightoff_ac_3-> value ( )); | 230 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); |
184 | config. writeEntry ( "Suspend", interval_suspend_ac_3-> value ( )); | 231 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); |
185 | config. writeEntry ( "Brightness", brightness_ac_3-> value ( ) * 255 / ( m_res - 1 )); | 232 | config. writeEntry ( "Brightness", brightness_ac-> value ( ) * 255 / ( m_bres - 1 )); |
233 | if (m_cres) | ||
234 | config. writeEntry ( "Contrast", contrast_ac-> value ( ) * 255 / ( m_cres - 1 )); | ||
186 | 235 | ||
187 | // only make light sensor stuff appear if the unit has a sensor | 236 | // only make light sensor stuff appear if the unit has a sensor |
188 | if ( ODevice::inst ( )-> hasLightSensor ( )) { | 237 | if ( ODevice::inst ( )-> hasLightSensor ( )) { |
@@ -190,7 +239,7 @@ void LightSettings::accept ( ) | |||
190 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); | 239 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); |
191 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); | 240 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); |
192 | config. setGroup ( "AC" ); | 241 | config. setGroup ( "AC" ); |
193 | config. writeEntry ( "LightSensor", auto_brightness_ac_3->isChecked() ); | 242 | config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); |
194 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); | 243 | config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); |
195 | } | 244 | } |
196 | 245 | ||