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 | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/core/settings/light-and-power/sensor.cpp b/core/settings/light-and-power/sensor.cpp new file mode 100644 index 0000000..ddd71d6 --- a/dev/null +++ b/core/settings/light-and-power/sensor.cpp | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> | ||
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This file is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This file is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | ||
18 | ..}^=.= = ; Public License for more details. | ||
19 | ++= -. .` .: | ||
20 | : = ...= . :.=- You should have received a copy of the GNU | ||
21 | -. .:....=;==+<; General Public License along with this file; | ||
22 | -_. . . )=. = see the file COPYING. If not, write to the | ||
23 | -- :-=` Free Software Foundation, Inc., | ||
24 | 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | #include <qframe.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qslider.h> | ||
31 | #include <qspinbox.h> | ||
32 | |||
33 | #include "calibration.h" | ||
34 | #include "sensor.h" | ||
35 | |||
36 | Sensor::Sensor ( QStringList ¶ms, QWidget *parent, const char *name ) | ||
37 | : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params ) | ||
38 | { | ||
39 | int steps = 5; | ||
40 | int inter = 5; | ||
41 | |||
42 | int smin = 0; | ||
43 | int smax = 255; | ||
44 | int lmin = 0; | ||
45 | int lmax = 255; | ||
46 | |||
47 | switch ( params. count ( )) { | ||
48 | case 6: lmax = params [5]. toInt ( ); | ||
49 | case 5: lmin = params [4]. toInt ( ); | ||
50 | case 4: smax = params [3]. toInt ( ); | ||
51 | case 3: smin = params [2]. toInt ( ); | ||
52 | case 2: steps = params [1]. toInt ( ); | ||
53 | case 1: inter = params [0]. toInt ( ); | ||
54 | } | ||
55 | |||
56 | QVBoxLayout *lay = new QVBoxLayout ( frame ); | ||
57 | lay-> setMargin ( 2 ); | ||
58 | m_calib = new Calibration ( frame ); | ||
59 | lay-> add ( m_calib ); | ||
60 | |||
61 | m_calib-> setScale ( QSize ( 256, 256 )); | ||
62 | m_calib-> setLineSteps ( steps ); | ||
63 | m_calib-> setInterval ( inter ); | ||
64 | m_calib-> setStartPoint ( QPoint ( smin, lmin )); | ||
65 | m_calib-> setEndPoint ( QPoint ( smax, lmax )); | ||
66 | |||
67 | interval-> setValue ( inter ); | ||
68 | linesteps-> setValue ( steps ); | ||
69 | |||
70 | connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int ))); | ||
71 | connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int ))); | ||
72 | } | ||
73 | |||
74 | void Sensor::accept ( ) | ||
75 | { | ||
76 | m_params. clear ( ); | ||
77 | m_params << QString::number ( m_calib-> interval ( )) | ||
78 | << QString::number ( m_calib-> lineSteps ( )) | ||
79 | << QString::number ( m_calib-> startPoint ( ). x ( )) | ||
80 | << QString::number ( m_calib-> endPoint ( ). x ( )) | ||
81 | << QString::number ( m_calib-> startPoint ( ). y ( )) | ||
82 | << QString::number ( m_calib-> endPoint ( ). y ( )); | ||
83 | |||
84 | QDialog::accept ( ); | ||
85 | } | ||