From 1fd6464884b8c794af052378223ffc667d984c70 Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 29 May 2014 10:08:54 +0300 Subject: [PATCH] New command line parser. New Qt requirements. Fix issue with build project. --HG-- branch : develop --- README | 6 ++-- Valentina.pro | 4 +-- src/app/app.pro | 10 +++--- src/app/main.cpp | 42 +++++++---------------- src/app/mainwindow.cpp | 28 +++++++++++---- src/app/xml/vpattern.cpp | 2 +- src/libs/libs.pro | 3 ++ src/src.pro | 55 +++--------------------------- src/test/ParserTest/ParserTest.pro | 11 +++--- src/test/test.pro | 3 ++ 10 files changed, 61 insertions(+), 103 deletions(-) create mode 100644 src/libs/libs.pro create mode 100644 src/test/test.pro diff --git a/README b/README index 84349b95e..2cd83e0cf 100644 --- a/README +++ b/README @@ -13,14 +13,14 @@ Supported Platforms The standalone binary packages support the following platforms: Windows XP SP2 or later -Ubuntu Linux 11.10 (32-bit) or later +Ubuntu Linux 14.04 (32-bit) or later -Building the sources requires Qt 5.1.0 or later. +Building the sources requires Qt 5.2.1 or later. Compiling Valentina ==================== Prerequisites: - * Qt 5.1.0 or later (On Unix development packages needed) + * Qt 5.2.1 or later (On Unix development packages needed) * mercurial * On Unix: - ccache diff --git a/Valentina.pro b/Valentina.pro index fc3aa522f..7134680c9 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -1,9 +1,9 @@ include(Valentina.pri) #version check qt -!minQtVersion(5, 1, 0) { +!minQtVersion(5, 2, 1) { message("Cannot build Valentina with Qt version $${QT_VERSION}.") - error("Use at least Qt 5.1.0.") + error("Use at least Qt 5.2.1.") } TEMPLATE = subdirs diff --git a/src/app/app.pro b/src/app/app.pro index 909719a1e..bbc31238c 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -219,9 +219,9 @@ for(DIR, INSTALL_STANDARD_MEASHUREMENTS) { copyToDestdir($$st_path, $$shell_path($$OUT_PWD/$$DESTDIR/tables/standard)) -win32:CONFIG(release, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2 -else:win32:CONFIG(debug, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2 -else:unix: LIBS += -L../libs/qmuparser/bin -lqmuparser +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2 +else:unix: LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser -INCLUDEPATH += ../libs/qmuparser -DEPENDPATH += ../libs/qmuparser +INCLUDEPATH += $$PWD/../libs/qmuparser +DEPENDPATH += $$PWD/../libs/qmuparser diff --git a/src/app/main.cpp b/src/app/main.cpp index 3f6a00fc3..52b453603 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(theme); - QT_REQUIRE_VERSION(argc, argv, "5.1.0"); + QT_REQUIRE_VERSION(argc, argv, "5.2.1"); VApplication app(argc, argv); #ifdef QT_DEBUG @@ -175,36 +175,18 @@ int main(int argc, char *argv[]) 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 + 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); + const QStringList args = parser.positionalArguments(); + if (args.size() > 0) + { + w.LoadPattern(args.at(0)); - 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.LoadPattern(fileName); - } - w.show(); - break; - } - else - { - qDebug() << "Uknown arg:" << args.at(i); - w.show(); - break; - } - } - } - else - { - w.show(); } + w.show(); return app.exec(); } diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index f9ee3c4b8..b7f028a29 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1249,12 +1249,23 @@ void MainWindow::Open() dir = QFileInfo(files.first()).absolutePath(); } QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter); - if (fileName.isEmpty() == false) + if (fileName.isEmpty() == false && fileName != curFile) { - LoadPattern(fileName); + if (curFile.isEmpty()) + { + LoadPattern(fileName); - VAbstractTool::NewSceneRect(sceneDraw, view); - VAbstractTool::NewSceneRect(sceneDetails, view); + VAbstractTool::NewSceneRect(sceneDraw, view); + VAbstractTool::NewSceneRect(sceneDetails, view); + } + else + { + QProcess *v = new QProcess(this); + QStringList arguments; + arguments << fileName; + v->startDetached(QCoreApplication::applicationFilePath(), arguments); + delete v; + } } } } @@ -1303,9 +1314,12 @@ void MainWindow::Clear() */ void MainWindow::NewPattern() { - QProcess *v = new QProcess(this); - v->startDetached(QCoreApplication::applicationFilePath ()); - delete v; + if (doc->isPatternModified() || curFile.isEmpty() == false) + { + QProcess *v = new QProcess(this); + v->startDetached(QCoreApplication::applicationFilePath ()); + delete v; + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index a3a8834a4..380a74b15 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -39,7 +39,7 @@ #include "vindividualmeasurements.h" #include -#include +#include "../../libs/qmuparser/qmuparsererror.h" const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagCalculation = QStringLiteral("calculation"); diff --git a/src/libs/libs.pro b/src/libs/libs.pro new file mode 100644 index 000000000..5d08776e9 --- /dev/null +++ b/src/libs/libs.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = qmuparser diff --git a/src/src.pro b/src/src.pro index 6e951fd25..dbc4d1aaa 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,52 +1,7 @@ TEMPLATE = subdirs +CONFIG += ordered + SUBDIRS = \ - sub_app \ - sub_lib_qmuparser \ - test/ParserTest - -sub_lib_qmuparser.file = libs/qmuparser/qmuparser.pro -sub_parser_tests.file = test/ParserTest/ParserTest.pro -sub_parser_tests.depends = sub_lib_qmuparser -sub_app.file = app/app.pro -sub_app.depends = sub_lib_qmuparser - - -#This makes it possible to use make -j 4 on your fancy quad-core system with a project that consists of several -#components that depend on each other. To simplify the process a bit, the following test function can be defined: - -# addSubdirs(subdirs,deps): Adds directories to the project that depend on -# other directories -defineTest(addSubdirs) { - for(subdirs, 1) { - entries = $$files($$subdirs) - for(entry, entries) { - name = $$replace(entry, [/\\\\], _) - SUBDIRS += $$name - eval ($${name}.subdir = $$entry) - for(dep, 2):eval ($${name}.depends += $$replace(dep, [/\\\\], _)) - export ($${name}.subdir) - export ($${name}.depends) - } - } - export (SUBDIRS) -} -#You can then use it like to define a project that has: - -#several contributed modules that should be compiled first -#addSubdirs (contrib/*) - -#a kernel lib for non-gui related stuff that depends on some contrib modules -#addSubdirs (src/lib/kernel, contrib/module1 contrib/module2) - -#a gui lib that depends on the kernel lib and some other contrib modules -#addSubdirs (src/lib/gui, src/lib/kernel contrib/module3 contrib/module4) - -#test benches for the kernel and gui libs -#addSubdirs (src/tests/kernel, src/lib/kernel) -#addSubdirs (src/tests/gui, src/lib/gui) - -#a main program that uses the gui and kernel libs -#addSubdirs (src/main, src/lib/gui src/lib/kernel) - -#several modules that only depend on the kernel lib -#addSubdirs (src/modules/*, src/lib/kernel) + libs \ + app \ + test diff --git a/src/test/ParserTest/ParserTest.pro b/src/test/ParserTest/ParserTest.pro index e7da26428..3be053f5d 100644 --- a/src/test/ParserTest/ParserTest.pro +++ b/src/test/ParserTest/ParserTest.pro @@ -58,9 +58,10 @@ CONFIG(debug, debug|release){ QMAKE_DISTCLEAN += $${DESTDIR}/* \ $${OBJECTS_DIR}/* -win32:CONFIG(release, debug|release): LIBS += -L../../libs/qmuparser/bin -lqmuparser2 -else:win32:CONFIG(debug, debug|release): LIBS += -L../../libs/qmuparser/bin -lqmuparser2 -else:unix: LIBS += -L../../libs/qmuparser/bin -lqmuparser -INCLUDEPATH += ../../libs/qmuparser -DEPENDPATH += ../../libs/qmuparser +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser2 +else:unix: LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser + +INCLUDEPATH += $$PWD/../../libs/qmuparser +DEPENDPATH += $$PWD/../../libs/qmuparser diff --git a/src/test/test.pro b/src/test/test.pro new file mode 100644 index 000000000..db8b1c7c4 --- /dev/null +++ b/src/test/test.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = ParserTest