Merge remote-tracking branch 'upstream/feature/manual-layout' into feature/manual-layout

This commit is contained in:
Ronan Le Tiec 2020-04-18 11:25:42 +02:00
commit 2cb5b8e6aa
9 changed files with 190 additions and 45 deletions

59
dist/debian/puzzle.1 vendored Normal file
View File

@ -0,0 +1,59 @@
.\" Manpage for puzzle
.\" Contact dismine@gmail.com to correct errors.
.TH puzzle 1 "23 March, 2020" "puzzle man page"
.SH NAME
Puzzle \- Valentina's manual layout
.SH SYNOPSIS
puzzle [options] file
.SH DESCRIPTION
.B Valentina
Puzzle is the name of the new application to create manual layouts. Similar to "Tape", it is an application that is separated from Valentina and work on it's own, but is a part of the Valentina package and work closely together with Valentina.
.B Puzzle
is a part of Valentina. And used for creating and editing manual layouts.
.IP "-h, --help"
Displays this help.
.IP "-v, --version"
Displays version information.
.IP "-e, --exportFile <The filename of layout file>"
The filename of exported layout file. Use it to enable console export mode.
.IP "-r, --rawLayout <The raw layout data file>"
Load pattern pieces form the raw layout data file.
.IP "-f, --format <Format number>"
Number corresponding to tiled pdf page template (default = 0, export mode with tiled pdf format): <not defined>
.IP "--bdxf"
Export dxf in binary form.
.IP "--text2paths"
Export text as paths.
.IP "-c, --crop"
Auto crop unused length (export mode).
.IP "--cropWidth"
Auto crop unused width (export mode).
.IP "--tiledPageformat <Template number>"
Number corresponding to tiled pdf page template (default = 0, export mode with tiled pdf format): <not defined>
.IP "--tiledlmargin <The left margin>"
Tiled page left margin in current units like 3.0 (export mode). If not set will be used default value 1 cm.
.IP "--tiledrmargin <The right margin>"
Tiled page right margin in current units like 3.0 (export mode). If not set will be used default value 1 cm.
.IP "--tiledtmargin <The top margin>"
Tiled page top margin in current units like 3.0 (export mode). If not set will be used value default value 1 cm.
.IP "--tiledbmargin <The bottom margin>"
Tiled page bottom margin in current units like 3.0 (export mode). If not set will be used value default value 1 cm.
.IP "--tiledLandscape"
Set tiled page orienatation to landscape (export mode). Default value if not set portrait.
.IP "-t, --test"
Run the program in a test mode. The program in this mode loads a single layout file and silently quit without showing the main window. The key have priority before key 'exportFile'.
.IP "--no-scaling"
Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable.
.IP Arguments:
.I filename
\- the manual layout file.
.SH AUTHOR
.RI "This manual page was written by Roman Telezhynskyi <" dismine@gmail.com ">"
.SH "SEE ALSO"
.RB "Full " "User Manual" " is availiable in"
.UR https://bitbucket.org/dismine/valentina/wiki/manual/Content
.UE
.BR valentina (1)

0
dist/debian/tape.1 vendored Normal file → Executable file
View File

0
dist/debian/valentina.1 vendored Normal file → Executable file
View File

View File

