From 4c7033492ac4aefb359831285dea0d908f3ee7ad Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 11 Jun 2015 15:24:38 +0300 Subject: [PATCH] Refactoring. --HG-- branch : feature --- src/app/core/vapplication.cpp | 64 +++++++++++++++++++++++++++++++++ src/app/core/vapplication.h | 2 ++ src/app/main.cpp | 68 +---------------------------------- 3 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index 7d54a830b..63bfefc49 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -548,6 +548,70 @@ void VApplication::setPatternUnit(const Unit &patternUnit) InitLineWidth(); } +//--------------------------------------------------------------------------------------------------------------------- +void VApplication::InitOptions() +{ + setApplicationDisplayName(VER_PRODUCTNAME_STR); + setApplicationName(VER_INTERNALNAME_STR); + setOrganizationName(VER_COMPANYNAME_STR); + setOrganizationDomain(VER_COMPANYDOMAIN_STR); + // Setting the Application version + setApplicationVersion(APP_VERSION_STR); + + OpenSettings(); + +#if defined(Q_OS_WIN) && defined(Q_CC_GNU) + // Catch and send report + VApplication::DrMingw(); + this->CollectReports(); +#endif + + // Run creation log after sending crash report + StartLogging(); + + qDebug()<<"Version:"<arguments(); + qDebug()<<"Process ID:"<applicationPid(); + + const QString checkedLocale = getSettings()->GetLocale(); + qDebug()<<"Checked locale:"<load("qt_" + checkedLocale, translationsPath()); +#else + qtTranslator->load("qt_" + checkedLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); +#endif + installTranslator(qtTranslator); + + QTranslator *qtxmlTranslator = new QTranslator(this); +#if defined(Q_OS_WIN) + qtxmlTranslator->load("qtxmlpatterns_" + checkedLocale, translationsPath()); +#else + qtxmlTranslator->load("qtxmlpatterns_" + checkedLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); +#endif + installTranslator(qtxmlTranslator); + + QTranslator *appTranslator = new QTranslator(this); + appTranslator->load("valentina_" + checkedLocale, translationsPath()); + installTranslator(appTranslator); + + InitTrVars();//Very important do it after load QM files. + + static const char * GENERIC_ICON_TO_CHECK = "document-open"; + if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false) + { + //If there is no default working icon theme then we should + //use an icon theme that we provide via a .qrc file + //This case happens under Windows and Mac OS X + //This does not happen under GNOME or KDE + QIcon::setThemeName("win.icon.theme"); + } +} + //--------------------------------------------------------------------------------------------------------------------- QWidget *VApplication::getMainWindow() const { diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h index cc3f469ae..1afbea2f0 100644 --- a/src/app/core/vapplication.h +++ b/src/app/core/vapplication.h @@ -66,6 +66,8 @@ public: MeasurementsType patternType() const; void setPatternType(const MeasurementsType &patternType); + void InitOptions(); + double toPixel(double val, const Unit &unit) const; double toPixel(double val) const; double fromPixel(double pix, const Unit &unit) const; diff --git a/src/app/main.cpp b/src/app/main.cpp index 03f087598..6a35142bf 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -28,19 +28,12 @@ #include "mainwindow.h" #include "core/vapplication.h" -#include "core/vsettings.h" -#include "version.h" -#include -#include -#include #if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) # include "../core/backport/qcommandlineparser.h" #else # include #endif -#include -#include //--------------------------------------------------------------------------------------------------------------------- int main(int argc, char *argv[]) @@ -56,66 +49,7 @@ int main(int argc, char *argv[]) QT_REQUIRE_VERSION(argc, argv, "5.0.0"); VApplication app(argc, argv); - - app.setApplicationDisplayName(VER_PRODUCTNAME_STR); - app.setApplicationName(VER_INTERNALNAME_STR); - app.setOrganizationName(VER_COMPANYNAME_STR); - app.setOrganizationDomain(VER_COMPANYDOMAIN_STR); - // Setting the Application version - app.setApplicationVersion(APP_VERSION_STR); - - app.OpenSettings(); - -#if defined(Q_OS_WIN) && defined(Q_CC_GNU) - // Catch and send report - VApplication::DrMingw(); - app.CollectReports(); -#endif - - // Run creation log after sending crash report - app.StartLogging(); - - qDebug()<<"Version:"<getSettings()->GetLocale(); - qDebug()<<"Checked locale:"<translationsPath()); -#else - qtTranslator.load("qt_" + checkedLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); -#endif - app.installTranslator(&qtTranslator); - - QTranslator qtxmlTranslator; -#if defined(Q_OS_WIN) - qtxmlTranslator.load("qtxmlpatterns_" + checkedLocale, qApp->translationsPath()); -#else - qtxmlTranslator.load("qtxmlpatterns_" + checkedLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); -#endif - app.installTranslator(&qtxmlTranslator); - - QTranslator appTranslator; - appTranslator.load("valentina_" + checkedLocale, qApp->translationsPath()); - app.installTranslator(&appTranslator); - - app.InitTrVars();//Very important do it after load QM files. - - static const char * GENERIC_ICON_TO_CHECK = "document-open"; - if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false) - { - //If there is no default working icon theme then we should - //use an icon theme that we provide via a .qrc file - //This case happens under Windows and Mac OS X - //This does not happen under GNOME or KDE - QIcon::setThemeName("win.icon.theme"); - } + app.InitOptions(); MainWindow w; app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));