mirror of
https://github.com/YACReader/yacreader
synced 2025-07-19 05:24:57 -04:00
fixed some Qt4/Qt5 compilation issues
added first version of messageHandler
This commit is contained in:
@ -7,7 +7,11 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
#if QT_VERSION >= 0x050000
|
||||||
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
|
#else
|
||||||
|
#include <QtConcurrentRun>
|
||||||
|
#endif
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QtScript>
|
#include <QtScript>
|
||||||
#include "data_base_management.h"
|
#include "data_base_management.h"
|
||||||
|
@ -4,6 +4,14 @@
|
|||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QtDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
#include "startup.h"
|
#include "startup.h"
|
||||||
@ -12,6 +20,43 @@
|
|||||||
|
|
||||||
#define PICTUREFLOW_QT4 1
|
#define PICTUREFLOW_QT4 1
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
void yacreaderMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
QString txt;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
txt = QString("Debug: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
txt = QString("Warning: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
txt = QString("Critical: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
txt = QString("Fatal: %1").arg(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
|
||||||
|
|
||||||
|
QFile outFile(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)+"/yacreaderlibrary.log");
|
||||||
|
|
||||||
|
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
|
||||||
|
QTextStream ts(&outFile);
|
||||||
|
ts << QDateTime::currentDateTime().toString() << " - " << txt << endl;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void yacreaderMessageHandler(QtMsgType type, const char *)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//interfaz al servidor
|
//interfaz al servidor
|
||||||
Startup * s;
|
Startup * s;
|
||||||
|
|
||||||
@ -19,6 +64,14 @@ int main( int argc, char ** argv )
|
|||||||
{
|
{
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
qInstallMessageHandler(yacreaderMessageHandler);
|
||||||
|
#else
|
||||||
|
qInstallMsgHandler(yacreaderMessageHandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
qDebug() << "YACReaderLibrary started" << endl;
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QString sufix = QLocale::system().name();
|
QString sufix = QLocale::system().name();
|
||||||
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix);
|
translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix);
|
||||||
@ -65,5 +118,7 @@ int main( int argc, char ** argv )
|
|||||||
s->stop();
|
s->stop();
|
||||||
delete s;
|
delete s;
|
||||||
|
|
||||||
|
qDebug() << "YACReaderLibrary closed" << endl;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user