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); ui->comboBoxPieceList->blockSignals(false);
} }
on_ActivePieceListChanged(index != -1 ? index: 0); ui->comboBoxPieceList->setCurrentIndex(-1);
ui->comboBoxPieceList->setCurrentIndex(index != -1 ? index : 0);
RefreshOrientation(); RefreshOrientation();
} }

View File

@ -69,17 +69,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
m_cmd(cmd), m_cmd(cmd),
m_statusLabel(new QLabel(this)) 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------------------ // // ----- for test purposes, to be removed------------------
sheet->SetSheetMarginsConverted(1, 1, 1, 1);
sheet->SetSheetSizeConverted(84.1, 118.9);
sheet->SetPiecesGapConverted(1);
m_layout->SetUnit(Unit::Cm); m_layout->SetUnit(Unit::Cm);
m_layout->SetWarningSuperpositionOfPieces(true); m_layout->SetWarningSuperpositionOfPieces(true);
m_layout->SetTitle(QString("My Test Layout")); m_layout->SetTitle(QString("My Test Layout"));
@ -94,6 +84,9 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
// create a standard sheet
AddSheet();
// init the tile factory // init the tile factory
m_tileFactory = new VPTileFactory(m_layout, VPApplication::VApp()->Settings()); m_tileFactory = new VPTileFactory(m_layout, VPApplication::VApp()->Settings());
m_tileFactory->refreshTileInfos(); 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() void VPMainWindow::on_actionNew_triggered()
{ {
@ -1867,6 +1874,13 @@ void VPMainWindow::ToolBarStyles()
ToolBarStyle(ui->toolBarZoom); ToolBarStyle(ui->toolBarZoom);
} }
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_actionAddSheet_triggered()
{
AddSheet();
m_carrousel->Refresh();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
void VPMainWindow::AboutToShowDockMenu() void VPMainWindow::AboutToShowDockMenu()

View File

@ -400,6 +400,8 @@ protected:
void ToolBarStyles(); void ToolBarStyles();
void on_actionAddSheet_triggered();
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
void AboutToShowDockMenu(); void AboutToShowDockMenu();
#endif //defined(Q_OS_MAC) #endif //defined(Q_OS_MAC)
@ -551,6 +553,8 @@ private:
void generateTiledPdf(QString fileName); void generateTiledPdf(QString fileName);
void CreateWindowMenu(QMenu *menu); void CreateWindowMenu(QMenu *menu);
void AddSheet();
}; };
#endif // VPMAINWINDOW_H #endif // VPMAINWINDOW_H

View File

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

View File

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