mirror of
				https://github.com/YACReader/yacreader
				synced 2025-10-30 15:54:27 -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 <QMessageBox> | ||||
| #include <QTableView> | ||||
| #if QT_VERSION >= 0x050000 | ||||
| 	#include <QtConcurrent/QtConcurrentRun> | ||||
| #else | ||||
| 	#include <QtConcurrentRun> | ||||
| #endif | ||||
| #include <QSqlDatabase> | ||||
| #include <QtScript> | ||||
| #include "data_base_management.h" | ||||
|  | ||||
| @ -4,6 +4,14 @@ | ||||
| #include <QTranslator> | ||||
| #include <QSettings> | ||||
| #include <QLocale> | ||||
| #include <QTextStream> | ||||
| #include <QtDebug> | ||||
| #include <QDir> | ||||
| #include <QDateTime> | ||||
|  | ||||
| #if QT_VERSION >= 0x050000 | ||||
| #include <QStandardPaths> | ||||
| #endif | ||||
|  | ||||
| #include "yacreader_global.h" | ||||
| #include "startup.h" | ||||
| @ -12,6 +20,43 @@ | ||||
|  | ||||
| #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 | ||||
| Startup * s; | ||||
|  | ||||
| @ -19,6 +64,14 @@ int main( int argc, char ** argv ) | ||||
| { | ||||
|   QApplication app( argc, argv ); | ||||
|  | ||||
| #if QT_VERSION >= 0x050000 | ||||
|   qInstallMessageHandler(yacreaderMessageHandler); | ||||
| #else | ||||
|   qInstallMsgHandler(yacreaderMessageHandler); | ||||
| #endif | ||||
|  | ||||
|   qDebug() << "YACReaderLibrary started" << endl; | ||||
|  | ||||
|   QTranslator translator; | ||||
|   QString sufix = QLocale::system().name(); | ||||
|   translator.load(QCoreApplication::applicationDirPath()+"/languages/yacreaderlibrary_"+sufix); | ||||
| @ -65,5 +118,7 @@ int main( int argc, char ** argv ) | ||||
|   s->stop(); | ||||
|   delete s; | ||||
|  | ||||
|   qDebug() << "YACReaderLibrary closed" << endl; | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user