Refactoring.

This commit is contained in:
Roman Telezhynskyi 2024-04-06 12:09:38 +03:00
parent a4e2e1f1bf
commit 54ee9e0629
2 changed files with 109 additions and 92 deletions

View File

@ -43,6 +43,7 @@
#include <QtMath>
#include <chrono>
#include <thread>
#include <utility>
#include "../ifc/exception/vexception.h"
#include "../ifc/xml/vlayoutconverter.h"
@ -323,10 +324,10 @@ struct VPExportData
};
//---------------------------------------------------------------------------------------------------------------------
VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent)
VPMainWindow::VPMainWindow(VPCommandLinePtr cmd, QWidget *parent)
: VAbstractMainWindow(parent),
ui(std::make_unique<Ui::VPMainWindow>()),
m_cmd(cmd),
m_cmd(std::move(cmd)),
m_undoStack(new QUndoStack(this)),
m_layout{VPLayout::CreateLayout(m_undoStack)},
m_statusLabel(new QLabel(this)),
@ -770,10 +771,7 @@ void VPMainWindow::InitProperties()
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitPropertyTabCurrentPiece()
{
connect(ui->checkBoxCurrentPieceShowSeamline, &QCheckBox::toggled, this,
[this](bool checked)
void VPMainWindow::CurrentPieceShowSeamLineToggled(bool checked)
{
QList<VPPiecePtr> const selectedPieces = SelectedPieces();
if (selectedPieces.size() == 1)
@ -787,11 +785,12 @@ void VPMainWindow::InitPropertyTabCurrentPiece()
emit m_layout->PieceTransformationChanged(selectedPiece);
}
}
});
}
connect(ui->checkBoxShowFullPiece, &QCheckBox::toggled, this,
[this](bool checked)
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::ShowFullPieceToggled(bool checked)
{
QList<VPPiecePtr> const selectedPieces = SelectedPieces();
if (selectedPieces.size() == 1)
{
@ -806,10 +805,10 @@ void VPMainWindow::InitPropertyTabCurrentPiece()
}
}
}
});
}
connect(ui->checkBoxShowMirrorLine, &QCheckBox::toggled, this,
[this](bool checked)
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::ShowMirrorLineToggled(bool checked)
{
QList<VPPiecePtr> const selectedPieces = SelectedPieces();
if (selectedPieces.size() == 1)
@ -825,10 +824,10 @@ void VPMainWindow::InitPropertyTabCurrentPiece()
}
}
}
});
}
connect(ui->checkBoxCurrentPieceVerticallyFlipped, &QCheckBox::toggled, this,
[this](bool checked)
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::CurrentPieceVerticallyFlippedToggled(bool checked)
{
QList<VPPiecePtr> const selectedPieces = SelectedPieces();
if (selectedPieces.size() == 1)
@ -844,10 +843,10 @@ void VPMainWindow::InitPropertyTabCurrentPiece()
}
}
}
});
}
connect(ui->checkBoxCurrentPieceHorizontallyFlipped, &QCheckBox::toggled, this,
[this](bool checked)
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::CurrentPieceHorizontallyFlippedToggled(bool checked)
{
QList<VPPiecePtr> const selectedPieces = SelectedPieces();
if (selectedPieces.size() == 1)
@ -863,7 +862,19 @@ void VPMainWindow::InitPropertyTabCurrentPiece()
}
}
}
});
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::InitPropertyTabCurrentPiece()
{
connect(ui->checkBoxCurrentPieceShowSeamline, &QCheckBox::toggled, this,
&VPMainWindow::CurrentPieceShowSeamLineToggled);
connect(ui->checkBoxShowFullPiece, &QCheckBox::toggled, this, &VPMainWindow::ShowFullPieceToggled);
connect(ui->checkBoxShowMirrorLine, &QCheckBox::toggled, this, &VPMainWindow::ShowMirrorLineToggled);
connect(ui->checkBoxCurrentPieceVerticallyFlipped, &QCheckBox::toggled, this,
&VPMainWindow::CurrentPieceVerticallyFlippedToggled);
connect(ui->checkBoxCurrentPieceHorizontallyFlipped, &QCheckBox::toggled, this,
&VPMainWindow::CurrentPieceHorizontallyFlippedToggled);
// Translate
ui->comboBoxTranslateUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm)));
@ -2174,6 +2185,7 @@ void VPMainWindow::FindTemplate(QComboBox *box, qreal width, qreal height)
const QSizeF tmplSize =
VAbstractLayoutDialog::GetTemplateSize(static_cast<VAbstractLayoutDialog::PaperSizeTemplate>(i), paperUnit);
if (VAbstractLayoutDialog::RoundTemplateSize(width, height, paperUnit) == tmplSize ||
// NOLINTNEXTLINE(readability-suspicious-call-argument)
VAbstractLayoutDialog::RoundTemplateSize(height, width, paperUnit) == tmplSize)
{
box->blockSignals(true);

View File

@ -61,7 +61,7 @@ class VPMainWindow : public VAbstractMainWindow
Q_OBJECT // NOLINT
public:
explicit VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent = nullptr);
explicit VPMainWindow(VPCommandLinePtr cmd, QWidget *parent = nullptr);
~VPMainWindow() override;
auto CurrentFile() const -> QString;
@ -300,6 +300,11 @@ private slots:
void UpdateShortcuts();
void TogetherWithNotchesChanged(bool checked);
void CurrentPieceShowSeamLineToggled(bool checked);
void ShowFullPieceToggled(bool checked);
void ShowMirrorLineToggled(bool checked);
void CurrentPieceVerticallyFlippedToggled(bool checked);
void CurrentPieceHorizontallyFlippedToggled(bool checked);
private:
Q_DISABLE_COPY_MOVE(VPMainWindow) // NOLINT