Diffstat (limited to 'core/settings/light-and-power/sensor.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/settings/light-and-power/sensor.cpp | 32 |
1 files changed, 25 insertions, 7 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 | |||
@@ -30,6 +30,10 @@ | |||
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qspinbox.h> | 31 | #include <qspinbox.h> |
32 | 32 | ||
33 | #include <opie/odevice.h> | ||
34 | |||
35 | using namespace Opie; | ||
36 | |||
33 | #include "calibration.h" | 37 | #include "calibration.h" |
34 | #include "sensor.h" | 38 | #include "sensor.h" |
35 | 39 | ||
@@ -53,33 +57,47 @@ Sensor::Sensor ( QStringList ¶ms, QWidget *parent, const char *name ) | |||
53 | case 1: inter = params [0]. toInt ( ) / 1000; | 57 | case 1: inter = params [0]. toInt ( ) / 1000; |
54 | } | 58 | } |
55 | 59 | ||
60 | int xscale = ODevice::inst ( )-> lightSensorResolution ( ); | ||
61 | int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); | ||
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 | ||
74 | void Sensor::accept ( ) | 84 | void 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 | |||
100 | void Sensor::pointDrag ( const QPoint &p ) | ||
101 | { | ||
102 | emit viewBacklight ( p. y ( )); | ||
103 | } | ||