-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
104 lines (65 loc) · 2.49 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "mainwindow.h"
#include "mousewidget.h"
#include "optionsdialog.h"
#include <QApplication>
// disable consol output
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN32
QApplication* temp = new QApplication(argc, argv);
QScreen* _screen = QApplication::screens().at(0);
QSize _MyRect = _screen->size();
double width = _MyRect.width();
// assumes that the default desktop resolution is 720p (scale of 1)
int minWidth = 1920;
delete temp;
double scale = width / minWidth;
std::string scaleAsString = std::to_string(scale);
QByteArray scaleAsQByteArray(scaleAsString.c_str(), scaleAsString.length());
qputenv("QT_SCALE_FACTOR", scaleAsQByteArray);
#endif
QApplication a(argc, argv);
MainWindow w;
MouseWidget m;
#ifdef Q_OS_WIN32
w.setWindowFlags(Qt::WindowCloseButtonHint);
#endif
w.show();
w.pm = &m;
w.readSerialized("parameters.bin");
// qDebug() << "1 init" << w.language;
w.initiateDialogs();
if(w.language)w.changeLanguage(w.language);
//w.changeCamera(w.cameraIndex);
#ifdef Q_OS_WIN32
m.setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
#endif
#ifdef Q_OS_MAC
m.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowTransparentForInput);
m.setAttribute(Qt::WA_TranslucentBackground);
#endif
m.setAttribute( Qt::WA_TransparentForMouseEvents );
m.resetPointer();
QScreen* screen = QApplication::screens().at(0);
QSize MyRect = screen->size();
w.tracker->horLimit = (int)MyRect.width();
w.tracker->vertLimit = (int)MyRect.height();
m.horLimit = (int)MyRect.width();
m.vertLimit = (int)MyRect.height();
m.show();
m.setAttribute( Qt::WA_QuitOnClose, false );
// connect tracker and cursor
MainWindow::connect(w.tracker, SIGNAL(cursorPosition(QPoint)),
&m, SLOT(updatePosition(QPoint)));
// connect dwell and click
MainWindow::connect(w.tracker, SIGNAL(cursorDisplacement(float)),
&m, SLOT(dwellDetecting(float)));
// connect smile and click
MainWindow::connect(w.tracker, SIGNAL(quickClickSignal(bool)),
&m, SLOT(quickSmileDetecting(bool)));
// return control to left click after drag&drop or right click
MainWindow::connect(&m, SIGNAL(returnTo1Click()),
&w, SLOT (onClick1Button_pressed()));
return a.exec();
}