2020-02-16 17:17:50 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
2020-05-23 14:17:20 +02:00
|
|
|
** @file vpmainwindow.cpp
|
2020-02-16 17:17:50 +01:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 16 2, 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
2020-05-23 14:17:20 +02:00
|
|
|
#include "vpmainwindow.h"
|
2020-04-18 16:32:54 +02:00
|
|
|
|
|
|
|
#include <QFileDialog>
|
2020-05-23 13:49:38 +02:00
|
|
|
#include <QCloseEvent>
|
2020-11-14 10:20:02 +01:00
|
|
|
#include <QtMath>
|
2020-04-18 16:32:54 +02:00
|
|
|
|
2020-05-23 14:17:20 +02:00
|
|
|
#include "ui_vpmainwindow.h"
|
2020-05-23 13:49:38 +02:00
|
|
|
#include "dialogs/vpdialogabout.h"
|
2020-05-23 14:02:39 +02:00
|
|
|
#include "xml/vplayoutfilewriter.h"
|
2020-05-23 14:01:03 +02:00
|
|
|
#include "xml/vplayoutfilereader.h"
|
2020-05-23 14:10:05 +02:00
|
|
|
#include "vpapplication.h"
|
2020-04-21 18:03:36 +02:00
|
|
|
#include "../vlayout/vrawlayout.h"
|
|
|
|
#include "../vmisc/vsysexits.h"
|
2020-05-10 17:38:06 +02:00
|
|
|
#include "../vmisc/projectversion.h"
|
2020-04-23 17:05:00 +02:00
|
|
|
#include "../ifc/xml/vlayoutconverter.h"
|
|
|
|
#include "../ifc/exception/vexception.h"
|
2020-11-14 10:55:57 +01:00
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
2020-05-23 17:47:04 +02:00
|
|
|
#include "vpsheet.h"
|
2020-04-19 16:01:46 +02:00
|
|
|
|
2020-04-21 18:03:36 +02:00
|
|
|
#include <QLoggingCategory>
|
2020-11-14 12:37:43 +01:00
|
|
|
#include <QtSvg>
|
2020-04-19 16:01:46 +02:00
|
|
|
|
2020-04-21 18:03:36 +02:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
|
|
|
QT_WARNING_DISABLE_INTEL(1418)
|
|
|
|
|
|
|
|
Q_LOGGING_CATEGORY(pWindow, "p.window")
|
|
|
|
|
|
|
|
QT_WARNING_POP
|
2020-02-16 17:17:50 +01:00
|
|
|
|
2020-02-16 18:18:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:48:31 +02:00
|
|
|
VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
|
2020-02-16 17:17:50 +01:00
|
|
|
QMainWindow(parent),
|
2020-05-23 14:17:20 +02:00
|
|
|
ui(new Ui::VPMainWindow),
|
2020-04-21 18:03:36 +02:00
|
|
|
m_cmd(cmd)
|
2020-02-16 17:17:50 +01:00
|
|
|
{
|
2020-05-23 15:34:11 +02:00
|
|
|
m_layout = new VPLayout();
|
2020-04-26 12:09:28 +02:00
|
|
|
|
2020-05-23 17:47:04 +02:00
|
|
|
// create a standard sheet
|
|
|
|
VPSheet *sheet = new VPSheet(m_layout);
|
|
|
|
sheet->SetName(QObject::tr("Sheet #1"));
|
|
|
|
m_layout->AddSheet(sheet);
|
|
|
|
m_layout->SetFocusedSheet();
|
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
// ----- for test purposes, to be removed------------------
|
2020-06-25 16:59:48 +02:00
|
|
|
sheet->SetSheetMarginsConverted(1, 1, 1, 1);
|
|
|
|
sheet->SetSheetSizeConverted(84.1, 118.9);
|
2020-05-23 17:47:04 +02:00
|
|
|
sheet->SetPiecesGapConverted(1);
|
|
|
|
|
2020-04-19 11:58:43 +02:00
|
|
|
m_layout->SetUnit(Unit::Cm);
|
2020-04-19 12:47:38 +02:00
|
|
|
m_layout->SetWarningSuperpositionOfPieces(true);
|
2020-11-11 19:14:06 +01:00
|
|
|
m_layout->SetTitle(QString("My Test Layout"));
|
|
|
|
m_layout->SetDescription(QString("Description of my Layout"));
|
2020-11-14 15:58:42 +01:00
|
|
|
|
|
|
|
m_layout->SetTilesSizeConverted(21,29.7);
|
|
|
|
m_layout->SetTilesOrientation(PageOrientation::Portrait);
|
|
|
|
m_layout->SetTilesMarginsConverted(1,1,1,1);
|
|
|
|
m_layout->SetShowTiles(true);
|
|
|
|
|
2020-04-24 16:10:42 +02:00
|
|
|
// --------------------------------------------------------
|
|
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
InitMenuBar();
|
|
|
|
InitProperties();
|
2020-05-23 14:29:18 +02:00
|
|
|
InitCarrousel();
|
2020-05-05 07:44:20 +02:00
|
|
|
InitMainGraphics();
|
|
|
|
|
2020-11-14 10:20:02 +01:00
|
|
|
InitZoomToolBar();
|
2020-04-24 16:10:42 +02:00
|
|
|
|
2020-04-19 11:58:43 +02:00
|
|
|
SetPropertiesData();
|
2020-05-10 17:38:06 +02:00
|
|
|
|
|
|
|
ReadSettings();
|
2020-02-16 17:17:50 +01:00
|
|
|
}
|
|
|
|
|
2020-02-16 18:18:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
VPMainWindow::~VPMainWindow()
|
2020-02-16 17:17:50 +01:00
|
|
|
{
|
|
|
|
delete ui;
|
2020-05-23 14:29:18 +02:00
|
|
|
delete m_carrousel;
|
2020-02-16 17:17:50 +01:00
|
|
|
}
|
2020-02-16 18:18:39 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
bool VPMainWindow::LoadFile(QString path)
|
2020-02-16 18:18:39 +01:00
|
|
|
{
|
2020-05-02 09:30:53 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
VLayoutConverter converter(path);
|
|
|
|
path = converter.Convert();
|
|
|
|
}
|
|
|
|
catch (VException &e)
|
|
|
|
{
|
|
|
|
qCCritical(pWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")),
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-23 17:05:00 +02:00
|
|
|
|
2020-04-19 16:01:46 +02:00
|
|
|
QFile file(path);
|
|
|
|
file.open(QIODevice::ReadOnly);
|
|
|
|
|
2020-05-23 14:01:03 +02:00
|
|
|
QScopedPointer<VPLayoutFileReader> fileReader(new VPLayoutFileReader());
|
2020-04-19 16:01:46 +02:00
|
|
|
|
|
|
|
if(m_layout == nullptr)
|
|
|
|
{
|
2020-05-23 15:34:11 +02:00
|
|
|
m_layout = new VPLayout();
|
2020-04-19 16:01:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fileReader->ReadFile(m_layout, &file);
|
|
|
|
|
|
|
|
// TODO / FIXME : better return value and error handling
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
bool VPMainWindow::SaveFile(const QString &path)
|
2020-04-19 16:01:46 +02:00
|
|
|
{
|
|
|
|
QFile file(path);
|
|
|
|
file.open(QIODevice::WriteOnly);
|
|
|
|
|
2020-05-23 14:02:39 +02:00
|
|
|
VPLayoutFileWriter *fileWriter = new VPLayoutFileWriter();
|
2020-04-19 16:01:46 +02:00
|
|
|
fileWriter->WriteFile(m_layout, &file);
|
|
|
|
|
|
|
|
// TODO / FIXME : better return value and error handling
|
|
|
|
|
2020-02-16 20:51:41 +01:00
|
|
|
return true;
|
2020-02-16 18:18:39 +01:00
|
|
|
}
|
2020-04-10 21:08:29 +02:00
|
|
|
|
2020-04-14 10:36:21 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts)
|
2020-04-14 10:36:21 +02:00
|
|
|
{
|
2020-04-26 12:09:28 +02:00
|
|
|
VRawLayout rawLayoutReader;
|
2020-04-21 18:03:36 +02:00
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
for(auto &path : rawLayouts)
|
2020-04-21 18:03:36 +02:00
|
|
|
{
|
|
|
|
VRawLayoutData data;
|
2020-04-26 12:09:28 +02:00
|
|
|
if (rawLayoutReader.ReadFile(path, data))
|
2020-04-21 18:03:36 +02:00
|
|
|
{
|
2020-04-26 12:09:28 +02:00
|
|
|
for (int i = 0; i < data.pieces.size(); ++i)
|
|
|
|
{
|
|
|
|
VLayoutPiece rawPiece = data.pieces.at(i);
|
2020-04-26 15:36:20 +02:00
|
|
|
|
|
|
|
|
2020-05-02 12:17:06 +02:00
|
|
|
|
|
|
|
// TODO / FIXME: make a few tests, on the data to check for validity. If not
|
|
|
|
//
|
|
|
|
// If seam allowance enabled, but the path is empty — invalid.
|
|
|
|
// If seam line path not hidden, but the path is empty — invalid.
|
|
|
|
// If seam allowance is built-in, but the seam line path is empty — invalid.
|
|
|
|
|
|
|
|
|
2020-05-05 07:44:20 +02:00
|
|
|
// TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece()
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece *piece = CreatePiece(rawPiece);
|
2020-05-23 15:29:57 +02:00
|
|
|
m_layout->GetUnplacedPieceList()->AddPiece(piece);
|
2020-04-26 12:09:28 +02:00
|
|
|
}
|
|
|
|
|
2020-05-23 14:29:18 +02:00
|
|
|
m_carrousel->Refresh();
|
2020-04-21 18:03:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2")
|
2020-04-26 12:09:28 +02:00
|
|
|
.arg(path, rawLayoutReader.ErrorString())));
|
2020-04-21 18:03:36 +02:00
|
|
|
if (m_cmd != nullptr && not m_cmd->IsGuiEnabled())
|
|
|
|
{
|
|
|
|
m_cmd->ShowHelp(V_EX_DATAERR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-14 10:36:21 +02:00
|
|
|
}
|
|
|
|
|
2020-11-13 23:31:22 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::InitZoom()
|
|
|
|
{
|
|
|
|
m_graphicsView->ZoomFitBest();
|
|
|
|
}
|
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece* VPMainWindow::CreatePiece(const VLayoutPiece &rawPiece)
|
2020-04-26 12:09:28 +02:00
|
|
|
{
|
2020-06-25 14:17:31 +02:00
|
|
|
VPPiece *piece = new VPPiece(rawPiece);
|
2020-05-06 15:05:01 +02:00
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
|
2020-06-25 14:17:31 +02:00
|
|
|
// cutting line : GetMappedSeamAllowancePoints();
|
|
|
|
// seamline : GetMappedContourPoints();
|
|
|
|
|
|
|
|
// rawPiece.IsGrainlineEnabled() , GrainlineAngle , GetGrainline
|
|
|
|
|
2020-05-06 15:05:01 +02:00
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
// TODO : set all the information we need for the piece!
|
|
|
|
|
2020-05-05 17:40:36 +02:00
|
|
|
//
|
2020-05-23 15:42:51 +02:00
|
|
|
connect(piece, &VPPiece::SelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged);
|
|
|
|
connect(piece, &VPPiece::PositionChanged, this, &VPMainWindow::on_PiecePositionChanged);
|
|
|
|
connect(piece, &VPPiece::RotationChanged, this, &VPMainWindow::on_PieceRotationChanged);
|
2020-05-05 17:40:36 +02:00
|
|
|
|
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
return piece;
|
|
|
|
}
|
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::InitMenuBar()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
2020-04-24 16:10:42 +02:00
|
|
|
// most of the actions are connected through name convention (auto-connection)
|
|
|
|
|
|
|
|
|
2020-04-13 12:24:26 +02:00
|
|
|
// -------------------- connects the actions for the file menu
|
2020-05-23 14:17:20 +02:00
|
|
|
connect(ui->actionExit, &QAction::triggered, this, &VPMainWindow::close);
|
2020-04-10 21:08:29 +02:00
|
|
|
|
2020-04-13 12:24:26 +02:00
|
|
|
// -------------------- connects the actions for the edit menu
|
2020-04-10 21:08:29 +02:00
|
|
|
// TODO : initialise the undo / redo
|
|
|
|
|
2020-04-13 12:24:26 +02:00
|
|
|
// -------------------- connects the actions for the windows menu
|
2020-04-10 21:08:29 +02:00
|
|
|
// TODO : initialise the entries for the different windows
|
|
|
|
|
2020-04-13 12:24:26 +02:00
|
|
|
// Add dock properties action
|
|
|
|
QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction();
|
|
|
|
ui->menuWindows->addAction(actionDockWidgetToolOptions);
|
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 11:17:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::InitProperties()
|
2020-04-11 11:17:53 +02:00
|
|
|
{
|
2020-04-11 16:25:23 +02:00
|
|
|
InitPropertyTabCurrentPiece();
|
2020-11-11 19:31:39 +01:00
|
|
|
InitPropertyTabCurrentSheet();
|
2020-04-11 16:25:23 +02:00
|
|
|
InitPropertyTabLayout();
|
|
|
|
InitPropertyTabTiles();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::InitPropertyTabCurrentPiece()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-11-11 19:31:39 +01:00
|
|
|
// FIXME ---- For MVP we hide a few things. To be displayed when functions there
|
|
|
|
ui->groupBoxLayoutControl->hide();
|
|
|
|
ui->groupBoxCurrentPieceGeometry->hide();
|
|
|
|
|
2020-04-11 17:04:44 +02:00
|
|
|
|
|
|
|
// ------------------------------ placement -----------------------------------
|
|
|
|
connect(ui->doubleSpinBoxCurrentPieceBoxPositionX, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-05-23 14:17:20 +02:00
|
|
|
&VPMainWindow::on_CurrentPiecePositionEdited);
|
2020-04-11 17:04:44 +02:00
|
|
|
connect(ui->doubleSpinBoxCurrentPieceBoxPositionY, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-05-23 14:17:20 +02:00
|
|
|
&VPMainWindow::on_CurrentPiecePositionEdited);
|
2020-04-11 11:17:53 +02:00
|
|
|
}
|
|
|
|
|
2020-11-11 19:31:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::InitPropertyTabCurrentSheet()
|
|
|
|
{
|
|
|
|
// FIXME ---- For MVP we hide a few things. To be displayed when functions there
|
|
|
|
ui->pushButtonSheetRemoveUnusedLength->hide();
|
|
|
|
ui->groupBoxSheetControl->hide();
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-24 16:10:42 +02:00
|
|
|
// some of the UI Elements are connected to the slots via auto-connect
|
|
|
|
// see https://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect
|
2020-04-11 16:25:23 +02:00
|
|
|
|
|
|
|
// -------------------- layout width, length, orientation ------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
connect(ui->doubleSpinBoxSheetWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
|
|
|
&VPMainWindow::on_SheetSizeChanged);
|
|
|
|
connect(ui->doubleSpinBoxSheetLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
|
|
|
&VPMainWindow::on_SheetSizeChanged);
|
|
|
|
connect(ui->radioButtonSheetPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
|
|
|
|
&VPMainWindow::on_SheetOrientationChanged);
|
|
|
|
connect(ui->radioButtonSheetLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
|
|
|
|
&VPMainWindow::on_SheetOrientationChanged);
|
2020-04-11 16:25:23 +02:00
|
|
|
|
|
|
|
// -------------------- margins ------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
connect(ui->doubleSpinBoxSheetMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
|
|
|
&VPMainWindow::on_SheetMarginChanged);
|
|
|
|
connect(ui->doubleSpinBoxSheetMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
|
|
|
&VPMainWindow::on_SheetMarginChanged);
|
|
|
|
connect(ui->doubleSpinBoxSheetMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
|
|
|
&VPMainWindow::on_SheetMarginChanged);
|
|
|
|
connect(ui->doubleSpinBoxSheetMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
|
|
|
&VPMainWindow::on_SheetMarginChanged);
|
2020-04-11 16:25:23 +02:00
|
|
|
|
|
|
|
// ------------------- follow grainline -----------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
connect(ui->radioButtonSheetFollowGrainlineNo, QOverload<bool>::of(&QRadioButton::clicked), this,
|
|
|
|
&VPMainWindow::on_SheetFollowGrainlineChanged);
|
|
|
|
connect(ui->radioButtonSheetFollowGrainlineVertical, QOverload<bool>::of(&QRadioButton::clicked), this,
|
|
|
|
&VPMainWindow::on_SheetFollowGrainlineChanged);
|
|
|
|
connect(ui->radioButtonSheetFollowGrainlineHorizontal, QOverload<bool>::of(&QRadioButton::clicked), this,
|
|
|
|
&VPMainWindow::on_SheetFollowGrainlineChanged);
|
2020-04-11 16:25:23 +02:00
|
|
|
|
|
|
|
// -------------------- export ---------------------------
|
2020-04-11 16:32:49 +02:00
|
|
|
|
|
|
|
// TODO init the file format export combobox
|
|
|
|
|
2020-11-14 15:58:42 +01:00
|
|
|
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::InitPropertyTabTiles()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-11-14 15:58:42 +01:00
|
|
|
// -------------------- layout width, length, orientation ------------------------
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->doubleSpinBoxTilesWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesSizeChanged);
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->doubleSpinBoxTilesLength, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesSizeChanged);
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->radioButtonTilesPortrait, QOverload<bool>::of(&QRadioButton::clicked), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesOrientationChanged);
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->radioButtonTilesLandscape, QOverload<bool>::of(&QRadioButton::clicked), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesOrientationChanged);
|
|
|
|
|
|
|
|
// -------------------- margins ------------------------
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->doubleSpinBoxTilesMarginTop, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesMarginChanged);
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->doubleSpinBoxTilesMarginRight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesMarginChanged);
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->doubleSpinBoxTilesMarginBottom, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesMarginChanged);
|
2020-11-14 17:31:34 +01:00
|
|
|
connect(ui->doubleSpinBoxTilesMarginLeft, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
2020-11-14 15:58:42 +01:00
|
|
|
&VPMainWindow::on_TilesMarginChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::InitPropertyTabLayout()
|
|
|
|
{
|
|
|
|
|
|
|
|
// FIXME ---- For MVP we hide a few things. To be displayed when functions there
|
|
|
|
ui->groupBoxLayoutControl->hide();
|
|
|
|
|
|
|
|
// -------------------- init the unit combobox ---------------------
|
|
|
|
ui->comboBoxLayoutUnit->addItem(tr("Centimeters"), QVariant(UnitsToStr(Unit::Cm)));
|
|
|
|
ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm)));
|
|
|
|
ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch)));
|
|
|
|
|
|
|
|
// set default unit - TODO when we have the setting for the unit
|
|
|
|
// const qint32 indexUnit = -1;//ui->comboBoxLayoutUnit->findData(qApp->ValentinaSettings()->GetUnit());
|
|
|
|
// if (indexUnit != -1)
|
|
|
|
// {
|
|
|
|
// ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit);
|
|
|
|
// }
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
2020-04-13 12:24:26 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:29:18 +02:00
|
|
|
void VPMainWindow::InitCarrousel()
|
2020-04-13 12:24:26 +02:00
|
|
|
{
|
2020-05-23 14:29:18 +02:00
|
|
|
m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel);
|
|
|
|
ui->dockWidgetCarrousel->setWidget(m_carrousel);
|
2020-04-13 12:24:26 +02:00
|
|
|
|
2020-05-23 14:29:18 +02:00
|
|
|
connect(ui->dockWidgetCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
|
|
|
|
&VPMainWindow::on_CarrouselLocationChanged);
|
2020-04-13 12:24:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-19 11:58:43 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::SetPropertiesData()
|
2020-04-19 11:58:43 +02:00
|
|
|
{
|
|
|
|
if(m_layout == nullptr)
|
|
|
|
{
|
|
|
|
// TODO : hide the tabs when there is no layout
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetPropertyTabCurrentPieceData();
|
2020-05-23 17:47:04 +02:00
|
|
|
SetPropertyTabSheetData();
|
2020-04-19 11:58:43 +02:00
|
|
|
SetPropertyTabTilesData();
|
2020-05-23 17:47:04 +02:00
|
|
|
SetPropertyTabLayoutData();
|
2020-04-19 11:58:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::SetPropertyTabCurrentPieceData()
|
2020-04-19 11:58:43 +02:00
|
|
|
{
|
2020-05-05 17:40:36 +02:00
|
|
|
if(m_selectedPieces.count() == 0)
|
2020-04-19 11:58:43 +02:00
|
|
|
{
|
2020-05-06 15:05:01 +02:00
|
|
|
// show the content "no piece selected"
|
|
|
|
|
2020-05-05 17:40:36 +02:00
|
|
|
ui->containerCurrentPieceNoData->setVisible(true);
|
|
|
|
ui->containerCurrentPieceData->setVisible(false);
|
2020-05-06 15:05:01 +02:00
|
|
|
ui->containerCurrentPieceMultipleData->setVisible(false);
|
2020-04-19 11:58:43 +02:00
|
|
|
}
|
2020-05-05 17:40:36 +02:00
|
|
|
else if(m_selectedPieces.count() == 1)
|
2020-04-19 11:58:43 +02:00
|
|
|
{
|
2020-05-06 15:05:01 +02:00
|
|
|
// show the content "selected piece data"
|
2020-05-01 19:08:48 +02:00
|
|
|
ui->containerCurrentPieceNoData->setVisible(false);
|
|
|
|
ui->containerCurrentPieceData->setVisible(true);
|
2020-05-06 15:05:01 +02:00
|
|
|
ui->containerCurrentPieceMultipleData->setVisible(false);
|
|
|
|
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece *selectedPiece = m_selectedPieces.first();
|
2020-05-01 19:08:48 +02:00
|
|
|
|
2020-05-01 18:26:02 +02:00
|
|
|
// set the value to the current piece
|
2020-05-05 17:40:36 +02:00
|
|
|
ui->lineEditCurrentPieceName->setText(selectedPiece->GetName());
|
2020-11-10 20:55:39 +01:00
|
|
|
ui->plainTextEditCurrentPieceUUID->setPlainText(selectedPiece->GetUUID().toString());
|
2020-05-01 18:26:02 +02:00
|
|
|
|
2020-05-05 17:40:36 +02:00
|
|
|
ui->checkBoxCurrentPieceShowSeamline->setChecked(selectedPiece->GetShowSeamLine());
|
|
|
|
ui->checkBoxCurrentPieceMirrorPiece->setChecked(selectedPiece->GetPieceMirrored());
|
2020-05-01 19:08:48 +02:00
|
|
|
|
2020-05-05 17:40:36 +02:00
|
|
|
QPointF pos = selectedPiece->GetPosition();
|
2020-05-11 16:44:30 +02:00
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
|
|
|
|
UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit()));
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY,
|
|
|
|
UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit()));
|
2020-05-05 17:40:36 +02:00
|
|
|
|
2020-05-09 11:13:29 +02:00
|
|
|
qreal angle = selectedPiece->GetRotation();
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle);
|
2020-05-05 17:40:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-06 15:05:01 +02:00
|
|
|
// show the content "multiple pieces selected"
|
|
|
|
|
|
|
|
ui->containerCurrentPieceNoData->setVisible(false);
|
|
|
|
ui->containerCurrentPieceData->setVisible(false);
|
|
|
|
ui->containerCurrentPieceMultipleData->setVisible(true);
|
|
|
|
|
|
|
|
// if needed in the future, we can show some properties that coul be edited for all the pieces
|
2020-04-19 11:58:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::SetPropertyTabSheetData()
|
2020-04-19 11:58:43 +02:00
|
|
|
{
|
2020-05-24 19:53:51 +02:00
|
|
|
// set name // TODO FIXME make it better
|
|
|
|
ui->lineEditSheetName->setText(m_layout->GetFocusedSheet()->GetName());
|
|
|
|
|
2020-04-19 11:58:43 +02:00
|
|
|
// set Width / Length
|
2020-05-23 17:47:04 +02:00
|
|
|
QSizeF size = m_layout->GetFocusedSheet()->GetSheetSizeConverted();
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetWidth, size.width());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetLength, size.height());
|
2020-04-19 11:58:43 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// Set Orientation
|
2020-11-14 15:58:42 +01:00
|
|
|
if(m_layout->GetFocusedSheet()->GetOrientation() == PageOrientation::Portrait)
|
2020-04-19 12:47:38 +02:00
|
|
|
{
|
2020-05-23 17:47:04 +02:00
|
|
|
ui->radioButtonSheetPortrait->setChecked(true);
|
2020-04-19 12:47:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-23 17:47:04 +02:00
|
|
|
ui->radioButtonSheetLandscape->setChecked(true);
|
2020-04-19 12:47:38 +02:00
|
|
|
}
|
|
|
|
|
2020-04-19 11:58:43 +02:00
|
|
|
// set margins
|
2020-05-23 17:47:04 +02:00
|
|
|
QMarginsF margins = m_layout->GetFocusedSheet()->GetSheetMarginsConverted();
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginLeft, margins.left());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginTop, margins.top());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginRight, margins.right());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetMarginBottom, margins.bottom());
|
2020-04-19 11:58:43 +02:00
|
|
|
|
|
|
|
// set pieces gap
|
2020-05-23 17:47:04 +02:00
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, m_layout->GetFocusedSheet()->GetPiecesGapConverted());
|
2020-04-19 12:47:38 +02:00
|
|
|
|
|
|
|
// set the checkboxes
|
2020-05-23 17:47:04 +02:00
|
|
|
SetCheckBoxValue(ui->checkBoxSheetStickyEdges, m_layout->GetFocusedSheet()->GetStickyEdges());
|
|
|
|
}
|
|
|
|
|
2020-11-14 15:58:42 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::SetPropertyTabTilesData()
|
|
|
|
{
|
|
|
|
// set Width / Length
|
|
|
|
QSizeF size = m_layout->GetTilesSizeConverted();
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesWidth, size.width());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesLength, size.height());
|
|
|
|
|
|
|
|
// Set Orientation
|
|
|
|
if(m_layout->GetTilesOrientation() == PageOrientation::Portrait)
|
|
|
|
{
|
|
|
|
ui->radioButtonSheetPortrait->setChecked(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->radioButtonSheetLandscape->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// set margins
|
|
|
|
QMarginsF margins = m_layout->GetTilesMarginsConverted();
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginLeft, margins.left());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginTop, margins.top());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginRight, margins.right());
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxTilesMarginBottom, margins.bottom());
|
|
|
|
|
|
|
|
// set "show tiles" checkbox
|
|
|
|
ui->checkBoxTilesShowTiles->setChecked(m_layout->GetShowTiles());
|
|
|
|
}
|
|
|
|
|
2020-05-23 17:47:04 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::SetPropertyTabLayoutData()
|
|
|
|
{
|
2020-11-11 19:31:39 +01:00
|
|
|
// set the title and description
|
|
|
|
ui->lineEditLayoutName->setText(m_layout->GetTitle());
|
|
|
|
ui->plainTextEditLayoutDescription->setPlainText(m_layout->GetDescription());
|
2020-05-23 17:47:04 +02:00
|
|
|
|
|
|
|
// set Unit
|
|
|
|
int index = ui->comboBoxLayoutUnit->findData(QVariant(UnitsToStr(m_layout->GetUnit())));
|
|
|
|
if(index != -1)
|
|
|
|
{
|
|
|
|
ui->comboBoxLayoutUnit->blockSignals(true); // FIXME: is there a better way to block the signals?
|
|
|
|
ui->comboBoxLayoutUnit->setCurrentIndex(index);
|
|
|
|
ui->comboBoxLayoutUnit->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// set controls
|
2020-04-19 12:47:38 +02:00
|
|
|
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesOutOfBound, m_layout->GetWarningPiecesOutOfBound());
|
|
|
|
SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->GetWarningSuperpositionOfPieces());
|
2020-04-19 11:58:43 +02:00
|
|
|
}
|
|
|
|
|
2020-11-14 15:58:42 +01:00
|
|
|
|
2020-04-19 11:58:43 +02:00
|
|
|
|
2020-05-05 07:44:20 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::InitMainGraphics()
|
2020-05-05 07:44:20 +02:00
|
|
|
{
|
2020-05-23 15:36:46 +02:00
|
|
|
m_graphicsView = new VPMainGraphicsView(m_layout, this);
|
2020-05-05 07:44:20 +02:00
|
|
|
ui->centralWidget->layout()->addWidget(m_graphicsView);
|
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
2020-11-14 10:20:02 +01:00
|
|
|
|
|
|
|
connect(m_graphicsView, &VPMainGraphicsView::ScaleChanged, this, &VPMainWindow::on_ScaleChanged);
|
2020-11-14 10:55:57 +01:00
|
|
|
connect(m_graphicsView->GetScene(), &VMainGraphicsScene::mouseMove, this, &VPMainWindow::on_MouseMoved);
|
2020-05-05 07:44:20 +02:00
|
|
|
}
|
|
|
|
|
2020-11-13 23:31:22 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-11-14 10:20:02 +01:00
|
|
|
void VPMainWindow::InitZoomToolBar()
|
2020-11-13 23:31:22 +01:00
|
|
|
{
|
2020-11-14 10:55:57 +01:00
|
|
|
if (not m_doubleSpinBoxScale.isNull())
|
|
|
|
{
|
|
|
|
delete m_doubleSpinBoxScale;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_mouseCoordinate != nullptr)
|
|
|
|
{
|
|
|
|
delete m_mouseCoordinate;
|
|
|
|
}
|
2020-11-14 10:20:02 +01:00
|
|
|
|
|
|
|
// connect the zoom buttons and shortcuts to the slots
|
2020-11-13 23:31:22 +01:00
|
|
|
QList<QKeySequence> zoomInShortcuts;
|
|
|
|
zoomInShortcuts.append(QKeySequence(QKeySequence::ZoomIn));
|
|
|
|
zoomInShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Plus + Qt::KeypadModifier));
|
|
|
|
ui->actionZoomIn->setShortcuts(zoomInShortcuts);
|
|
|
|
connect(ui->actionZoomIn, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomIn);
|
|
|
|
|
|
|
|
QList<QKeySequence> zoomOutShortcuts;
|
|
|
|
zoomOutShortcuts.append(QKeySequence(QKeySequence::ZoomOut));
|
|
|
|
zoomOutShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier));
|
|
|
|
ui->actionZoomOut->setShortcuts(zoomOutShortcuts);
|
|
|
|
connect(ui->actionZoomOut, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOut);
|
|
|
|
|
|
|
|
QList<QKeySequence> zoomOriginalShortcuts;
|
|
|
|
zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0));
|
|
|
|
zoomOriginalShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_0 + Qt::KeypadModifier));
|
|
|
|
ui->actionZoomOriginal->setShortcuts(zoomOriginalShortcuts);
|
|
|
|
connect(ui->actionZoomOriginal, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomOriginal);
|
|
|
|
|
|
|
|
QList<QKeySequence> zoomFitBestShortcuts;
|
|
|
|
zoomFitBestShortcuts.append(QKeySequence(Qt::ControlModifier + Qt::Key_Equal));
|
|
|
|
ui->actionZoomFitBest->setShortcuts(zoomFitBestShortcuts);
|
|
|
|
connect(ui->actionZoomFitBest, &QAction::triggered, m_graphicsView, &VPMainGraphicsView::ZoomFitBest);
|
2020-11-14 10:20:02 +01:00
|
|
|
|
|
|
|
// defined the scale
|
|
|
|
ui->toolBarZoom->addSeparator();
|
|
|
|
QLabel* zoomScale = new QLabel(tr("Scale:"), this);
|
|
|
|
ui->toolBarZoom->addWidget(zoomScale);
|
|
|
|
|
|
|
|
m_doubleSpinBoxScale = new QDoubleSpinBox(this);
|
|
|
|
m_doubleSpinBoxScale->setDecimals(1);
|
|
|
|
m_doubleSpinBoxScale->setSuffix("%");
|
|
|
|
on_ScaleChanged(m_graphicsView->transform().m11());
|
|
|
|
connect(m_doubleSpinBoxScale.data(), QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](double d){m_graphicsView->Zoom(d/100.0);});
|
|
|
|
ui->toolBarZoom->addWidget(m_doubleSpinBoxScale);
|
|
|
|
|
|
|
|
|
|
|
|
// define the mouse position
|
|
|
|
ui->toolBarZoom->addSeparator();
|
|
|
|
|
|
|
|
m_mouseCoordinate = new QLabel(QString("0, 0 (%1)").arg(UnitsToStr(m_layout->GetUnit(), true)));
|
|
|
|
ui->toolBarZoom->addWidget(m_mouseCoordinate);
|
|
|
|
ui->toolBarZoom->addSeparator();
|
2020-11-13 23:31:22 +01:00
|
|
|
}
|
2020-04-19 11:58:43 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::SetDoubleSpinBoxValue(QDoubleSpinBox *spinBox, qreal value)
|
2020-04-19 11:58:43 +02:00
|
|
|
{
|
|
|
|
spinBox->blockSignals(true);
|
|
|
|
spinBox->setValue(value);
|
|
|
|
spinBox->blockSignals(false);
|
|
|
|
}
|
2020-04-13 12:24:26 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
|
2020-04-19 12:47:38 +02:00
|
|
|
{
|
|
|
|
checkbox->blockSignals(true);
|
|
|
|
checkbox->setChecked(value);
|
|
|
|
checkbox->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:38:06 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::ReadSettings()
|
2020-05-10 17:38:06 +02:00
|
|
|
{
|
|
|
|
qCDebug(pWindow, "Reading settings.");
|
2020-05-23 15:44:44 +02:00
|
|
|
const VPSettings *settings = qApp->PuzzleSettings();
|
2020-05-10 17:38:06 +02:00
|
|
|
|
|
|
|
if (settings->status() == QSettings::NoError)
|
|
|
|
{
|
|
|
|
restoreGeometry(settings->GetGeometry());
|
|
|
|
restoreState(settings->GetWindowState());
|
|
|
|
restoreState(settings->GetToolbarsState(), APP_VERSION);
|
|
|
|
|
|
|
|
ui->dockWidgetProperties->setVisible(settings->IsDockWidgetPropertiesActive());
|
|
|
|
ui->dockWidgetPropertiesContents->setVisible(settings->IsDockWidgetPropertiesContentsActive());
|
|
|
|
|
|
|
|
// Scene antialiasing
|
|
|
|
m_graphicsView->SetAntialiasing(settings->GetGraphicalOutput());
|
|
|
|
|
|
|
|
// Stack limit
|
|
|
|
// qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning() << tr("Cannot read settings from a malformed .INI file.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::WriteSettings()
|
2020-05-10 17:38:06 +02:00
|
|
|
{
|
2020-05-23 15:44:44 +02:00
|
|
|
VPSettings *settings = qApp->PuzzleSettings();
|
2020-05-10 17:38:06 +02:00
|
|
|
settings->SetGeometry(saveGeometry());
|
|
|
|
settings->SetWindowState(saveState());
|
|
|
|
settings->SetToolbarsState(saveState(APP_VERSION));
|
|
|
|
|
|
|
|
settings->SetDockWidgetPropertiesActive(ui->dockWidgetProperties->isEnabled());
|
|
|
|
settings->SetDockWidgetPropertiesContentsActive(ui->dockWidgetPropertiesContents->isEnabled());
|
2020-04-19 12:47:38 +02:00
|
|
|
|
2020-05-10 17:38:06 +02:00
|
|
|
settings->sync();
|
|
|
|
if (settings->status() == QSettings::AccessError)
|
|
|
|
{
|
|
|
|
qWarning() << tr("Cannot save settings. Access denied.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
bool VPMainWindow::MaybeSave()
|
2020-05-10 17:38:06 +02:00
|
|
|
{
|
|
|
|
// TODO: Implement maybe save check
|
|
|
|
// if (this->isWindowModified())
|
|
|
|
// {
|
|
|
|
// if (curFile.isEmpty() && ui->tableWidget->rowCount() == 0)
|
|
|
|
// {
|
|
|
|
// return true;// Don't ask if file was created without modifications.
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QScopedPointer<QMessageBox> messageBox(new QMessageBox(tr("Unsaved changes"),
|
|
|
|
// tr("Measurements have been modified.\n"
|
|
|
|
// "Do you want to save your changes?"),
|
|
|
|
// QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
|
|
|
|
// QMessageBox::Cancel, this, Qt::Sheet));
|
|
|
|
|
|
|
|
// messageBox->setDefaultButton(QMessageBox::Yes);
|
|
|
|
// messageBox->setEscapeButton(QMessageBox::Cancel);
|
|
|
|
|
|
|
|
// messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() || mIsReadOnly ? tr("Save…") : tr("Save"));
|
|
|
|
// messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
|
|
|
|
|
|
|
|
// messageBox->setWindowModality(Qt::ApplicationModal);
|
|
|
|
// const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
|
|
|
|
|
|
|
|
// switch (ret)
|
|
|
|
// {
|
|
|
|
// case QMessageBox::Yes:
|
|
|
|
// if (mIsReadOnly)
|
|
|
|
// {
|
|
|
|
// return FileSaveAs();
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// return FileSave();
|
|
|
|
// }
|
|
|
|
// case QMessageBox::No:
|
|
|
|
// return true;
|
|
|
|
// case QMessageBox::Cancel:
|
|
|
|
// return false;
|
|
|
|
// default:
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return true;
|
|
|
|
}
|
2020-04-13 12:24:26 +02:00
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionNew_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
|
|
|
// just for test purpuses, to be removed:
|
|
|
|
QMessageBox msgBox;
|
2020-05-23 14:17:20 +02:00
|
|
|
msgBox.setText("TODO VPMainWindow::New");
|
2020-04-10 21:08:29 +02:00
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
2020-04-11 16:25:23 +02:00
|
|
|
Q_UNUSED(ret);
|
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
// TODO
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:38:06 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::closeEvent(QCloseEvent *event)
|
2020-05-10 17:38:06 +02:00
|
|
|
{
|
|
|
|
#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1)
|
|
|
|
// Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344
|
|
|
|
static int numCalled = 0;
|
|
|
|
if (numCalled++ >= 1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (MaybeSave())
|
|
|
|
{
|
|
|
|
WriteSettings();
|
|
|
|
event->accept();
|
|
|
|
deleteLater();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionOpen_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
2020-04-22 17:36:50 +02:00
|
|
|
qCDebug(pWindow, "Openning puzzle layout file.");
|
2020-04-10 21:08:29 +02:00
|
|
|
|
2020-04-19 16:01:46 +02:00
|
|
|
const QString filter(tr("Layout files") + QLatin1String(" (*.vlt)"));
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-19 16:01:46 +02:00
|
|
|
//Get list last open files
|
|
|
|
QStringList recentFiles = qApp->PuzzleSettings()->GetRecentFileList();
|
|
|
|
QString dir;
|
|
|
|
if (recentFiles.isEmpty())
|
|
|
|
{
|
|
|
|
dir = QDir::homePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Absolute path to last open file
|
|
|
|
dir = QFileInfo(recentFiles.first()).absolutePath();
|
|
|
|
}
|
2020-04-22 17:36:50 +02:00
|
|
|
qCDebug(pWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
|
2020-04-23 20:17:49 +02:00
|
|
|
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr);
|
2020-04-19 16:01:46 +02:00
|
|
|
|
|
|
|
if (filePath.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO : if m_layout == nullptr, open in current window
|
|
|
|
// otherwise open in new window
|
|
|
|
|
|
|
|
// TODO : if layout file has a lock, warning message
|
|
|
|
|
|
|
|
|
|
|
|
if(!LoadFile(filePath))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Updates the list of recent files
|
|
|
|
recentFiles.removeAll(filePath);
|
|
|
|
recentFiles.prepend(filePath);
|
|
|
|
while (recentFiles.size() > MaxRecentFiles)
|
|
|
|
{
|
|
|
|
recentFiles.removeLast();
|
|
|
|
}
|
|
|
|
qApp->PuzzleSettings()->SetRecentFileList(recentFiles);
|
|
|
|
|
|
|
|
// updates the properties with the loaded data
|
|
|
|
SetPropertiesData();
|
|
|
|
|
|
|
|
// TODO : update the Carrousel and the QGraphicView
|
2020-04-10 21:08:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionSave_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
|
|
|
// just for test purpuses, to be removed:
|
|
|
|
QMessageBox msgBox;
|
2020-05-23 14:17:20 +02:00
|
|
|
msgBox.setText("TODO VPMainWindow::Save");
|
2020-04-10 21:08:29 +02:00
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
2020-04-11 16:25:23 +02:00
|
|
|
Q_UNUSED(ret);
|
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionSaveAs_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
2020-04-18 16:32:54 +02:00
|
|
|
// TODO / FIXME : See valentina how the save is done over there. we need to add the extension .vlt, check for empty file names etc.
|
2020-04-10 21:08:29 +02:00
|
|
|
|
2020-04-19 16:01:46 +02:00
|
|
|
//Get list last open files
|
|
|
|
QStringList recentFiles = qApp->PuzzleSettings()->GetRecentFileList();
|
|
|
|
QString dir;
|
|
|
|
if (recentFiles.isEmpty())
|
|
|
|
{
|
|
|
|
dir = QDir::homePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Absolute path to last open file
|
|
|
|
dir = QFileInfo(recentFiles.first()).absolutePath();
|
|
|
|
}
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-19 16:01:46 +02:00
|
|
|
QString filters(tr("Layout files") + QLatin1String("(*.vlt)"));
|
2020-04-18 16:32:54 +02:00
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
|
2020-04-19 16:01:46 +02:00
|
|
|
dir + QLatin1String("/") + tr("Layout") + QLatin1String(".vlt"),
|
2020-04-18 16:32:54 +02:00
|
|
|
filters, nullptr
|
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
, QFileDialog::DontUseNativeDialog
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
2020-04-19 16:01:46 +02:00
|
|
|
SaveFile(fileName);
|
2020-04-10 21:08:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionImportRawLayout_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
2020-04-26 12:09:28 +02:00
|
|
|
// TODO: here the code is probably just bad, to be edited
|
2020-04-10 21:08:29 +02:00
|
|
|
|
2020-04-26 12:09:28 +02:00
|
|
|
QString dir;
|
|
|
|
if (true)
|
|
|
|
{
|
|
|
|
dir = QDir::homePath();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO / FIXME get the default path for raw layouts
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString filter(tr("Raw Layout files") + QLatin1String(" (*.rld)"));
|
|
|
|
|
|
|
|
qCDebug(pWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir));
|
|
|
|
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr);
|
|
|
|
|
|
|
|
QStringList rawLayouts = QStringList();
|
|
|
|
rawLayouts.append(filePath);
|
|
|
|
|
|
|
|
ImportRawLayouts(rawLayouts);
|
|
|
|
|
|
|
|
// TODO / FIXME : better error handling
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionCloseLayout_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
|
|
|
// just for test purpuses, to be removed:
|
|
|
|
QMessageBox msgBox;
|
2020-05-23 14:17:20 +02:00
|
|
|
msgBox.setText("TODO VPMainWindow::CloseLayout");
|
2020-04-10 21:08:29 +02:00
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
2020-04-11 16:25:23 +02:00
|
|
|
Q_UNUSED(ret);
|
|
|
|
|
2020-04-10 21:08:29 +02:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionAboutQt_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
|
|
|
QMessageBox::aboutQt(this, tr("About Qt"));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_actionAboutPuzzle_triggered()
|
2020-04-10 21:08:29 +02:00
|
|
|
{
|
2020-05-23 13:49:38 +02:00
|
|
|
auto *aboutDialog = new VPDialogAbout(this);
|
2020-04-11 11:40:02 +02:00
|
|
|
aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
aboutDialog->show();
|
2020-04-10 21:08:29 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 16:25:23 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index)
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(index);
|
2020-04-19 12:47:38 +02:00
|
|
|
QVariant comboBoxValue = ui->comboBoxLayoutUnit->currentData();
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
if(comboBoxValue == QVariant(UnitsToStr(Unit::Cm)))
|
|
|
|
{
|
|
|
|
m_layout->SetUnit(Unit::Cm);
|
|
|
|
}
|
|
|
|
else if(comboBoxValue == QVariant(UnitsToStr(Unit::Mm)))
|
|
|
|
{
|
|
|
|
m_layout->SetUnit(Unit::Mm);
|
|
|
|
}
|
|
|
|
else if(comboBoxValue == QVariant(UnitsToStr(Unit::Inch)))
|
|
|
|
{
|
|
|
|
m_layout->SetUnit(Unit::Inch);
|
|
|
|
}
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-05-23 17:47:04 +02:00
|
|
|
SetPropertyTabSheetData();
|
2020-04-19 12:47:38 +02:00
|
|
|
SetPropertyTabCurrentPieceData();
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_comboBoxSheetTemplate_currentIndexChanged(int index)
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
|
|
|
// just for test purpuses, to be removed:
|
|
|
|
QMessageBox msgBox;
|
2020-05-23 17:47:04 +02:00
|
|
|
msgBox.setText("TODO VPMainWindow::SheetTemplateChanged");
|
2020-04-11 16:25:23 +02:00
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
|
|
|
Q_UNUSED(index);
|
|
|
|
Q_UNUSED(ret);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_SheetSizeChanged()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-05-23 17:47:04 +02:00
|
|
|
m_layout->GetFocusedSheet()->SetSheetSizeConverted(ui->doubleSpinBoxSheetWidth->value(), ui->doubleSpinBoxSheetLength->value());
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// TODO Undo / Redo
|
2020-05-05 07:44:20 +02:00
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_SheetOrientationChanged()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-06-25 16:59:48 +02:00
|
|
|
// Updates the orientation
|
|
|
|
if(ui->radioButtonSheetPortrait->isChecked())
|
|
|
|
{
|
|
|
|
m_layout->GetFocusedSheet()->SetOrientation(PageOrientation::Portrait);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_layout->GetFocusedSheet()->SetOrientation(PageOrientation::Landscape);
|
|
|
|
}
|
2020-05-05 07:44:20 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// TODO Undo / Redo
|
2020-05-05 07:44:20 +02:00
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
|
|
|
// just for test purpuses, to be removed:
|
|
|
|
QMessageBox msgBox;
|
2020-05-23 17:51:00 +02:00
|
|
|
msgBox.setText("TODO VPMainWindow::on_pushButtonSheetRemoveUnusedLength_clicked");
|
2020-04-11 16:25:23 +02:00
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
|
|
|
Q_UNUSED(ret);
|
2020-04-11 16:32:49 +02:00
|
|
|
|
|
|
|
// TODO
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_SheetMarginChanged()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-05-23 17:47:04 +02:00
|
|
|
m_layout->GetFocusedSheet()->SetSheetMarginsConverted(
|
|
|
|
ui->doubleSpinBoxSheetMarginLeft->value(),
|
|
|
|
ui->doubleSpinBoxSheetMarginTop->value(),
|
|
|
|
ui->doubleSpinBoxSheetMarginRight->value(),
|
|
|
|
ui->doubleSpinBoxSheetMarginBottom->value()
|
2020-04-19 12:47:38 +02:00
|
|
|
);
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// TODO Undo / Redo
|
2020-05-05 07:44:20 +02:00
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 15:58:42 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::on_TilesSizeChanged()
|
|
|
|
{
|
|
|
|
m_layout->SetTilesSizeConverted(ui->doubleSpinBoxTilesWidth->value(), ui->doubleSpinBoxTilesLength->value());
|
|
|
|
|
|
|
|
// TODO Undo / Redo
|
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::on_TilesOrientationChanged()
|
|
|
|
{
|
|
|
|
// Updates the orientation
|
|
|
|
if(ui->radioButtonTilesPortrait->isChecked())
|
|
|
|
{
|
|
|
|
m_layout->SetTilesOrientation(PageOrientation::Portrait);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_layout->SetTilesOrientation(PageOrientation::Landscape);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO Undo / Redo
|
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::on_TilesMarginChanged()
|
|
|
|
{
|
2020-11-14 17:31:34 +01:00
|
|
|
m_layout->SetTilesMarginsConverted(
|
2020-11-14 15:58:42 +01:00
|
|
|
ui->doubleSpinBoxTilesMarginLeft->value(),
|
|
|
|
ui->doubleSpinBoxTilesMarginTop->value(),
|
|
|
|
ui->doubleSpinBoxTilesMarginRight->value(),
|
|
|
|
ui->doubleSpinBoxTilesMarginBottom->value()
|
|
|
|
);
|
|
|
|
|
|
|
|
// TODO Undo / Redo
|
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::on_checkBoxTilesShowTiles_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_layout->SetShowTiles(checked);
|
|
|
|
|
|
|
|
// TODO Undo / Redo
|
|
|
|
|
|
|
|
m_graphicsView->RefreshLayout();
|
|
|
|
}
|
|
|
|
|
2020-11-14 17:31:34 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::on_pushButtonTilesExport_clicked()
|
|
|
|
{
|
|
|
|
// svg export to do some test for the first test
|
|
|
|
|
|
|
|
QString dir = QDir::homePath();
|
|
|
|
QString filters(tr("PDF Files") + QLatin1String("(*.pdf)"));
|
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
|
|
|
|
dir + QLatin1String("/") + tr("Layout") + QLatin1String(".pdf"),
|
|
|
|
filters, nullptr
|
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
, QFileDialog::DontUseNativeDialog
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
|
|
|
if(not fileName.isEmpty())
|
|
|
|
{
|
|
|
|
m_graphicsView->PrepareForExport();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO : Tiles export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_graphicsView->CleanAfterExport();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 15:58:42 +01:00
|
|
|
|
2020-04-11 16:25:23 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_SheetFollowGrainlineChanged()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
|
|
|
// just for test purpuses, to be removed:
|
|
|
|
QMessageBox msgBox;
|
2020-05-23 17:51:00 +02:00
|
|
|
msgBox.setText("TODO VPMainWindow::on_SheetFollowGrainlineChanged");
|
2020-04-11 16:25:23 +02:00
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
|
|
|
Q_UNUSED(ret);
|
2020-04-11 16:32:49 +02:00
|
|
|
|
|
|
|
// TODO
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_doubleSpinBoxSheetPiecesGap_valueChanged(double value)
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-05-23 17:47:04 +02:00
|
|
|
m_layout->GetFocusedSheet()->SetPiecesGapConverted(value);
|
2020-04-11 16:32:49 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// TODO Undo / Redo
|
|
|
|
// TODO update the QGraphicView
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked)
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-04-19 12:47:38 +02:00
|
|
|
m_layout->SetWarningSuperpositionOfPieces(checked);
|
2020-04-11 16:25:23 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// TODO Undo / Redo
|
|
|
|
// TODO update the QGraphicView
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked)
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-04-19 12:47:38 +02:00
|
|
|
m_layout->SetWarningPiecesOutOfBound(checked);
|
2020-04-11 16:32:49 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// TODO Undo / Redo
|
|
|
|
// TODO update the QGraphicView
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_checkBoxSheetStickyEdges_toggled(bool checked)
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-05-23 17:47:04 +02:00
|
|
|
m_layout->GetFocusedSheet()->SetStickyEdges(checked);
|
2020-04-11 16:32:49 +02:00
|
|
|
|
2020-04-19 12:47:38 +02:00
|
|
|
// TODO Undo / Redo
|
|
|
|
// TODO update the QGraphicView
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 17:47:04 +02:00
|
|
|
void VPMainWindow::on_pushButtonSheetExport_clicked()
|
2020-04-11 16:25:23 +02:00
|
|
|
{
|
2020-11-14 12:37:43 +01:00
|
|
|
// svg export to do some test for the first test
|
2020-04-11 16:32:49 +02:00
|
|
|
|
2020-11-14 12:37:43 +01:00
|
|
|
QString dir = QDir::homePath();
|
|
|
|
QString filters(tr("SVG Files") + QLatin1String("(*.svg)"));
|
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"),
|
|
|
|
dir + QLatin1String("/") + tr("Layout") + QLatin1String(".svg"),
|
|
|
|
filters, nullptr
|
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
, QFileDialog::DontUseNativeDialog
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
2020-11-14 12:46:18 +01:00
|
|
|
if(not fileName.isEmpty())
|
|
|
|
{
|
|
|
|
m_graphicsView->PrepareForExport();
|
2020-11-14 12:37:43 +01:00
|
|
|
|
|
|
|
const QSizeF s = m_layout->GetFocusedSheet()->GetSheetSize();
|
|
|
|
const QRectF r = QRectF(0, 0, s.width(), s.height());
|
|
|
|
|
|
|
|
QSvgGenerator generator;
|
|
|
|
generator.setFileName(fileName);
|
|
|
|
generator.setSize(QSize(qFloor(s.width()),qFloor(s.height())));
|
|
|
|
generator.setViewBox(r);
|
|
|
|
generator.setTitle(tr("Pattern"));
|
|
|
|
generator.setDescription(m_layout->GetDescription().toHtmlEscaped());
|
|
|
|
generator.setResolution(static_cast<int>(PrintDPI));
|
|
|
|
|
|
|
|
QPainter painter;
|
|
|
|
painter.begin(&generator);
|
|
|
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
|
|
|
painter.setPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
|
|
|
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
|
|
|
m_graphicsView->GetScene()->render(&painter, r, r, Qt::IgnoreAspectRatio);
|
|
|
|
painter.end();
|
|
|
|
|
|
|
|
m_graphicsView->CleanAfterExport();
|
2020-11-14 12:46:18 +01:00
|
|
|
}
|
2020-04-11 16:32:49 +02:00
|
|
|
|
2020-04-11 16:25:23 +02:00
|
|
|
}
|
2020-04-10 21:08:29 +02:00
|
|
|
|
2020-04-11 17:04:44 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked)
|
2020-04-11 17:04:44 +02:00
|
|
|
{
|
2020-05-05 17:40:36 +02:00
|
|
|
if(m_selectedPieces.count() == 1)
|
2020-05-01 19:08:48 +02:00
|
|
|
{
|
2020-05-05 17:40:36 +02:00
|
|
|
m_selectedPieces.first()->SetShowSeamLine(checked);
|
2020-05-01 19:08:48 +02:00
|
|
|
}
|
2020-04-11 17:04:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked)
|
2020-04-11 17:04:44 +02:00
|
|
|
{
|
2020-05-05 17:40:36 +02:00
|
|
|
if(m_selectedPieces.count() == 1)
|
2020-05-01 19:08:48 +02:00
|
|
|
{
|
2020-05-05 17:40:36 +02:00
|
|
|
m_selectedPieces.first()->SetPieceMirrored(checked);
|
2020-05-01 19:08:48 +02:00
|
|
|
}
|
2020-04-11 17:04:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value)
|
2020-04-11 17:04:44 +02:00
|
|
|
{
|
2020-05-09 11:13:29 +02:00
|
|
|
if(m_selectedPieces.count() == 1)
|
|
|
|
{
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece *piece = m_selectedPieces.first();
|
2020-05-09 11:13:29 +02:00
|
|
|
piece->SetRotation(value);
|
|
|
|
}
|
2020-04-11 17:04:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_CurrentPiecePositionEdited()
|
2020-04-11 17:04:44 +02:00
|
|
|
{
|
2020-05-05 17:40:36 +02:00
|
|
|
if(m_selectedPieces.count() == 1)
|
|
|
|
{
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece *piece = m_selectedPieces.first();
|
2020-05-05 17:40:36 +02:00
|
|
|
QPointF pos(UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), m_layout->GetUnit(), Unit::Px),
|
|
|
|
UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), m_layout->GetUnit(), Unit::Px));
|
|
|
|
piece->SetPosition(pos);
|
|
|
|
}
|
2020-04-11 17:04:44 +02:00
|
|
|
}
|
2020-04-13 12:24:26 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:29:18 +02:00
|
|
|
void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area)
|
2020-04-13 12:24:26 +02:00
|
|
|
{
|
|
|
|
if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea)
|
|
|
|
{
|
2020-05-23 14:29:18 +02:00
|
|
|
m_carrousel->SetOrientation(Qt::Horizontal);
|
2020-04-13 12:24:26 +02:00
|
|
|
}
|
|
|
|
else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea)
|
|
|
|
{
|
2020-05-23 14:29:18 +02:00
|
|
|
m_carrousel->SetOrientation(Qt::Vertical);
|
2020-04-13 12:24:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-01 18:26:02 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_PieceSelectionChanged()
|
2020-05-01 18:26:02 +02:00
|
|
|
{
|
2020-05-05 17:40:36 +02:00
|
|
|
m_selectedPieces = m_layout->GetSelectedPieces();
|
2020-05-01 18:26:02 +02:00
|
|
|
|
|
|
|
// update the property of the piece currently selected
|
|
|
|
SetPropertyTabCurrentPieceData();
|
|
|
|
}
|
2020-05-05 17:40:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_PiecePositionChanged()
|
2020-05-05 17:40:36 +02:00
|
|
|
{
|
|
|
|
if(m_selectedPieces.count() == 1)
|
|
|
|
{
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece *piece = m_selectedPieces.first();
|
2020-05-05 17:40:36 +02:00
|
|
|
QPointF pos = piece->GetPosition();
|
|
|
|
|
2020-05-10 17:35:15 +02:00
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
|
|
|
|
UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit()));
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY,
|
|
|
|
UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit()));
|
2020-05-05 17:40:36 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-09 14:45:36 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2020-05-23 14:17:20 +02:00
|
|
|
void VPMainWindow::on_PieceRotationChanged()
|
2020-05-09 14:45:36 +02:00
|
|
|
{
|
|
|
|
if(m_selectedPieces.count() == 1)
|
|
|
|
{
|
2020-05-23 15:42:51 +02:00
|
|
|
VPPiece *piece = m_selectedPieces.first();
|
2020-05-09 14:45:36 +02:00
|
|
|
qreal angle = piece->GetRotation();
|
|
|
|
|
|
|
|
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle);
|
|
|
|
}
|
|
|
|
}
|
2020-11-14 10:20:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::on_ScaleChanged(qreal scale)
|
|
|
|
{
|
|
|
|
if (not m_doubleSpinBoxScale.isNull())
|
|
|
|
{
|
|
|
|
m_doubleSpinBoxScale->blockSignals(true);
|
|
|
|
m_doubleSpinBoxScale->setMaximum(qFloor(VPMainGraphicsView::MaxScale()*1000)/10.0);
|
|
|
|
m_doubleSpinBoxScale->setMinimum(qFloor(VPMainGraphicsView::MinScale()*1000)/10.0);
|
|
|
|
m_doubleSpinBoxScale->setValue(qFloor(scale*1000)/10.0);
|
|
|
|
m_doubleSpinBoxScale->setSingleStep(1);
|
|
|
|
m_doubleSpinBoxScale->blockSignals(false);
|
|
|
|
}
|
|
|
|
}
|
2020-11-14 10:55:57 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPMainWindow::on_MouseMoved(const QPointF &scenePos)
|
|
|
|
{
|
|
|
|
if (m_mouseCoordinate != nullptr)
|
|
|
|
{
|
|
|
|
m_mouseCoordinate->setText(QStringLiteral("%1, %2 (%3)")
|
|
|
|
.arg(static_cast<qint32>(FromPixel(scenePos.x(), m_layout->GetUnit())))
|
|
|
|
.arg(static_cast<qint32>(FromPixel(scenePos.y(), m_layout->GetUnit())))
|
|
|
|
.arg(UnitsToStr(m_layout->GetUnit(), true)));
|
|
|
|
}
|
|
|
|
}
|