diff --git a/src/app/puzzle/puzzle.pro b/src/app/puzzle/puzzle.pro index 7463ba832..be7037a9e 100644 --- a/src/app/puzzle/puzzle.pro +++ b/src/app/puzzle/puzzle.pro @@ -7,7 +7,7 @@ # File with common stuff for whole project include(../../../common.pri) -QT += core gui widgets network xml xmlpatterns printsupport +QT += core gui widgets network xml xmlpatterns printsupport concurrent # Name of binary file TARGET = puzzle @@ -187,7 +187,7 @@ noRunPath{ # For enable run qmake with CONFIG+=noRunPath # When the GNU linker sees a library, it discards all symbols that it doesn't need. # Dependent library go first. -#VTools static library (depend on VWidgets, VMisc, VPatternDB) +##VTools static library (depend on VWidgets, VMisc, VPatternDB) #unix|win32: LIBS += -L$$OUT_PWD/../../libs/vtools/$${DESTDIR}/ -lvtools #INCLUDEPATH += $$PWD/../../libs/vtools @@ -215,14 +215,23 @@ noRunPath{ # For enable run qmake with CONFIG+=noRunPath #win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib #else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a -##VPatternDB static library (depend on vgeometry, vmisc, VLayout) -#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb +# VLayout static library (depend on VGeometry) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout -#INCLUDEPATH += $$PWD/../../libs/vpatterndb -#DEPENDPATH += $$PWD/../../libs/vpatterndb +INCLUDEPATH += $$PWD/../../libs/vlayout +DEPENDPATH += $$PWD/../../libs/vlayout -#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib -#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a + +#VPatternDB static library (depend on vgeometry, vmisc) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb + +INCLUDEPATH += $$PWD/../../libs/vpatterndb +DEPENDPATH += $$PWD/../../libs/vpatterndb + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a # Fervor static library (depend on VMisc, IFC) unix|win32: LIBS += -L$$OUT_PWD/../../libs/fervor/$${DESTDIR}/ -lfervor @@ -251,31 +260,22 @@ DEPENDPATH += $$PWD/../../libs/vmisc win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/vmisc.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/libvmisc.a -## VLayout static library (depend on VGeometry) -#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout +# VGeometry static library (depend on ifc) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/ -lvgeometry -#INCLUDEPATH += $$PWD/../../libs/vlayout -#DEPENDPATH += $$PWD/../../libs/vlayout +INCLUDEPATH += $$PWD/../../libs/vgeometry +DEPENDPATH += $$PWD/../../libs/vgeometry -#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib -#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a -## VGeometry static library (depend on ifc) -#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/ -lvgeometry +# QMuParser library +win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 +else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 +else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser -#INCLUDEPATH += $$PWD/../../libs/vgeometry -#DEPENDPATH += $$PWD/../../libs/vgeometry - -#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/vgeometry.lib -#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vgeometry/$${DESTDIR}/libvgeometry.a - -## QMuParser library -#win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 -#else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2 -#else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser - -#INCLUDEPATH += $${PWD}/../../libs/qmuparser -#DEPENDPATH += $${PWD}/../../libs/qmuparser +INCLUDEPATH += $${PWD}/../../libs/qmuparser +DEPENDPATH += $${PWD}/../../libs/qmuparser ## VPropertyExplorer library #win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer diff --git a/src/app/puzzle/puzzleapplication.cpp b/src/app/puzzle/puzzleapplication.cpp index 0a43246b2..32e84e1bd 100644 --- a/src/app/puzzle/puzzleapplication.cpp +++ b/src/app/puzzle/puzzleapplication.cpp @@ -337,7 +337,7 @@ PuzzleMainWindow *PuzzleApplication::MainWindow() { VPuzzleCommandLinePtr cmd; VPuzzleCommandLine::ProcessInstance(cmd, QStringList()); - NewMainWindow(true); + NewMainWindow(VPuzzleCommandLinePtr()); } return mainWindows[0]; } @@ -355,11 +355,11 @@ QList PuzzleApplication::MainWindows() } //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow *PuzzleApplication::NewMainWindow(bool guiMode) +PuzzleMainWindow *PuzzleApplication::NewMainWindow(const VPuzzleCommandLinePtr &cmd) { - PuzzleMainWindow *puzzle = new PuzzleMainWindow(); + PuzzleMainWindow *puzzle = new PuzzleMainWindow(cmd); mainWindows.prepend(puzzle); - if (guiMode) + if (cmd->IsGuiEnabled()) { puzzle->show(); } @@ -505,7 +505,7 @@ void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd) for (auto &arg : args) { - NewMainWindow(cmd->IsGuiEnabled()); + NewMainWindow(cmd); if (not MainWindow()->LoadFile(arg)) { if (not cmd->IsGuiEnabled()) @@ -516,10 +516,10 @@ void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd) continue; } -// if (rawLayouts.size() > 0) -// { -// MainWindow()->ImportRawLayouts(rawLayouts); -// } + if (rawLayouts.size() > 0) + { + MainWindow()->ImportRawLayouts(rawLayouts); + } } } else @@ -530,12 +530,12 @@ void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd) cmd.get()->parser.showHelp(V_EX_USAGE); } - NewMainWindow(cmd->IsGuiEnabled()); -// if (rawLayouts.size() > 0) -// { + NewMainWindow(cmd); + if (rawLayouts.size() > 0) + { // MainWindow()->New(); // prepare layout settings -// MainWindow()->ImportRawLayouts(rawLayouts); -// } + MainWindow()->ImportRawLayouts(rawLayouts); + } } if (not cmd->IsGuiEnabled()) diff --git a/src/app/puzzle/puzzleapplication.h b/src/app/puzzle/puzzleapplication.h index c0dcf24ed..d93748835 100644 --- a/src/app/puzzle/puzzleapplication.h +++ b/src/app/puzzle/puzzleapplication.h @@ -58,7 +58,7 @@ public: virtual bool IsAppInGUIMode() const override; PuzzleMainWindow *MainWindow(); QList MainWindows(); - PuzzleMainWindow *NewMainWindow(bool guiMode); + PuzzleMainWindow *NewMainWindow(const VPuzzleCommandLinePtr &cmd); void InitOptions(); diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index c663a6858..bbf781b5e 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -28,12 +28,25 @@ #include "puzzlemainwindow.h" #include "ui_puzzlemainwindow.h" #include "dialogs/dialogaboutpuzzle.h" +#include "../vlayout/vrawlayout.h" +#include "../vmisc/vsysexits.h" + +#include + +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pWindow, "p.window") + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- -PuzzleMainWindow::PuzzleMainWindow(QWidget *parent) : +PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : QMainWindow(parent), ui(new Ui::PuzzleMainWindow), - pieceCarrousel(new VPieceCarrousel) + pieceCarrousel(new VPieceCarrousel), + m_cmd(cmd) { ui->setupUi(this); @@ -59,7 +72,25 @@ bool PuzzleMainWindow::LoadFile(const QString &path) //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::ImportRawLayouts(const QStringList &layouts) { - Q_UNUSED(layouts) + VRawLayout layoutReader; + + for(auto &path : layouts) + { + VRawLayoutData data; + if (layoutReader.ReadFile(path, data)) + { + // Do somethinmg with raw layout data + } + else + { + qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2") + .arg(path, layoutReader.ErrorString()))); + if (m_cmd != nullptr && not m_cmd->IsGuiEnabled()) + { + m_cmd->ShowHelp(V_EX_DATAERR); + } + } + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/puzzlemainwindow.h index 86f786f2c..8275373d2 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -33,6 +33,7 @@ #include "../vmisc/def.h" #include "vpiececarrousel.h" +#include "vpuzzlecommandline.h" namespace Ui { @@ -44,7 +45,7 @@ class PuzzleMainWindow : public QMainWindow Q_OBJECT public: - explicit PuzzleMainWindow(QWidget *parent = nullptr); + PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent = nullptr); virtual ~PuzzleMainWindow(); bool LoadFile(const QString &path); @@ -58,6 +59,7 @@ private: Q_DISABLE_COPY(PuzzleMainWindow) Ui::PuzzleMainWindow *ui; VPieceCarrousel *pieceCarrousel; + VPuzzleCommandLinePtr m_cmd; void InitMenuBar(); void InitProperties();