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 | |||
@@ -77,25 +77,23 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
77 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); | 77 | interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); |
78 | 78 | ||
79 | // battery check and slider | 79 | // battery check and slider |
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 |
99 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 97 | auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
100 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); | 98 | m_sensordata = config. readListEntry ( "LightSensorData", ';' ); |
101 | 99 | ||
@@ -107,25 +105,23 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
107 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); | 105 | interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); |
108 | 106 | ||
109 | // ac check and slider | 107 | // ac check and slider |
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 |
129 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); | 125 | auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); |
130 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); | 126 | m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); |
131 | 127 | ||
@@ -144,13 +140,13 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
144 | else { | 140 | else { |
145 | tabs-> setCurrentPage ( 1 ); | 141 | tabs-> setCurrentPage ( 1 ); |
146 | } | 142 | } |
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 | } |
154 | } | 150 | } |
155 | 151 | ||
156 | LightSettings::~LightSettings ( ) | 152 | LightSettings::~LightSettings ( ) |
@@ -174,36 +170,26 @@ void LightSettings::calibrateSensorAC ( ) | |||
174 | s-> exec ( ); | 170 | s-> exec ( ); |
175 | delete s; | 171 | delete s; |
176 | } | 172 | } |
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 ( ) |
207 | { | 193 | { |
208 | setBacklight ( -1 ); | 194 | setBacklight ( -1 ); |
209 | setContrast ( -1 ); | 195 | setContrast ( -1 ); |
@@ -216,25 +202,25 @@ void LightSettings::accept ( ) | |||
216 | // bat | 202 | // bat |
217 | config. setGroup ( "Battery" ); | 203 | config. setGroup ( "Battery" ); |
218 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); | 204 | config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); |
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" ); |
228 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); | 214 | config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); |
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 ( )) { |
238 | config. setGroup ( "Battery" ); | 224 | config. setGroup ( "Battery" ); |
239 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); | 225 | config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); |
240 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); | 226 | config. writeEntry ( "LightSensorData", m_sensordata, ';' ); |