-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·124 lines (106 loc) · 4.76 KB
/
main.cpp
File metadata and controls
executable file
·124 lines (106 loc) · 4.76 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "LttoMainWindow.h"
#include <QApplication>
#include <QSplashScreen>
#include <QStandardPaths>
#include <QDateTime>
#include <QPixmap>
#include <QSoundEffect>
#include <QMessageBox>
#include "Defines.h"
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
// Replicate the messages to DeBug for local use
QByteArray localMsg = msg.toLocal8Bit();
switch (type)
{
case QtDebugMsg:
//fprintf(stderr, "Debug:\t%s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Debug:\t%s\n", localMsg.constData());
break;
case QtWarningMsg:
if(context.file == nullptr && context.function == nullptr) break; // hides the annoying QAbstractSocket 'alreadyconnecting' message
//fprintf(stderr, "Warning:\t%s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Warning:\t%s\n", localMsg.constData());
break;
case QtCriticalMsg:
//fprintf(stderr, "Critical:\t%s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Critical:\t%s\n", localMsg.constData());
break;
case QtInfoMsg:
//fprintf(stderr, "Info:\t%s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Info:\t%s\n", localMsg.constData());
break;
case QtFatalMsg:
//fprintf(stderr, "Fatal:\t%s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
fprintf(stderr, "Fatal:\t%s\n", localMsg.constData());
break;
default:
break;
//abort();
}
QString logMessage = (QString)localMsg;
//Send to Log file
QString filePath = QStandardPaths::standardLocations( QStandardPaths::DocumentsLocation ).value(0);
//qDebug() << "main::myMessageOutput() - FilePath =" << filePath;
QDir thisDir;
thisDir.setPath(filePath);
QDir::setCurrent(filePath);
QFile outFile("Combobulator_Log.txt");
bool good = outFile.open(QIODevice::WriteOnly | QIODevice::Append);
thisDir.setPath(filePath);
if (!thisDir.exists()) thisDir.mkpath(filePath);
QDir::setCurrent(filePath);
if(good)
{
QTextStream ts(&outFile);
ts << logMessage << Qt::endl;
outFile.close();
}
else qDebug() << "main::myMessageOutput() - Cannot create file" << thisDir << ":" << outFile;
if(LttoMainWindow::textEditLogFile != nullptr)
{
//fprintf(stderr, "\t*** Writing to Log ***\n","","","","");
LttoMainWindow::textEditLogFile->append(msg);
}
}
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setApplicationName( QString("Combobulator") );
QApplication::setDesktopSettingsAware(false);
qInstallMessageHandler(myMessageOutput);
QApplication theApp(argc, argv);
qDebug() << "----------------------------------------------------------------------------" << Qt::endl;
qDebug() << "----------------------------------------------------------------------------" << Qt::endl;
qDebug() << " Starting the main application.";
qDebug() << " " << BUILD_NUMBER << "-" << VERSION_NUMBER << Qt::endl;
qDebug() << "\t" << QDateTime::currentDateTime();
qDebug() << "----------------------------------------------------------------------------" << Qt::endl;
qDebug() << "----------------------------------------------------------------------------" << Qt::endl;
qDebug() << "----------------------------------------------------------------------------" << Qt::endl;
qDebug() << "----------------------------------------------------------------------------" << Qt::endl;
qDebug() << "----------------------------------------------------------------------------" << Qt::endl;
qDebug() << "Creating main windoow";
#ifndef QT_DEBUG
QEventLoop loop;
QSoundEffect sound_PowerUp;
QPixmap pixmap(":/resources/images/Combobulator Logo.jpg");
QSplashScreen splashScreen(pixmap);
theApp.processEvents();
sound_PowerUp.setVolume(50);
sound_PowerUp.setSource(QUrl::fromLocalFile(":/resources/audio/stinger-power-on.wav"));
splashScreen.show();
sound_PowerUp.play();
QTimer::singleShot(2000, &loop, SLOT(quit()));
loop.exec();
splashScreen.close();
#endif
LttoMainWindow lttoMainWindow;
lttoMainWindow.setWindowIcon(QIcon(":/resources/images/Combobulator.ico"));
#ifndef QT_DEBUG
lttoMainWindow.showFullScreen();
#else
lttoMainWindow.show();
#endif
return theApp.exec();
}