2017-02-27 01:13:56 +08:00
|
|
|
#include <QString>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QApplication>
|
2017-03-28 18:01:27 +08:00
|
|
|
#include <QDebug>
|
2017-02-27 01:13:56 +08:00
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
static void initStyleSheet(QApplication& a)
|
|
|
|
{
|
2017-02-27 21:15:20 +08:00
|
|
|
QFile f(":ads/stylesheets/default-windows2.css");
|
2017-02-27 01:13:56 +08:00
|
|
|
if (f.open(QFile::ReadOnly))
|
|
|
|
{
|
|
|
|
const QByteArray ba = f.readAll();
|
|
|
|
f.close();
|
|
|
|
a.setStyleSheet(QString(ba));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-28 18:01:27 +08:00
|
|
|
|
|
|
|
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
|
|
{
|
|
|
|
QByteArray localMsg = msg.toLocal8Bit();
|
|
|
|
switch (type) {
|
|
|
|
case QtDebugMsg:
|
|
|
|
fprintf(stdout, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
break;
|
|
|
|
case QtInfoMsg:
|
|
|
|
fprintf(stdout, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
break;
|
|
|
|
case QtWarningMsg:
|
|
|
|
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
break;
|
|
|
|
case QtCriticalMsg:
|
|
|
|
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
break;
|
|
|
|
case QtFatalMsg:
|
|
|
|
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
fflush(stderr);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2017-02-27 01:13:56 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
a.setQuitOnLastWindowClosed(true);
|
|
|
|
initStyleSheet(a);
|
2017-03-28 18:01:27 +08:00
|
|
|
qInstallMessageHandler(myMessageOutput);
|
|
|
|
qDebug() << "Message handler test";
|
2017-02-27 01:13:56 +08:00
|
|
|
|
|
|
|
MainWindow mw;
|
|
|
|
mw.show();
|
|
|
|
return a.exec();
|
|
|
|
}
|