-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (29 loc) · 1.4 KB
/
main.cpp
File metadata and controls
40 lines (29 loc) · 1.4 KB
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
#include "settingswindow.h"
#include "screenanalyzer.h"
#include "ledostalker.h"
#include <QApplication>
#include <QColor>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// This is a hack to prevent some OS to pause executing the program when the window is not visible
a.setQuitOnLastWindowClosed(false);
// The settings window allows the user to control the program
SettingsWindow window;
window.show();
// The Screen Analyzer class outputs a single color based on the image displayed on the screen
ScreenAnalyzer analyzer;
// LEDOS Talker communicates color from the Screen Analyzer to LEDOS
LEDOSTalker talker;
// Whenever the user "starts" the program, start the analysis thread
QObject::connect( &window, SIGNAL(start()), &analyzer, SLOT(start()) );
// And stop it when the user doesn't need it anymore
QObject::connect( &window, SIGNAL(stop()), &analyzer, SLOT(stop()) );
// Close the program when the window is closed
QObject::connect( &window, SIGNAL(quit()), &a, SLOT(quit()) );
// When a serial port is selected, update it in the LEDOS Talker instance
QObject::connect( &window, SIGNAL(serial(QString)), &talker, SLOT(serial(QString)) );
// Every time a color is ready to be sent pass it to the LEDOS Talker
QObject::connect( &analyzer, SIGNAL(color(QColor)), &talker, SLOT(color(QColor)) );
return a.exec();
}