@ -198,7 +198,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg) if (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
{ {
if (not qApp->IsTestMode()) if (qApp->IsAppInGUIMode())
{ {
if (topWinAllowsPop) if (topWinAllowsPop)
{ {
@ -235,8 +235,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
PuzzleApplication::PuzzleApplication(int &argc, char **argv) PuzzleApplication::PuzzleApplication(int &argc, char **argv)
:VAbstractApplication(argc, argv), :VAbstractApplication(argc, argv),
mainWindows(), mainWindows(),
localServer(nullptr), localServer(nullptr)
testMode(false)
{ {
setApplicationDisplayName(VER_PRODUCTNAME_STR); setApplicationDisplayName(VER_PRODUCTNAME_STR);
setApplicationName(VER_INTERNALNAME_STR); setApplicationName(VER_INTERNALNAME_STR);
@ -321,19 +320,13 @@ bool PuzzleApplication::notify(QObject *receiver, QEvent *event)
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------
bool PuzzleApplication::IsTestMode() const
{
return testMode;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication class. * @brief IsAppInGUIMode little hack that allow to have access to application state from VAbstractApplication class.
*/ */
bool PuzzleApplication::IsAppInGUIMode() const bool PuzzleApplication::IsAppInGUIMode() const
{ {
return IsTestMode(); return CommandLine()->IsGuiEnabled();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -342,7 +335,9 @@ PuzzleMainWindow *PuzzleApplication::MainWindow()
Clean(); Clean();
if (mainWindows.isEmpty()) if (mainWindows.isEmpty())
{ {
NewMainWindow(); VPuzzleCommandLinePtr cmd;
VPuzzleCommandLine::ProcessInstance(cmd, QStringList());
NewMainWindow(true);
} }
return mainWindows[0]; return mainWindows[0];
} }
@ -360,11 +355,11 @@ QList<PuzzleMainWindow *> PuzzleApplication::MainWindows()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzleMainWindow *PuzzleApplication::NewMainWindow() PuzzleMainWindow *PuzzleApplication::NewMainWindow(bool guiMode)
{ {
PuzzleMainWindow *puzzle = new PuzzleMainWindow(); PuzzleMainWindow *puzzle = new PuzzleMainWindow();
mainWindows.prepend(puzzle); mainWindows.prepend(puzzle);
if (not qApp->IsTestMode()) if (guiMode)
{ {
puzzle->show(); puzzle->show();
} }
@ -444,10 +439,10 @@ void PuzzleApplication::ActivateDarkMode()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments) void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, const QStringList &arguments)
{ {
VPuzzleCommandLinePtr cmd = CommandLine(); VPuzzleCommandLinePtr cmd;
testMode = cmd->IsTestModeEnabled(); VPuzzleCommandLine::ProcessInstance(cmd, arguments);
if (not testMode && connection == SocketConnection::Client) if (cmd->IsGuiEnabled() && connection == SocketConnection::Client)
{ {
const QString serverName = QCoreApplication::applicationName(); const QString serverName = QCoreApplication::applicationName();
QLocalSocket socket; QLocalSocket socket;
@ -456,7 +451,7 @@ void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, con
{ {
qCDebug(mApp, "Connected to the server '%s'", qUtf8Printable(serverName)); qCDebug(mApp, "Connected to the server '%s'", qUtf8Printable(serverName));
QTextStream stream(&socket); QTextStream stream(&socket);
stream << QCoreApplication::arguments().join(";;"); stream << arguments.join(";;");
stream.flush(); stream.flush();
socket.waitForBytesWritten(); socket.waitForBytesWritten();
qApp->exit(V_EX_OK); qApp->exit(V_EX_OK);
@ -485,43 +480,65 @@ void PuzzleApplication::ParseCommandLine(const SocketConnection &connection, con
LoadTranslation(PuzzleSettings()->GetLocale()); LoadTranslation(PuzzleSettings()->GetLocale());
} }
ProcessArguments(cmd);
}
//---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::ProcessArguments(const VPuzzleCommandLinePtr &cmd)
{
const QStringList rawLayouts = cmd->OptionRawLayouts();
const QStringList args = cmd->OptionFileNames(); const QStringList args = cmd->OptionFileNames();
if (args.count() > 0) if (args.count() > 0)
{ {
if (testMode && args.count() > 1) if (not cmd->IsGuiEnabled() && args.count() > 1)
{ {
qCCritical(mApp, "%s\n", qPrintable(tr("Test mode doesn't support openning several files."))); qCCritical(mApp, "%s\n", qPrintable(tr("Export mode doesn't support openning several files.")));
cmd.get()->parser.showHelp(V_EX_USAGE);
}
if (args.count() > 1 && rawLayouts.size() > 0)
{
qCCritical(mApp, "%s\n",
qPrintable(tr("Import raw layout data does not support penning several layout files.")));
cmd.get()->parser.showHelp(V_EX_USAGE); cmd.get()->parser.showHelp(V_EX_USAGE);
} }
for (auto &arg : args) for (auto &arg : args)
{ {
NewMainWindow(); NewMainWindow(cmd->IsGuiEnabled());
if (not MainWindow()->LoadFile(arg)) if (not MainWindow()->LoadFile(arg))
{ {
if (testMode) if (not cmd->IsGuiEnabled())
{ {
return; // process only one input file return; // process only one input file
} }
delete MainWindow(); delete MainWindow();
continue; continue;
} }
// if (rawLayouts.size() > 0)
// {
// MainWindow()->ImportRawLayouts(rawLayouts);
// }
} }
} }
else else
{ {
if (not testMode) if (cmd->IsTestModeEnabled())
{
NewMainWindow();
}
else
{ {
qCCritical(mApp, "%s\n", qPrintable(tr("Please, provide one input file."))); qCCritical(mApp, "%s\n", qPrintable(tr("Please, provide one input file.")));
cmd.get()->parser.showHelp(V_EX_USAGE); cmd.get()->parser.showHelp(V_EX_USAGE);
} }
NewMainWindow(cmd->IsGuiEnabled());
// if (rawLayouts.size() > 0)
// {
// MainWindow()->New(); // prepare layout settings
// MainWindow()->ImportRawLayouts(rawLayouts);
// }
} }
if (testMode) if (not cmd->IsGuiEnabled())
{ {
qApp->exit(V_EX_OK); // close program after processing in console mode qApp->exit(V_EX_OK); // close program after processing in console mode
} }
@ -591,19 +608,18 @@ void PuzzleApplication::AboutToQuit()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleApplication::NewLocalSocketConnection() void PuzzleApplication::NewLocalSocketConnection()
{ {
QLocalSocket *socket = localServer->nextPendingConnection(); QScopedPointer<QLocalSocket>socket(localServer->nextPendingConnection());
if (not socket) if (socket.isNull())
{ {
return; return;
} }
socket->waitForReadyRead(1000); socket->waitForReadyRead(1000);
QTextStream stream(socket); QTextStream stream(socket.data());
const QString arg = stream.readAll(); const QString arg = stream.readAll();
if (not arg.isEmpty()) if (not arg.isEmpty())
{ {
ParseCommandLine(SocketConnection::Server, arg.split(";;")); ParseCommandLine(SocketConnection::Server, arg.split(";;"));
} }
delete socket;
MainWindow()->raise(); MainWindow()->raise();
MainWindow()->activateWindow(); MainWindow()->activateWindow();
} }
@ -622,7 +638,7 @@ void PuzzleApplication::Clean()
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
const VPuzzleCommandLinePtr PuzzleApplication::CommandLine() VPuzzleCommandLinePtr PuzzleApplication::CommandLine() const
{ {
return VPuzzleCommandLine::instance; return VPuzzleCommandLine::instance;
} }

View File

@ -55,15 +55,13 @@ public:
virtual bool notify(QObject * receiver, QEvent * event) override; virtual bool notify(QObject * receiver, QEvent * event) override;
bool IsTestMode() const;
virtual bool IsAppInGUIMode() const override; virtual bool IsAppInGUIMode() const override;
PuzzleMainWindow *MainWindow(); PuzzleMainWindow *MainWindow();
QList<PuzzleMainWindow*> MainWindows(); QList<PuzzleMainWindow*> MainWindows();
PuzzleMainWindow *NewMainWindow(); PuzzleMainWindow *NewMainWindow(bool guiMode);
void InitOptions(); void InitOptions();
virtual const VTranslateVars *TrVars() override; virtual const VTranslateVars *TrVars() override;
virtual void OpenSettings() override; virtual void OpenSettings() override;
@ -71,7 +69,8 @@ public:
void ActivateDarkMode(); void ActivateDarkMode();
void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments);
const VPuzzleCommandLinePtr CommandLine(); void ProcessArguments(const VPuzzleCommandLinePtr &cmd);
VPuzzleCommandLinePtr CommandLine() const;
public slots: public slots:
void ProcessCMD(); void ProcessCMD();
@ -89,7 +88,6 @@ private:
Q_DISABLE_COPY(PuzzleApplication) Q_DISABLE_COPY(PuzzleApplication)
QList<QPointer<PuzzleMainWindow> > mainWindows; QList<QPointer<PuzzleMainWindow> > mainWindows;
QLocalServer *localServer; QLocalServer *localServer;
bool testMode;
void Clean(); void Clean();
}; };

View File

@ -56,6 +56,12 @@ bool PuzzleMainWindow::LoadFile(const QString &path)
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::ImportRawLayouts(const QStringList &layouts)
{
Q_UNUSED(layouts)
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::InitMenuBar() void PuzzleMainWindow::InitMenuBar()
{ {

View File

@ -28,14 +28,15 @@
#ifndef PUZZLEMAINWINDOW_H #ifndef PUZZLEMAINWINDOW_H
#define PUZZLEMAINWINDOW_H #define PUZZLEMAINWINDOW_H
#include "../vmisc/def.h"
#include <QMainWindow> #include <QMainWindow>
#include <QMessageBox> #include <QMessageBox>
#include "../vmisc/def.h"
#include "vpiececarrousel.h" #include "vpiececarrousel.h"
namespace Ui { namespace Ui
class PuzzleMainWindow; {
class PuzzleMainWindow;
} }
class PuzzleMainWindow : public QMainWindow class PuzzleMainWindow : public QMainWindow
@ -48,6 +49,11 @@ public:
bool LoadFile(const QString &path); bool LoadFile(const QString &path);
void ImportRawLayouts(const QStringList &layouts);
public slots:
void New();
private: private:
Q_DISABLE_COPY(PuzzleMainWindow) Q_DISABLE_COPY(PuzzleMainWindow)
Ui::PuzzleMainWindow *ui; Ui::PuzzleMainWindow *ui;
@ -62,7 +68,6 @@ private:
void InitPieceCarrousel(); void InitPieceCarrousel();
private slots: private slots:
void New();
void Open(); void Open();
void Save(); void Save();
void SaveAs(); void SaveAs();

View File

@ -1,3 +1,30 @@
/************************************************************************
**
** @file vpuzzlecommandline.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina 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.
**
** Valentina 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/>.
**
*************************************************************************/
#include "vpuzzlecommandline.h" #include "vpuzzlecommandline.h"
#include "puzzlecommands.h" #include "puzzlecommands.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
@ -84,15 +111,21 @@ VPuzzleCommandLine::VPuzzleCommandLine():
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
VPuzzleCommandLinePtr VPuzzleCommandLine::Instance(const QCoreApplication &app) VPuzzleCommandLinePtr VPuzzleCommandLine::Instance(const QCoreApplication &app)
{
VPuzzleCommandLine::ProcessInstance(instance, app.arguments());
return instance;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleCommandLine::ProcessInstance(VPuzzleCommandLinePtr &instance, const QStringList &arguments)
{ {
if (instance == nullptr) if (instance == nullptr)
{ {
instance.reset(new VPuzzleCommandLine); instance.reset(new VPuzzleCommandLine);
} }
instance->parser.process(app); instance->parser.process(arguments);
instance->isGuiEnabled = not (instance->IsGuiEnabled() || instance->IsExportEnabled()); instance->isGuiEnabled = not (instance->IsGuiEnabled() || instance->IsExportEnabled());
return instance;
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------

View File

@ -1,3 +1,30 @@
/************************************************************************
**
** @file vpuzzlecommandline.h
** @author Dmytro Hladkykh <vorzelmir@gmail.com>
** @date 12 4, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina 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.
**
** Valentina 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/>.
**
*************************************************************************/
#ifndef VPUZZLECOMMANDLINE_H #ifndef VPUZZLECOMMANDLINE_H
#define VPUZZLECOMMANDLINE_H #define VPUZZLECOMMANDLINE_H
@ -39,6 +66,7 @@ protected:
/** @brief create the single instance of the class inside puzzleapplication */ /** @brief create the single instance of the class inside puzzleapplication */
static VPuzzleCommandLinePtr Instance(const QCoreApplication &app); static VPuzzleCommandLinePtr Instance(const QCoreApplication &app);
static void ProcessInstance(VPuzzleCommandLinePtr &instance, const QStringList &arguments);
private: private:
Q_DISABLE_COPY(VPuzzleCommandLine) Q_DISABLE_COPY(VPuzzleCommandLine)
static VPuzzleCommandLinePtr instance; static VPuzzleCommandLinePtr instance;