From 44bf83a089936a3dc40c8225f4aee7a349fffef4 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 11 Apr 2020 16:25:23 +0200 Subject: [PATCH] slots for the layout properties --- src/app/puzzle/puzzlemainwindow.cpp | 243 +++++++++++++++++++++++++++- src/app/puzzle/puzzlemainwindow.h | 20 +++ src/app/puzzle/puzzlemainwindow.ui | 7 +- 3 files changed, 264 insertions(+), 6 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 560fcb1b1..b3d36e74d 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -82,14 +82,87 @@ void PuzzleMainWindow::InitMenuBar() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPropertyTabs() { - // for the MVP we don't want the tiles and current layer tabs. - // we remove them. As soon as we need them, delete / update this code - ui->tabWidgetProperties->removeTab(3); // remove layers - ui->tabWidgetProperties->removeTab(2); // remove tiles + InitPropertyTabCurrentPiece(); + InitPropertyTabLayout(); + InitPropertyTabLayers(); + InitPropertyTabTiles(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::InitPropertyTabCurrentPiece() +{ } +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::InitPropertyTabLayout() +{ + // -------------------- 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); + } + + connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), this, &PuzzleMainWindow::LayoutUnitChanged); + + + // -------------------- init the template combobox --------------------- + + // TODO + + connect(ui->comboBoxLayoutTemplate, QOverload::of(&QComboBox::currentIndexChanged), this, &PuzzleMainWindow::LayoutTemplateChanged); + + // -------------------- layout width, length, orientation ------------------------ + connect(ui->doubleSpinBoxLayoutWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutSizeChanged); + connect(ui->doubleSpinBoxLayoutLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutSizeChanged); + connect(ui->radioButtonLayoutPortrait, QOverload::of(&QRadioButton::toggled), this, &PuzzleMainWindow::LayoutOrientationChanged); + connect(ui->radioButtonLayoutLandscape, QOverload::of(&QRadioButton::toggled), this, &PuzzleMainWindow::LayoutOrientationChanged); + connect(ui->pushButtonLayoutRemoveUnusedLength, QOverload::of(&QPushButton::clicked), this, &PuzzleMainWindow::LayoutRemoveUnusedLength); + + // -------------------- margins ------------------------ + connect(ui->doubleSpinBoxLayoutMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); + connect(ui->doubleSpinBoxLayoutMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); + connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); + connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutMarginChanged); + + // ------------------- follow grainline ----------------------- + connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload::of(&QRadioButton::clicked), this, &PuzzleMainWindow::LayoutFollowGrainlineChanged); + connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload::of(&QRadioButton::clicked), this, &PuzzleMainWindow::LayoutFollowGrainlineChanged); + connect(ui->radioButtonLayoutFollowGrainlineHorizontal, QOverload::of(&QRadioButton::clicked), this, &PuzzleMainWindow::LayoutFollowGrainlineChanged); + + // -------------------- pieces gap and checkboxes --------------- + connect(ui->doubleSpinBoxLayoutPiecesGap, QOverload::of(&QDoubleSpinBox::valueChanged), this, &PuzzleMainWindow::LayoutPiecesGapChanged); + connect(ui->checkBoxLayoutWarningPiecesSuperposition, QOverload::of(&QCheckBox::toggled), this, &PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged); + connect(ui->checkBoxLayoutWarningPiecesOutOfBound, QOverload::of(&QCheckBox::toggled), this, &PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged); + connect(ui->checkBoxLayoutStickyEdges, QOverload::of(&QCheckBox::toggled), this, &PuzzleMainWindow::LayoutStickyEdgesChanged); + + // -------------------- export --------------------------- + connect(ui->pushButtonLayoutExport, QOverload::of(&QPushButton::clicked), this, &PuzzleMainWindow::LayoutExport); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::InitPropertyTabTiles() +{ + // for the MVP we don't want the tiles tab. + // we remove it. As soon as we need it, update this code + ui->tabWidgetProperties->removeTab(2); // remove tiles +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::InitPropertyTabLayers() +{ + // for the MVP we don't want the layers tab. + // we remove it. As soon as we need it, update this code + ui->tabWidgetProperties->removeTab(3); // remove layers +} + //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::New() { @@ -98,6 +171,8 @@ void PuzzleMainWindow::New() msgBox.setText("TODO PuzzleMainWindow::New"); int ret = msgBox.exec(); + Q_UNUSED(ret); + // TODO @@ -111,6 +186,8 @@ void PuzzleMainWindow::Open() msgBox.setText("TODO PuzzleMainWindow::Open"); int ret = msgBox.exec(); + Q_UNUSED(ret); + // TODO } @@ -122,6 +199,8 @@ void PuzzleMainWindow::Save() msgBox.setText("TODO PuzzleMainWindow::Save"); int ret = msgBox.exec(); + Q_UNUSED(ret); + // TODO } @@ -133,6 +212,8 @@ void PuzzleMainWindow::SaveAs() msgBox.setText("TODO PuzzleMainWindow::SaveAs"); int ret = msgBox.exec(); + Q_UNUSED(ret); + // TODO } @@ -144,6 +225,8 @@ void PuzzleMainWindow::ImportRawLayout() msgBox.setText("TODO PuzzleMainWindow::ImportRawLayout"); int ret = msgBox.exec(); + Q_UNUSED(ret); + // TODO } @@ -155,6 +238,8 @@ void PuzzleMainWindow::CloseLayout() msgBox.setText("TODO PuzzleMainWindow::CloseLayout"); int ret = msgBox.exec(); + Q_UNUSED(ret); + // TODO } @@ -172,4 +257,154 @@ void PuzzleMainWindow::AboutPuzzle() aboutDialog->show(); } +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutUnitChanged(int index) +{ + + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutUnitChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(index); + Q_UNUSED(ret); + + + // TODO +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutTemplateChanged(int index) +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutTemplateChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(index); + Q_UNUSED(ret); + + + // TODO +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutSizeChanged() +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutSizeChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(ret); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutOrientationChanged() +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutOrientationChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(ret); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutRemoveUnusedLength() +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutRemoveUnusedLength"); + int ret = msgBox.exec(); + + Q_UNUSED(ret); +} + + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutMarginChanged() +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutMarginChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(ret); +} + + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutFollowGrainlineChanged() +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutFollowGrainlineChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(ret); +} + + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutPiecesGapChanged(double value) +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutPieceGapChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(value); + Q_UNUSED(ret); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged(bool checked) +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(checked); + Q_UNUSED(ret); +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged(bool checked) +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(checked); + Q_UNUSED(ret); + +} + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutStickyEdgesChanged(bool checked) +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutStickyEdgesChanged"); + int ret = msgBox.exec(); + + Q_UNUSED(checked); + Q_UNUSED(ret); +} + + + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::LayoutExport() +{ + // just for test purpuses, to be removed: + QMessageBox msgBox; + msgBox.setText("TODO PuzzleMainWindow::LayoutExport"); + int ret = msgBox.exec(); + + Q_UNUSED(ret); +} diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/puzzlemainwindow.h index 73167d585..6eb86aaed 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -28,6 +28,8 @@ #ifndef PUZZLEMAINWINDOW_H #define PUZZLEMAINWINDOW_H +#include "../vmisc/def.h" + #include #include @@ -51,6 +53,11 @@ private: void InitMenuBar(); void InitPropertyTabs(); + void InitPropertyTabCurrentPiece(); + void InitPropertyTabLayout(); + void InitPropertyTabTiles(); + void InitPropertyTabLayers(); + private slots: void New(); @@ -63,6 +70,19 @@ private slots: void AboutQt(); void AboutPuzzle(); + void LayoutUnitChanged(int index); + void LayoutTemplateChanged(int index); + void LayoutSizeChanged(); + void LayoutOrientationChanged(); + void LayoutRemoveUnusedLength(); + void LayoutMarginChanged(); + void LayoutFollowGrainlineChanged(); + void LayoutPiecesGapChanged(double value); + void LayoutWarningPiecesSuperpositionChanged(bool checked); + void LayoutWarningPiecesOutOfBoundChanged(bool checked); + void LayoutStickyEdgesChanged(bool checked); + void LayoutExport(); + }; #endif // PUZZLEMAINWINDOW_H diff --git a/src/app/puzzle/puzzlemainwindow.ui b/src/app/puzzle/puzzlemainwindow.ui index 30bb49096..f98fe7ec3 100644 --- a/src/app/puzzle/puzzlemainwindow.ui +++ b/src/app/puzzle/puzzlemainwindow.ui @@ -419,6 +419,9 @@ No + + true + @@ -471,14 +474,14 @@ - + - Wargnin superposition of pieces + Warning superposition of pieces