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 | 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 | |||
@@ -43,2 +43,3 @@ | |||
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qgroupbox.h> | ||
44 | 45 | ||
@@ -53,3 +54,4 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
53 | { | 54 | { |
54 | m_res = ODevice::inst ( )-> displayBrightnessResolution ( ); | 55 | m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); |
56 | m_cres = ODevice::inst ( )-> displayContrastResolution ( ); | ||
55 | 57 | ||
@@ -58,4 +60,10 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
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 | } |
@@ -74,7 +82,16 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
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 | ||
@@ -87,18 +104,27 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
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", ';' ); |
@@ -122,3 +148,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) | |||
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 | } |
@@ -150,3 +180,3 @@ void LightSettings::setBacklight ( int bright ) | |||
150 | if ( bright >= 0 ) | 180 | if ( bright >= 0 ) |
151 | bright = bright * 255 / ( m_res - 1 ); | 181 | bright = bright * 255 / ( m_bres - 1 ); |
152 | 182 | ||
@@ -161,2 +191,16 @@ void LightSettings::setBacklight ( int bright ) | |||
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 ( ) |
@@ -164,2 +208,3 @@ void LightSettings::resetBacklight ( ) | |||
164 | setBacklight ( -1 ); | 208 | setBacklight ( -1 ); |
209 | setContrast ( -1 ); | ||
165 | } | 210 | } |
@@ -176,3 +221,5 @@ void LightSettings::accept ( ) | |||
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 | ||
@@ -180,7 +227,9 @@ void LightSettings::accept ( ) | |||
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 | ||
@@ -192,3 +241,3 @@ void LightSettings::accept ( ) | |||
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, ';' ); |