mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 00:58:32 -04:00
Code cleanup for main.cpp files
Remove ancient OS detection code, unneeded includes and ugly workarounds.
This commit is contained in:
parent
601e70fc85
commit
f9ed9b19b5
@ -1,15 +1,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPixmap>
|
#include <QDir>
|
||||||
#include <QLabel>
|
|
||||||
//#include <QMetaObject>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QtCore>
|
|
||||||
#include <QThread>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDataStream>
|
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QSysInfo>
|
|
||||||
#include "main_window_viewer.h"
|
#include "main_window_viewer.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "exit_check.h"
|
#include "exit_check.h"
|
||||||
@ -19,16 +11,17 @@
|
|||||||
|
|
||||||
using namespace QsLogging;
|
using namespace QsLogging;
|
||||||
|
|
||||||
#if defined(WIN32) && defined(_DEBUG)
|
#if defined(WIN32) && defined(_DEBUG)
|
||||||
#define _CRTDBG_MAP_ALLOC
|
#define _CRTDBG_MAP_ALLOC
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
|
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QFileOpenEvent>
|
||||||
class YACReaderApplication: public QApplication
|
class YACReaderApplication: public QApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -64,23 +57,14 @@ int main(int argc, char * argv[])
|
|||||||
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//fix for misplaced text in Qt4.8 and Mavericks
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#if QT_VERSION < 0x050000
|
YACReaderApplication app(argc,argv);
|
||||||
if(QSysInfo::MacintoshVersion > QSysInfo::MV_10_8)
|
|
||||||
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
YACReaderApplication app(argc,argv);
|
|
||||||
#else
|
#else
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FORCE_ANGLE
|
#ifdef FORCE_ANGLE
|
||||||
app.setAttribute(Qt::AA_UseOpenGLES);
|
app.setAttribute(Qt::AA_UseOpenGLES);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
app.setApplicationName("YACReader");
|
app.setApplicationName("YACReader");
|
||||||
@ -126,7 +110,7 @@ int main(int argc, char * argv[])
|
|||||||
QDir().mkpath(YACReader::getSettingsPath());
|
QDir().mkpath(YACReader::getSettingsPath());
|
||||||
|
|
||||||
Logger& logger = Logger::instance();
|
Logger& logger = Logger::instance();
|
||||||
logger.setLoggingLevel(QsLogging::InfoLevel);
|
logger.setLoggingLevel(QsLogging::InfoLevel);
|
||||||
|
|
||||||
DestinationPtr fileDestination(DestinationFactory::MakeFileDestination(
|
DestinationPtr fileDestination(DestinationFactory::MakeFileDestination(
|
||||||
destLog, EnableLogRotation, MaxSizeBytes(1048576), MaxOldLogCount(2)));
|
destLog, EnableLogRotation, MaxSizeBytes(1048576), MaxOldLogCount(2)));
|
||||||
@ -165,22 +149,10 @@ int main(int argc, char * argv[])
|
|||||||
app.setWindow(mwv);
|
app.setWindow(mwv);
|
||||||
#endif
|
#endif
|
||||||
mwv->show();
|
mwv->show();
|
||||||
|
|
||||||
int ret = app.exec();
|
int ret = app.exec();
|
||||||
|
delete mwv;
|
||||||
delete mwv;
|
|
||||||
|
|
||||||
//Configuration::getConfiguration().save();
|
//Configuration::getConfiguration().save();
|
||||||
|
|
||||||
YACReader::exitCheck(ret);
|
YACReader::exitCheck(ret);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
// ugly workaround to avoid crash when app exit on MacOS Sierra due to Qt's QColorDialog bug.
|
|
||||||
// cf. https://bugreports.qt.io/browse/QTBUG-56448
|
|
||||||
QColorDialog colorDlg(0);
|
|
||||||
colorDlg.setOption(QColorDialog::NoButtons);
|
|
||||||
colorDlg.setCurrentColor(Qt::white);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,9 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QSettings>
|
#ifndef use_unarr
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
#include <QMessageBox>
|
#endif
|
||||||
#include <QTextStream>
|
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
#include "startup.h"
|
#include "startup.h"
|
||||||
@ -33,80 +32,25 @@ using namespace QsLogging;
|
|||||||
|
|
||||||
void logSystemAndConfig()
|
void logSystemAndConfig()
|
||||||
{
|
{
|
||||||
QLOG_INFO() << "---------- System & configuration ----------";
|
QLOG_INFO() << "---------- System & configuration ----------";
|
||||||
#if defined(Q_OS_WIN)
|
QLOG_INFO() << "OS:" << QSysInfo::prettyProductName() << "Version: " << QSysInfo::productVersion();
|
||||||
switch (QSysInfo::windowsVersion())
|
QLOG_INFO() << "Kernel:" << QSysInfo::kernelType() << QSysInfo::kernelVersion() << "Architecture:" << QSysInfo::currentCpuArchitecture();
|
||||||
{
|
|
||||||
case QSysInfo::WV_NT:
|
|
||||||
QLOG_INFO() << "SO : Windows NT";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_2000:
|
|
||||||
QLOG_INFO() << "SO : Windows 2000";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_XP:
|
|
||||||
QLOG_INFO() << "SO : Windows XP";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_2003:
|
|
||||||
QLOG_INFO() << "SO : Windows 2003";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_VISTA:
|
|
||||||
QLOG_INFO() << "SO : Windows Vista";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_WINDOWS7:
|
|
||||||
QLOG_INFO() << "SO : Windows 7";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_WINDOWS8:
|
|
||||||
QLOG_INFO() << "SO : Windows 8";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
QLOG_INFO() << "Windows (unknown version)";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(Q_OS_MAC)
|
|
||||||
|
|
||||||
switch (QSysInfo::MacVersion())
|
|
||||||
{
|
|
||||||
case QSysInfo::MV_SNOWLEOPARD:
|
|
||||||
QLOG_INFO() << "SO : MacOSX Snow Leopard";
|
|
||||||
break;
|
|
||||||
case QSysInfo::MV_LION:
|
|
||||||
QLOG_INFO() << "SO : MacOSX Lion";
|
|
||||||
break;
|
|
||||||
case QSysInfo::MV_MOUNTAINLION:
|
|
||||||
QLOG_INFO() << "SO : MacOSX Mountain Lion";
|
|
||||||
break;
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
case QSysInfo::MV_MAVERICKS:
|
|
||||||
QLOG_INFO() << "SO : MacOSX Maverics";
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
QLOG_INFO() << "SO : MacOSX (unknown version)";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(Q_OS_LINUX)
|
|
||||||
QLOG_INFO() << "SO : Linux (unknown version)";
|
|
||||||
|
|
||||||
#else
|
|
||||||
QLOG_INFO() << "SO : Unknown";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef use_unarr
|
#ifndef use_unarr
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if(QLibrary::isLibrary(QApplication::applicationDirPath()+"/utils/7z.dll"))
|
if(QLibrary::isLibrary(QApplication::applicationDirPath()+"/utils/7z.dll"))
|
||||||
#elif defined Q_OS_UNIX && !defined Q_OS_MAC
|
#elif defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
if(QLibrary::isLibrary(QString(LIBDIR)+"/yacreader/7z.so") | QLibrary::isLibrary(QString(LIBDIR)+"/p7zip/7z.so"))
|
if(QLibrary::isLibrary(QString(LIBDIR)+"/yacreader/7z.so") | QLibrary::isLibrary(QString(LIBDIR)+"/p7zip/7z.so"))
|
||||||
#else
|
#else
|
||||||
if(QLibrary::isLibrary(QApplication::applicationDirPath()+"/utils/7z.so"))
|
if(QLibrary::isLibrary(QApplication::applicationDirPath()+"/utils/7z.so"))
|
||||||
#endif
|
#endif
|
||||||
QLOG_INFO() << "7z : found";
|
QLOG_INFO() << "7z : found";
|
||||||
else
|
else
|
||||||
QLOG_ERROR() << "7z : not found";
|
QLOG_ERROR() << "7z : not found";
|
||||||
#else
|
#else // use_unarr
|
||||||
QLOG_INFO() << "using unarr decompression backend";
|
QLOG_INFO() << "using unarr decompression backend";
|
||||||
#endif
|
#endif // use_unarr
|
||||||
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
if(QFileInfo(QString(BINDIR)+"/qrencode").exists())
|
if(QFileInfo(QString(BINDIR)+"/qrencode").exists())
|
||||||
#else
|
#else
|
||||||
@ -131,33 +75,23 @@ void logSystemAndConfig()
|
|||||||
OpenGLChecker checker;
|
OpenGLChecker checker;
|
||||||
QLOG_INFO() << "OpenGL version : " << checker.textVersionDescription();
|
QLOG_INFO() << "OpenGL version : " << checker.textVersionDescription();
|
||||||
|
|
||||||
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries();
|
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries();
|
||||||
QLOG_INFO() << "--------------------------------------------";
|
QLOG_INFO() << "--------------------------------------------";
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char ** argv )
|
int main( int argc, char ** argv )
|
||||||
{
|
{
|
||||||
|
|
||||||
//fix for misplaced text in Qt4.8 and Mavericks
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
#if QT_VERSION < 0x050000
|
|
||||||
if(QSysInfo::MacintoshVersion > QSysInfo::MV_10_8)
|
|
||||||
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
|
|
||||||
#ifdef FORCE_ANGLE
|
#ifdef FORCE_ANGLE
|
||||||
app.setAttribute(Qt::AA_UseOpenGLES);
|
app.setAttribute(Qt::AA_UseOpenGLES);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
app.setApplicationName("YACReaderLibrary");
|
app.setApplicationName("YACReaderLibrary");
|
||||||
app.setOrganizationName("YACReader");
|
app.setOrganizationName("YACReader");
|
||||||
app.setApplicationVersion(VERSION);
|
app.setApplicationVersion(VERSION);
|
||||||
|
|
||||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
|
||||||
if (QIcon::hasThemeIcon("YACReaderLibrary")) {
|
if (QIcon::hasThemeIcon("YACReaderLibrary")) {
|
||||||
app.setWindowIcon(QIcon::fromTheme("YACReaderLibrary"));
|
app.setWindowIcon(QIcon::fromTheme("YACReaderLibrary"));
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#include <QtCore>
|
//#include <QtCore>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QSysInfo>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
#include "db_helper.h"
|
#include "db_helper.h"
|
||||||
@ -17,8 +20,8 @@ using namespace QsLogging;
|
|||||||
void logSystemAndConfig()
|
void logSystemAndConfig()
|
||||||
{
|
{
|
||||||
QLOG_INFO() << "---------- System & configuration ----------";
|
QLOG_INFO() << "---------- System & configuration ----------";
|
||||||
QLOG_INFO() << "OS: " + QSysInfo::prettyProductName() + ", Version: " + QSysInfo::productVersion();
|
QLOG_INFO() << "OS:" << QSysInfo::prettyProductName() << "Version: " << QSysInfo::productVersion();
|
||||||
QLOG_INFO() << "Kernel: " + QSysInfo::kernelType() + " " + QSysInfo::kernelVersion() + " Architecture: " + QSysInfo::currentCpuArchitecture();
|
QLOG_INFO() << "Kernel:" << QSysInfo::kernelType() << QSysInfo::kernelVersion() << "Architecture:" << QSysInfo::currentCpuArchitecture();
|
||||||
/* TODO: qrencode could be helpfull for showing a qr code in the web client for client devices
|
/* TODO: qrencode could be helpfull for showing a qr code in the web client for client devices
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||||
if(QFileInfo(QString(BINDIR)+"/qrencode").exists())
|
if(QFileInfo(QString(BINDIR)+"/qrencode").exists())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user