summaryrefslogtreecommitdiff
authorschurig <schurig>2003-06-10 16:35:43 (UTC)
committer schurig <schurig>2003-06-10 16:35:43 (UTC)
commitd2f78d2aba17a491739d10bd73f6fce033849537 (patch) (unidiff)
tree0d8e5683afaa6da476001e00fc6db2ebc5c1a0df
parent8ffea5d37080bd173d55a458296c1fc461a54d13 (diff)
downloadopie-d2f78d2aba17a491739d10bd73f6fce033849537.zip
opie-d2f78d2aba17a491739d10bd73f6fce033849537.tar.gz
opie-d2f78d2aba17a491739d10bd73f6fce033849537.tar.bz2
renamed frequency access methods
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp4
-rw-r--r--libopie/odevice.cpp8
-rw-r--r--libopie/odevice.h5
3 files changed, 8 insertions, 9 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 68c2929..eda0c1f 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -1,283 +1,283 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "light.h" 29#include "light.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/power.h> 33#include <qpe/power.h>
34#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 34#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#endif 36#endif
37 37
38#include <qcheckbox.h> 38#include <qcheckbox.h>
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#include <qcombobox.h>
46 46
47#include <opie/odevice.h> 47#include <opie/odevice.h>
48 48
49#include "sensor.h" 49#include "sensor.h"
50 50
51using namespace Opie; 51using namespace Opie;
52 52
53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) 54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
55{ 55{
56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); 56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
57 m_cres = ODevice::inst ( )-> displayContrastResolution ( ); 57 m_cres = ODevice::inst ( )-> displayContrastResolution ( );
58 58
59 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 59 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
60 auto_brightness-> hide ( ); 60 auto_brightness-> hide ( );
61 CalibrateLightSensor-> hide ( ); 61 CalibrateLightSensor-> hide ( );
62 auto_brightness_ac-> hide ( ); 62 auto_brightness_ac-> hide ( );
63 CalibrateLightSensor_ac-> hide ( ); 63 CalibrateLightSensor_ac-> hide ( );
64 } 64 }
65 if (m_cres) { 65 if (m_cres) {
66 GroupLight->setTitle(tr("Backlight && Contrast")); 66 GroupLight->setTitle(tr("Backlight && Contrast"));
67 GroupLight_ac->setTitle(GroupLight->title()); 67 GroupLight_ac->setTitle(GroupLight->title());
68 } else { 68 } else {
69 contrast->hide(); 69 contrast->hide();
70 contrast_ac->hide(); 70 contrast_ac->hide();
71 } 71 }
72 72
73 QStrList freq = ODevice::inst()->cpuFrequencies(); 73 QStrList freq = ODevice::inst()->allowedCpuFrequencies();
74 if ( freq.count() ) { 74 if ( freq.count() ) {
75 frequency->insertStrList( freq ); 75 frequency->insertStrList( freq );
76 frequency_ac->insertStrList( freq ); 76 frequency_ac->insertStrList( freq );
77 } else { 77 } else {
78 frequency->hide(); 78 frequency->hide();
79 frequency_ac->hide(); 79 frequency_ac->hide();
80 } 80 }
81 81
82 Config config ( "apm" ); 82 Config config ( "apm" );
83 config. setGroup ( "Battery" ); 83 config. setGroup ( "Battery" );
84 84
85 // battery spinboxes 85 // battery spinboxes
86 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 86 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
87 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 87 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
88 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 88 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
89 89
90 // battery check and slider 90 // battery check and slider
91 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 91 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
92 92
93 // CPU frequency 93 // CPU frequency
94 frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); 94 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
95 95
96 int bright = config. readNumEntry ( "Brightness", 127 ); 96 int bright = config. readNumEntry ( "Brightness", 127 );
97 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 97 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
98 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 98 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
99 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 99 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
100 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 100 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
101 brightness-> setValue ( bright ); 101 brightness-> setValue ( bright );
102 102
103 if (m_cres) { 103 if (m_cres) {
104 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); 104 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
105 contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); 105 contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
106 contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); 106 contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
107 contrast-> setValue ( contr ); 107 contrast-> setValue ( contr );
108 } 108 }
109 109
110 // light sensor 110 // light sensor
111 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 111 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
112 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 112 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
113 113
114 config. setGroup ( "AC" ); 114 config. setGroup ( "AC" );
115 115
116 // ac spinboxes 116 // ac spinboxes
117 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); 117 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
118 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 118 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
119 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 119 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
120 120
121 // ac check and slider 121 // ac check and slider
122 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 122 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
123 123
124 // CPU frequency 124 // CPU frequency
125 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); 125 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
126 126
127 bright = config. readNumEntry ( "Brightness", 255 ); 127 bright = config. readNumEntry ( "Brightness", 255 );
128 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 128 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
129 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 129 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
130 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 130 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
131 brightness_ac-> setValue ( bright ); 131 brightness_ac-> setValue ( bright );
132 132
133 if (m_cres) { 133 if (m_cres) {
134 contr = config. readNumEntry ( "Contrast", 127); 134 contr = config. readNumEntry ( "Contrast", 127);
135 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); 135 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
136 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); 136 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
137 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); 137 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
138 contrast_ac-> setValue ( contr ); 138 contrast_ac-> setValue ( contr );
139 } 139 }
140 140
141 // light sensor 141 // light sensor
142 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 142 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
143 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 143 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
144 144
145 // advanced settings 145 // advanced settings
146 config. setGroup ( "Warnings" ); 146 config. setGroup ( "Warnings" );
147 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 147 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
148 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 148 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
149 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 149 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
150 150
151 m_resettimer = new QTimer ( this ); 151 m_resettimer = new QTimer ( this );
152 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); 152 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( )));
153 153
154 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 154 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
155 tabs-> setCurrentPage ( 0 ); 155 tabs-> setCurrentPage ( 0 );
156 } 156 }
157 else { 157 else {
158 tabs-> setCurrentPage ( 1 ); 158 tabs-> setCurrentPage ( 1 );
159 } 159 }
160 160
161 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 161 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
162 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 162 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
163 if (m_cres) { 163 if (m_cres) {
164 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 164 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
165 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 165 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
166 } 166 }
167 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 167 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
168} 168}
169 169
170LightSettings::~LightSettings ( ) 170LightSettings::~LightSettings ( )
171{ 171{
172} 172}
173 173
174void LightSettings::calibrateSensor ( ) 174void LightSettings::calibrateSensor ( )
175{ 175{
176 Sensor *s = new Sensor ( m_sensordata, this ); 176 Sensor *s = new Sensor ( m_sensordata, this );
177 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 177 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
178 s-> showMaximized ( ); 178 s-> showMaximized ( );
179 s-> exec ( ); 179 s-> exec ( );
180 delete s; 180 delete s;
181} 181}
182 182
183void LightSettings::calibrateSensorAC ( ) 183void LightSettings::calibrateSensorAC ( )
184{ 184{
185 Sensor *s = new Sensor ( m_sensordata_ac, this ); 185 Sensor *s = new Sensor ( m_sensordata_ac, this );
186 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 186 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
187 s-> showMaximized ( ); 187 s-> showMaximized ( );
188 s-> exec ( ); 188 s-> exec ( );
189 delete s; 189 delete s;
190} 190}
191 191
192void LightSettings::setBacklight ( int bright ) 192void LightSettings::setBacklight ( int bright )
193{ 193{
194 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 194 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
195 e << bright; 195 e << bright;
196 196
197 if ( bright != -1 ) { 197 if ( bright != -1 ) {
198 m_resettimer-> stop ( ); 198 m_resettimer-> stop ( );
199 m_resettimer-> start ( 4000, true ); 199 m_resettimer-> start ( 4000, true );
200 } 200 }
201} 201}
202 202
203void LightSettings::setContrast ( int contr ) 203void LightSettings::setContrast ( int contr )
204{ 204{
205 if (contr == -1) contr = m_oldcontrast; 205 if (contr == -1) contr = m_oldcontrast;
206 206
207 ODevice::inst ( )-> setDisplayContrast(contr); 207 ODevice::inst ( )-> setDisplayContrast(contr);
208} 208}
209 209
210void LightSettings::setFrequency ( int index ) 210void LightSettings::setFrequency ( int index )
211{ 211{
212qWarning("LightSettings::setFrequency(%d)", index); 212qWarning("LightSettings::setFrequency(%d)", index);
213 ODevice::inst ( )-> setCpuFrequency(index); 213 ODevice::inst ( )-> setCurrentCpuFrequency(index);
214} 214}
215 215
216void LightSettings::resetBacklight ( ) 216void LightSettings::resetBacklight ( )
217{ 217{
218 setBacklight ( -1 ); 218 setBacklight ( -1 );
219 setContrast ( -1 ); 219 setContrast ( -1 );
220} 220}
221 221
222void LightSettings::accept ( ) 222void LightSettings::accept ( )
223{ 223{
224 Config config ( "apm" ); 224 Config config ( "apm" );
225 225
226 // bat 226 // bat
227 config. setGroup ( "Battery" ); 227 config. setGroup ( "Battery" );
228 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 228 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
229 config. writeEntry ( "Dim", interval_dim-> value ( )); 229 config. writeEntry ( "Dim", interval_dim-> value ( ));
230 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 230 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
231 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 231 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
232 config. writeEntry ( "Brightness", brightness-> value () ); 232 config. writeEntry ( "Brightness", brightness-> value () );
233 if (m_cres) 233 if (m_cres)
234 config. writeEntry ( "Contrast", contrast-> value () ); 234 config. writeEntry ( "Contrast", contrast-> value () );
235 config. writeEntry ( "Freq", frequency->currentItem() ); 235 config. writeEntry ( "Freq", frequency->currentItem() );
236 236
237 // ac 237 // ac
238 config. setGroup ( "AC" ); 238 config. setGroup ( "AC" );
239 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 239 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
240 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 240 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
241 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 241 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
242 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 242 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
243 config. writeEntry ( "Brightness", brightness_ac-> value () ); 243 config. writeEntry ( "Brightness", brightness_ac-> value () );
244 if (m_cres) 244 if (m_cres)
245 config. writeEntry ( "Contrast", contrast_ac-> value () ); 245 config. writeEntry ( "Contrast", contrast_ac-> value () );
246 config. writeEntry ( "Freq", frequency_ac->currentItem() ); 246 config. writeEntry ( "Freq", frequency_ac->currentItem() );
247 247
248 // 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
249 if ( ODevice::inst ( )-> hasLightSensor ( )) { 249 if ( ODevice::inst ( )-> hasLightSensor ( )) {
250 config. setGroup ( "Battery" ); 250 config. setGroup ( "Battery" );
251 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 251 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
252 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 252 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
253 config. setGroup ( "AC" ); 253 config. setGroup ( "AC" );
254 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); 254 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
255 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 255 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
256 } 256 }
257 257
258 // advanced 258 // advanced
259 config. setGroup ( "Warnings" ); 259 config. setGroup ( "Warnings" );
260 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 260 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
261 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 261 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
262 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 262 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
263 config. write ( ); 263 config. write ( );
264 264
265 // notify the launcher 265 // notify the launcher
266 { 266 {
267 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 267 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
268 } 268 }
269 { 269 {
270 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 270 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
271 e << -1; 271 e << -1;
272 } 272 }
273 LightSettingsBase::accept ( ); 273 LightSettingsBase::accept ( );
274} 274}
275 275
276void LightSettings::done ( int r ) 276void LightSettings::done ( int r )
277{ 277{
278 m_resettimer-> stop ( ); 278 m_resettimer-> stop ( );
279 resetBacklight ( ); 279 resetBacklight ( );
280 280
281 LightSettingsBase::done ( r ); 281 LightSettingsBase::done ( r );
282 close ( ); 282 close ( );
283} 283}
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 4c33a0e..d6e6892 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -682,206 +682,206 @@ void ODevice::alarmSound ( )
682 682
683 if ( snd. isFinished ( )) 683 if ( snd. isFinished ( ))
684 snd. play ( ); 684 snd. play ( );
685#endif 685#endif
686} 686}
687 687
688/** 688/**
689 * This plays a key sound 689 * This plays a key sound
690 */ 690 */
691void ODevice::keySound ( ) 691void ODevice::keySound ( )
692{ 692{
693#ifndef QT_NO_SOUND 693#ifndef QT_NO_SOUND
694 static Sound snd ( "keysound" ); 694 static Sound snd ( "keysound" );
695 695
696 if ( snd. isFinished ( )) 696 if ( snd. isFinished ( ))
697 snd. play ( ); 697 snd. play ( );
698#endif 698#endif
699} 699}
700 700
701/** 701/**
702 * This plays a touch sound 702 * This plays a touch sound
703 */ 703 */
704void ODevice::touchSound ( ) 704void ODevice::touchSound ( )
705{ 705{
706#ifndef QT_NO_SOUND 706#ifndef QT_NO_SOUND
707 static Sound snd ( "touchsound" ); 707 static Sound snd ( "touchsound" );
708 708
709 if ( snd. isFinished ( )) 709 if ( snd. isFinished ( ))
710 snd. play ( ); 710 snd. play ( );
711#endif 711#endif
712} 712}
713 713
714/** 714/**
715 * This method will return a list of leds 715 * This method will return a list of leds
716 * available on this device 716 * available on this device
717 * @return a list of LEDs. 717 * @return a list of LEDs.
718 */ 718 */
719QValueList <OLed> ODevice::ledList ( ) const 719QValueList <OLed> ODevice::ledList ( ) const
720{ 720{
721 return QValueList <OLed> ( ); 721 return QValueList <OLed> ( );
722} 722}
723 723
724/** 724/**
725 * This does return the state of the LEDs 725 * This does return the state of the LEDs
726 */ 726 */
727QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 727QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
728{ 728{
729 return QValueList <OLedState> ( ); 729 return QValueList <OLedState> ( );
730} 730}
731 731
732/** 732/**
733 * @return the state for a given OLed 733 * @return the state for a given OLed
734 */ 734 */
735OLedState ODevice::ledState ( OLed /*which*/ ) const 735OLedState ODevice::ledState ( OLed /*which*/ ) const
736{ 736{
737 return Led_Off; 737 return Led_Off;
738} 738}
739 739
740/** 740/**
741 * Set the state for a LED 741 * Set the state for a LED
742 * @param which Which OLed to use 742 * @param which Which OLed to use
743 * @param st The state to set 743 * @param st The state to set
744 * @return success or failure 744 * @return success or failure
745 */ 745 */
746bool ODevice::setLedState ( OLed which, OLedState st ) 746bool ODevice::setLedState ( OLed which, OLedState st )
747{ 747{
748 Q_UNUSED( which ) 748 Q_UNUSED( which )
749 Q_UNUSED( st ) 749 Q_UNUSED( st )
750 return false; 750 return false;
751} 751}
752 752
753/** 753/**
754 * @return if the device has a light sensor 754 * @return if the device has a light sensor
755 */ 755 */
756bool ODevice::hasLightSensor ( ) const 756bool ODevice::hasLightSensor ( ) const
757{ 757{
758 return false; 758 return false;
759} 759}
760 760
761/** 761/**
762 * @return a value from the light senso 762 * @return a value from the light senso
763 */ 763 */
764int ODevice::readLightSensor ( ) 764int ODevice::readLightSensor ( )
765{ 765{
766 return -1; 766 return -1;
767} 767}
768 768
769/** 769/**
770 * @return the light sensor resolution whatever that is ;) 770 * @return the light sensor resolution whatever that is ;)
771 */ 771 */
772int ODevice::lightSensorResolution ( ) const 772int ODevice::lightSensorResolution ( ) const
773{ 773{
774 return 0; 774 return 0;
775} 775}
776 776
777/** 777/**
778 * @return a list with valid CPU frequency 778 * @return a list with CPU frequencies supported by the hardware
779 */ 779 */
780QStrList &ODevice::cpuFrequencies ( ) const 780const QStrList &ODevice::allowedCpuFrequencies ( ) const
781{ 781{
782 return *d->m_cpu_frequencies; 782 return *d->m_cpu_frequencies;
783} 783}
784 784
785 785
786/** 786/**
787 * Set desired cpu frequency 787 * Set desired CPU frequency
788 * 788 *
789 * @param index index into d->m_cpu_frequencies of the frequency to be set 789 * @param index index into d->m_cpu_frequencies of the frequency to be set
790 */ 790 */
791bool ODevice::setCpuFrequency(uint index) 791bool ODevice::setCurrentCpuFrequency(uint index)
792{ 792{
793 if (index >= d->m_cpu_frequencies->count()) 793 if (index >= d->m_cpu_frequencies->count())
794 return false; 794 return false;
795 795
796 char *freq = d->m_cpu_frequencies->at(index); 796 char *freq = d->m_cpu_frequencies->at(index);
797 qWarning("set freq to %s", freq); 797 qWarning("set freq to %s", freq);
798 798
799 int fd; 799 int fd;
800 800
801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
802 char writeCommand[50]; 802 char writeCommand[50];
803 const int count = sprintf(writeCommand, "%s\n", freq); 803 const int count = sprintf(writeCommand, "%s\n", freq);
804 int res = (::write(fd, writeCommand, count) != -1); 804 int res = (::write(fd, writeCommand, count) != -1);
805 ::close(fd); 805 ::close(fd);
806 return res; 806 return res;
807 } 807 }
808 808
809 return false; 809 return false;
810} 810}
811 811
812 812
813/** 813/**
814 * @return a list of hardware buttons 814 * @return a list of hardware buttons
815 */ 815 */
816const QValueList <ODeviceButton> &ODevice::buttons ( ) 816const QValueList <ODeviceButton> &ODevice::buttons ( )
817{ 817{
818 initButtons ( ); 818 initButtons ( );
819 819
820 return *d-> m_buttons; 820 return *d-> m_buttons;
821} 821}
822 822
823/** 823/**
824 * @return The amount of time that would count as a hold 824 * @return The amount of time that would count as a hold
825 */ 825 */
826uint ODevice::buttonHoldTime ( ) const 826uint ODevice::buttonHoldTime ( ) const
827{ 827{
828 return d-> m_holdtime; 828 return d-> m_holdtime;
829} 829}
830 830
831/** 831/**
832 * This method return a ODeviceButton for a key code 832 * This method return a ODeviceButton for a key code
833 * or 0 if no special hardware button is available for the device 833 * or 0 if no special hardware button is available for the device
834 * 834 *
835 * @return The devicebutton or 0l 835 * @return The devicebutton or 0l
836 * @see ODeviceButton 836 * @see ODeviceButton
837 */ 837 */
838const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 838const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
839{ 839{
840 initButtons ( ); 840 initButtons ( );
841 841
842 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 842 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
843 if ( (*it). keycode ( ) == code ) 843 if ( (*it). keycode ( ) == code )
844 return &(*it); 844 return &(*it);
845 } 845 }
846 return 0; 846 return 0;
847} 847}
848 848
849void ODevice::reloadButtonMapping ( ) 849void ODevice::reloadButtonMapping ( )
850{ 850{
851 initButtons ( ); 851 initButtons ( );
852 852
853 Config cfg ( "ButtonSettings" ); 853 Config cfg ( "ButtonSettings" );
854 854
855 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 855 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
856 ODeviceButton &b = ( *d-> m_buttons ) [i]; 856 ODeviceButton &b = ( *d-> m_buttons ) [i];
857 QString group = "Button" + QString::number ( i ); 857 QString group = "Button" + QString::number ( i );
858 858
859 QCString pch, hch; 859 QCString pch, hch;
860 QCString pm, hm; 860 QCString pm, hm;
861 QByteArray pdata, hdata; 861 QByteArray pdata, hdata;
862 862
863 if ( cfg. hasGroup ( group )) { 863 if ( cfg. hasGroup ( group )) {
864 cfg. setGroup ( group ); 864 cfg. setGroup ( group );
865 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 865 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
866 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 866 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
867 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 867 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
868 868
869 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 869 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
870 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 870 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
871 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 871 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
872 } 872 }
873 873
874 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 874 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
875 875
876 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 876 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
877 } 877 }
878} 878}
879 879
880void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 880void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
881{ 881{
882 initButtons ( ); 882 initButtons ( );
883 883
884 QString mb_chan; 884 QString mb_chan;
885 885
886 if ( button >= (int) d-> m_buttons-> count ( )) 886 if ( button >= (int) d-> m_buttons-> count ( ))
887 return; 887 return;
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 18ff5f1..f2f6467 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -105,145 +105,144 @@ enum OLedState {
105enum OLed { 105enum OLed {
106 Led_Mail, 106 Led_Mail,
107 Led_Power, 107 Led_Power,
108 Led_BlueTooth 108 Led_BlueTooth
109}; 109};
110 110
111enum OHardKey { 111enum OHardKey {
112 HardKey_Datebook = Qt::Key_F9, 112 HardKey_Datebook = Qt::Key_F9,
113 HardKey_Contacts = Qt::Key_F10, 113 HardKey_Contacts = Qt::Key_F10,
114 HardKey_Menu = Qt::Key_F11, 114 HardKey_Menu = Qt::Key_F11,
115 HardKey_Home = Qt::Key_F12, 115 HardKey_Home = Qt::Key_F12,
116 HardKey_Mail = Qt::Key_F13, 116 HardKey_Mail = Qt::Key_F13,
117 HardKey_Record = Qt::Key_F24, 117 HardKey_Record = Qt::Key_F24,
118 HardKey_Suspend = Qt::Key_F34, 118 HardKey_Suspend = Qt::Key_F34,
119 HardKey_Backlight = Qt::Key_F35, 119 HardKey_Backlight = Qt::Key_F35,
120}; 120};
121 121
122enum ODirection { 122enum ODirection {
123 CW = 0, 123 CW = 0,
124 CCW = 1, 124 CCW = 1,
125 Flip = 2, 125 Flip = 2,
126}; 126};
127 127
128/** 128/**
129 * A singleton which gives informations about device specefic option 129 * A singleton which gives informations about device specefic option
130 * like the Hardware used, LEDs, the Base Distribution and 130 * like the Hardware used, LEDs, the Base Distribution and
131 * hardware key mappings. 131 * hardware key mappings.
132 * 132 *
133 * @short A small class for device specefic options 133 * @short A small class for device specefic options
134 * @see QObject 134 * @see QObject
135 * @author Robert Griebl 135 * @author Robert Griebl
136 * @version 1.0 136 * @version 1.0
137 */ 137 */
138class ODevice : public QObject { 138class ODevice : public QObject {
139 Q_OBJECT 139 Q_OBJECT
140 140
141private: 141private:
142 /* disable copy */ 142 /* disable copy */
143 ODevice ( const ODevice & ); 143 ODevice ( const ODevice & );
144 144
145protected: 145protected:
146 ODevice ( ); 146 ODevice ( );
147 virtual void init ( ); 147 virtual void init ( );
148 virtual void initButtons ( ); 148 virtual void initButtons ( );
149 149
150 ODeviceData *d; 150 ODeviceData *d;
151 151
152public: 152public:
153 // sandman do we want to allow destructions? -zecke? 153 // sandman do we want to allow destructions? -zecke?
154 virtual ~ODevice ( ); 154 virtual ~ODevice ( );
155 155
156 static ODevice *inst ( ); 156 static ODevice *inst ( );
157 157
158 // information 158 // information
159 159
160 QString modelString ( ) const; 160 QString modelString ( ) const;
161 OModel model ( ) const; 161 OModel model ( ) const;
162 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 162 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
163 163
164 QString vendorString ( ) const; 164 QString vendorString ( ) const;
165 OVendor vendor ( ) const; 165 OVendor vendor ( ) const;
166 166
167 QString systemString ( ) const; 167 QString systemString ( ) const;
168 OSystem system ( ) const; 168 OSystem system ( ) const;
169 169
170 QString systemVersionString ( ) const; 170 QString systemVersionString ( ) const;
171 171
172 Transformation rotation ( ) const; 172 Transformation rotation ( ) const;
173 ODirection direction ( ) const; 173 ODirection direction ( ) const;
174 174
175// system 175// system
176 176
177 virtual bool setSoftSuspend ( bool on ); 177 virtual bool setSoftSuspend ( bool on );
178 virtual bool suspend ( ); 178 virtual bool suspend ( );
179 179
180 virtual bool setDisplayStatus ( bool on ); 180 virtual bool setDisplayStatus ( bool on );
181 virtual bool setDisplayBrightness ( int brightness ); 181 virtual bool setDisplayBrightness ( int brightness );
182 virtual int displayBrightnessResolution ( ) const; 182 virtual int displayBrightnessResolution ( ) const;
183 virtual bool setDisplayContrast ( int contrast ); 183 virtual bool setDisplayContrast ( int contrast );
184 virtual int displayContrastResolution ( ) const; 184 virtual int displayContrastResolution ( ) const;
185 185
186// input / output 186// input / output
187 //FIXME playAlarmSound and al might be better -zecke 187 //FIXME playAlarmSound and al might be better -zecke
188 virtual void alarmSound ( ); 188 virtual void alarmSound ( );
189 virtual void keySound ( ); 189 virtual void keySound ( );
190 virtual void touchSound ( ); 190 virtual void touchSound ( );
191 191
192 virtual QValueList <OLed> ledList ( ) const; 192 virtual QValueList <OLed> ledList ( ) const;
193 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 193 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
194 virtual OLedState ledState ( OLed led ) const; 194 virtual OLedState ledState ( OLed led ) const;
195 virtual bool setLedState ( OLed led, OLedState st ); 195 virtual bool setLedState ( OLed led, OLedState st );
196 196
197 virtual bool hasLightSensor ( ) const; 197 virtual bool hasLightSensor ( ) const;
198 virtual int readLightSensor ( ); 198 virtual int readLightSensor ( );
199 virtual int lightSensorResolution ( ) const; 199 virtual int lightSensorResolution ( ) const;
200 200
201 QStrList &cpuFrequencies() const; 201 const QStrList &allowedCpuFrequencies() const;
202 bool setCpuFrequency(uint index); 202 bool setCurrentCpuFrequency(uint index);
203 int cpuFrequency() const;
204 203
205 /** 204 /**
206 * Returns the available buttons on this device. The number and location 205 * Returns the available buttons on this device. The number and location
207 * of buttons will vary depending on the device. Button numbers will be assigned 206 * of buttons will vary depending on the device. Button numbers will be assigned
208 * by the device manufacturer and will be from most preferred button to least preffered 207 * by the device manufacturer and will be from most preferred button to least preffered
209 * button. Note that this list only contains "user mappable" buttons. 208 * button. Note that this list only contains "user mappable" buttons.
210 */ 209 */
211 const QValueList<ODeviceButton> &buttons ( ); 210 const QValueList<ODeviceButton> &buttons ( );
212 211
213 /** 212 /**
214 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 213 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
215 * returns 0L 214 * returns 0L
216 */ 215 */
217 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 216 const ODeviceButton *buttonForKeycode ( ushort keyCode );
218 217
219 /** 218 /**
220 * Reassigns the pressed action for \a button. To return to the factory 219 * Reassigns the pressed action for \a button. To return to the factory
221 * default pass an empty string as \a qcopMessage. 220 * default pass an empty string as \a qcopMessage.
222 */ 221 */
223 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 222 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
224 223
225 /** 224 /**
226 * Reassigns the held action for \a button. To return to the factory 225 * Reassigns the held action for \a button. To return to the factory
227 * default pass an empty string as \a qcopMessage. 226 * default pass an empty string as \a qcopMessage.
228 */ 227 */
229 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 228 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
230 229
231 /** 230 /**
232 * How long (in ms) you have to press a button for a "hold" action 231 * How long (in ms) you have to press a button for a "hold" action
233 */ 232 */
234 uint buttonHoldTime ( ) const; 233 uint buttonHoldTime ( ) const;
235 234
236signals: 235signals:
237 void buttonMappingChanged ( ); 236 void buttonMappingChanged ( );
238 237
239private slots: 238private slots:
240 void systemMessage ( const QCString &, const QByteArray & ); 239 void systemMessage ( const QCString &, const QByteArray & );
241 240
242protected: 241protected:
243 void reloadButtonMapping ( ); 242 void reloadButtonMapping ( );
244}; 243};
245 244
246} 245}
247 246
248#endif 247#endif
249 248