2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file main.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-06-20 16:09:50 +02:00
|
|
|
#include "mainwindow.h"
|
2014-09-25 17:44:06 +02:00
|
|
|
#include "core/vapplication.h"
|
2014-11-22 17:15:47 +01:00
|
|
|
#include "core/vsettings.h"
|
|
|
|
#include "tablewindow.h"
|
|
|
|
#include "version.h"
|
|
|
|
|
2013-07-03 14:29:26 +02:00
|
|
|
#include <QTextCodec>
|
2014-03-27 12:41:00 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QThread>
|
2014-11-20 13:28:21 +01:00
|
|
|
#include <QCommandLineParser>
|
2014-10-03 12:32:12 +02:00
|
|
|
#include <QtXml>
|
2014-09-09 15:11:50 +02:00
|
|
|
#include <QLibraryInfo>
|
2013-06-20 16:09:50 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2014-02-07 17:12:18 +01:00
|
|
|
Q_INIT_RESOURCE(cursor);
|
|
|
|
Q_INIT_RESOURCE(icon);
|
|
|
|
Q_INIT_RESOURCE(schema);
|
|
|
|
Q_INIT_RESOURCE(theme);
|
2014-12-05 13:52:24 +01:00
|
|
|
Q_INIT_RESOURCE(flags);
|
2014-02-07 17:12:18 +01:00
|
|
|
|
2014-12-22 20:46:36 +01:00
|
|
|
QT_REQUIRE_VERSION(argc, argv, "5.2.0");
|
2014-05-07 18:59:54 +02:00
|
|
|
|
2013-10-01 20:15:59 +02:00
|
|
|
VApplication app(argc, argv);
|
2014-11-13 13:14:00 +01:00
|
|
|
|
2014-04-16 17:32:41 +02:00
|
|
|
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);
|
2014-02-14 12:29:04 +01:00
|
|
|
|
2014-07-10 11:36:46 +02:00
|
|
|
app.OpenSettings();
|
|
|
|
|
2014-11-15 16:52:27 +01:00
|
|
|
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
2014-11-20 13:18:43 +01:00
|
|
|
// Catch and send report
|
2014-11-15 16:52:27 +01:00
|
|
|
VApplication::DrMingw();
|
|
|
|
app.CollectReports();
|
|
|
|
#endif
|
|
|
|
|
2014-11-20 13:18:43 +01:00
|
|
|
// Run creation log after sending crash report
|
|
|
|
app.StartLogging();
|
|
|
|
|
2014-11-20 18:52:51 +01:00
|
|
|
qDebug()<<"Version:"<<APP_VERSION;
|
2014-12-29 17:06:09 +01:00
|
|
|
qDebug()<<"Build revision:"<<BUILD_REVISION;
|
|
|
|
qDebug()<<buildCompatibilityString();
|
2014-11-20 18:52:51 +01:00
|
|
|
qDebug()<<"Built on"<<__DATE__<<"at"<<__TIME__;
|
|
|
|
qDebug()<<"Command-line arguments:"<<app.arguments();
|
2014-11-28 14:49:06 +01:00
|
|
|
qDebug()<<"Process ID:"<<app.applicationPid();
|
2014-11-20 18:52:51 +01:00
|
|
|
|
2014-11-22 17:15:47 +01:00
|
|
|
const QString checkedLocale = qApp->getSettings()->GetLocale();
|
2014-11-20 18:52:51 +01:00
|
|
|
qDebug()<<"Checked locale:"<<checkedLocale;
|
2013-09-18 18:52:49 +02:00
|
|
|
|
|
|
|
QTranslator qtTranslator;
|
2014-09-21 19:06:15 +02:00
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
qtTranslator.load("qt_" + checkedLocale, QCoreApplication::applicationDirPath());
|
|
|
|
#else
|
2014-02-14 12:29:04 +01:00
|
|
|
qtTranslator.load("qt_" + checkedLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
2014-09-21 19:06:15 +02:00
|
|
|
#endif
|
2013-09-18 18:52:49 +02:00
|
|
|
app.installTranslator(&qtTranslator);
|
|
|
|
|
|
|
|
QTranslator appTranslator;
|
2014-03-23 15:36:34 +01:00
|
|
|
appTranslator.load("valentina_" + checkedLocale, qApp->translationsPath());
|
2014-02-17 19:31:49 +01:00
|
|
|
app.installTranslator(&appTranslator);
|
2014-02-10 17:10:20 +01:00
|
|
|
|
2014-02-19 22:34:57 +01:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2013-06-20 16:09:50 +02:00
|
|
|
MainWindow w;
|
2013-07-03 14:29:26 +02:00
|
|
|
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
2014-07-08 12:59:50 +02:00
|
|
|
app.setMainWindow(&w);
|
2013-08-29 12:31:50 +02:00
|
|
|
TableWindow table;
|
|
|
|
QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen);
|
|
|
|
QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed);
|
2013-09-23 15:17:15 +02:00
|
|
|
|
2014-05-29 09:08:54 +02:00
|
|
|
QCommandLineParser parser;
|
|
|
|
parser.setApplicationDescription(QCoreApplication::translate("main", "Pattern making program."));
|
|
|
|
parser.addHelpOption();
|
|
|
|
parser.addVersionOption();
|
|
|
|
parser.addPositionalArgument("filename", QCoreApplication::translate("main", "Pattern file."));
|
|
|
|
parser.process(app);
|
2014-10-30 11:19:17 +01:00
|
|
|
QStringList args = parser.positionalArguments();
|
2014-07-13 14:49:00 +02:00
|
|
|
|
|
|
|
//Before we load pattern show window.
|
|
|
|
w.show();
|
|
|
|
|
2014-10-30 11:19:17 +01:00
|
|
|
w.ReopenFilesAfterCrash(args);
|
2014-10-23 15:53:46 +02:00
|
|
|
|
2014-09-10 19:57:08 +02:00
|
|
|
for (int i=0;i<args.size();++i)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-10-23 11:13:18 +02:00
|
|
|
w.LoadPattern(args.at(i));
|
2013-09-23 15:17:15 +02:00
|
|
|
}
|
2014-07-13 14:49:00 +02:00
|
|
|
|
2013-07-03 14:29:26 +02:00
|
|
|
return app.exec();
|
2013-06-20 16:09:50 +02:00
|
|
|
}
|