From 9c5b23e7ebf4f0ae8790b04932428d68b08daea1 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Fri, 24 Apr 2020 16:10:42 +0200 Subject: [PATCH 01/12] Slot auto connection, name convention and comments --- src/app/puzzle/puzzlemainwindow.cpp | 142 +++++++---------- src/app/puzzle/puzzlemainwindow.h | 231 +++++++++++++++++++++++++--- 2 files changed, 258 insertions(+), 115 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 3452a8b70..a76d220f8 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -56,11 +56,6 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa pieceCarrousel(new VPieceCarrousel), m_cmd(cmd) { - ui->setupUi(this); - - InitMenuBar(); - InitProperties(); - InitPieceCarrousel(); // ----- for test purposes, to be removed------------------ m_layout = new VPuzzleLayout(); @@ -69,6 +64,14 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa m_layout->SetPiecesGapConverted(1.27); m_layout->SetUnit(Unit::Cm); m_layout->SetWarningSuperpositionOfPieces(true); + // -------------------------------------------------------- + + ui->setupUi(this); + + InitMenuBar(); + InitProperties(); + InitPieceCarrousel(); + SetPropertiesData(); } @@ -153,12 +156,10 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &layouts) //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitMenuBar() { + // most of the actions are connected through name convention (auto-connection) + + // -------------------- connects the actions for the file menu - connect(ui->actionNew, &QAction::triggered, this, &PuzzleMainWindow::New); - connect(ui->actionOpen, &QAction::triggered, this, &PuzzleMainWindow::Open); - connect(ui->actionSave, &QAction::triggered, this, &PuzzleMainWindow::Save); - connect(ui->actionSaveAs, &QAction::triggered, this, &PuzzleMainWindow::SaveAs); - connect(ui->actionImportRawLayout, &QAction::triggered, this, &PuzzleMainWindow::ImportRawLayout); connect(ui->actionExit, &QAction::triggered, this, &PuzzleMainWindow::close); // -------------------- connects the actions for the edit menu @@ -166,16 +167,11 @@ void PuzzleMainWindow::InitMenuBar() // -------------------- connects the actions for the windows menu // TODO : initialise the entries for the different windows - connect(ui->actionCloseLayout, &QAction::triggered, this, &PuzzleMainWindow::CloseLayout); // Add dock properties action QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction(); ui->menuWindows->addAction(actionDockWidgetToolOptions); - // connects the action for the Help Menu - connect(ui->actionAboutQt, &QAction::triggered, this, &PuzzleMainWindow::AboutQt); - connect(ui->actionAboutPuzzle, &QAction::triggered, this, &PuzzleMainWindow::AboutPuzzle); - } //--------------------------------------------------------------------------------------------------------------------- @@ -190,24 +186,12 @@ void PuzzleMainWindow::InitProperties() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPropertyTabCurrentPiece() { - // ------------------------------ seamline ------------------------------------ - connect(ui->checkBoxCurrentPieceShowSeamline, QOverload::of(&QCheckBox::toggled), this, - &PuzzleMainWindow::CurrentPieceShowSeamlineChanged); - - // ------------------------------ geometry ------------------------------------ - connect(ui->checkBoxCurrentPieceMirrorPiece, QOverload::of(&QCheckBox::toggled), this, - &PuzzleMainWindow::CurrentPieceMirrorPieceChanged); - - // ------------------------------ rotation ------------------------------------ - connect(ui->doubleSpinBoxCurrentPieceAngle, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::CurrentPieceAngleChanged); // ------------------------------ placement ----------------------------------- connect(ui->doubleSpinBoxCurrentPieceBoxPositionX, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::CurrentPiecePositionChanged); + &PuzzleMainWindow::on_CurrentPiecePositionChanged); connect(ui->doubleSpinBoxCurrentPieceBoxPositionY, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::CurrentPiecePositionChanged); - + &PuzzleMainWindow::on_CurrentPiecePositionChanged); } @@ -226,63 +210,41 @@ void PuzzleMainWindow::InitPropertyTabLayout() // 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); + // 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 // -------------------- layout width, length, orientation ------------------------ connect(ui->doubleSpinBoxLayoutWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::LayoutSizeChanged); + &PuzzleMainWindow::on_LayoutSizeChanged); connect(ui->doubleSpinBoxLayoutLength, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::LayoutSizeChanged); + &PuzzleMainWindow::on_LayoutSizeChanged); connect(ui->radioButtonLayoutPortrait, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::LayoutOrientationChanged); + &PuzzleMainWindow::on_LayoutOrientationChanged); connect(ui->radioButtonLayoutLandscape, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::LayoutOrientationChanged); - connect(ui->pushButtonLayoutRemoveUnusedLength, QOverload::of(&QPushButton::clicked), this, - &PuzzleMainWindow::LayoutRemoveUnusedLength); + &PuzzleMainWindow::on_LayoutOrientationChanged); // -------------------- margins ------------------------ connect(ui->doubleSpinBoxLayoutMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::LayoutMarginChanged); + &PuzzleMainWindow::on_LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::LayoutMarginChanged); + &PuzzleMainWindow::on_LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::LayoutMarginChanged); + &PuzzleMainWindow::on_LayoutMarginChanged); connect(ui->doubleSpinBoxLayoutMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, - &PuzzleMainWindow::LayoutMarginChanged); + &PuzzleMainWindow::on_LayoutMarginChanged); // ------------------- follow grainline ----------------------- connect(ui->radioButtonLayoutFollowGrainlineNo, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::LayoutFollowGrainlineChanged); + &PuzzleMainWindow::on_LayoutFollowGrainlineChanged); connect(ui->radioButtonLayoutFollowGrainlineVertical, QOverload::of(&QRadioButton::clicked), this, - &PuzzleMainWindow::LayoutFollowGrainlineChanged); + &PuzzleMainWindow::on_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); + &PuzzleMainWindow::on_LayoutFollowGrainlineChanged); // -------------------- export --------------------------- // TODO init the file format export combobox - connect(ui->pushButtonLayoutExport, QOverload::of(&QPushButton::clicked), this, - &PuzzleMainWindow::LayoutExport); } //--------------------------------------------------------------------------------------------------------------------- @@ -307,7 +269,7 @@ void PuzzleMainWindow::InitPieceCarrousel() ui->dockWidgetPieceCarrousel->setWidget(pieceCarrousel); connect(ui->dockWidgetPieceCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, - &PuzzleMainWindow::PieceCarrouselLocationChanged); + &PuzzleMainWindow::on_PieceCarrouselLocationChanged); } @@ -422,7 +384,7 @@ void PuzzleMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value) //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::New() +void PuzzleMainWindow::on_actionNew_triggered() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -437,7 +399,7 @@ void PuzzleMainWindow::New() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::Open() +void PuzzleMainWindow::on_actionOpen_triggered() { qCDebug(pWindow, "Openning puzzle layout file."); @@ -491,7 +453,7 @@ void PuzzleMainWindow::Open() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::Save() +void PuzzleMainWindow::on_actionSave_triggered() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -504,7 +466,7 @@ void PuzzleMainWindow::Save() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::SaveAs() +void PuzzleMainWindow::on_actionSaveAs_triggered() { // TODO / FIXME : See valentina how the save is done over there. we need to add the extension .vlt, check for empty file names etc. @@ -534,7 +496,7 @@ void PuzzleMainWindow::SaveAs() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::ImportRawLayout() +void PuzzleMainWindow::on_actionImportRawLayout_triggered() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -547,7 +509,7 @@ void PuzzleMainWindow::ImportRawLayout() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::CloseLayout() +void PuzzleMainWindow::on_actionCloseLayout_triggered() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -560,13 +522,13 @@ void PuzzleMainWindow::CloseLayout() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::AboutQt() +void PuzzleMainWindow::on_actionAboutQt_triggered() { QMessageBox::aboutQt(this, tr("About Qt")); } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::AboutPuzzle() +void PuzzleMainWindow::on_actionAboutPuzzle_triggered() { auto *aboutDialog = new DialogAboutPuzzle(this); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); @@ -574,7 +536,7 @@ void PuzzleMainWindow::AboutPuzzle() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutUnitChanged(int index) +void PuzzleMainWindow::on_comboBoxLayoutUnit_currentIndexChanged(int index) { Q_UNUSED(index); QVariant comboBoxValue = ui->comboBoxLayoutUnit->currentData(); @@ -597,7 +559,7 @@ void PuzzleMainWindow::LayoutUnitChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutTemplateChanged(int index) +void PuzzleMainWindow::on_comboBoxLayoutTemplate_currentIndexChanged(int index) { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -612,7 +574,7 @@ void PuzzleMainWindow::LayoutTemplateChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutSizeChanged() +void PuzzleMainWindow::on_LayoutSizeChanged() { m_layout->SetLayoutSizeConverted(ui->doubleSpinBoxLayoutWidth->value(), ui->doubleSpinBoxLayoutLength->value()); @@ -633,7 +595,7 @@ void PuzzleMainWindow::LayoutSizeChanged() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutOrientationChanged() +void PuzzleMainWindow::on_LayoutOrientationChanged() { // swap the width and length qreal width_before = ui->doubleSpinBoxLayoutWidth->value(); @@ -647,7 +609,7 @@ void PuzzleMainWindow::LayoutOrientationChanged() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutRemoveUnusedLength() +void PuzzleMainWindow::on_pushButtonLayoutRemoveUnusedLength_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -661,7 +623,7 @@ void PuzzleMainWindow::LayoutRemoveUnusedLength() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutMarginChanged() +void PuzzleMainWindow::on_LayoutMarginChanged() { m_layout->SetLayoutMarginsConverted( ui->doubleSpinBoxLayoutMarginLeft->value(), @@ -676,7 +638,7 @@ void PuzzleMainWindow::LayoutMarginChanged() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutFollowGrainlineChanged() +void PuzzleMainWindow::on_LayoutFollowGrainlineChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -690,7 +652,7 @@ void PuzzleMainWindow::LayoutFollowGrainlineChanged() //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutPiecesGapChanged(double value) +void PuzzleMainWindow::on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value) { m_layout->SetPiecesGapConverted(value); @@ -699,7 +661,7 @@ void PuzzleMainWindow::LayoutPiecesGapChanged(double value) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged(bool checked) +void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked) { m_layout->SetWarningSuperpositionOfPieces(checked); @@ -708,7 +670,7 @@ void PuzzleMainWindow::LayoutWarningPiecesSuperpositionChanged(bool checked) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged(bool checked) +void PuzzleMainWindow::on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked) { m_layout->SetWarningPiecesOutOfBound(checked); @@ -717,7 +679,7 @@ void PuzzleMainWindow::LayoutWarningPiecesOutOfBoundChanged(bool checked) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutStickyEdgesChanged(bool checked) +void PuzzleMainWindow::on_checkBoxLayoutStickyEdges_toggled(bool checked) { m_layout->SetStickyEdges(checked); @@ -728,7 +690,7 @@ void PuzzleMainWindow::LayoutStickyEdgesChanged(bool checked) //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::LayoutExport() +void PuzzleMainWindow::on_pushButtonLayoutExport_clicked() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -742,7 +704,7 @@ void PuzzleMainWindow::LayoutExport() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::CurrentPieceShowSeamlineChanged(bool checked) +void PuzzleMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked) { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -756,7 +718,7 @@ void PuzzleMainWindow::CurrentPieceShowSeamlineChanged(bool checked) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::CurrentPieceMirrorPieceChanged(bool checked) +void PuzzleMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked) { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -770,7 +732,7 @@ void PuzzleMainWindow::CurrentPieceMirrorPieceChanged(bool checked) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::CurrentPieceAngleChanged(double value) +void PuzzleMainWindow::on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value) { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -785,7 +747,7 @@ void PuzzleMainWindow::CurrentPieceAngleChanged(double value) //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::CurrentPiecePositionChanged() +void PuzzleMainWindow::on_CurrentPiecePositionChanged() { // just for test purpuses, to be removed: QMessageBox msgBox; @@ -798,7 +760,7 @@ void PuzzleMainWindow::CurrentPiecePositionChanged() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::PieceCarrouselLocationChanged(Qt::DockWidgetArea area) +void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) { if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) { diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/puzzlemainwindow.h index 7b2456a10..6578b1a3d 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -66,10 +66,19 @@ public: */ bool SaveFile(const QString &path); + /** + * @brief ImportRawLayouts The function imports the raw layouts of given paths + * @param layouts paths of the layouts to import + */ void ImportRawLayouts(const QStringList &layouts); public slots: - void New(); + /** + * @brief on_actionNew_triggered When the menu action File > New + * is triggered + * + */ + void on_actionNew_triggered(); protected: enum { MaxRecentFiles = 5 }; @@ -85,12 +94,39 @@ private: VPuzzlePiece *m_selectedPiece{nullptr}; + /** + * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...) + */ void InitMenuBar(); + + /** + * @brief InitProperties Init the properties + */ void InitProperties(); + + /** + * @brief InitPropertyTabCurrentPiece Inits the current piece tab in the properties + */ void InitPropertyTabCurrentPiece(); + + /** + * @brief InitPropertyTabLayout Inits the layout tab in the properties + */ void InitPropertyTabLayout(); + + /** + * @brief InitPropertyTabTiles Inits the tiles tab in the properties + */ void InitPropertyTabTiles(); + + /** + * @brief InitPropertyTabLayers Inits the layers tab in the properties + */ void InitPropertyTabLayers(); + + /** + * @brief InitPieceCarrousel Inits the piece carrousel + */ void InitPieceCarrousel(); @@ -141,34 +177,179 @@ private: void SetCheckBoxValue(QCheckBox *checkbox, bool value); private slots: - void Open(); - void Save(); - void SaveAs(); - void ImportRawLayout(); - void CloseLayout(); + /** + * @brief on_actionOpen_triggered When the menu action File > Open is + * triggered. + * The slot is automatically connected through name convention. + */ + void on_actionOpen_triggered(); - void AboutQt(); - void AboutPuzzle(); + /** + * @brief on_actionSave_triggered When the menu action File > Save is + * triggered. + * The slot is automatically connected through name convention. + */ + void on_actionSave_triggered(); - 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(); + /** + * @brief on_actionSaveAs_triggered When the menu action File > Save As + * is triggered. + * The slot is automatically connected through name convention. + */ + void on_actionSaveAs_triggered(); - void CurrentPieceShowSeamlineChanged(bool checked); - void CurrentPieceMirrorPieceChanged(bool checked); - void CurrentPieceAngleChanged(double value); - void CurrentPiecePositionChanged(); + /** + * @brief on_actionImportRawLayout_triggered When the menu action + * File > Import Raw Layout is triggered. + * The slot is automatically connected through name convention. + */ + void on_actionImportRawLayout_triggered(); - void PieceCarrouselLocationChanged(Qt::DockWidgetArea area); + /** + * @brief on_actionCloseLayout_triggered When the menu action + * File > Close Layout is triggered. + * The slot is automatically connected through name convention. + */ + void on_actionCloseLayout_triggered(); + + /** + * @brief on_actionAboutQt_triggered When the menu action Help > About Qt + * is triggered. + * The slot is automatically connected through name convention. + */ + void on_actionAboutQt_triggered(); + + /** + * @brief on_actionAboutPuzzle_triggered When the menu action Help > About Puzzle + * is triggered. + * The slot is automatically connected through name convention. + */ + void on_actionAboutPuzzle_triggered(); + + /** + * @brief on_comboBoxLayoutUnit_currentIndexChanged When the unit is changed in + * the layout property tab. + * The slot is automatically connected through name convention. + * @param index the index of the selected unit + */ + void on_comboBoxLayoutUnit_currentIndexChanged(int index); + + /** + * @brief on_comboBoxLayoutTemplate_currentIndexChanged When the template is + * changed in the layout property tab. + * The slot is automatically connected through name convention. + * @param index the index of the selected templated + */ + void on_comboBoxLayoutTemplate_currentIndexChanged(int index); + + /** + * @brief LayoutSizeChanged When the width or the length has been changed in + * the layout property tab + */ + void on_LayoutSizeChanged(); + + /** + * @brief LayoutOrientationChanged When one of the radio boxes for the layout + * orientation has been clicked + */ + void on_LayoutOrientationChanged(); + + /** + * @brief on_pushButtonLayoutRemoveUnusedLength_clicked When the button + * "Remove unused length" in the layout property tab is clicked. + * The slot is automatically connected through name convention. + */ + void on_pushButtonLayoutRemoveUnusedLength_clicked(); + + /** + * @brief on_LayoutMarginChanged When one of the margin values has been changed + * in the layout property tab. + */ + void on_LayoutMarginChanged(); + + /** + * @brief LayoutFollowGrainlineChanged When one of the radio boxes for the + * "Follow grainline" has been clicked in the layout property tab. + */ + void on_LayoutFollowGrainlineChanged(); + + /** + * @brief on_doubleSpinBoxLayoutPiecesGap_valueChanged When the "pieces gap" + * value is changed in the layout property tab. + * The slot is automatically connected through name convention. + * @param value the new value of the pieces gap + */ + void on_doubleSpinBoxLayoutPiecesGap_valueChanged(double value); + + /** + * @brief on_checkBoxLayoutWarningPiecesSuperposition_toggled When the + * "Warning when pieces superposition" checkbox value in the layout + * property tab is toggled. + * The slot is automatically connected through name convention. + * @param checked the new checked value + */ + void on_checkBoxLayoutWarningPiecesSuperposition_toggled(bool checked); + + /** + * @brief on_checkBoxLayoutWarningPiecesOutOfBound_toggled When the + * "Warning when pieces out of bound" checkbox value in the layout property + * tab is toggled. + * The slot is automatically connected through name convention. + * @param checked the new checked value + */ + void on_checkBoxLayoutWarningPiecesOutOfBound_toggled(bool checked); + + /** + * @brief on_checkBoxLayoutStickyEdges_toggled When the "Sticky edges" + * checkbox value in the layout property tab is toggled. + * The slot is automatically connected through name convention. + * @param checked the new checked value + */ + void on_checkBoxLayoutStickyEdges_toggled(bool checked); + + /** + * @brief on_pushButtonLayoutExport_clicked When the button + * "Export layout" in the layout property is clicked. + * The slot is automatically connected through name convention. + */ + void on_pushButtonLayoutExport_clicked(); + + /** + * @brief on_checkBoxCurrentPieceShowSeamline_toggled When the + * "Show seamline" checkbox value in the current piece tab is toggled. + * The slot is automatically connected through name convention. + * @param checked the new checked value + */ + void on_checkBoxCurrentPieceShowSeamline_toggled(bool checked); + + /** + * @brief on_checkBoxCurrentPieceMirrorPiece_toggled When the + * "Mirror piece" checkbox in the current piece tab is toggled. + * The slot is automatically connected through name convention. + * @param checked the new checked value + */ + void on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked); + + /** + * @brief on_doubleSpinBoxCurrentPieceAngle_valueChanged When the + * "Current Piece Angle" value in the current piece property is changed + * The slot is automatically connected through name convention. + * @param value the new angle value + */ + void on_doubleSpinBoxCurrentPieceAngle_valueChanged(double value); + + /** + * @brief on_CurrentPiecePositionChanged When the positionX or the positionY + * is changed in the current piece tab + */ + void on_CurrentPiecePositionChanged(); + + /** + * @brief PieceCarrouselLocationChanged When the Piece Carrousel's location + * has been changed + * @param area The new area where the Piece Carrousel has been placed + */ + void on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area); }; From 1c598ab069f5f446ff1c6a1a8bbd26174665ebf8 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Fri, 24 Apr 2020 16:23:06 +0200 Subject: [PATCH 02/12] extend Q_ASSERT of ReadLayer function --- src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp index 106338f60..8fd1de929 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp @@ -219,7 +219,7 @@ void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer) { - Q_ASSERT(isStartElement() && name() == ML::TagLayer); + Q_ASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer)); QXmlStreamAttributes attribs = attributes(); layer->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Layer"))); From 664c6dcd51069bf334b24067d2aa47424fa6045b Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Fri, 24 Apr 2020 17:25:43 +0200 Subject: [PATCH 03/12] Typo --- src/libs/vlayout/vrawlayout.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/vlayout/vrawlayout.h b/src/libs/vlayout/vrawlayout.h index 6521f62e7..23078048a 100644 --- a/src/libs/vlayout/vrawlayout.h +++ b/src/libs/vlayout/vrawlayout.h @@ -34,8 +34,8 @@ struct VRawLayoutData { QVector pieces{}; - friend QDataStream& operator<< (QDataStream& dataStream, const VRawLayoutData& date); - friend QDataStream& operator>> (QDataStream& dataStream, VRawLayoutData& date); + friend QDataStream& operator<< (QDataStream& dataStream, const VRawLayoutData& data); + friend QDataStream& operator>> (QDataStream& dataStream, VRawLayoutData& data); private: static const quint32 streamHeader; From bf09544d87b9ab587c50d5649e9257ada28b4cd9 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 26 Apr 2020 12:09:28 +0200 Subject: [PATCH 04/12] Piece Carrousel --- src/app/puzzle/puzzle.pri | 8 +- src/app/puzzle/puzzlemainwindow.cpp | 98 +++++++---- src/app/puzzle/puzzlemainwindow.h | 13 +- src/app/puzzle/vpiececarrousel.cpp | 209 ++++++++++++++---------- src/app/puzzle/vpiececarrousel.h | 35 +++- src/app/puzzle/vpiececarrousellayer.cpp | 78 +++++++++ src/app/puzzle/vpiececarrousellayer.h | 60 +++++++ src/app/puzzle/vpiececarrouselpiece.cpp | 87 ++++++++++ src/app/puzzle/vpiececarrouselpiece.h | 60 +++++++ src/app/puzzle/vpuzzlelayout.cpp | 6 + src/app/puzzle/vpuzzlelayout.h | 1 - src/app/puzzle/vpuzzlepiece.cpp | 26 +++ src/app/puzzle/vpuzzlepiece.h | 30 +++- 13 files changed, 583 insertions(+), 128 deletions(-) create mode 100644 src/app/puzzle/vpiececarrousellayer.cpp create mode 100644 src/app/puzzle/vpiececarrousellayer.h create mode 100644 src/app/puzzle/vpiececarrouselpiece.cpp create mode 100644 src/app/puzzle/vpiececarrouselpiece.h diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index c6a0ccadb..4cd78670e 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -14,7 +14,9 @@ SOURCES += \ $$PWD/vpuzzlepiece.cpp \ $$PWD/xml/layoutliterals.cpp \ $$PWD/xml/vpuzzlelayoutfilewriter.cpp \ - $$PWD/xml/vpuzzlelayoutfilereader.cpp + $$PWD/xml/vpuzzlelayoutfilereader.cpp \ + $$PWD/vpiececarrousellayer.cpp \ + $$PWD/vpiececarrouselpiece.cpp *msvc*:SOURCES += $$PWD/stable.cpp @@ -31,7 +33,9 @@ HEADERS += \ $$PWD/vpuzzlepiece.h \ $$PWD/xml/layoutliterals.h \ $$PWD/xml/vpuzzlelayoutfilewriter.h \ - $$PWD/xml/vpuzzlelayoutfilereader.h + $$PWD/xml/vpuzzlelayoutfilereader.h \ + $$PWD/vpiececarrousellayer.h \ + $$PWD/vpiececarrouselpiece.h FORMS += \ $$PWD/puzzlemainwindow.ui \ diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index a76d220f8..bcc90cb9e 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -53,17 +53,21 @@ QT_WARNING_POP PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *parent) : QMainWindow(parent), ui(new Ui::PuzzleMainWindow), - pieceCarrousel(new VPieceCarrousel), m_cmd(cmd) { - // ----- for test purposes, to be removed------------------ m_layout = new VPuzzleLayout(); + + // ----- for test purposes, to be removed------------------ m_layout->SetLayoutMarginsConverted(1.5, 2.00, 4.21, 0.25); m_layout->SetLayoutSizeConverted(30.0, 29.7); m_layout->SetPiecesGapConverted(1.27); m_layout->SetUnit(Unit::Cm); m_layout->SetWarningSuperpositionOfPieces(true); + VPuzzleLayer *unplacedLayer = m_layout->GetUnplacedPiecesLayer(); + VPuzzlePiece *piece = new VPuzzlePiece(); + piece->SetName("Hello"); + unplacedLayer->AddPiece(piece); // -------------------------------------------------------- ui->setupUi(this); @@ -80,23 +84,23 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa PuzzleMainWindow::~PuzzleMainWindow() { delete ui; - delete pieceCarrousel; + delete m_pieceCarrousel; } //--------------------------------------------------------------------------------------------------------------------- bool PuzzleMainWindow::LoadFile(QString path) { - 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; - } +// 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; +// } QFile file(path); file.open(QIODevice::ReadOnly); @@ -130,21 +134,28 @@ bool PuzzleMainWindow::SaveFile(const QString &path) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::ImportRawLayouts(const QStringList &layouts) +void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts) { - VRawLayout layoutReader; + VRawLayout rawLayoutReader; - for(auto &path : layouts) + for(auto &path : rawLayouts) { VRawLayoutData data; - if (layoutReader.ReadFile(path, data)) + if (rawLayoutReader.ReadFile(path, data)) { - // Do somethinmg with raw layout data + for (int i = 0; i < data.pieces.size(); ++i) + { + VLayoutPiece rawPiece = data.pieces.at(i); + VPuzzlePiece *piece = CreatePiece(rawPiece); + m_layout->GetUnplacedPiecesLayer()->AddPiece(piece); + } + + m_pieceCarrousel->Refresh(); } else { qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2") - .arg(path, layoutReader.ErrorString()))); + .arg(path, rawLayoutReader.ErrorString()))); if (m_cmd != nullptr && not m_cmd->IsGuiEnabled()) { m_cmd->ShowHelp(V_EX_DATAERR); @@ -153,6 +164,18 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &layouts) } } +//--------------------------------------------------------------------------------------------------------------------- +VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece) +{ + VPuzzlePiece *piece = new VPuzzlePiece(); + piece->SetName(rawPiece.GetName()); + piece->SetUuid(rawPiece.GetUUID()); + + // TODO : set all the information we need for the piece! + + return piece; +} + //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitMenuBar() { @@ -266,7 +289,8 @@ void PuzzleMainWindow::InitPropertyTabLayers() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPieceCarrousel() { - ui->dockWidgetPieceCarrousel->setWidget(pieceCarrousel); + m_pieceCarrousel = new VPieceCarrousel(m_layout); + ui->dockWidgetPieceCarrousel->setWidget(m_pieceCarrousel); connect(ui->dockWidgetPieceCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, &PuzzleMainWindow::on_PieceCarrouselLocationChanged); @@ -498,14 +522,30 @@ void PuzzleMainWindow::on_actionSaveAs_triggered() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::on_actionImportRawLayout_triggered() { - // just for test purpuses, to be removed: - QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::ImportRawLayout"); - int ret = msgBox.exec(); + // TODO: here the code is probably just bad, to be edited - Q_UNUSED(ret); + 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 - // TODO } //--------------------------------------------------------------------------------------------------------------------- @@ -764,13 +804,13 @@ void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) { if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) { - pieceCarrousel->setOrientation(Qt::Horizontal); + m_pieceCarrousel->SetOrientation(Qt::Horizontal); ui->dockWidgetPieceCarrousel->setMaximumHeight(208); ui->dockWidgetPieceCarrousel->setMaximumWidth(10000); } else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea) { - pieceCarrousel->setOrientation(Qt::Vertical); + m_pieceCarrousel->SetOrientation(Qt::Vertical); ui->dockWidgetPieceCarrousel->setMaximumHeight(10000); ui->dockWidgetPieceCarrousel->setMaximumWidth(160); } diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/puzzlemainwindow.h index 6578b1a3d..3432d50e5 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -36,6 +36,7 @@ #include "vpiececarrousel.h" #include "vpuzzlelayout.h" #include "vpuzzlepiece.h" +#include "../vlayout/vlayoutpiece.h" #include "vpuzzlecommandline.h" namespace Ui @@ -68,15 +69,14 @@ public: /** * @brief ImportRawLayouts The function imports the raw layouts of given paths - * @param layouts paths of the layouts to import + * @param rawLayouts paths of the layouts to import */ - void ImportRawLayouts(const QStringList &layouts); + void ImportRawLayouts(const QStringList &rawLayouts); public slots: /** * @brief on_actionNew_triggered When the menu action File > New * is triggered - * */ void on_actionNew_triggered(); @@ -86,13 +86,18 @@ protected: private: Q_DISABLE_COPY(PuzzleMainWindow) Ui::PuzzleMainWindow *ui; - VPieceCarrousel *pieceCarrousel; + VPieceCarrousel *m_pieceCarrousel{nullptr}; VPuzzleCommandLinePtr m_cmd; VPuzzleLayout *m_layout{nullptr}; VPuzzlePiece *m_selectedPiece{nullptr}; + /** + * @brief CreatePiece creates a piece from the given VLayoutPiece data + * @param rawPiece the raw piece data + */ + VPuzzlePiece* CreatePiece(const VLayoutPiece &rawPiece); /** * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...) diff --git a/src/app/puzzle/vpiececarrousel.cpp b/src/app/puzzle/vpiececarrousel.cpp index 02b85c0a1..1bf2ee2de 100644 --- a/src/app/puzzle/vpiececarrousel.cpp +++ b/src/app/puzzle/vpiececarrousel.cpp @@ -27,131 +27,170 @@ *************************************************************************/ #include "vpiececarrousel.h" #include -#include #include #include "../vmisc/backport/qoverload.h" +#include + +Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") + //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrousel::VPieceCarrousel(QWidget *parent) : +VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) : QWidget(parent), - comboBoxLayer(new QComboBox), - mainScrollArea(new QScrollArea(this)), - layers(QList()) + m_layout(layout), + m_comboBoxLayer(new QComboBox(this)), + m_layersContainer(new QWidget(this)), + m_carrouselLayers(QList()) { - - QVBoxLayout *mainLayout = new QVBoxLayout(); - setLayout(mainLayout); - - setMinimumSize(140,140); - - mainLayout->addWidget(comboBoxLayer); - comboBoxLayer->addItem(tr("Unplaced pieces")); - comboBoxLayer->addItem(tr("Layout")); - comboBoxLayer->setCurrentIndex(0); - connect(comboBoxLayer, QOverload::of(&QComboBox::currentIndexChanged), this, - &VPieceCarrousel::ActiveLayerChanged); - - QWidget *widget = new QWidget(); - QVBoxLayout *mainScrollAreaLayout = new QVBoxLayout(); - mainScrollAreaLayout->setMargin(0); - widget->setLayout(mainScrollAreaLayout); - mainScrollArea->setWidget(widget); - - mainLayout->addWidget(mainScrollArea); -// mainScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); - mainScrollArea->setWidgetResizable( true ); - - - // this code is for test purpuses, it needs to be updated when we have proper data! - - QWidget *unplacedPieces = new QWidget(); - QVBoxLayout *unplacedPiecesLayout = new QVBoxLayout(); - unplacedPiecesLayout->setMargin(0); - unplacedPieces->setLayout(unplacedPiecesLayout); - for(int i=0; i<=10; ++i) - { - QLabel *myLabel = new QLabel(); - myLabel->setText(QString ("Element A.%1").arg(i)); - myLabel->setFixedSize(120,120); - myLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); - if(i%2 ==0) - { - myLabel->setStyleSheet("background-color:white"); - } - else { - myLabel->setStyleSheet("background-color:red"); - } - unplacedPiecesLayout->addWidget(myLabel); - } - mainScrollAreaLayout->addWidget(unplacedPieces); - layers.append(unplacedPieces); - - QWidget *layoutPieces = new QWidget(); - QVBoxLayout *layoutPiecesLayout = new QVBoxLayout(); - layoutPiecesLayout->setMargin(0); - layoutPieces->setLayout(layoutPiecesLayout); - for(int i=0; i<=5; ++i) - { - QLabel *myLabel = new QLabel(); - myLabel->setText(QString ("Element B.%1").arg(i)); - myLabel->setFixedSize(120,120); - myLabel->sizePolicy(); - myLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); - myLabel->setStyleSheet("background-color:cornflowerblue"); - layoutPiecesLayout->addWidget(myLabel); - } - mainScrollAreaLayout->addWidget(layoutPieces); - layers.append(layoutPieces); - - QSpacerItem *spacer = new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding); - mainScrollAreaLayout->addSpacerItem(spacer); - - // -------------------- init the layers combobox --------------------- - ActiveLayerChanged(0); + Init(); } //--------------------------------------------------------------------------------------------------------------------- VPieceCarrousel::~VPieceCarrousel() { - delete comboBoxLayer; - delete mainScrollArea; + delete m_comboBoxLayer; + delete m_layersContainer; } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::ActiveLayerChanged(int index) +void VPieceCarrousel::Init() { + // ------ first we initialize the structure of the carrousel + + // init the combo box + connect(m_comboBoxLayer, QOverload::of(&QComboBox::currentIndexChanged), this, + &VPieceCarrousel::on_ActiveLayerChanged); + + // init the layers container and corresponding scroll area + QWidget *layersContainerWrapper = new QWidget(); + QVBoxLayout *layersContainerWrapperLayout = new QVBoxLayout(); + layersContainerWrapperLayout->setMargin(0); + layersContainerWrapper->setLayout(layersContainerWrapperLayout); + + QVBoxLayout *layersContainerLayout = new QVBoxLayout(); + layersContainerLayout->setMargin(0); + m_layersContainer->setLayout(layersContainerLayout); + QSpacerItem *spacer = new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding); + + layersContainerWrapperLayout->addWidget(m_layersContainer); + layersContainerWrapperLayout->addSpacerItem(spacer); + + QScrollArea *scrollArea = new QScrollArea(); + scrollArea->setWidgetResizable( true ); + scrollArea->setWidget(layersContainerWrapper); + + // init the layout of the piece carrousel + QVBoxLayout *mainLayout = new QVBoxLayout(); + setLayout(mainLayout); + setMinimumSize(140,140); + + mainLayout->addWidget(m_comboBoxLayer); + mainLayout->addWidget(scrollArea); + + // ------ then we fill the carrousel with the layout content + Refresh(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrousel::Refresh() +{ + + // NOTE: alternative to clearing the carrousel and adding things again, we could make comparision + + // --- clears the content of the carrousel + Clear(); + + // --- add the content saved in the layout to the carrousel. + QList layers = m_layout->GetLayers(); + layers.prepend(m_layout->GetUnplacedPiecesLayer()); + + for (auto layer : layers) + { + // add layer name to combo + m_comboBoxLayer->addItem(layer->GetName()); + + qCDebug(pCarrousel, "layer name : %s", layer->GetName().toStdString().c_str()); + + // add new carrousel layer + VPieceCarrouselLayer *carrouselLayer = new VPieceCarrouselLayer(layer, this); + m_carrouselLayers.append(carrouselLayer); + m_layersContainer->layout()->addWidget(carrouselLayer); + } + + m_comboBoxLayer->setCurrentIndex(0); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrousel::Clear() +{ + // remove the combobox entries + int layerCount = m_comboBoxLayer->count(); + for(int i=0;iremoveItem(0); + } + + // remove the carrousel layers from the qlayout + while(!m_layersContainer->layout()->isEmpty()) + { + QLayoutItem* item = m_layersContainer->layout()->takeAt(0); + if(item != nullptr) + { + delete item; + } + } + + // Removes and deletes the carrousel layer from the list + while (!m_carrouselLayers.isEmpty()) + { + VPieceCarrouselLayer *carrouselLayer = m_carrouselLayers.takeLast(); + if(carrouselLayer != nullptr) + { + delete carrouselLayer; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrousel::on_ActiveLayerChanged(int index) +{ + qCDebug(pCarrousel, "index changed %i", index); + int j=0; - for (QWidget *widget: layers) { - widget->setVisible(j == index); + for (VPieceCarrouselLayer *carrouselLayer: m_carrouselLayers) { + carrouselLayer->setVisible(j == index); j++; } } //--------------------------------------------------------------------------------------------------------------------- -void VPieceCarrousel::setOrientation(Qt::Orientation orientation) +void VPieceCarrousel::SetOrientation(Qt::Orientation orientation) { QBoxLayout::Direction direction = QBoxLayout::LeftToRight; if(orientation == Qt::Horizontal) { - comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); } else // Qt::Vertical { direction = QBoxLayout::TopToBottom; - comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + m_comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); } - QBoxLayout* mainScrollAreaLayout = qobject_cast(mainScrollArea->widget()->layout()); + // TODO: it's not updated anymore: + + QBoxLayout* mainScrollAreaLayout = qobject_cast(m_layersContainer->layout()); mainScrollAreaLayout->setDirection(direction); - for (QWidget *widget: layers) { + for (VPieceCarrouselLayer *widget: m_carrouselLayers) { QBoxLayout* layerLayout = qobject_cast(widget->layout()); layerLayout->setDirection(direction); } } + diff --git a/src/app/puzzle/vpiececarrousel.h b/src/app/puzzle/vpiececarrousel.h index 009d5348e..22a08cd79 100644 --- a/src/app/puzzle/vpiececarrousel.h +++ b/src/app/puzzle/vpiececarrousel.h @@ -32,27 +32,50 @@ #include #include #include +#include "vpuzzlelayout.h" +#include "vpiececarrousellayer.h" class VPieceCarrousel : public QWidget { Q_OBJECT public: - explicit VPieceCarrousel(QWidget *parent = nullptr); + explicit VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr); virtual ~VPieceCarrousel(); - void setOrientation(Qt::Orientation orientation); + void SetOrientation(Qt::Orientation orientation); + + /** + * @brief Inits the carroussel + */ + void Init(); + + /** + * @brief Refresh Refreshes the content of the carrousel + */ + void Refresh(); + + /** + * @brief Clear Clears the carrousel (removes everything) + */ + void Clear(); + signals: public slots: private: Q_DISABLE_COPY(VPieceCarrousel) - QComboBox *comboBoxLayer; - QScrollArea *mainScrollArea; - QList layers; + + VPuzzleLayout *m_layout; + + QComboBox *m_comboBoxLayer; + QWidget *m_layersContainer; + + QList m_carrouselLayers; + private slots: - void ActiveLayerChanged(int index); + void on_ActiveLayerChanged(int index); }; #endif // VPIECECARROUSEL_H diff --git a/src/app/puzzle/vpiececarrousellayer.cpp b/src/app/puzzle/vpiececarrousellayer.cpp new file mode 100644 index 000000000..7a28c7fd0 --- /dev/null +++ b/src/app/puzzle/vpiececarrousellayer.cpp @@ -0,0 +1,78 @@ +/************************************************************************ + ** + ** @file vpiececarrousellayer.cpp + ** @author Ronan Le Tiec + ** @date 25 4, 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 + ** 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 . + ** + *************************************************************************/ + +#include "vpiececarrousellayer.h" + +#include + +#include + +Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer") + +//--------------------------------------------------------------------------------------------------------------------- +VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, QWidget *parent) : QWidget(parent), m_layer(layer) +{ + Init(); +} + +//--------------------------------------------------------------------------------------------------------------------- +VPieceCarrouselLayer::~VPieceCarrouselLayer() +{ + // TODO +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselLayer::Init() +{ + // initiales the structure + QVBoxLayout *layoutPiecesLayout = new QVBoxLayout(); + layoutPiecesLayout->setMargin(0); + setLayout(layoutPiecesLayout); + + // then refresh the content + Refresh(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselLayer::Refresh() +{ + // remove the existing carrousel pieces + // TODO + + // Updates the carrousel pieces from the pieces list + QList pieces = m_layer->GetPieces(); + + for (auto piece : pieces) + { + qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str()); + + VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece); + m_carrouselPieces.append(carrouselPiece); + layout()->addWidget(carrouselPiece); + } +} diff --git a/src/app/puzzle/vpiececarrousellayer.h b/src/app/puzzle/vpiececarrousellayer.h new file mode 100644 index 000000000..82dcad530 --- /dev/null +++ b/src/app/puzzle/vpiececarrousellayer.h @@ -0,0 +1,60 @@ +/************************************************************************ + ** + ** @file vpiececarrousellayer.h + ** @author Ronan Le Tiec + ** @date 25 4, 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 + ** 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 . + ** + *************************************************************************/ + +#ifndef VPIECECARROUSELLAYER_H +#define VPIECECARROUSELLAYER_H + +#include +#include "vpuzzlelayer.h" +#include "vpiececarrouselpiece.h" + +class VPieceCarrouselLayer : public QWidget +{ + Q_OBJECT +public: + explicit VPieceCarrouselLayer(VPuzzleLayer *layer, QWidget *parent = nullptr); + ~VPieceCarrouselLayer(); + + void Init(); + void Refresh(); + +signals: + +public slots: + +private: + Q_DISABLE_COPY(VPieceCarrouselLayer) + + VPuzzleLayer *m_layer; + QList m_carrouselPieces; + +private slots: + +}; + +#endif // VPIECECARROUSELLAYER_H diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp new file mode 100644 index 000000000..553ff8db0 --- /dev/null +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -0,0 +1,87 @@ +/************************************************************************ + ** + ** @file vpiececarrouselpiece.cpp + ** @author Ronan Le Tiec + ** @date 25 4, 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 + ** 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 . + ** + *************************************************************************/ + +#include "vpiececarrouselpiece.h" +#include +#include + +#include + +Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") + +//--------------------------------------------------------------------------------------------------------------------- +VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent) : QWidget(parent), m_piece(piece) +{ + Init(); +} + + +//--------------------------------------------------------------------------------------------------------------------- +VPieceCarrouselPiece::~VPieceCarrouselPiece() +{ + +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselPiece::Init() +{ + // first define the structure + + QVBoxLayout *pieceLayout = new QVBoxLayout(); + pieceLayout->setMargin(0); + setLayout(pieceLayout); + + // NOTE: this label structure is for test purpuses, it has to be changed when we see the piece preview + m_label = new QLabel(); + m_label->setFixedSize(120,120); + m_label->sizePolicy(); + m_label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); + m_label->setStyleSheet("background-color:cornflowerblue"); + + pieceLayout->addWidget(m_label); + + // then refresh the data + Refresh(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselPiece::Refresh() +{ + // update the label of the piece + + QFontMetrics metrix(m_label->font()); + int width = m_label->width() - 8; + QString clippedText = metrix.elidedText(m_piece->GetName(), Qt::ElideRight, width); + m_label->setText(clippedText); + + m_label->setToolTip(m_piece->GetName()); + + + // update the graphic preview of the piece + // TODO +} diff --git a/src/app/puzzle/vpiececarrouselpiece.h b/src/app/puzzle/vpiececarrouselpiece.h new file mode 100644 index 000000000..29e8cdc28 --- /dev/null +++ b/src/app/puzzle/vpiececarrouselpiece.h @@ -0,0 +1,60 @@ +/************************************************************************ + ** + ** @file vpiececarrouselpiece.h + ** @author Ronan Le Tiec + ** @date 25 4, 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 + ** 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 . + ** + *************************************************************************/ +#ifndef VPIECECARROUSELPIECE_H +#define VPIECECARROUSELPIECE_H + +#include +#include + +#include "vpuzzlepiece.h" + +class VPieceCarrouselPiece : public QWidget +{ + Q_OBJECT +public: + explicit VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent = nullptr); + ~VPieceCarrouselPiece(); + + void Init(); + void Refresh(); + +signals: + +public slots: + +private: + Q_DISABLE_COPY(VPieceCarrouselPiece) + + VPuzzlePiece *m_piece; + QLabel *m_label; + +private slots: + +}; + +#endif // VPIECECARROUSELPIECE_H diff --git a/src/app/puzzle/vpuzzlelayout.cpp b/src/app/puzzle/vpuzzlelayout.cpp index e1f7603cc..61290add7 100644 --- a/src/app/puzzle/vpuzzlelayout.cpp +++ b/src/app/puzzle/vpuzzlelayout.cpp @@ -27,12 +27,18 @@ *************************************************************************/ #include "vpuzzlelayout.h" #include "vpuzzlelayer.h" +#include "vpuzzlepiece.h" //--------------------------------------------------------------------------------------------------------------------- VPuzzleLayout::VPuzzleLayout() : m_unplacedPiecesLayer(new VPuzzleLayer()) { + m_unplacedPiecesLayer->SetName(QObject::tr("Unplaced pieces")); + // create a standard default layer: + VPuzzleLayer *layer = new VPuzzleLayer(); + layer->SetName(QObject::tr("Layout")); + AddLayer(layer); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/vpuzzlelayout.h b/src/app/puzzle/vpuzzlelayout.h index f26e753dd..436957475 100644 --- a/src/app/puzzle/vpuzzlelayout.h +++ b/src/app/puzzle/vpuzzlelayout.h @@ -41,7 +41,6 @@ enum class FollowGrainline : qint8 { No = 0, Follow90 = 1, Follow180 = 2}; class VPuzzleLayout { - public: VPuzzleLayout(); virtual ~VPuzzleLayout(); diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vpuzzlepiece.cpp index 8c9a708f5..cd3df00c4 100644 --- a/src/app/puzzle/vpuzzlepiece.cpp +++ b/src/app/puzzle/vpuzzlepiece.cpp @@ -39,3 +39,29 @@ VPuzzlePiece::~VPuzzlePiece() } + +//--------------------------------------------------------------------------------------------------------------------- +QString VPuzzlePiece::GetName() const +{ + return m_name; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzlePiece::SetName(const QString &name) +{ + m_name = name; +} + + +//--------------------------------------------------------------------------------------------------------------------- +QUuid VPuzzlePiece::GetUuid() const +{ + return m_uuid; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzlePiece::SetUuid(const QUuid &uuid) +{ + m_uuid = uuid; +} diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vpuzzlepiece.h index f20473764..beef8072c 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vpuzzlepiece.h @@ -28,14 +28,42 @@ #ifndef VPUZZLEPIECE_H #define VPUZZLEPIECE_H +#include + class VPuzzlePiece { public: VPuzzlePiece(); ~VPuzzlePiece(); -private: + /** + * @brief GetName Returns the name of the piece + * @return the piece's name + */ + QString GetName() const; + /** + * @brief SetName Sets the piece's name to the given name + * @param name new name of the piece + */ + void SetName(const QString &name); + + /** + * @brief GetUuid Returns the uuid of the piece + * @return the uuid of the piece + */ + QUuid GetUuid() const; + + /** + * @brief SetUuid Sets the uuid of the piece to the given value + * @return the uuid of the piece + */ + void SetUuid(const QUuid &uuid); + + +private: + QUuid m_uuid{QUuid()}; + QString m_name{QString()}; }; #endif // VPUZZLEPIECE_H From 25cb7f9e6ed0e1ab476845baac7aa9528eb1ea6f Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 26 Apr 2020 14:03:43 +0200 Subject: [PATCH 05/12] Optimization piece carrousel --- src/app/puzzle/puzzlemainwindow.cpp | 6 +-- src/app/puzzle/puzzlemainwindow.ui | 22 ++++---- src/app/puzzle/vpiececarrousel.cpp | 68 +++++++++++++++++-------- src/app/puzzle/vpiececarrousel.h | 1 + src/app/puzzle/vpiececarrousellayer.cpp | 7 ++- src/app/puzzle/vpiececarrouselpiece.cpp | 1 + 6 files changed, 68 insertions(+), 37 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index bcc90cb9e..245149e7e 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -64,10 +64,6 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa m_layout->SetPiecesGapConverted(1.27); m_layout->SetUnit(Unit::Cm); m_layout->SetWarningSuperpositionOfPieces(true); - VPuzzleLayer *unplacedLayer = m_layout->GetUnplacedPiecesLayer(); - VPuzzlePiece *piece = new VPuzzlePiece(); - piece->SetName("Hello"); - unplacedLayer->AddPiece(piece); // -------------------------------------------------------- ui->setupUi(this); @@ -289,7 +285,7 @@ void PuzzleMainWindow::InitPropertyTabLayers() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitPieceCarrousel() { - m_pieceCarrousel = new VPieceCarrousel(m_layout); + m_pieceCarrousel = new VPieceCarrousel(m_layout, ui->dockWidgetPieceCarrousel); ui->dockWidgetPieceCarrousel->setWidget(m_pieceCarrousel); connect(ui->dockWidgetPieceCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, diff --git a/src/app/puzzle/puzzlemainwindow.ui b/src/app/puzzle/puzzlemainwindow.ui index d8516accc..d2731a6e5 100644 --- a/src/app/puzzle/puzzlemainwindow.ui +++ b/src/app/puzzle/puzzlemainwindow.ui @@ -94,8 +94,8 @@ - 160 - 208 + 24 + 37 @@ -126,7 +126,11 @@ 0 - + + + 0 + + @@ -228,8 +232,8 @@ 0 0 - 170 - 452 + 356 + 760 @@ -858,8 +862,8 @@ 0 0 - 98 - 41 + 356 + 760 @@ -938,8 +942,8 @@ 0 0 - 98 - 41 + 356 + 760 diff --git a/src/app/puzzle/vpiececarrousel.cpp b/src/app/puzzle/vpiececarrousel.cpp index 1bf2ee2de..327e53054 100644 --- a/src/app/puzzle/vpiececarrousel.cpp +++ b/src/app/puzzle/vpiececarrousel.cpp @@ -32,6 +32,7 @@ #include "../vmisc/backport/qoverload.h" #include +#include Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") @@ -40,6 +41,7 @@ VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) : QWidget(parent), m_layout(layout), m_comboBoxLayer(new QComboBox(this)), + m_scrollArea(new QScrollArea(this)), m_layersContainer(new QWidget(this)), m_carrouselLayers(QList()) { @@ -65,6 +67,7 @@ void VPieceCarrousel::Init() // init the layers container and corresponding scroll area QWidget *layersContainerWrapper = new QWidget(); + QVBoxLayout *layersContainerWrapperLayout = new QVBoxLayout(); layersContainerWrapperLayout->setMargin(0); layersContainerWrapper->setLayout(layersContainerWrapperLayout); @@ -77,20 +80,21 @@ void VPieceCarrousel::Init() layersContainerWrapperLayout->addWidget(m_layersContainer); layersContainerWrapperLayout->addSpacerItem(spacer); - QScrollArea *scrollArea = new QScrollArea(); - scrollArea->setWidgetResizable( true ); - scrollArea->setWidget(layersContainerWrapper); + m_scrollArea->setWidgetResizable( true ); + m_scrollArea->setWidget(layersContainerWrapper); // init the layout of the piece carrousel QVBoxLayout *mainLayout = new QVBoxLayout(); setLayout(mainLayout); - setMinimumSize(140,140); mainLayout->addWidget(m_comboBoxLayer); - mainLayout->addWidget(scrollArea); + mainLayout->addWidget(m_scrollArea); // ------ then we fill the carrousel with the layout content Refresh(); + + // ------ and make sure the calculation for the qlayout is right + SetOrientation(Qt::Vertical); } //--------------------------------------------------------------------------------------------------------------------- @@ -111,8 +115,6 @@ void VPieceCarrousel::Refresh() // add layer name to combo m_comboBoxLayer->addItem(layer->GetName()); - qCDebug(pCarrousel, "layer name : %s", layer->GetName().toStdString().c_str()); - // add new carrousel layer VPieceCarrouselLayer *carrouselLayer = new VPieceCarrouselLayer(layer, this); m_carrouselLayers.append(carrouselLayer); @@ -142,7 +144,7 @@ void VPieceCarrousel::Clear() } } - // Removes and deletes the carrousel layer from the list + // Removes and deletes the carrousel layers from the list while (!m_carrouselLayers.isEmpty()) { VPieceCarrouselLayer *carrouselLayer = m_carrouselLayers.takeLast(); @@ -168,29 +170,51 @@ void VPieceCarrousel::on_ActiveLayerChanged(int index) //--------------------------------------------------------------------------------------------------------------------- void VPieceCarrousel::SetOrientation(Qt::Orientation orientation) { - QBoxLayout::Direction direction = QBoxLayout::LeftToRight; - if(orientation == Qt::Horizontal) - { - m_comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - } - else // Qt::Vertical - { - direction = QBoxLayout::TopToBottom; - m_comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); - } - - // TODO: it's not updated anymore: + QBoxLayout::Direction direction = (orientation == Qt::Horizontal)? + QBoxLayout::LeftToRight + : + QBoxLayout::TopToBottom; + // Update the various qlayouts QBoxLayout* mainScrollAreaLayout = qobject_cast(m_layersContainer->layout()); mainScrollAreaLayout->setDirection(direction); + QBoxLayout* layerContainerWrapper = qobject_cast(m_scrollArea->widget()->layout()); + layerContainerWrapper->setDirection(direction); + for (VPieceCarrouselLayer *widget: m_carrouselLayers) { QBoxLayout* layerLayout = qobject_cast(widget->layout()); layerLayout->setDirection(direction); } + + // then update the scrollarea min height / width and scrollbar behaviour + if(orientation == Qt::Horizontal) + { + m_comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + + // scroll bar policy of scroll area + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + + // FIXME: find a nicer way than putting directly the 120 height of the piece + m_scrollArea->setMinimumHeight(120 + m_scrollArea->horizontalScrollBar()->sizeHint().height()+2); + m_scrollArea->setMinimumWidth(0); + } + else // Qt::Vertical + { + m_comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + + + // scroll bar policy of scroll area + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + m_scrollArea->setMinimumHeight(0); + m_scrollArea->setMinimumWidth(120 + m_scrollArea->verticalScrollBar()->sizeHint().width()+2); + // FIXME: find a nicer way than putting directly the 120 width of the piece + } + } diff --git a/src/app/puzzle/vpiececarrousel.h b/src/app/puzzle/vpiececarrousel.h index 22a08cd79..e8dd9c9ed 100644 --- a/src/app/puzzle/vpiececarrousel.h +++ b/src/app/puzzle/vpiececarrousel.h @@ -69,6 +69,7 @@ private: VPuzzleLayout *m_layout; QComboBox *m_comboBoxLayer; + QScrollArea *m_scrollArea; QWidget *m_layersContainer; QList m_carrouselLayers; diff --git a/src/app/puzzle/vpiececarrousellayer.cpp b/src/app/puzzle/vpiececarrousellayer.cpp index 7a28c7fd0..5993ed71a 100644 --- a/src/app/puzzle/vpiececarrousellayer.cpp +++ b/src/app/puzzle/vpiececarrousellayer.cpp @@ -67,9 +67,14 @@ void VPieceCarrouselLayer::Refresh() // Updates the carrousel pieces from the pieces list QList pieces = m_layer->GetPieces(); + // sort the pieces in alphabetical order + std::sort(pieces.begin(), pieces.end(), + [](const VPuzzlePiece* a, const VPuzzlePiece* b) -> bool { return a->GetName() < b->GetName();}); + + // create the corresponding carrousel pieces for (auto piece : pieces) { - qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str()); +// qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str()); VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece); m_carrouselPieces.append(carrouselPiece); diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp index 553ff8db0..7c1085f3e 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -64,6 +64,7 @@ void VPieceCarrouselPiece::Init() m_label->setStyleSheet("background-color:cornflowerblue"); pieceLayout->addWidget(m_label); + setMinimumSize(120,120); // then refresh the data Refresh(); From 39c889d43b199ee9c042014c9a44db0f40665491 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 26 Apr 2020 14:12:20 +0200 Subject: [PATCH 06/12] Piece Name and UUID taken into account in *vlt reader / writer --- src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp | 8 +++++++- src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp index 8fd1de929..be52922c3 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp @@ -247,7 +247,13 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) Q_UNUSED(piece); Q_ASSERT(isStartElement() && name() == ML::TagPiece); - // TODO read the attributes + QXmlStreamAttributes attribs = attributes(); + piece->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece"))); + QString uuidStr = ReadAttributeString(attribs, ML::AttrID, QUuid().toString());// FIXME: is that correct to have a default value here? + piece->SetUuid(QUuid(uuidStr)); + + // TODO read the further attributes + while (readNextStartElement()) { diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp index c85f725b9..f9d4ef1c7 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp @@ -163,8 +163,8 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) Q_UNUSED(piece); writeStartElement(ML::TagPiece); - SetAttribute(ML::AttrID, "uuid1"); // TODO / Fixme get the right value - SetAttribute(ML::AttrName, "Piece name"); // TODO / Fixme get the right value + SetAttribute(ML::AttrID, piece->GetUuid().toString()); + SetAttribute(ML::AttrName, piece->GetName()); SetAttribute(ML::AttrMirrored, "false"); // TODO / Fixme get the right value SetAttribute(ML::AttrTransform, "string representation of the transformation"); // TODO / Fixme get the right value From 4edcbfd0c5258c846cdcebbc6e0f209852db543f Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 26 Apr 2020 15:36:20 +0200 Subject: [PATCH 07/12] work on the piece and carrousel --- src/app/puzzle/puzzlemainwindow.cpp | 4 ++ src/app/puzzle/vpiececarrouselpiece.cpp | 50 ++++++++++++++++++------- src/app/puzzle/vpiececarrouselpiece.h | 3 ++ src/app/puzzle/vpuzzlepiece.cpp | 13 +++++++ src/app/puzzle/vpuzzlepiece.h | 7 ++++ 5 files changed, 63 insertions(+), 14 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 245149e7e..1fa45c60e 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -142,6 +142,9 @@ void PuzzleMainWindow::ImportRawLayouts(const QStringList &rawLayouts) for (int i = 0; i < data.pieces.size(); ++i) { VLayoutPiece rawPiece = data.pieces.at(i); + + // TODO for feature "Update piece" : CreateOrUpdate() function indstead of CreatePiece() + VPuzzlePiece *piece = CreatePiece(rawPiece); m_layout->GetUnplacedPiecesLayer()->AddPiece(piece); } @@ -166,6 +169,7 @@ VPuzzlePiece* PuzzleMainWindow::CreatePiece(const VLayoutPiece &rawPiece) VPuzzlePiece *piece = new VPuzzlePiece(); piece->SetName(rawPiece.GetName()); piece->SetUuid(rawPiece.GetUUID()); + piece->SetCuttingLine(rawPiece.GetMappedSeamAllowancePoints()); // TODO : set all the information we need for the piece! diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp index 7c1085f3e..f31f4f963 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -29,6 +29,8 @@ #include "vpiececarrouselpiece.h" #include #include +#include +#include #include @@ -44,27 +46,34 @@ VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent) //--------------------------------------------------------------------------------------------------------------------- VPieceCarrouselPiece::~VPieceCarrouselPiece() { - + delete m_graphicsView; } //--------------------------------------------------------------------------------------------------------------------- void VPieceCarrouselPiece::Init() { - // first define the structure - + //m_label->setStyleSheet("background-color:cornflowerblue"); + + // Define the structure + setFixedSize(120,120); QVBoxLayout *pieceLayout = new QVBoxLayout(); pieceLayout->setMargin(0); setLayout(pieceLayout); - // NOTE: this label structure is for test purpuses, it has to be changed when we see the piece preview - m_label = new QLabel(); - m_label->setFixedSize(120,120); - m_label->sizePolicy(); - m_label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); - m_label->setStyleSheet("background-color:cornflowerblue"); + // define the preview of the piece + m_graphicsView = new QGraphicsView(this); + QGraphicsScene *graphicsScene = new QGraphicsScene(this); + m_graphicsView->setScene(graphicsScene); + m_graphicsView->setFixedSize(120,100); + // define the label + m_label = new QLabel(); + m_label->sizePolicy(); + m_label->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + m_label->setFixedSize(120,20); + + pieceLayout->addWidget(m_graphicsView); pieceLayout->addWidget(m_label); - setMinimumSize(120,120); // then refresh the data Refresh(); @@ -73,8 +82,24 @@ void VPieceCarrouselPiece::Init() //--------------------------------------------------------------------------------------------------------------------- void VPieceCarrouselPiece::Refresh() { - // update the label of the piece + // update the graphic view / the scene + // TODO / FIXME : not perfect and maybe not the right way, still need to work on this + QVector points = m_piece->GetCuttingLine(); + + QPen pen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + pen.setCosmetic(true); + QBrush noBrush(Qt::NoBrush); + + QPainterPath path; + path.moveTo(points.first()); + for (int i = 1; i < points.size(); ++i) + path.lineTo(points.at(i)); + m_graphicsView->scene()->addPath(path, pen, noBrush); + + m_graphicsView->fitInView(m_graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio); + + // update the label of the piece QFontMetrics metrix(m_label->font()); int width = m_label->width() - 8; QString clippedText = metrix.elidedText(m_piece->GetName(), Qt::ElideRight, width); @@ -82,7 +107,4 @@ void VPieceCarrouselPiece::Refresh() m_label->setToolTip(m_piece->GetName()); - - // update the graphic preview of the piece - // TODO } diff --git a/src/app/puzzle/vpiececarrouselpiece.h b/src/app/puzzle/vpiececarrouselpiece.h index 29e8cdc28..845e3902c 100644 --- a/src/app/puzzle/vpiececarrouselpiece.h +++ b/src/app/puzzle/vpiececarrouselpiece.h @@ -30,9 +30,11 @@ #include #include +#include #include "vpuzzlepiece.h" + class VPieceCarrouselPiece : public QWidget { Q_OBJECT @@ -52,6 +54,7 @@ private: VPuzzlePiece *m_piece; QLabel *m_label; + QGraphicsView *m_graphicsView; private slots: diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vpuzzlepiece.cpp index cd3df00c4..e4c8558eb 100644 --- a/src/app/puzzle/vpuzzlepiece.cpp +++ b/src/app/puzzle/vpuzzlepiece.cpp @@ -65,3 +65,16 @@ void VPuzzlePiece::SetUuid(const QUuid &uuid) { m_uuid = uuid; } + + +//--------------------------------------------------------------------------------------------------------------------- +QVector VPuzzlePiece::GetCuttingLine() const +{ + return m_cuttingLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzlePiece::SetCuttingLine(const QVector &cuttingLine) +{ + m_cuttingLine = cuttingLine; +} diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vpuzzlepiece.h index beef8072c..6504e6d66 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vpuzzlepiece.h @@ -29,6 +29,8 @@ #define VPUZZLEPIECE_H #include +#include +#include class VPuzzlePiece { @@ -60,10 +62,15 @@ public: */ void SetUuid(const QUuid &uuid); + QVector GetCuttingLine() const; + + void SetCuttingLine(const QVector &cuttingLine); + private: QUuid m_uuid{QUuid()}; QString m_name{QString()}; + QVector m_cuttingLine{QVector()}; }; #endif // VPUZZLEPIECE_H From 7bca5f41ecf75c5c3b00fc9fc33af795e241290a Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sun, 26 Apr 2020 22:32:08 +0200 Subject: [PATCH 08/12] Optimize the carrousel piece fitInView --- src/app/puzzle/vpiececarrousel.cpp | 2 +- src/app/puzzle/vpiececarrousellayer.cpp | 7 +++++++ src/app/puzzle/vpiececarrouselpiece.cpp | 6 ++++++ src/app/puzzle/vpiececarrouselpiece.h | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/app/puzzle/vpiececarrousel.cpp b/src/app/puzzle/vpiececarrousel.cpp index 327e53054..1ff7db0e2 100644 --- a/src/app/puzzle/vpiececarrousel.cpp +++ b/src/app/puzzle/vpiececarrousel.cpp @@ -121,7 +121,7 @@ void VPieceCarrousel::Refresh() m_layersContainer->layout()->addWidget(carrouselLayer); } - m_comboBoxLayer->setCurrentIndex(0); + on_ActiveLayerChanged(0); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/vpiececarrousellayer.cpp b/src/app/puzzle/vpiececarrousellayer.cpp index 5993ed71a..1c7c0e1f3 100644 --- a/src/app/puzzle/vpiececarrousellayer.cpp +++ b/src/app/puzzle/vpiececarrousellayer.cpp @@ -72,6 +72,7 @@ void VPieceCarrouselLayer::Refresh() [](const VPuzzlePiece* a, const VPuzzlePiece* b) -> bool { return a->GetName() < b->GetName();}); // create the corresponding carrousel pieces + for (auto piece : pieces) { // qCDebug(pCarrouselLayer, "piece name : %s", piece->GetName().toStdString().c_str()); @@ -79,5 +80,11 @@ void VPieceCarrouselLayer::Refresh() VPieceCarrouselPiece *carrouselPiece = new VPieceCarrouselPiece(piece); m_carrouselPieces.append(carrouselPiece); layout()->addWidget(carrouselPiece); + + // FIXME? the fitInView inside the refresh of the piece doesn't workd properly. + // only by doing the following I did get it to work: + setVisible(true); + carrouselPiece->CleanPreview(); + setVisible(false); } } diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp index f31f4f963..fea3c1f57 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -79,6 +79,12 @@ void VPieceCarrouselPiece::Init() Refresh(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselPiece::CleanPreview() +{ + m_graphicsView->fitInView(m_graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio); +} + //--------------------------------------------------------------------------------------------------------------------- void VPieceCarrouselPiece::Refresh() { diff --git a/src/app/puzzle/vpiececarrouselpiece.h b/src/app/puzzle/vpiececarrouselpiece.h index 845e3902c..7b9cc8e90 100644 --- a/src/app/puzzle/vpiececarrouselpiece.h +++ b/src/app/puzzle/vpiececarrouselpiece.h @@ -44,6 +44,11 @@ public: void Init(); void Refresh(); + /** + * @brief CleanPiecesPreview fitInView of the qGraphicsView of the pieces works properly + * only when the piece is in place in the layer and we call it from the layer. + */ + void CleanPreview(); signals: From f5e325a23591e2cfa7ab3b4cbce16460a27d35b8 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Fri, 1 May 2020 18:26:02 +0200 Subject: [PATCH 09/12] Piece carrousel design and piece selection --- src/app/puzzle/puzzlemainwindow.cpp | 23 +++++++- src/app/puzzle/puzzlemainwindow.h | 6 ++ src/app/puzzle/vpiececarrousel.cpp | 28 ++++++++- src/app/puzzle/vpiececarrousel.h | 11 ++++ src/app/puzzle/vpiececarrousellayer.cpp | 16 +++++ src/app/puzzle/vpiececarrousellayer.h | 4 ++ src/app/puzzle/vpiececarrouselpiece.cpp | 58 +++++++++++++++++-- src/app/puzzle/vpiececarrouselpiece.h | 33 +++++++++-- src/app/puzzle/vpuzzlepiece.h | 1 - .../puzzle/xml/vpuzzlelayoutfilereader.cpp | 12 ++-- 10 files changed, 172 insertions(+), 20 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 1fa45c60e..de5220dcb 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -294,6 +294,9 @@ void PuzzleMainWindow::InitPieceCarrousel() connect(ui->dockWidgetPieceCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, &PuzzleMainWindow::on_PieceCarrouselLocationChanged); + + connect(m_pieceCarrousel, QOverload::of(&VPieceCarrousel::pieceClicked), this, + &PuzzleMainWindow::on_PieceSelected); } @@ -329,7 +332,10 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData() } else { - // TODO set the values of the piece currently selected + // set the value to the current piece + ui->lineEditCurrentPieceName->setText(m_selectedPiece->GetName()); + + // TODO: checkbox show seamline, mirror piece, rotation and placement; } } @@ -816,3 +822,18 @@ void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area) } } +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::on_PieceSelected(VPuzzlePiece* piece) +{ + m_selectedPiece = piece; + + // update the state of the piece carrousel + m_pieceCarrousel->SelectPiece(piece); + + // update the Layout + + // TODO + + // update the property of the piece currently selected + SetPropertyTabCurrentPieceData(); +} diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/puzzlemainwindow.h index 3432d50e5..011021d9c 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -356,6 +356,12 @@ private slots: */ void on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area); + /** + * @brief on_PieceSelected When a been has been selected + * @param piece the piece that was selected + */ + void on_PieceSelected(VPuzzlePiece* piece); + }; #endif // PUZZLEMAINWINDOW_H diff --git a/src/app/puzzle/vpiececarrousel.cpp b/src/app/puzzle/vpiececarrousel.cpp index 1ff7db0e2..06741ffb7 100644 --- a/src/app/puzzle/vpiececarrousel.cpp +++ b/src/app/puzzle/vpiececarrousel.cpp @@ -119,6 +119,10 @@ void VPieceCarrousel::Refresh() VPieceCarrouselLayer *carrouselLayer = new VPieceCarrouselLayer(layer, this); m_carrouselLayers.append(carrouselLayer); m_layersContainer->layout()->addWidget(carrouselLayer); + + connect(carrouselLayer, QOverload::of(&VPieceCarrouselLayer::pieceClicked), this, + &VPieceCarrousel::on_PieceClicked); + } on_ActiveLayerChanged(0); @@ -155,6 +159,20 @@ void VPieceCarrousel::Clear() } } +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrousel::SelectPiece(VPuzzlePiece* piece) +{ + for (auto layer : m_carrouselLayers) + { + QList carrouselPieces = layer->GetCarrouselPieces(); + for (auto carrouselPiece : carrouselPieces) + { + carrouselPiece->SetIsSelected(carrouselPiece->GetPiece() == piece); + } + } +} + + //--------------------------------------------------------------------------------------------------------------------- void VPieceCarrousel::on_ActiveLayerChanged(int index) { @@ -198,7 +216,7 @@ void VPieceCarrousel::SetOrientation(Qt::Orientation orientation) m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); // FIXME: find a nicer way than putting directly the 120 height of the piece - m_scrollArea->setMinimumHeight(120 + m_scrollArea->horizontalScrollBar()->sizeHint().height()+2); + m_scrollArea->setMinimumHeight(128 + m_scrollArea->horizontalScrollBar()->sizeHint().height()+2); m_scrollArea->setMinimumWidth(0); } else // Qt::Vertical @@ -211,10 +229,16 @@ void VPieceCarrousel::SetOrientation(Qt::Orientation orientation) m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); m_scrollArea->setMinimumHeight(0); - m_scrollArea->setMinimumWidth(120 + m_scrollArea->verticalScrollBar()->sizeHint().width()+2); + m_scrollArea->setMinimumWidth(124 + m_scrollArea->verticalScrollBar()->sizeHint().width()+2); // FIXME: find a nicer way than putting directly the 120 width of the piece } } +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrousel::on_PieceClicked(VPieceCarrouselPiece* carrouselPiece) +{ + emit pieceClicked(carrouselPiece->GetPiece()); +} + diff --git a/src/app/puzzle/vpiececarrousel.h b/src/app/puzzle/vpiececarrousel.h index e8dd9c9ed..9e90c56d7 100644 --- a/src/app/puzzle/vpiececarrousel.h +++ b/src/app/puzzle/vpiececarrousel.h @@ -33,6 +33,7 @@ #include #include #include "vpuzzlelayout.h" +#include "vpuzzlepiece.h" #include "vpiececarrousellayer.h" class VPieceCarrousel : public QWidget @@ -59,9 +60,19 @@ public: */ void Clear(); + /** + * @brief SelectPiece Updates the carrousel so that the given piece is selected + * @param piece the piece to select + */ + void SelectPiece(VPuzzlePiece* piece); + + signals: + void pieceClicked(VPuzzlePiece* piece); public slots: + void on_PieceClicked(VPieceCarrouselPiece* carrouselPiece); + private: Q_DISABLE_COPY(VPieceCarrousel) diff --git a/src/app/puzzle/vpiececarrousellayer.cpp b/src/app/puzzle/vpiececarrousellayer.cpp index 1c7c0e1f3..20cecd43d 100644 --- a/src/app/puzzle/vpiececarrousellayer.cpp +++ b/src/app/puzzle/vpiececarrousellayer.cpp @@ -86,5 +86,21 @@ void VPieceCarrouselLayer::Refresh() setVisible(true); carrouselPiece->CleanPreview(); setVisible(false); + + connect(carrouselPiece, QOverload::of(&VPieceCarrouselPiece::clicked), this, + &VPieceCarrouselLayer::on_PieceClicked); + } } + +//--------------------------------------------------------------------------------------------------------------------- +QList VPieceCarrouselLayer::GetCarrouselPieces() +{ + return m_carrouselPieces; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselLayer::on_PieceClicked(VPieceCarrouselPiece* carrouselPiece) +{ + emit pieceClicked(carrouselPiece); +} diff --git a/src/app/puzzle/vpiececarrousellayer.h b/src/app/puzzle/vpiececarrousellayer.h index 82dcad530..aa3bae3a2 100644 --- a/src/app/puzzle/vpiececarrousellayer.h +++ b/src/app/puzzle/vpiececarrousellayer.h @@ -43,9 +43,13 @@ public: void Init(); void Refresh(); + QList GetCarrouselPieces(); + signals: + void pieceClicked(VPieceCarrouselPiece* carrouselPiece); public slots: + void on_PieceClicked(VPieceCarrouselPiece* carrouselPiece); private: Q_DISABLE_COPY(VPieceCarrouselLayer) diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp index fea3c1f57..ae690b0ae 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -37,7 +37,7 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent) : QWidget(parent), m_piece(piece) +VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent) : QFrame(parent), m_piece(piece) { Init(); } @@ -52,25 +52,31 @@ VPieceCarrouselPiece::~VPieceCarrouselPiece() //--------------------------------------------------------------------------------------------------------------------- void VPieceCarrouselPiece::Init() { - //m_label->setStyleSheet("background-color:cornflowerblue"); - // Define the structure - setFixedSize(120,120); + setFixedSize(124,128); QVBoxLayout *pieceLayout = new QVBoxLayout(); pieceLayout->setMargin(0); + pieceLayout->setSpacing(0); setLayout(pieceLayout); + setStyleSheet("background-color:white; border: 2px solid transparent;"); + // define the preview of the piece m_graphicsView = new QGraphicsView(this); + + // m_graphicsView = new VMainGraphicsView(this); + // --> undefined reference to 'VMainGraphicsView::VMainGraphicView(QWidget*)' QGraphicsScene *graphicsScene = new QGraphicsScene(this); m_graphicsView->setScene(graphicsScene); m_graphicsView->setFixedSize(120,100); + m_graphicsView->setStyleSheet("border: 4px solid transparent;"); // define the label m_label = new QLabel(); m_label->sizePolicy(); m_label->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); - m_label->setFixedSize(120,20); + m_label->setFixedSize(120,24); + m_label->setStyleSheet("border: 0px;"); pieceLayout->addWidget(m_graphicsView); pieceLayout->addWidget(m_label); @@ -111,6 +117,46 @@ void VPieceCarrouselPiece::Refresh() QString clippedText = metrix.elidedText(m_piece->GetName(), Qt::ElideRight, width); m_label->setText(clippedText); - m_label->setToolTip(m_piece->GetName()); + setToolTip(m_piece->GetName()); } + +//--------------------------------------------------------------------------------------------------------------------- +VPuzzlePiece * VPieceCarrouselPiece::GetPiece() +{ + return m_piece; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselPiece::SetIsSelected(bool value) +{ + m_isSelected = value; + + if(value) + { + setStyleSheet("background-color:white; border: 2px solid red;"); + } + else + { + setStyleSheet("background-color:white; border: 2px solid transparent;"); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPieceCarrouselPiece::GetIsSelected() +{ + return m_isSelected; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrouselPiece::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + if(!m_isSelected) + { + emit clicked(this); + } + } +} + diff --git a/src/app/puzzle/vpiececarrouselpiece.h b/src/app/puzzle/vpiececarrouselpiece.h index 7b9cc8e90..6eb7df138 100644 --- a/src/app/puzzle/vpiececarrouselpiece.h +++ b/src/app/puzzle/vpiececarrouselpiece.h @@ -28,14 +28,15 @@ #ifndef VPIECECARROUSELPIECE_H #define VPIECECARROUSELPIECE_H -#include +#include #include #include +#include #include "vpuzzlepiece.h" -class VPieceCarrouselPiece : public QWidget +class VPieceCarrouselPiece : public QFrame { Q_OBJECT public: @@ -50,16 +51,40 @@ public: */ void CleanPreview(); + /** + * @brief GetLayoutPiece Returns the corresponding layout piece + * @return the corresponding layout piece + */ + VPuzzlePiece * GetPiece(); + + /** + * @brief SetSelected sets the selected state to the given value + * @param value the new selected state + */ + void SetIsSelected(bool value); + + /** + * @brief GetSelected Returns wether the piece is selected or not + * @return true if the piece is selected + */ + bool GetIsSelected(); + signals: + void clicked(VPieceCarrouselPiece* m_piece); public slots: +protected: + void mousePressEvent(QMouseEvent *event) override; + private: Q_DISABLE_COPY(VPieceCarrouselPiece) VPuzzlePiece *m_piece; - QLabel *m_label; - QGraphicsView *m_graphicsView; + QLabel *m_label{nullptr}; + QGraphicsView *m_graphicsView{nullptr}; + + bool m_isSelected = false; private slots: diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vpuzzlepiece.h index 6504e6d66..42331232f 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vpuzzlepiece.h @@ -58,7 +58,6 @@ public: /** * @brief SetUuid Sets the uuid of the piece to the given value - * @return the uuid of the piece */ void SetUuid(const QUuid &uuid); diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp index be52922c3..f622fd733 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp @@ -62,7 +62,7 @@ bool VPuzzleLayoutFileReader::ReadFile(VPuzzleLayout *layout, QFile *file) //--------------------------------------------------------------------------------------------------------------------- void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout) { - Q_ASSERT(isStartElement() && name() == ML::TagLayout); + SCASSERT(isStartElement() && name() == ML::TagLayout); while (readNextStartElement()) { @@ -84,7 +84,7 @@ void VPuzzleLayoutFileReader::ReadLayout(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- void VPuzzleLayoutFileReader::ReadProperties(VPuzzleLayout *layout) { - Q_ASSERT(isStartElement() && name() == ML::TagProperties); + SCASSERT(isStartElement() && name() == ML::TagProperties); while (readNextStartElement()) { @@ -162,7 +162,7 @@ void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout) { Q_UNUSED(layout); // to be removed when used - Q_ASSERT(isStartElement() && name() == ML::TagTiles); + SCASSERT(isStartElement() && name() == ML::TagTiles); // QXmlStreamAttributes attribs = attributes(); // attribs.value(ML::AttrVisible); // TODO @@ -195,7 +195,7 @@ void VPuzzleLayoutFileReader::ReadTiles(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout) { - Q_ASSERT(isStartElement() && name() == ML::TagLayers); + SCASSERT(isStartElement() && name() == ML::TagLayers); while (readNextStartElement()) { @@ -219,7 +219,7 @@ void VPuzzleLayoutFileReader::ReadLayers(VPuzzleLayout *layout) //--------------------------------------------------------------------------------------------------------------------- void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer) { - Q_ASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer)); + SCASSERT(isStartElement() && (name() == ML::TagLayer || name() == ML::TagUnplacedPiecesLayer)); QXmlStreamAttributes attribs = attributes(); layer->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Layer"))); @@ -245,7 +245,7 @@ void VPuzzleLayoutFileReader::ReadLayer(VPuzzleLayer *layer) void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) { Q_UNUSED(piece); - Q_ASSERT(isStartElement() && name() == ML::TagPiece); + SCASSERT(isStartElement() && name() == ML::TagPiece); QXmlStreamAttributes attribs = attributes(); piece->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece"))); From 9a8fabc25e08392447f5a1524d009bd170acff99 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Fri, 1 May 2020 19:08:48 +0200 Subject: [PATCH 10/12] optimization current piece tab --- src/app/puzzle/puzzlemainwindow.cpp | 37 ++- src/app/puzzle/puzzlemainwindow.ui | 239 ++++++++++-------- src/app/puzzle/vpuzzlepiece.cpp | 26 ++ src/app/puzzle/vpuzzlepiece.h | 26 ++ src/app/puzzle/xml/layoutliterals.cpp | 1 + src/app/puzzle/xml/layoutliterals.h | 1 + .../puzzle/xml/vpuzzlelayoutfilereader.cpp | 6 + .../puzzle/xml/vpuzzlelayoutfilewriter.cpp | 3 +- 8 files changed, 214 insertions(+), 125 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index de5220dcb..208f8af8b 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -72,7 +72,6 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa InitProperties(); InitPieceCarrousel(); - SetPropertiesData(); } @@ -328,14 +327,22 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData() else { // TODO : update current piece data to show a "no current piece selected" + ui->containerCurrentPieceNoData->setVisible(true); + ui->containerCurrentPieceData->setVisible(false); } } else { + ui->containerCurrentPieceNoData->setVisible(false); + ui->containerCurrentPieceData->setVisible(true); + // set the value to the current piece ui->lineEditCurrentPieceName->setText(m_selectedPiece->GetName()); - // TODO: checkbox show seamline, mirror piece, rotation and placement; + ui->checkBoxCurrentPieceShowSeamline->setChecked(m_selectedPiece->GetShowSeamLine()); + ui->checkBoxCurrentPieceMirrorPiece->setChecked(m_selectedPiece->GetPieceMirrored()); + + // TODO:rotation and placement; } } @@ -752,29 +759,19 @@ void PuzzleMainWindow::on_pushButtonLayoutExport_clicked() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::on_checkBoxCurrentPieceShowSeamline_toggled(bool checked) { - // just for test purpuses, to be removed: - QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::CurrentPieceShowSeamlineChanged"); - int ret = msgBox.exec(); - - Q_UNUSED(checked); - Q_UNUSED(ret); - - // TODO + if(m_selectedPiece != nullptr) + { + m_selectedPiece->SetShowSeamLine(checked); + } } //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::on_checkBoxCurrentPieceMirrorPiece_toggled(bool checked) { - // just for test purpuses, to be removed: - QMessageBox msgBox; - msgBox.setText("TODO PuzzleMainWindow::CurrentPieceMirrorPieceChanged"); - int ret = msgBox.exec(); - - Q_UNUSED(checked); - Q_UNUSED(ret); - - // TODO + if(m_selectedPiece != nullptr) + { + m_selectedPiece->SetPieceMirrored(checked); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/puzzlemainwindow.ui b/src/app/puzzle/puzzlemainwindow.ui index d2731a6e5..5f63f8644 100644 --- a/src/app/puzzle/puzzlemainwindow.ui +++ b/src/app/puzzle/puzzlemainwindow.ui @@ -175,7 +175,7 @@ QTabWidget::Rounded - 1 + 0 @@ -232,8 +232,8 @@ 0 0 - 356 - 760 + 342 + 894 @@ -254,44 +254,24 @@ - - - Infos - - - - - - DummyName - - - true - - - - - - - Name: - - - - - - - - - - Seamline - - + + + + 0 + - - - Show Seamline + + + + 0 + 400 + - - true + + No piece selected + + + Qt::AlignCenter @@ -299,85 +279,136 @@ - - - Geometry - - + + - - - Mirror piece + + + Infos + + + + + DummyName + + + true + + + + + + + Name: + + + + - - - - - - - Rotation - - - - - - Angle: + + + + Seamline + + + + + Show Seamline + + + true + + + + - - - - 360.000000000000000 - - - 0.100000000000000 + + + + Geometry + + + + + Mirror piece + + + + - - - - - - - Placement - - - - - - X: + + + + Rotation + + + + + Angle: + + + + + + + 360.000000000000000 + + + 0.100000000000000 + + + + - - - - 10000.000000000000000 - - - 0.100000000000000 - - - - - - - Y: - - - - - - - 10000.000000000000000 - - - 0.100000000000000 + + + + Placement + + + + + X: + + + + + + + 10000.000000000000000 + + + 0.100000000000000 + + + + + + + Y: + + + + + + + 10000.000000000000000 + + + 0.100000000000000 + + + + diff --git a/src/app/puzzle/vpuzzlepiece.cpp b/src/app/puzzle/vpuzzlepiece.cpp index e4c8558eb..21daa67a2 100644 --- a/src/app/puzzle/vpuzzlepiece.cpp +++ b/src/app/puzzle/vpuzzlepiece.cpp @@ -78,3 +78,29 @@ void VPuzzlePiece::SetCuttingLine(const QVector &cuttingLine) { m_cuttingLine = cuttingLine; } + + +//--------------------------------------------------------------------------------------------------------------------- +bool VPuzzlePiece::GetShowSeamLine() +{ + return m_showSeamline; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzlePiece::SetShowSeamLine(bool value) +{ + m_showSeamline = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPuzzlePiece::GetPieceMirrored() +{ + return m_mirrorPiece; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPuzzlePiece::SetPieceMirrored(bool value) +{ + m_mirrorPiece = value; +} + diff --git a/src/app/puzzle/vpuzzlepiece.h b/src/app/puzzle/vpuzzlepiece.h index 42331232f..55d0f3fd8 100644 --- a/src/app/puzzle/vpuzzlepiece.h +++ b/src/app/puzzle/vpuzzlepiece.h @@ -65,11 +65,37 @@ public: void SetCuttingLine(const QVector &cuttingLine); + /** + * @brief GetShowSeamLine returns wether the seam line of the piece has to be shown or not + * @return true if the seamline has to be shown + */ + bool GetShowSeamLine(); + + /** + * @brief SetShowSeamLine sets wether the seam line of the piece has to be shown or not + * @param value true if the seamline has to be shown + */ + void SetShowSeamLine(bool value); + + /** + * @brief GetMirrorPiece returns wether the piece is mirrored or not + * @return true if the piece is mirrored + */ + bool GetPieceMirrored(); + + /** + * @brief SetMirrorPiece sets wether the piece is mirrored or not + * @param value true if the piece will be mirrored + */ + void SetPieceMirrored(bool value); + private: QUuid m_uuid{QUuid()}; QString m_name{QString()}; QVector m_cuttingLine{QVector()}; + bool m_showSeamline{true}; + bool m_mirrorPiece{false}; }; #endif // VPUZZLEPIECE_H diff --git a/src/app/puzzle/xml/layoutliterals.cpp b/src/app/puzzle/xml/layoutliterals.cpp index c3bdb6d6d..d73088fc8 100644 --- a/src/app/puzzle/xml/layoutliterals.cpp +++ b/src/app/puzzle/xml/layoutliterals.cpp @@ -60,4 +60,5 @@ const QString AttrFollowGrainLine = QStringLiteral("followGrainLine"); const QString AttrID = QStringLiteral("id"); const QString AttrMirrored = QStringLiteral("mirrored"); const QString AttrTransform = QStringLiteral("transform"); +const QString AttrShowSeamline = QStringLiteral("showSeamline"); } diff --git a/src/app/puzzle/xml/layoutliterals.h b/src/app/puzzle/xml/layoutliterals.h index 3f2577203..82157f9bf 100644 --- a/src/app/puzzle/xml/layoutliterals.h +++ b/src/app/puzzle/xml/layoutliterals.h @@ -65,6 +65,7 @@ extern const QString AttrFollowGrainLine; extern const QString AttrID; extern const QString AttrMirrored; extern const QString AttrTransform; +extern const QString AttrShowSeamline; } diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp index f622fd733..31ab72691 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilereader.cpp @@ -249,9 +249,15 @@ void VPuzzleLayoutFileReader::ReadPiece(VPuzzlePiece *piece) QXmlStreamAttributes attribs = attributes(); piece->SetName(ReadAttributeString(attribs, ML::AttrName, tr("Piece"))); + QString uuidStr = ReadAttributeString(attribs, ML::AttrID, QUuid().toString());// FIXME: is that correct to have a default value here? piece->SetUuid(QUuid(uuidStr)); + bool showSeamline = ReadAttributeBool(attribs, ML::AttrShowSeamline, trueStr); + piece->SetShowSeamLine(showSeamline); + + bool pieceMirrored = ReadAttributeBool(attribs, ML::AttrMirrored, falseStr); + piece->SetPieceMirrored(pieceMirrored); // TODO read the further attributes diff --git a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp index f9d4ef1c7..6b8dced26 100644 --- a/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vpuzzlelayoutfilewriter.cpp @@ -165,7 +165,8 @@ void VPuzzleLayoutFileWriter::WritePiece(VPuzzlePiece *piece) writeStartElement(ML::TagPiece); SetAttribute(ML::AttrID, piece->GetUuid().toString()); SetAttribute(ML::AttrName, piece->GetName()); - SetAttribute(ML::AttrMirrored, "false"); // TODO / Fixme get the right value + SetAttribute(ML::AttrMirrored, piece->GetPieceMirrored()); // TODO / Fixme get the right value + SetAttribute(ML::AttrShowSeamline, piece->GetShowSeamLine()); // TODO / Fixme get the right value SetAttribute(ML::AttrTransform, "string representation of the transformation"); // TODO / Fixme get the right value // TODO cuttingLine From 928c57f74b32c892c6dc55bd886bdea59f7e1dee Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 2 May 2020 09:30:53 +0200 Subject: [PATCH 11/12] remove uncomment in LoadFile --- src/app/puzzle/puzzlemainwindow.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 208f8af8b..8f8252a76 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -85,17 +85,17 @@ PuzzleMainWindow::~PuzzleMainWindow() //--------------------------------------------------------------------------------------------------------------------- bool PuzzleMainWindow::LoadFile(QString path) { -// 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; -// } + 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; + } QFile file(path); file.open(QIODevice::ReadOnly); From e27e543fbca0eb34829ee6c2e953f37536d422d9 Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 2 May 2020 09:44:45 +0200 Subject: [PATCH 12/12] comments --- src/app/puzzle/puzzlemainwindow.h | 6 +++--- src/app/puzzle/vpiececarrousellayer.cpp | 5 ++++- src/app/puzzle/vpiececarrouselpiece.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app/puzzle/puzzlemainwindow.h b/src/app/puzzle/puzzlemainwindow.h index 011021d9c..eb8dde989 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -350,14 +350,14 @@ private slots: void on_CurrentPiecePositionChanged(); /** - * @brief PieceCarrouselLocationChanged When the Piece Carrousel's location + * @brief PieceCarrouselLocationChanged When the piece carrousel's location * has been changed - * @param area The new area where the Piece Carrousel has been placed + * @param area The new area where the piece carrousel has been placed */ void on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area); /** - * @brief on_PieceSelected When a been has been selected + * @brief on_PieceSelected When a piece has been selected * @param piece the piece that was selected */ void on_PieceSelected(VPuzzlePiece* piece); diff --git a/src/app/puzzle/vpiececarrousellayer.cpp b/src/app/puzzle/vpiececarrousellayer.cpp index 20cecd43d..d00ed6ecb 100644 --- a/src/app/puzzle/vpiececarrousellayer.cpp +++ b/src/app/puzzle/vpiececarrousellayer.cpp @@ -35,7 +35,10 @@ Q_LOGGING_CATEGORY(pCarrouselLayer, "p.carrouselLayer") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, QWidget *parent) : QWidget(parent), m_layer(layer) +VPieceCarrouselLayer::VPieceCarrouselLayer(VPuzzleLayer *layer, QWidget *parent) : + QWidget(parent), + m_layer(layer), + m_carrouselPieces(QList()) { Init(); } diff --git a/src/app/puzzle/vpiececarrouselpiece.cpp b/src/app/puzzle/vpiececarrouselpiece.cpp index ae690b0ae..3ce4771a1 100644 --- a/src/app/puzzle/vpiececarrouselpiece.cpp +++ b/src/app/puzzle/vpiececarrouselpiece.cpp @@ -37,7 +37,9 @@ Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") //--------------------------------------------------------------------------------------------------------------------- -VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent) : QFrame(parent), m_piece(piece) +VPieceCarrouselPiece::VPieceCarrouselPiece(VPuzzlePiece *piece, QWidget *parent) : + QFrame(parent), + m_piece(piece) { Init(); } @@ -97,6 +99,7 @@ void VPieceCarrouselPiece::Refresh() // update the graphic view / the scene // TODO / FIXME : not perfect and maybe not the right way, still need to work on this + // for instance: use a painter to habve a better quality, less pixeled. QVector points = m_piece->GetCuttingLine(); QPen pen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); @@ -117,8 +120,8 @@ void VPieceCarrouselPiece::Refresh() QString clippedText = metrix.elidedText(m_piece->GetName(), Qt::ElideRight, width); m_label->setText(clippedText); + // set the tooltip setToolTip(m_piece->GetName()); - } //---------------------------------------------------------------------------------------------------------------------