-rw-r--r-- | core/settings/light-and-power/light.cpp | 4 | ||||
-rw-r--r-- | libopie/odevice.cpp | 8 | ||||
-rw-r--r-- | libopie/odevice.h | 5 |
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 @@ -25,97 +25,97 @@ Boston, MA 02111-1307, USA. */ #include "light.h" #include <qpe/config.h> #include <qpe/qpeapplication.h> #include <qpe/power.h> #if defined(Q_WS_QWS) && !defined(QT_NO_COP) #include <qpe/qcopenvelope_qws.h> #endif #include <qcheckbox.h> #include <qtabwidget.h> #include <qslider.h> #include <qtimer.h> #include <qspinbox.h> #include <qpushbutton.h> #include <qgroupbox.h> #include <qcombobox.h> #include <opie/odevice.h> #include "sensor.h" using namespace Opie; LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) { m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); m_cres = ODevice::inst ( )-> displayContrastResolution ( ); if ( !ODevice::inst ( )-> hasLightSensor ( )) { auto_brightness-> hide ( ); CalibrateLightSensor-> hide ( ); auto_brightness_ac-> hide ( ); CalibrateLightSensor_ac-> hide ( ); } if (m_cres) { GroupLight->setTitle(tr("Backlight && Contrast")); GroupLight_ac->setTitle(GroupLight->title()); } else { contrast->hide(); contrast_ac->hide(); } - QStrList freq = ODevice::inst()->cpuFrequencies(); + QStrList freq = ODevice::inst()->allowedCpuFrequencies(); if ( freq.count() ) { frequency->insertStrList( freq ); frequency_ac->insertStrList( freq ); } else { frequency->hide(); frequency_ac->hide(); } Config config ( "apm" ); config. setGroup ( "Battery" ); // battery spinboxes interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); // battery check and slider LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); // CPU frequency frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); int bright = config. readNumEntry ( "Brightness", 127 ); int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); brightness-> setValue ( bright ); if (m_cres) { contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); contrast-> setValue ( contr ); } // light sensor auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); m_sensordata = config. readListEntry ( "LightSensorData", ';' ); config. setGroup ( "AC" ); // ac spinboxes interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); // ac check and slider @@ -165,97 +165,97 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); } connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); } LightSettings::~LightSettings ( ) { } void LightSettings::calibrateSensor ( ) { Sensor *s = new Sensor ( m_sensordata, this ); connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); s-> showMaximized ( ); s-> exec ( ); delete s; } void LightSettings::calibrateSensorAC ( ) { Sensor *s = new Sensor ( m_sensordata_ac, this ); connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); s-> showMaximized ( ); s-> exec ( ); delete s; } void LightSettings::setBacklight ( int bright ) { QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); e << bright; if ( bright != -1 ) { m_resettimer-> stop ( ); m_resettimer-> start ( 4000, true ); } } void LightSettings::setContrast ( int contr ) { if (contr == -1) contr = m_oldcontrast; ODevice::inst ( )-> setDisplayContrast(contr); } void LightSettings::setFrequency ( int index ) { qWarning("LightSettings::setFrequency(%d)", index); - ODevice::inst ( )-> setCpuFrequency(index); + ODevice::inst ( )-> setCurrentCpuFrequency(index); } void LightSettings::resetBacklight ( ) { setBacklight ( -1 ); setContrast ( -1 ); } void LightSettings::accept ( ) { Config config ( "apm" ); // bat config. setGroup ( "Battery" ); config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); config. writeEntry ( "Dim", interval_dim-> value ( )); config. writeEntry ( "LightOff", interval_lightoff-> value ( )); config. writeEntry ( "Suspend", interval_suspend-> value ( )); config. writeEntry ( "Brightness", brightness-> value () ); if (m_cres) config. writeEntry ( "Contrast", contrast-> value () ); config. writeEntry ( "Freq", frequency->currentItem() ); // ac config. setGroup ( "AC" ); config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); config. writeEntry ( "Dim", interval_dim_ac-> value ( )); config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); config. writeEntry ( "Brightness", brightness_ac-> value () ); if (m_cres) config. writeEntry ( "Contrast", contrast_ac-> value () ); config. writeEntry ( "Freq", frequency_ac->currentItem() ); // only make light sensor stuff appear if the unit has a sensor if ( ODevice::inst ( )-> hasLightSensor ( )) { config. setGroup ( "Battery" ); config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); config. writeEntry ( "LightSensorData", m_sensordata, ';' ); config. setGroup ( "AC" ); config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); } // advanced config. setGroup ( "Warnings" ); config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 4c33a0e..d6e6892 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -730,110 +730,110 @@ QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const } /** * @return the state for a given OLed */ OLedState ODevice::ledState ( OLed /*which*/ ) const { return Led_Off; } /** * Set the state for a LED * @param which Which OLed to use * @param st The state to set * @return success or failure */ bool ODevice::setLedState ( OLed which, OLedState st ) { Q_UNUSED( which ) Q_UNUSED( st ) return false; } /** * @return if the device has a light sensor */ bool ODevice::hasLightSensor ( ) const { return false; } /** * @return a value from the light senso */ int ODevice::readLightSensor ( ) { return -1; } /** * @return the light sensor resolution whatever that is ;) */ int ODevice::lightSensorResolution ( ) const { return 0; } /** - * @return a list with valid CPU frequency + * @return a list with CPU frequencies supported by the hardware */ -QStrList &ODevice::cpuFrequencies ( ) const +const QStrList &ODevice::allowedCpuFrequencies ( ) const { return *d->m_cpu_frequencies; } /** - * Set desired cpu frequency + * Set desired CPU frequency * * @param index index into d->m_cpu_frequencies of the frequency to be set */ -bool ODevice::setCpuFrequency(uint index) +bool ODevice::setCurrentCpuFrequency(uint index) { if (index >= d->m_cpu_frequencies->count()) return false; char *freq = d->m_cpu_frequencies->at(index); qWarning("set freq to %s", freq); int fd; if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { char writeCommand[50]; const int count = sprintf(writeCommand, "%s\n", freq); int res = (::write(fd, writeCommand, count) != -1); ::close(fd); return res; } return false; } /** * @return a list of hardware buttons */ const QValueList <ODeviceButton> &ODevice::buttons ( ) { initButtons ( ); return *d-> m_buttons; } /** * @return The amount of time that would count as a hold */ uint ODevice::buttonHoldTime ( ) const { return d-> m_holdtime; } /** * This method return a ODeviceButton for a key code * or 0 if no special hardware button is available for the device * * @return The devicebutton or 0l * @see ODeviceButton */ const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) { diff --git a/libopie/odevice.h b/libopie/odevice.h index 18ff5f1..f2f6467 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h @@ -153,97 +153,96 @@ public: // sandman do we want to allow destructions? -zecke? virtual ~ODevice ( ); static ODevice *inst ( ); // information QString modelString ( ) const; OModel model ( ) const; inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } QString vendorString ( ) const; OVendor vendor ( ) const; QString systemString ( ) const; OSystem system ( ) const; QString systemVersionString ( ) const; Transformation rotation ( ) const; ODirection direction ( ) const; // system virtual bool setSoftSuspend ( bool on ); virtual bool suspend ( ); virtual bool setDisplayStatus ( bool on ); virtual bool setDisplayBrightness ( int brightness ); virtual int displayBrightnessResolution ( ) const; virtual bool setDisplayContrast ( int contrast ); virtual int displayContrastResolution ( ) const; // input / output //FIXME playAlarmSound and al might be better -zecke virtual void alarmSound ( ); virtual void keySound ( ); virtual void touchSound ( ); virtual QValueList <OLed> ledList ( ) const; virtual QValueList <OLedState> ledStateList ( OLed led ) const; virtual OLedState ledState ( OLed led ) const; virtual bool setLedState ( OLed led, OLedState st ); virtual bool hasLightSensor ( ) const; virtual int readLightSensor ( ); virtual int lightSensorResolution ( ) const; - QStrList &cpuFrequencies() const; - bool setCpuFrequency(uint index); - int cpuFrequency() const; + const QStrList &allowedCpuFrequencies() const; + bool setCurrentCpuFrequency(uint index); /** * Returns the available buttons on this device. The number and location * of buttons will vary depending on the device. Button numbers will be assigned * by the device manufacturer and will be from most preferred button to least preffered * button. Note that this list only contains "user mappable" buttons. */ const QValueList<ODeviceButton> &buttons ( ); /** * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it * returns 0L */ const ODeviceButton *buttonForKeycode ( ushort keyCode ); /** * Reassigns the pressed action for \a button. To return to the factory * default pass an empty string as \a qcopMessage. */ void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); /** * Reassigns the held action for \a button. To return to the factory * default pass an empty string as \a qcopMessage. */ void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); /** * How long (in ms) you have to press a button for a "hold" action */ uint buttonHoldTime ( ) const; signals: void buttonMappingChanged ( ); private slots: void systemMessage ( const QCString &, const QByteArray & ); protected: void reloadButtonMapping ( ); }; } #endif |