From 33dbbfe57cb0a5a7de5600ea052e19b7bb5cb674 Mon Sep 17 00:00:00 2001 From: schurig Date: Thu, 05 Jun 2003 15:01:01 +0000 Subject: initial contrast support. You won't see anything unless ODevice::displayContrastResulution() returns != 0. --- (limited to 'core/settings') 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 @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -51,13 +52,20 @@ using namespace Opie; LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) { - m_res = ODevice::inst ( )-> displayBrightnessResolution ( ); + m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); + m_cres = ODevice::inst ( )-> displayContrastResolution ( ); if ( !ODevice::inst ( )-> hasLightSensor ( )) { auto_brightness-> hide ( ); CalibrateLightSensor-> hide ( ); - auto_brightness_ac_3-> hide ( ); - CalibrateLightSensorAC-> hide ( ); + auto_brightness_ac-> hide ( ); + CalibrateLightSensor_ac-> hide ( ); + } + if (m_cres) { + GroupLight->setTitle(tr("Backlight & Contrast")); + } else { + contrast->hide(); + contrast_ac->hide(); } Config config ( "apm" ); @@ -72,11 +80,20 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); int bright = config. readNumEntry ( "Brightness", 127 ); - brightness-> setMaxValue ( m_res - 1 ); - brightness-> setTickInterval ( QMAX( 1, m_res / 16 )); - brightness-> setLineStep ( QMAX( 1, m_res / 16 )); - brightness-> setPageStep ( QMAX( 1, m_res / 16 )); - brightness-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); + int contr = config. readNumEntry ( "Contrast", 127 ); + brightness-> setMaxValue ( m_bres - 1 ); + brightness-> setTickInterval ( QMAX( 1, m_bres / 16 )); + brightness-> setLineStep ( QMAX( 1, m_bres / 16 )); + brightness-> setPageStep ( QMAX( 1, m_bres / 16 )); + brightness-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); + + if (m_cres) { + contrast-> setMaxValue ( m_cres - 1 ); + contrast-> setTickInterval ( QMAX( 1, m_cres / 16 )); + contrast-> setLineStep ( QMAX( 1, m_cres / 16 )); + contrast-> setPageStep ( QMAX( 1, m_cres / 16 )); + contrast-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); + } // light sensor auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); @@ -85,22 +102,31 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) config. setGroup ( "AC" ); // ac spinboxes - interval_dim_ac_3-> setValue ( config. readNumEntry ( "Dim", 60 )); - interval_lightoff_ac_3-> setValue ( config. readNumEntry ( "LightOff", 120 )); - interval_suspend_ac_3-> setValue ( config. readNumEntry ( "Suspend", 0 )); + 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 - LcdOffOnly_2_3-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); + LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); bright = config. readNumEntry ( "Brightness", 255 ); - brightness_ac_3-> setMaxValue ( m_res - 1 ); - brightness_ac_3-> setTickInterval ( QMAX( 1, m_res / 16 )); - brightness_ac_3-> setLineStep ( QMAX( 1, m_res / 16 )); - brightness_ac_3-> setPageStep ( QMAX( 1, m_res / 16 )); - brightness_ac_3-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); + brightness_ac-> setMaxValue ( m_bres - 1 ); + brightness_ac-> setTickInterval ( QMAX( 1, m_bres / 16 )); + brightness_ac-> setLineStep ( QMAX( 1, m_bres / 16 )); + brightness_ac-> setPageStep ( QMAX( 1, m_bres / 16 )); + brightness_ac-> setValue (( bright * ( m_bres - 1 ) + 127 ) / 255 ); + + if (m_cres) { + contr = config. readNumEntry ( "Contrast", 127); + contrast_ac-> setMaxValue ( m_cres - 1 ); + contrast_ac-> setTickInterval ( QMAX( 1, m_cres / 16 )); + contrast_ac-> setLineStep ( QMAX( 1, m_cres / 16 )); + contrast_ac-> setPageStep ( QMAX( 1, m_cres / 16 )); + contrast_ac-> setValue (( contr * ( m_cres - 1 ) + 127 ) / 255 ); + } // light sensor - auto_brightness_ac_3-> setChecked ( config. readBoolEntry ( "LightSensor", false )); + auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); // advanced settings @@ -120,7 +146,11 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) } connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); - connect ( brightness_ac_3, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); + connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); + if (m_havecontrast) { + connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); + connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); + } } LightSettings::~LightSettings ( ) @@ -148,7 +178,7 @@ void LightSettings::calibrateSensorAC ( ) void LightSettings::setBacklight ( int bright ) { if ( bright >= 0 ) - bright = bright * 255 / ( m_res - 1 ); + bright = bright * 255 / ( m_bres - 1 ); QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); e << bright; @@ -159,9 +189,24 @@ void LightSettings::setBacklight ( int bright ) } } +void LightSettings::setContrast ( int contr ) +{ + if ( contr >= 0 ) + contr = contr * 255 / ( m_cres - 1 ); + + QCopEnvelope e ( "QPE/System", "setContrast(int)" ); + e << contr; + + if ( contr != -1 ) { + m_resettimer-> stop ( ); + m_resettimer-> start ( 2000, true ); + } +} + void LightSettings::resetBacklight ( ) { setBacklight ( -1 ); + setContrast ( -1 ); } void LightSettings::accept ( ) @@ -174,15 +219,19 @@ void LightSettings::accept ( ) config. writeEntry ( "Dim", interval_dim-> value ( )); config. writeEntry ( "LightOff", interval_lightoff-> value ( )); config. writeEntry ( "Suspend", interval_suspend-> value ( )); - config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_res - 1 ) ); + config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_bres - 1 ) ); + if (m_cres) + config. writeEntry ( "Contrast", contrast-> value ( ) * 255 / ( m_cres - 1 ) ); // ac config. setGroup ( "AC" ); - config. writeEntry ( "LcdOffOnly", LcdOffOnly_2_3-> isChecked ( )); - config. writeEntry ( "Dim", interval_dim_ac_3-> value ( )); - config. writeEntry ( "LightOff", interval_lightoff_ac_3-> value ( )); - config. writeEntry ( "Suspend", interval_suspend_ac_3-> value ( )); - config. writeEntry ( "Brightness", brightness_ac_3-> value ( ) * 255 / ( m_res - 1 )); + 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 ( ) * 255 / ( m_bres - 1 )); + if (m_cres) + config. writeEntry ( "Contrast", contrast_ac-> value ( ) * 255 / ( m_cres - 1 )); // only make light sensor stuff appear if the unit has a sensor if ( ODevice::inst ( )-> hasLightSensor ( )) { @@ -190,7 +239,7 @@ void LightSettings::accept ( ) config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); config. writeEntry ( "LightSensorData", m_sensordata, ';' ); config. setGroup ( "AC" ); - config. writeEntry ( "LightSensor", auto_brightness_ac_3->isChecked() ); + config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); } diff --git a/core/settings/light-and-power/light.h b/core/settings/light-and-power/light.h index 0a3c60b..c9757da 100644 --- a/core/settings/light-and-power/light.h +++ b/core/settings/light-and-power/light.h @@ -50,10 +50,13 @@ protected slots: virtual void calibrateSensor ( ); virtual void calibrateSensorAC ( ); void setBacklight ( int ); + void setContrast ( int ); void resetBacklight ( ); private: - int m_res; + int m_bres; + int m_cres; + int m_havecontrast; QTimer *m_resettimer; QStringList m_sensordata; QStringList m_sensordata_ac; diff --git a/core/settings/light-and-power/lightsettingsbase.ui b/core/settings/light-and-power/lightsettingsbase.ui index 99bbd71..8fdd604 100644 --- a/core/settings/light-and-power/lightsettingsbase.ui +++ b/core/settings/light-and-power/lightsettingsbase.ui @@ -11,7 +11,7 @@ 0 0 - 363 + 355 532 @@ -276,7 +276,7 @@ QGroupBox name - GroupBox9 + GroupLight title @@ -291,11 +291,11 @@ margin - 5 + 11 spacing - 3 + 6 QSlider @@ -337,6 +337,45 @@ + QSlider + + name + contrast + + + maxValue + 255 + + + lineStep + 1 + + + pageStep + 16 + + + tracking + true + + + orientation + Horizontal + + + tickmarks + Right + + + tickInterval + 32 + + + whatsThis + set a fix value for contrast + + + QLayoutWidget name @@ -556,7 +595,7 @@ QSpinBox name - interval_lightoff_ac_3 + interval_lightoff_ac suffix @@ -605,7 +644,7 @@ QSpinBox name - interval_suspend_ac_3 + interval_suspend_ac suffix @@ -654,7 +693,7 @@ QSpinBox name - interval_dim_ac_3 + interval_dim_ac suffix @@ -703,7 +742,7 @@ QCheckBox name - LcdOffOnly_2_3 + LcdOffOnly_ac sizePolicy @@ -738,17 +777,60 @@ margin - 5 + 11 spacing - 3 + 6 QSlider name - brightness_ac_3 + brightness_ac + + + minValue + 0 + + + maxValue + 255 + + + lineStep + 16 + + + pageStep + 16 + + + value + 255 + + + tracking + true + + + orientation + Horizontal + + + tickmarks + Right + + + whatsThis + set a fix value for backlight + + + + QSlider + + name + contrast_ac minValue @@ -902,7 +984,7 @@ QCheckBox name - auto_brightness_ac_3 + auto_brightness_ac text @@ -917,7 +999,7 @@ QPushButton name - CalibrateLightSensorAC + CalibrateLightSensor_ac text @@ -1192,11 +1274,11 @@ image0 - 789c55d34b4fe2601487f13d9fa2811d9960cba5854c66a1584511046f209359f46d8b50b9df1427f3dda7cf31e2e13c2efebf77a118e349deea775a56fe24b3de049b716885a36065e5a3ed74bafffde7d7df4cd671adf4cb2d5b4ef647265bb042ab3d9fc5ec92daaeda35b5ab6adfaa9d533b56db537baaf650ed96da1db5efd53e55fb51ed2bb5376a3fa87da9f656ed62ba733543b002038f605928079f851141471813b485438203686c827d183a049f842ec1b5302038161a82d74239d880914d30103a0467c222c10f6185e099d023b813560946c21ac10ba121d8168604f74239d813c604cf616c13f4850ec177619160222c1334c20ac150e8126c0a3d8237c22ac13b618d6057287f24b8121a824b6148b02e94df014e847270048736c137a14370212c119c0bcb045f851ec117a121f907e4728109a358e6d7db307c496f34566f71f22a37997ebfcde68bc57cb15c99f5e6eb6dbb7b4bef7dbfdf7f9c1edeceea93ba39f77dffe2f076d9484c92186392ddd5e1fb5d376f3eaff1fd335ad152ae7dab3e5fa73b4aefaea53ff37d779e5ef341bf3dca87f68fde0a4f3ddfeff58f7edfc2f3c0769ce2f15ba93c1854dce3b78257ad0d3f57f6dfcfcc7f522034e9 + 789c5dd04d6ac3301005e0bd4f21ec5d280931b1c0941ca1a5cb42e962a4194956e2d8f9e9a294debd9e9168ec3cbcd0f72ca1b1372bf5fef6a2569be27a835b67950d70512bfceafbef8fcffd4f516eb59a9e7aabb6e55351ae9555afc389787d9ed6556bdbb6b5cc2b1376d0c08e79115a0090b74326258e4cb333b591cd27a66d6c6d1b669fa9134988162c328f99945831b1c11a65f32153271a2121a0cc1c3329b16392a69a3413327562101201c9669f4989c874dad54e36bb4c9d6885ce8173f2df24158049abff0eec14a479371de1f859573944873e00dd3b8353ba18e3e1de1dbcf7d04d31b3b39033eb8e1052aad9bdc64be262bec0b784e5cc81c78387efe0ae5b767decba785a76c3380cc379d9ad2fe3787df82fb394bfcfc51f5517a686 image1 - 789c75d5594fdb401007f0773e45c4bca1eadfc4b755f581fba6d0420b547db077d7248424908310aa7ef7ae6736ee9683c1917ed9b13d9e592b1fd75a97a7c7adb58f2b936931eda996ea16e3d69a9e0d068b9fbf3eff5e59ed24adfabf1db582d50f2bab67d3966a9d8c86a6066df9d8f371e8e3c0c7be8f231fca03c887f131f091fb17e8fad07edad847e5a7f5fc95637f65e8af843e36fcb4898fff6afbeee3c4c7a67f4e0dca4b1b8abd5bbb48eb606fb3f98fbd60ebc214157b836d0a53f28468ddb9727e665765bb0cd93bb5ad6cb09f6aeb5c2589664fd95a9569ccc5ded536460751c98e6a57818ec3845d386771c4ced8a12e42cea7b9d84459c6eb9a1de92a95e79b89ed7aceeb5c7f15ebbccdfdc00f6715707d982c1d49fd8f6293e46c6cb11313c41d76c94e4d9e73bfa09c8b829f8fc0ce4c184b7fc6ce59c6c617766ee250fa113827622a9dd398e7831b6795733f68c4b6e3c9a47f47ecd2a41d9e0f86ce4aee4777ce2693cdd217575129f3b965ab2ac8a59e0bb6362a907ae4feba0a32b1710e3399d7837324cf8f986daa3891fea5ce4922f5edb3ab2ae8c8f9078d797e386c2cf3fde61cba799d3b47813ccfded2a1e45f3ac7915cffbab15cbfdd58f2af1acb7e796e2cfbe56b639977c73971e7274b27b25f17cea9ec77a2c652ef9373964aff8ba533e9d76963b9fed9d2b9bc7f95732eef37769d8b5cfab3dd58eadd59ba90eb3f2e2def33668da5fe7963e9dfb4b1bc5f7de752d6e9c15929ee1fdd3796fdfbcfb25f478da51f3d676de47eb7cec6b9db38935f8c658050a0848286f9f7ad9f830a37e8a267e3167ddcbdcec100438c706f0ff97cc0f855ce0453ccf088b9fd7cc202cf58c7869f834d6c611b3bd8b5c71ef67180431ce1f8bf9c137cc129ceecf115df70ce71f122e73b7ee01257b8461b1d8e3602842fea891023f12245f6aae69c4044850ba292d4ebfe902643958b1beabed543ead12df5edb3cfa94f77347833674823bab7fdbba7071ad3e4ad1c9b35a5193dda98d3d3dbf3b2390b7aa675dab0b1f96ece166dd38e8d5dda7b2fc766edd3011dd291ffddea9f4f2b7f01e4bc2999 + 789c5dd35f53e2301000f0773e4507de981ba4a5443a37f7a028fe41101514bcb987344d0515a8b4a0e0dc77bfee6e36d0dbe121bf4d48361b38aa3ae341cfa91e95d24c6633e5a8a95c39d5683d9f6f7ffff9f55d2abbc2c93fcd63c72dff28956b8e72facb8586f1733eae042a080205f480d2974de903eb4825a5c4d927434d9c30435c3c26861ed105863ef31118692584043e18cae306700ad43af27c9cbd00c622120d2cf8c350d65bc02b66230056984d0f786ea83d9c7d67fab89562d2b92ba2f6e8bb4343d10a81236680579086927a1532a957d7c898b7fa32146e1db865d28d7acc26def7de50b6b0aa3b4b2ce3cc507bb8d58c498b0796b8386252cd1b62ec51199f96d8c95326f5aacfa49d6f99b455db50d0e235935ea1c3a43e279678c14ba6c0e62c99f40a5d4bbcc21b931afbc20c23e0c250d2e21b26d5bcb3c4d913265d21b5c417cc9874d09c49bfd857c358e1b931530ba0b6c4ff510da3224345239b8b74bee6657a989bbd62bc1de4dee7108b65f2b1cfadd22ccdd69bcde7d73eb7dd9dec92d376bb7db6cf9d77924e02b1dde72e2e4d5c1d9c7bddbdc9a3db2bd4d74ff3e8176bbe856206c5dc1d947c5fcc3d0c47a3e16331f7349e4c26cfc55cadeebade7f7d3988f2df9fa57f7da120b4 @@ -1207,7 +1289,7 @@ calibrateSensor() - CalibrateLightSensorAC + CalibrateLightSensor_ac clicked() LightSettingsBase calibrateSensorAC() @@ -1224,13 +1306,13 @@ auto_brightness CalibrateLightSensor tabs - interval_lightoff_ac_3 - interval_suspend_ac_3 - interval_dim_ac_3 - LcdOffOnly_2_3 - brightness_ac_3 - auto_brightness_ac_3 - CalibrateLightSensorAC + interval_lightoff_ac + interval_suspend_ac + interval_dim_ac + LcdOffOnly_ac + brightness_ac + auto_brightness_ac + CalibrateLightSensor_ac lowSpinBox warnintervalBox criticalSpinBox -- cgit v0.9.0.2