New menu option Add sheet.

This commit is contained in:
Roman Telezhynskyi 2021-05-27 21:11:32 +03:00
parent 962b5dd561
commit 7ee158c11c
5 changed files with 41 additions and 16 deletions

View File

@ -103,7 +103,8 @@ void VPCarrousel::Refresh()
ui->comboBoxPieceList->blockSignals(false);
}
on_ActivePieceListChanged(index != -1 ? index: 0);
ui->comboBoxPieceList->setCurrentIndex(-1);
ui->comboBoxPieceList->setCurrentIndex(index != -1 ? index : 0);
RefreshOrientation();
}

View File

@ -69,17 +69,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
m_cmd(cmd),
m_statusLabel(new QLabel(this))
{
// create a standard sheet
auto *sheet = new VPSheet(m_layout);
sheet->SetName(QObject::tr("Sheet 1"));
m_layout->AddSheet(sheet);
m_layout->SetFocusedSheet();
// // ----- for test purposes, to be removed------------------
sheet->SetSheetMarginsConverted(1, 1, 1, 1);
sheet->SetSheetSizeConverted(84.1, 118.9);
sheet->SetPiecesGapConverted(1);
// // ----- for test purposes, to be removed------------------
m_layout->SetUnit(Unit::Cm);
m_layout->SetWarningSuperpositionOfPieces(true);
m_layout->SetTitle(QString("My Test Layout"));
@ -94,6 +84,9 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
ui->setupUi(this);
// create a standard sheet
AddSheet();
// init the tile factory
m_tileFactory = new VPTileFactory(m_layout, VPApplication::VApp()->Settings());
m_tileFactory->refreshTileInfos();
@ -1088,6 +1081,20 @@ void VPMainWindow::CreateWindowMenu(QMenu *menu)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::AddSheet()
{
auto *sheet = new VPSheet(m_layout);
sheet->SetName(QObject::tr("Sheet %1").arg(m_layout->GetSheets().size()+1));
m_layout->AddSheet(sheet);
m_layout->SetFocusedSheet();
// // ----- for test purposes, to be removed------------------
sheet->SetSheetMarginsConverted(1, 1, 1, 1);
sheet->SetSheetSizeConverted(84.1, 118.9);
sheet->SetPiecesGapConverted(1);
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_actionNew_triggered()
{
@ -1867,6 +1874,13 @@ void VPMainWindow::ToolBarStyles()
ToolBarStyle(ui->toolBarZoom);
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_actionAddSheet_triggered()
{
AddSheet();
m_carrousel->Refresh();
}
//---------------------------------------------------------------------------------------------------------------------
#if defined(Q_OS_MAC)
void VPMainWindow::AboutToShowDockMenu()

View File

@ -106,7 +106,7 @@ protected:
virtual void changeEvent(QEvent* event) override;
virtual QStringList RecentFileList() const override;
private slots:
private slots:
/**
* @brief on_actionOpen_triggered When the menu action File > Open is
* triggered.
@ -400,6 +400,8 @@ protected:
void ToolBarStyles();
void on_actionAddSheet_triggered();
#if defined(Q_OS_MAC)
void AboutToShowDockMenu();
#endif //defined(Q_OS_MAC)
@ -551,6 +553,8 @@ private:
void generateTiledPdf(QString fileName);
void CreateWindowMenu(QMenu *menu);
void AddSheet();
};
#endif // VPMAINWINDOW_H

View File

@ -62,6 +62,7 @@
<string>&amp;Edit</string>
</property>
<addaction name="separator"/>
<addaction name="actionAddSheet"/>
</widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
@ -668,7 +669,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-170</y>
<y>0</y>
<width>342</width>
<height>870</height>
</rect>
@ -1761,6 +1762,11 @@
<string>Preferences</string>
</property>
</action>
<action name="actionAddSheet">
<property name="text">
<string>Add Sheet</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>

View File

@ -1186,7 +1186,7 @@ void VLayoutPiece::DrawMiniature(QPainter &painter) const
{
painter.drawPath(ContourPath());
for (auto &path : d->m_internalPaths)
for (const auto &path : d->m_internalPaths)
{
painter.save();
@ -1199,7 +1199,7 @@ void VLayoutPiece::DrawMiniature(QPainter &painter) const
painter.restore();
}
for (auto &label : d->m_placeLabels)
for (const auto &label : d->m_placeLabels)
{
painter.drawPath(VPlaceLabelItem::LabelShapePath(label.shape));
}