-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqcmainclass.cpp
More file actions
35 lines (30 loc) · 1.08 KB
/
Copy pathqcmainclass.cpp
File metadata and controls
35 lines (30 loc) · 1.08 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
#include "qcmainclass.h"
QCMainClass::QCMainClass(QObject *parent, bool RunAsConsole) {
this->RunAsConsole= RunAsConsole;
if (RunAsConsole) {
QCKeyboard *Keyboard= new QCKeyboard(parent);
connect(Keyboard, SIGNAL(OnData(QString)), this, SLOT(OnData(QString)));
}
connect(&Timer, SIGNAL(timeout()), this, SLOT(TimerTimeout()));
Timer.start(1000);
UpdateLog("QCMainClass::QCMainClass()");
}
QCMainClass::~QCMainClass() {
UpdateLog("QCMainClass::~QCMainClass()");
}
void QCMainClass::OnData(QString Data) {
if (Data.compare("q", Qt::CaseInsensitive)== 0) {
QCoreApplication::instance()->quit();
}
}
void QCMainClass::TimerTimeout() {
UpdateLog("run...");
}
void QCMainClass::UpdateLog(QString Log) {
QFile FileLog(QDateTime::currentDateTime().toString("yyyyMMdd")+ ".log");
if (FileLog.open(QIODevice::Append)) {
FileLog.write(QString(QDateTime::currentDateTime().toString("[hh:mm:ss] ")+ Log+ "\n").toLatin1());
FileLog.close();
}
if (RunAsConsole) qDebug() << Log;
}