summaryrefslogtreecommitdiff
path: root/core/settings/light-and-power/sensor.cpp
Unidiff
Diffstat (limited to 'core/settings/light-and-power/sensor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/sensor.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/core/settings/light-and-power/sensor.cpp b/core/settings/light-and-power/sensor.cpp
index c1df04d..5ca54d4 100644
--- a/core/settings/light-and-power/sensor.cpp
+++ b/core/settings/light-and-power/sensor.cpp
@@ -21,65 +21,83 @@
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#include <qframe.h> 28#include <qframe.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qspinbox.h> 31#include <qspinbox.h>
32 32
33#include <opie/odevice.h>
34
35using namespace Opie;
36
33#include "calibration.h" 37#include "calibration.h"
34#include "sensor.h" 38#include "sensor.h"
35 39
36Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name ) 40Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name )
37 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params ) 41 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params )
38{ 42{
39 int steps = 12; 43 int steps = 12;
40 int inter = 2; 44 int inter = 2;
41 45
42 int smin = 40; 46 int smin = 40;
43 int smax = 215; 47 int smax = 215;
44 int lmin = 1; 48 int lmin = 1;
45 int lmax = 255; 49 int lmax = 255;
46 50
47 switch ( params. count ( )) { 51 switch ( params. count ( )) {
48 case 6: lmax = params [5]. toInt ( ); 52 case 6: lmax = params [5]. toInt ( );
49 case 5: lmin = params [4]. toInt ( ); 53 case 5: lmin = params [4]. toInt ( );
50 case 4: smax = params [3]. toInt ( ); 54 case 4: smax = params [3]. toInt ( );
51 case 3: smin = params [2]. toInt ( ); 55 case 3: smin = params [2]. toInt ( );
52 case 2: steps = params [1]. toInt ( ); 56 case 2: steps = params [1]. toInt ( );
53 case 1: inter = params [0]. toInt ( ) / 1000; 57 case 1: inter = params [0]. toInt ( ) / 1000;
54 } 58 }
59
60 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
61 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
55 62
56 QVBoxLayout *lay = new QVBoxLayout ( frame ); 63 QVBoxLayout *lay = new QVBoxLayout ( frame );
57 lay-> setMargin ( 2 ); 64 lay-> setMargin ( 2 );
58 m_calib = new Calibration ( frame ); 65 m_calib = new Calibration ( frame );
59 lay-> add ( m_calib ); 66 lay-> add ( m_calib );
60 67
61 m_calib-> setScale ( QSize ( 256, 256 )); 68 m_calib-> setScale ( QSize ( xscale, yscale ));
62 m_calib-> setLineSteps ( steps ); 69 m_calib-> setLineSteps ( steps );
63 m_calib-> setInterval ( inter ); 70 m_calib-> setInterval ( inter );
64 m_calib-> setStartPoint ( QPoint ( smin, lmax )); 71 m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 ));
65 m_calib-> setEndPoint ( QPoint ( smax, lmin )); 72 m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 ));
66 73
67 interval-> setValue ( inter ); 74 interval-> setValue ( inter );
68 linesteps-> setValue ( steps ); 75 linesteps-> setValue ( steps );
69 76
70 connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int ))); 77 connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int )));
71 connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int ))); 78 connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int )));
79
80 connect ( m_calib, SIGNAL( startPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & )));
81 connect ( m_calib, SIGNAL( endPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & )));
72} 82}
73 83
74void Sensor::accept ( ) 84void Sensor::accept ( )
75{ 85{
86 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
87 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
88
76 m_params. clear ( ); 89 m_params. clear ( );
77 m_params << QString::number ( m_calib-> interval ( ) * 1000 ) 90 m_params << QString::number ( m_calib-> interval ( ) * 1000 )
78 << QString::number ( m_calib-> lineSteps ( )) 91 << QString::number ( m_calib-> lineSteps ( ))
79 << QString::number ( m_calib-> startPoint ( ). x ( )) 92 << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale )
80 << QString::number ( m_calib-> endPoint ( ). x ( )) 93 << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale )
81 << QString::number ( m_calib-> endPoint ( ). y ( )) 94 << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale )
82 << QString::number ( m_calib-> startPoint ( ). y ( )); 95 << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale );
83 96
84 QDialog::accept ( ); 97 QDialog::accept ( );
85} 98}
99
100void Sensor::pointDrag ( const QPoint &p )
101{
102 emit viewBacklight ( p. y ( ));
103}