Skip to content

Commit b7d0bf3

Browse files
committed
using threshold expressed in cm
1 parent 0fbc915 commit b7d0bf3

4 files changed

+17
-50
lines changed

ConfigDialog.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent)
1010
//setup
1111
mainWnd_ = dynamic_cast<VirtualTouchScreen*>(parent);
1212
if (NULL != mainWnd_) {
13-
ui_.doubleSpinBoxThreshold->setValue(mainWnd_->virtualScreenThreshold_);
13+
ui_.spinBoxThreshold->setValue(static_cast<int>(100*mainWnd_->virtualScreenThreshold_));
1414
ui_.spinBoxOffsetX->setValue(mainWnd_->offset.x());
1515
ui_.spinBoxOffsetY->setValue(mainWnd_->offset.y());
1616
ui_.spinBoxScaleFactor->setValue(static_cast<int>(100*mainWnd_->scaleFactor));
@@ -61,7 +61,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent)
6161

6262
void ConfigDialog::onBrowse()
6363
{
64-
QFileDialog openFile(NULL, "Select an Image File");//always in the center of the screen
64+
QFileDialog openFile(this, "Select an Image File");//always in the center of the screen
6565
openFile.setFileMode(QFileDialog::ExistingFile);
6666
openFile.setViewMode(QFileDialog::Detail);
6767
openFile.setNameFilter("*.png *.jpg *.jpeg");
@@ -103,7 +103,7 @@ void ConfigDialog::onCancel()
103103
void ConfigDialog::onApply()
104104
{
105105
if (NULL != mainWnd_) {
106-
mainWnd_->virtualScreenThreshold_ = ui_.doubleSpinBoxThreshold->value();
106+
mainWnd_->virtualScreenThreshold_ = ui_.spinBoxThreshold->value()/100.0;
107107
mainWnd_->offset.setX(ui_.spinBoxOffsetX->value());
108108
mainWnd_->offset.setY(ui_.spinBoxOffsetY->value());
109109
mainWnd_->scaleFactor = ui_.spinBoxScaleFactor->value()/100.0;

VirtualTouchScreen.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ VirtualTouchScreen::VirtualTouchScreen(QWidget *parent)
2424
config(NULL),
2525
handSkeletonPoints_(Hand::POINTS),
2626
touch_(new TouchInputEmulator()),
27-
virtualScreenThreshold_(VIRTUAL_SCREEN_THRESHOLD_x100/100.0),
27+
virtualScreenThreshold_(VIRTUAL_SCREEN_THRESHOLD_CM/100.0),
2828
fingerIcon_(FINGER_DEFAULT_ICON),
2929
fingerIconSize_(FINGER_ICON_SIZE),
3030
hideThumb_(false)
@@ -246,7 +246,7 @@ void VirtualTouchScreen::loadSettings()
246246
{
247247
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
248248
virtualScreenThreshold_ = settings.value(KEY_VIRTUAL_SCREEN_THRESHOLD,
249-
VIRTUAL_SCREEN_THRESHOLD_x100/100.0).toDouble();
249+
VIRTUAL_SCREEN_THRESHOLD_CM/100.0).toDouble();
250250
fingerIcon_ = settings.value(KEY_FINGER_ICON, FINGER_DEFAULT_ICON).toString();
251251
fingerIconSize_ = settings.value(KEY_FINGER_ICON_SIZE, FINGER_ICON_SIZE).toInt();
252252
hideThumb_ = settings.value(KEY_HIDE_THUMB, false).toBool();

VirtualTouchScreen.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class VirtualTouchScreen : public QMainWindow
2525
~VirtualTouchScreen();
2626
enum {OFFSET_X = 200, OFFSET_Y = 100,
2727
SCALE_FACTOR_x100 = 100,
28-
VIRTUAL_SCREEN_THRESHOLD_x100 = 35,
28+
VIRTUAL_SCREEN_THRESHOLD_CM = 35,
2929
FINGER_ICON_SIZE = 32};
3030
enum Hand {THUMB = 0, INDEX, POINTS};
3131
public slots:

configuration.ui

+11-44
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>273</width>
10-
<height>361</height>
10+
<height>349</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -20,7 +20,7 @@
2020
<property name="geometry">
2121
<rect>
2222
<x>20</x>
23-
<y>320</y>
23+
<y>310</y>
2424
<width>231</width>
2525
<height>32</height>
2626
</rect>
@@ -35,63 +35,30 @@
3535
<widget class="QWidget" name="horizontalLayoutWidget">
3636
<property name="geometry">
3737
<rect>
38-
<x>18</x>
38+
<x>28</x>
3939
<y>10</y>
40-
<width>231</width>
40+
<width>211</width>
4141
<height>31</height>
4242
</rect>
4343
</property>
4444
<layout class="QHBoxLayout" name="horizontalLayout">
45-
<item>
46-
<spacer name="horizontalSpacer">
47-
<property name="orientation">
48-
<enum>Qt::Horizontal</enum>
49-
</property>
50-
<property name="sizeHint" stdset="0">
51-
<size>
52-
<width>40</width>
53-
<height>20</height>
54-
</size>
55-
</property>
56-
</spacer>
57-
</item>
5845
<item>
5946
<widget class="QLabel" name="label">
6047
<property name="text">
61-
<string>Virtual Screen Threshold</string>
48+
<string>Virtual Screen Threshold [cm]</string>
6249
</property>
6350
</widget>
6451
</item>
6552
<item>
66-
<widget class="QDoubleSpinBox" name="doubleSpinBoxThreshold">
67-
<property name="maximum">
68-
<double>999.990000000000009</double>
69-
</property>
70-
<property name="singleStep">
71-
<double>0.100000000000000</double>
72-
</property>
73-
</widget>
74-
</item>
75-
<item>
76-
<spacer name="horizontalSpacer_2">
77-
<property name="orientation">
78-
<enum>Qt::Horizontal</enum>
79-
</property>
80-
<property name="sizeHint" stdset="0">
81-
<size>
82-
<width>40</width>
83-
<height>20</height>
84-
</size>
85-
</property>
86-
</spacer>
53+
<widget class="QSpinBox" name="spinBoxThreshold"/>
8754
</item>
8855
</layout>
8956
</widget>
9057
<widget class="QGroupBox" name="groupBox">
9158
<property name="geometry">
9259
<rect>
9360
<x>20</x>
94-
<y>50</y>
61+
<y>180</y>
9562
<width>231</width>
9663
<height>121</height>
9764
</rect>
@@ -182,9 +149,9 @@
182149
<property name="geometry">
183150
<rect>
184151
<x>20</x>
185-
<y>180</y>
152+
<y>50</y>
186153
<width>231</width>
187-
<height>131</height>
154+
<height>121</height>
188155
</rect>
189156
</property>
190157
<property name="title">
@@ -220,7 +187,7 @@
220187
<property name="geometry">
221188
<rect>
222189
<x>10</x>
223-
<y>60</y>
190+
<y>50</y>
224191
<width>171</width>
225192
<height>31</height>
226193
</rect>
@@ -246,7 +213,7 @@
246213
<property name="geometry">
247214
<rect>
248215
<x>10</x>
249-
<y>100</y>
216+
<y>80</y>
250217
<width>171</width>
251218
<height>31</height>
252219
</rect>

0 commit comments

Comments
 (0)