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 | 64 |
1 files changed, 25 insertions, 39 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index a58b1c1..8b98672 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp | |||
@@ -80,19 +80,17 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
80 | LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 80 | LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
81 | 81 | ||
82 | int bright = config. readNumEntry ( "Brightness", 127 ); | 82 | int bright = config. readNumEntry ( "Brightness", 127 ); |
83 | int contr = config. readNumEntry ( "Contrast", 127 ); | 83 | int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); |
84 | brightness-> setMaxValue ( m_bres - 1 ); | 84 | brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
85 | brightness-> setTickInterval ( QMAX( 1, m_bres / 16 )); | 85 | brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); |
86 | brightness-> setLineStep ( QMAX( 1, m_bres / 16 )); | 86 | brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); |
87 | brightness-> setPageStep ( QMAX( 1, m_bres / 16 )); | 87 | brightness-> setValue ( bright ); |
88 | brightness-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); | ||
89 | 88 | ||
90 | if (m_cres) { | 89 | if (m_cres) { |
91 | contrast-> setMaxValue ( m_cres - 1 ); | 90 | contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
92 | contrast-> setTickInterval ( QMAX( 1, m_cres / 16 )); | 91 | contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); |
93 | contrast-> setLineStep ( QMAX( 1, m_cres / 16 )); | 92 | contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); |
94 | contrast-> setPageStep ( QMAX( 1, m_cres / 16 )); | 93 | contrast-> setValue ( contr ); |
95 | contrast-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); | ||
96 | } | 94 | } |
97 | 95 | ||
98 | // light sensor | 96 | // light sensor |
@@ -110,19 +108,17 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
110 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); | 108 | LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); |
111 | 109 | ||
112 | bright = config. readNumEntry ( "Brightness", 255 ); | 110 | bright = config. readNumEntry ( "Brightness", 255 ); |
113 | brightness_ac-> setMaxValue ( m_bres - 1 ); | 111 | brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); |
114 | brightness_ac-> setTickInterval ( QMAX( 1, m_bres / 16 )); | 112 | brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); |
115 | brightness_ac-> setLineStep ( QMAX( 1, m_bres / 16 )); | 113 | brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); |
116 | brightness_ac-> setPageStep ( QMAX( 1, m_bres / 16 )); | 114 | brightness_ac-> setValue ( bright ); |
117 | brightness_ac-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); | ||
118 | 115 | ||
119 | if (m_cres) { | 116 | if (m_cres) { |
120 | contr = config. readNumEntry ( "Contrast", 127); | 117 | contr = config. readNumEntry ( "Contrast", 127); |
121 | contrast_ac-> setMaxValue ( m_cres - 1 ); | 118 | contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); |
122 | contrast_ac-> setTickInterval ( QMAX( 1, m_cres / 16 )); | 119 | contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); |
123 | contrast_ac-> setLineStep ( QMAX( 1, m_cres / 16 )); | 120 | contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); |
124 | contrast_ac-> setPageStep ( QMAX( 1, m_cres / 16 )); | 121 | contrast_ac-> setValue ( contr ); |
125 | contrast_ac-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); | ||
126 | } | 122 | } |
127 | 123 | ||
128 | // light sensor | 124 | // light sensor |
@@ -147,7 +143,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
147 | 143 | ||
148 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 144 | connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
149 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); | 145 | connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); |
150 | if (m_havecontrast) { | 146 | if (m_cres) { |
151 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 147 | connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); |
152 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); | 148 | connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); |
153 | } | 149 | } |
@@ -177,30 +173,20 @@ void LightSettings::calibrateSensorAC ( ) | |||
177 | 173 | ||
178 | void LightSettings::setBacklight ( int bright ) | 174 | void LightSettings::setBacklight ( int bright ) |
179 | { | 175 | { |
180 | if ( bright >= 0 ) | ||
181 | bright = bright * 255 / ( m_bres - 1 ); | ||
182 | |||
183 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); | 176 | QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); |
184 | e << bright; | 177 | e << bright; |
185 | 178 | ||
186 | if ( bright != -1 ) { | 179 | if ( bright != -1 ) { |
187 | m_resettimer-> stop ( ); | 180 | m_resettimer-> stop ( ); |
188 | m_resettimer-> start ( 2000, true ); | 181 | m_resettimer-> start ( 4000, true ); |
189 | } | 182 | } |
190 | } | 183 | } |
191 | 184 | ||
192 | void LightSettings::setContrast ( int contr ) | 185 | void LightSettings::setContrast ( int contr ) |
193 | { | 186 | { |
194 | if ( contr >= 0 ) | 187 | if (contr == -1) contr = m_oldcontrast; |
195 | contr = contr * 255 / ( m_cres - 1 ); | ||
196 | |||
197 | QCopEnvelope e ( "QPE/System", "setContrast(int)" ); | ||
198 | e << contr; | ||
199 | 188 | ||
200 | if ( contr != -1 ) { | 189 | ODevice::inst ( )-> setDisplayContrast(contr); |
201 | m_resettimer-> stop ( ); | ||
202 | m_resettimer-> start ( 2000, true ); | ||
203 | } | ||
204 | } | 190 | } |
205 | 191 | ||
206 | void LightSettings::resetBacklight ( ) | 192 | void LightSettings::resetBacklight ( ) |
@@ -219,9 +205,9 @@ void LightSettings::accept ( ) | |||
219 | config. writeEntry ( "Dim", interval_dim-> value ( )); | 205 | config. writeEntry ( "Dim", interval_dim-> value ( )); |
220 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); | 206 | config. writeEntry ( "LightOff", interval_lightoff-> value ( )); |
221 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); | 207 | config. writeEntry ( "Suspend", interval_suspend-> value ( )); |
222 | config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_bres - 1 ) ); | 208 | config. writeEntry ( "Brightness", brightness-> value () ); |
223 | if (m_cres) | 209 | if (m_cres) |
224 | config. writeEntry ( "Contrast", contrast-> value ( ) * 255 / ( m_cres - 1 ) ); | 210 | config. writeEntry ( "Contrast", contrast-> value () ); |
225 | 211 | ||
226 | // ac | 212 | // ac |
227 | config. setGroup ( "AC" ); | 213 | config. setGroup ( "AC" ); |
@@ -229,9 +215,9 @@ void LightSettings::accept ( ) | |||
229 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); | 215 | config. writeEntry ( "Dim", interval_dim_ac-> value ( )); |
230 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); | 216 | config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); |
231 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); | 217 | config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); |
232 | config. writeEntry ( "Brightness", brightness_ac-> value ( ) * 255 / ( m_bres - 1 )); | 218 | config. writeEntry ( "Brightness", brightness_ac-> value () ); |
233 | if (m_cres) | 219 | if (m_cres) |
234 | config. writeEntry ( "Contrast", contrast_ac-> value ( ) * 255 / ( m_cres - 1 )); | 220 | config. writeEntry ( "Contrast", contrast_ac-> value () ); |
235 | 221 | ||
236 | // only make light sensor stuff appear if the unit has a sensor | 222 | // only make light sensor stuff appear if the unit has a sensor |
237 | if ( ODevice::inst ( )-> hasLightSensor ( )) { | 223 | if ( ODevice::inst ( )-> hasLightSensor ( )) { |