New command line parser. New Qt requirements. Fix issue with build project.

--HG--
branch : develop
This commit is contained in:
dismine 2014-05-29 10:08:54 +03:00
parent 8b6a140ebb
commit 1fd6464884
10 changed files with 61 additions and 103 deletions

6
README
View File

@ -13,14 +13,14 @@ Supported Platforms
The standalone binary packages support the following platforms: The standalone binary packages support the following platforms:
Windows XP SP2 or later 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 Compiling Valentina
==================== ====================
Prerequisites: Prerequisites:
* Qt 5.1.0 or later (On Unix development packages needed) * Qt 5.2.1 or later (On Unix development packages needed)
* mercurial * mercurial
* On Unix: * On Unix:
- ccache - ccache

View File

@ -1,9 +1,9 @@
include(Valentina.pri) include(Valentina.pri)
#version check qt #version check qt
!minQtVersion(5, 1, 0) { !minQtVersion(5, 2, 1) {
message("Cannot build Valentina with Qt version $${QT_VERSION}.") 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 TEMPLATE = subdirs

View File

@ -219,9 +219,9 @@ for(DIR, INSTALL_STANDARD_MEASHUREMENTS) {
copyToDestdir($$st_path, $$shell_path($$OUT_PWD/$$DESTDIR/tables/standard)) copyToDestdir($$st_path, $$shell_path($$OUT_PWD/$$DESTDIR/tables/standard))
win32:CONFIG(release, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2 win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2
else:win32:CONFIG(debug, debug|release): LIBS += -L../libs/qmuparser/bin -lqmuparser2 else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2
else:unix: LIBS += -L../libs/qmuparser/bin -lqmuparser else:unix: LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser
INCLUDEPATH += ../libs/qmuparser INCLUDEPATH += $$PWD/../libs/qmuparser
DEPENDPATH += ../libs/qmuparser DEPENDPATH += $$PWD/../libs/qmuparser

View File

@ -126,7 +126,7 @@ int main(int argc, char *argv[])
Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(schema);
Q_INIT_RESOURCE(theme); Q_INIT_RESOURCE(theme);
QT_REQUIRE_VERSION(argc, argv, "5.1.0"); QT_REQUIRE_VERSION(argc, argv, "5.2.1");
VApplication app(argc, argv); VApplication app(argc, argv);
#ifdef QT_DEBUG #ifdef QT_DEBUG
@ -175,36 +175,18 @@ int main(int argc, char *argv[])
QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen); QObject::connect(&w, &MainWindow::ModelChosen, &table, &TableWindow::ModelChosen);
QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed); QObject::connect(&table, &TableWindow::closed, &w, &MainWindow::tableClosed);
const QStringList args = app.arguments(); QCommandLineParser parser;
QString fileName; parser.setApplicationDescription(QCoreApplication::translate("main", "Pattern making program."));
QRegExp rxArgOpenFile("-o");//parameter open file 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(); return app.exec();
} }

View File

@ -1249,12 +1249,23 @@ void MainWindow::Open()
dir = QFileInfo(files.first()).absolutePath(); dir = QFileInfo(files.first()).absolutePath();
} }
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter); 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(sceneDraw, view);
VAbstractTool::NewSceneRect(sceneDetails, 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() void MainWindow::NewPattern()
{ {
QProcess *v = new QProcess(this); if (doc->isPatternModified() || curFile.isEmpty() == false)
v->startDetached(QCoreApplication::applicationFilePath ()); {
delete v; QProcess *v = new QProcess(this);
v->startDetached(QCoreApplication::applicationFilePath ());
delete v;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@
#include "vindividualmeasurements.h" #include "vindividualmeasurements.h"
#include <QMessageBox> #include <QMessageBox>
#include <qmuparsererror.h> #include "../../libs/qmuparser/qmuparsererror.h"
const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagPattern = QStringLiteral("pattern");
const QString VPattern::TagCalculation = QStringLiteral("calculation"); const QString VPattern::TagCalculation = QStringLiteral("calculation");

3
src/libs/libs.pro Normal file
View File

@ -0,0 +1,3 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = qmuparser

View File

@ -1,52 +1,7 @@
TEMPLATE = subdirs TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = \ SUBDIRS = \
sub_app \ libs \
sub_lib_qmuparser \ app \
test/ParserTest test
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)

View File

@ -58,9 +58,10 @@ CONFIG(debug, debug|release){
QMAKE_DISTCLEAN += $${DESTDIR}/* \ QMAKE_DISTCLEAN += $${DESTDIR}/* \
$${OBJECTS_DIR}/* $${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 win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libs/qmuparser/bin/ -lqmuparser2
DEPENDPATH += ../../libs/qmuparser 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

3
src/test/test.pro Normal file
View File

@ -0,0 +1,3 @@
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = ParserTest