-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.cpp
55 lines (48 loc) · 1.29 KB
/
app.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
#include "app.h"
#include "blefinder.h"
#include "sslserver.h"
#include "mainwindow.h"
#include <QtCore/QDebug>
App::App(QObject *parent) : QObject(parent)
{
m_mainWindow = 0;
m_bleFinder = 0;
m_server = 0;
}
void App::init() {
status("Espruino Host v" APP_VERSION);
m_bleFinder = new BleFinder(this);
m_server = new SslServer(this);
}
App::~App() {
delete m_mainWindow;
m_mainWindow = 0;
delete m_bleFinder;
delete m_server;
}
void App::gui() {
m_mainWindow = new MainWindow();
m_mainWindow->show();
}
void App::status(QString msg) {
qDebug() << "STATUS:" << msg;
if (m_mainWindow) {
m_mainWindow->addLogMessage("<p style=\"padding:0;margin:0;\"><b>"+msg+"</b></p>\n");
m_mainWindow->setStatus(msg);
}
}
void App::log(QString msg) {
qDebug() << msg;
if (m_mainWindow)
m_mainWindow->addLogMessage("<p style=\"padding:0;margin:0;\">"+msg+"</p>\n");
}
void App::warn(QString msg) {
qDebug() << "WARN:" << msg;
if (m_mainWindow)
m_mainWindow->addLogMessage("<p style=\"padding:0; margin:0;color:#E67E22\">"+msg+"</p>\n");
}
void App::error(QString msg) {
qDebug() << "ERROR:" << msg;
if (m_mainWindow)
m_mainWindow->addLogMessage("<p style=\"padding:0;margin:0;color:red;\">"+msg+"</p>\n");
}