summaryrefslogtreecommitdiff
path: root/core/settings/light-and-power/light.cpp
Unidiff
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.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 8b98672..68c2929 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -39,12 +39,13 @@
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qslider.h> 40#include <qslider.h>
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#include <qgroupbox.h>
45#include <qcombobox.h>
45 46
46#include <opie/odevice.h> 47#include <opie/odevice.h>
47 48
48#include "sensor.h" 49#include "sensor.h"
49 50
50using namespace Opie; 51using namespace Opie;
@@ -59,29 +60,42 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
59 auto_brightness-> hide ( ); 60 auto_brightness-> hide ( );
60 CalibrateLightSensor-> hide ( ); 61 CalibrateLightSensor-> hide ( );
61 auto_brightness_ac-> hide ( ); 62 auto_brightness_ac-> hide ( );
62 CalibrateLightSensor_ac-> hide ( ); 63 CalibrateLightSensor_ac-> hide ( );
63 } 64 }
64 if (m_cres) { 65 if (m_cres) {
65 GroupLight->setTitle(tr("Backlight & Contrast")); 66 GroupLight->setTitle(tr("Backlight && Contrast"));
67 GroupLight_ac->setTitle(GroupLight->title());
66 } else { 68 } else {
67 contrast->hide(); 69 contrast->hide();
68 contrast_ac->hide(); 70 contrast_ac->hide();
69 } 71 }
70 72
73 QStrList freq = ODevice::inst()->cpuFrequencies();
74 if ( freq.count() ) {
75 frequency->insertStrList( freq );
76 frequency_ac->insertStrList( freq );
77 } else {
78 frequency->hide();
79 frequency_ac->hide();
80 }
81
71 Config config ( "apm" ); 82 Config config ( "apm" );
72 config. setGroup ( "Battery" ); 83 config. setGroup ( "Battery" );
73 84
74 // battery spinboxes 85 // battery spinboxes
75 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 86 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
76 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 87 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
77 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 88 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
78 89
79 // battery check and slider 90 // battery check and slider
80 LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 91 LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
81 92
93 // CPU frequency
94 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
95
82 int bright = config. readNumEntry ( "Brightness", 127 ); 96 int bright = config. readNumEntry ( "Brightness", 127 );
83 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 97 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
84 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 98 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
85 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 99 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
86 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 100 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
87 brightness-> setValue ( bright ); 101 brightness-> setValue ( bright );
@@ -104,12 +118,15 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
104 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 118 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
105 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 119 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
106 120
107 // ac check and slider 121 // ac check and slider
108 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 122 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
109 123
124 // CPU frequency
125 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
126
110 bright = config. readNumEntry ( "Brightness", 255 ); 127 bright = config. readNumEntry ( "Brightness", 255 );
111 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 128 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
112 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 129 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
113 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 130 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
114 brightness_ac-> setValue ( bright ); 131 brightness_ac-> setValue ( bright );
115 132
@@ -144,12 +161,13 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
144 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 161 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
145 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 162 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
146 if (m_cres) { 163 if (m_cres) {
147 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 164 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
148 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 165 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
149 } 166 }
167 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
150} 168}
151 169
152LightSettings::~LightSettings ( ) 170LightSettings::~LightSettings ( )
153{ 171{
154} 172}
155 173
@@ -186,12 +204,18 @@ void LightSettings::setContrast ( int contr )
186{ 204{
187 if (contr == -1) contr = m_oldcontrast; 205 if (contr == -1) contr = m_oldcontrast;
188 206
189 ODevice::inst ( )-> setDisplayContrast(contr); 207 ODevice::inst ( )-> setDisplayContrast(contr);
190} 208}
191 209
210void LightSettings::setFrequency ( int index )
211{
212qWarning("LightSettings::setFrequency(%d)", index);
213 ODevice::inst ( )-> setCpuFrequency(index);
214}
215
192void LightSettings::resetBacklight ( ) 216void LightSettings::resetBacklight ( )
193{ 217{
194 setBacklight ( -1 ); 218 setBacklight ( -1 );
195 setContrast ( -1 ); 219 setContrast ( -1 );
196} 220}
197 221
@@ -205,22 +229,24 @@ void LightSettings::accept ( )
205 config. writeEntry ( "Dim", interval_dim-> value ( )); 229 config. writeEntry ( "Dim", interval_dim-> value ( ));
206 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 230 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
207 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 231 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
208 config. writeEntry ( "Brightness", brightness-> value () ); 232 config. writeEntry ( "Brightness", brightness-> value () );
209 if (m_cres) 233 if (m_cres)
210 config. writeEntry ( "Contrast", contrast-> value () ); 234 config. writeEntry ( "Contrast", contrast-> value () );
235 config. writeEntry ( "Freq", frequency->currentItem() );
211 236
212 // ac 237 // ac
213 config. setGroup ( "AC" ); 238 config. setGroup ( "AC" );
214 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 239 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
215 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 240 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
216 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 241 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
217 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 242 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
218 config. writeEntry ( "Brightness", brightness_ac-> value () ); 243 config. writeEntry ( "Brightness", brightness_ac-> value () );
219 if (m_cres) 244 if (m_cres)
220 config. writeEntry ( "Contrast", contrast_ac-> value () ); 245 config. writeEntry ( "Contrast", contrast_ac-> value () );
246 config. writeEntry ( "Freq", frequency_ac->currentItem() );
221 247
222 // only make light sensor stuff appear if the unit has a sensor 248 // only make light sensor stuff appear if the unit has a sensor
223 if ( ODevice::inst ( )-> hasLightSensor ( )) { 249 if ( ODevice::inst ( )-> hasLightSensor ( )) {
224 config. setGroup ( "Battery" ); 250 config. setGroup ( "Battery" );
225 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 251 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
226 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 252 config. writeEntry ( "LightSensorData", m_sensordata, ';' );