valentina_old/main.cpp

94 lines
3.4 KiB
C++
Raw Normal View History

/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** 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.
**
** Tox is distributed in the hope that it will be useful,
** 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-06-20 16:09:50 +02:00
#include "mainwindow.h"
#include "widgets/vapplication.h"
2013-07-03 14:29:26 +02:00
#include <QTextCodec>
2013-08-29 12:31:50 +02:00
#include "tablewindow.h"
2013-06-20 16:09:50 +02:00
2013-07-25 14:00:51 +02:00
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg){
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
abort();
}
}
int main(int argc, char *argv[]){
qInstallMessageHandler(myMessageOutput);
VApplication app(argc, argv);
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator);
QTranslator appTranslator;
appTranslator.load("valentina_" + QLocale::system().name(),".");
app.installTranslator(&appTranslator);
2013-06-20 16:09:50 +02:00
MainWindow w;
w.setWindowState(w.windowState() ^ Qt::WindowMaximized);
2013-07-03 14:29:26 +02:00
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
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);
const QStringList args = app.arguments();
QString fileName;
QRegExp rxArgOpenFile("-o");//parameter open file
if(args.size()>1){
for (int i = 1; i < args.size(); ++i) {
if (rxArgOpenFile.indexIn(args.at(i)) != -1 ) {
if(args.at(i+1).isEmpty() == false){
fileName = args.at(i+1);
qDebug() << args.at(i)<< ":" << fileName;
w.OpenPattern(fileName);
}
w.show();
break;
} else {
qDebug() << "Uknown arg:" << args.at(i);
w.show();
break;
}
}
} else {
w.show();
}
2013-07-03 14:29:26 +02:00
return app.exec();
2013-06-20 16:09:50 +02:00
}