-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
72 lines (56 loc) · 1.91 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
#include "webwindow.h"
#include <QApplication>
#include <QTextCodec>
#include <locale.h>
#include <qapplication.h>
#include <stdio.h>
#include <stdlib.h>
#include <QFile>
#include <QTextStream>
#include <QDateTime>
#include <QFileInfo>
#include <QPixmap>
#include <QSplashScreen>
#include <QDebug>
#include "defines.h"
static const QtMessageHandler QT_DEFAULT_MESSAGE_HANDLER = qInstallMessageHandler(0);
void logToFile(const QString message)
{
QFile file(LOG_FILE_NAME);
if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) {
QTextStream stream(&file);
stream << message << endl;
}
}
void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QString message = QString("%1: %2").arg(
QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss:zzz "),
QString(localMsg.constData())
);
logToFile(message);
(*QT_DEFAULT_MESSAGE_HANDLER)(type, context, message);
}
int main(int argc, char *argv[])
{
setlocale( LC_CTYPE, ".1251" );
QCoreApplication::setOrganizationName("Zhitko Vladimir");
QCoreApplication::setOrganizationDomain("vladimir.zhitko.by");
QCoreApplication::setApplicationName("IntonTrainer");
QCoreApplication::setApplicationVersion(QString(__DATE__));
qInstallMessageHandler(messageOutput);
qDebug() << FULL_APP_VERIOSN;
QApplication app(argc, argv);
QPixmap pixmap(":/splash/icons/wave.png");
QSplashScreen splash(pixmap, Qt::WindowStaysOnTopHint);
splash.show();
app.processEvents();
splash.showMessage("Loaded modules");
WebWindow window;
window.show();
window.setWindowTitle(FULL_APP_VERIOSN);
window.setWindowIcon(QIcon(":/icons/icons/inton-50.png"));
splash.finish(&window);
return app.exec();
}