diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 4fc6ab236..84bfc2a66 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -32,20 +32,21 @@ //--------------------------------------------------------------------------------------------------------------------- PuzzleMainWindow::PuzzleMainWindow(QWidget *parent) : QMainWindow(parent), - ui(new Ui::PuzzleMainWindow) + ui(new Ui::PuzzleMainWindow), + pieceCarrousel(new VPieceCarrousel) { ui->setupUi(this); InitMenuBar(); - - InitPropertyTabs(); - + InitProperties(); + InitPieceCarrousel(); } //--------------------------------------------------------------------------------------------------------------------- PuzzleMainWindow::~PuzzleMainWindow() { delete ui; + delete pieceCarrousel; } //--------------------------------------------------------------------------------------------------------------------- @@ -58,7 +59,7 @@ bool PuzzleMainWindow::LoadFile(const QString &path) //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::InitMenuBar() { - // connects the actions for the file menu + // -------------------- 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); @@ -66,13 +67,17 @@ void PuzzleMainWindow::InitMenuBar() connect(ui->actionImportRawLayout, &QAction::triggered, this, &PuzzleMainWindow::ImportRawLayout); connect(ui->actionExit, &QAction::triggered, this, &PuzzleMainWindow::close); - // connects the actions for the edit menu + // -------------------- connects the actions for the edit menu // TODO : initialise the undo / redo - // connects the actions for the windows menu + // -------------------- 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); @@ -80,7 +85,7 @@ void PuzzleMainWindow::InitMenuBar() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzleMainWindow::InitPropertyTabs() +void PuzzleMainWindow::InitProperties() { InitPropertyTabCurrentPiece(); InitPropertyTabLayout(); @@ -202,6 +207,18 @@ void PuzzleMainWindow::InitPropertyTabLayers() ui->tabWidgetProperties->removeTab(3); // remove layers } +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::InitPieceCarrousel() +{ + ui->dockWidgetPieceCarrousel->setWidget(pieceCarrousel); + + connect(ui->dockWidgetPieceCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, + &PuzzleMainWindow::PieceCarrouselLocationChanged); +} + + + + //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::New() { @@ -525,3 +542,21 @@ void PuzzleMainWindow::CurrentPiecePositionChanged() // TODO } + +//--------------------------------------------------------------------------------------------------------------------- +void PuzzleMainWindow::PieceCarrouselLocationChanged(Qt::DockWidgetArea area) +{ + if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) + { + pieceCarrousel->setOrientation(Qt::Horizontal); + ui->dockWidgetPieceCarrousel->setMaximumHeight(208); + ui->dockWidgetPieceCarrousel->setMaximumWidth(10000); + } + else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea) + { + 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 b54bc0abd..9d2bdf70e 100644 --- a/src/app/puzzle/puzzlemainwindow.h +++ b/src/app/puzzle/puzzlemainwindow.h @@ -32,6 +32,7 @@ #include #include +#include "vpiececarrousel.h" namespace Ui { class PuzzleMainWindow; @@ -50,14 +51,15 @@ public: private: Q_DISABLE_COPY(PuzzleMainWindow) Ui::PuzzleMainWindow *ui; + VPieceCarrousel *pieceCarrousel; void InitMenuBar(); - void InitPropertyTabs(); + void InitProperties(); void InitPropertyTabCurrentPiece(); void InitPropertyTabLayout(); void InitPropertyTabTiles(); void InitPropertyTabLayers(); - + void InitPieceCarrousel(); private slots: void New(); @@ -88,6 +90,8 @@ private slots: void CurrentPieceAngleChanged(double value); void CurrentPiecePositionChanged(); + void PieceCarrouselLocationChanged(Qt::DockWidgetArea area); + }; #endif // PUZZLEMAINWINDOW_H diff --git a/src/app/puzzle/puzzlemainwindow.ui b/src/app/puzzle/puzzlemainwindow.ui index e36180443..7855f9b00 100644 --- a/src/app/puzzle/puzzlemainwindow.ui +++ b/src/app/puzzle/puzzlemainwindow.ui @@ -20,829 +20,13 @@ Qt::LeftToRight - + QLayout::SetDefaultConstraint - - - - - 0 - 0 - - - - - 360 - 0 - - - - QTabWidget::Rounded - - - 1 - - - - 32 - 32 - - - - - - - - - :/puzzleicon/64x64/iconCurrentPiece.png:/puzzleicon/64x64/iconCurrentPiece.png - - - - - - Current piece properties - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - true - - - - - 0 - 0 - 356 - 779 - - - - - - - font-weight:bold; - - - Current piece - - - Qt::AutoText - - - Qt::AlignCenter - - - - - - - Infos - - - - - - DummyName - - - true - - - - - - - Name: - - - - - - - - - - Seamline - - - - - - Show Seamline - - - true - - - - - - - - - - Geometry - - - - - - Mirror piece - - - - - - - - - - Rotation - - - - - - Angle: - - - - - - - 360.000000000000000 - - - 0.100000000000000 - - - - - - - - - - Placement - - - - - - X: - - - - - - - 10000.000000000000000 - - - 0.100000000000000 - - - - - - - Y: - - - - - - - 10000.000000000000000 - - - 0.100000000000000 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - :/puzzleicon/64x64/iconLayout.png:/puzzleicon/64x64/iconLayout.png - - - - - - Layout properties - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - true - - - - - 0 - 0 - 356 - 779 - - - - - - - font-weight: bold; - - - Layout - - - Qt::AlignCenter - - - - - - - Format - - - - - - - - Unit - - - - - - - - - - Template - - - - - - - - - - Width - - - - - - - - - - - - - Length - - - - - - - Orientation - - - - - - - - - Portrait - - - - - - - :/puzzleicon/64x64/iconPortrait.png:/puzzleicon/64x64/iconPortrait.png - - - - 32 - 32 - - - - true - - - - - - - Landscape - - - - - - - :/puzzleicon/64x64/iconLandscape.png:/puzzleicon/64x64/iconLandscape.png - - - - 32 - 32 - - - - - - - - - - - - Remove unused length - - - - - - - - - - Margins - - - - - - Right: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Top: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0.100000000000000 - - - - - - - 0.100000000000000 - - - - - - - Left: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0.100000000000000 - - - - - - - 0.100000000000000 - - - - - - - Bottom: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Control - - - - - - - - Follow grainline - - - - - - - - - No - - - true - - - - - - - Vertical grainline - - - - - - - :/puzzleicon/64x64/iconGrainlineVertical.png:/puzzleicon/64x64/iconGrainlineVertical.png - - - - 28 - 28 - - - - - - - - Horizontal grainline - - - - - - - :/puzzleicon/64x64/iconGrainlineHorizontal.png:/puzzleicon/64x64/iconGrainlineHorizontal.png - - - - 28 - 28 - - - - - - - - - - Pieces gap - - - - - - - - - - - - Warning superposition of pieces - - - - - - - Warning pieces out of bound - - - - - - - Sticky edges - - - - - - - - - - Export - - - - - - - - Format - - - - - - - - - - - - Export Layout - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - :/puzzleicon/64x64/iconTiles.png:/puzzleicon/64x64/iconTiles.png - - - - - - Tiles properties - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - true - - - - - 0 - 0 - 356 - 779 - - - - - - - font-weight: bold; - - - Tiles - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - :/puzzleicon/64x64/iconLayers.png:/puzzleicon/64x64/iconLayers.png - - - - - - Layers properties - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - true - - - - - 0 - 0 - 356 - 779 - - - - - - - font-weight:bold; - - - Layers - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - @@ -878,6 +62,7 @@ &Windows + @@ -900,15 +85,24 @@ - + + + + 0 + 0 + + 160 - 160 + 208 + + + - QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + QDockWidget::DockWidgetMovable Qt::AllDockWidgetAreas @@ -919,7 +113,864 @@ 1 - + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + 378 + 524287 + + + + QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable + + + Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea + + + Properties + + + 2 + + + + + 4 + + + + + + 0 + 0 + + + + + 360 + 0 + + + + QTabWidget::Rounded + + + 1 + + + + 32 + 32 + + + + + + + + + :/puzzleicon/64x64/iconCurrentPiece.png:/puzzleicon/64x64/iconCurrentPiece.png + + + + + + Current piece properties + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + true + + + + + 0 + 0 + 356 + 760 + + + + + + + font-weight:bold; + + + Current piece + + + Qt::AutoText + + + Qt::AlignCenter + + + + + + + Infos + + + + + + DummyName + + + true + + + + + + + Name: + + + + + + + + + + Seamline + + + + + + Show Seamline + + + true + + + + + + + + + + Geometry + + + + + + Mirror piece + + + + + + + + + + Rotation + + + + + + Angle: + + + + + + + 360.000000000000000 + + + 0.100000000000000 + + + + + + + + + + Placement + + + + + + X: + + + + + + + 10000.000000000000000 + + + 0.100000000000000 + + + + + + + Y: + + + + + + + 10000.000000000000000 + + + 0.100000000000000 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + :/puzzleicon/64x64/iconLayout.png:/puzzleicon/64x64/iconLayout.png + + + + + + Layout properties + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + true + + + + + 0 + 0 + 356 + 760 + + + + + + + font-weight: bold; + + + Layout + + + Qt::AlignCenter + + + + + + + Format + + + + + + + + Unit + + + + + + + + + + Template + + + + + + + + + + Width + + + + + + + + + + + + + Length + + + + + + + Orientation + + + + + + + + + Portrait + + + + + + + :/puzzleicon/64x64/iconPortrait.png:/puzzleicon/64x64/iconPortrait.png + + + + 32 + 32 + + + + true + + + + + + + Landscape + + + + + + + :/puzzleicon/64x64/iconLandscape.png:/puzzleicon/64x64/iconLandscape.png + + + + 32 + 32 + + + + + + + + + + + + Remove unused length + + + + + + + + + + Margins + + + + + + Right: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Top: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + + + + + Left: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 0.100000000000000 + + + + + + + 0.100000000000000 + + + + + + + Bottom: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Control + + + + + + + + Follow grainline + + + + + + + + + No + + + true + + + + + + + Vertical grainline + + + + + + + :/puzzleicon/64x64/iconGrainlineVertical.png:/puzzleicon/64x64/iconGrainlineVertical.png + + + + 28 + 28 + + + + + + + + Horizontal grainline + + + + + + + :/puzzleicon/64x64/iconGrainlineHorizontal.png:/puzzleicon/64x64/iconGrainlineHorizontal.png + + + + 28 + 28 + + + + + + + + + + Pieces gap + + + + + + + + + + + + Warning superposition of pieces + + + + + + + Warning pieces out of bound + + + + + + + Sticky edges + + + + + + + + + + Export + + + + + + + + Format + + + + + + + + + + + + Export Layout + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + :/puzzleicon/64x64/iconTiles.png:/puzzleicon/64x64/iconTiles.png + + + + + + Tiles properties + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + true + + + + + 0 + 0 + 356 + 760 + + + + + + + font-weight: bold; + + + Tiles + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + :/puzzleicon/64x64/iconLayers.png:/puzzleicon/64x64/iconLayers.png + + + + + + Layers properties + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + true + + + + + 0 + 0 + 356 + 760 + + + + + + + font-weight:bold; + + + Layers + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + @@ -988,11 +1039,21 @@ About &Puzzle + + + true + + + true + + + Properties + + graphicsView - tabWidgetProperties scrollAreaLayout doubleSpinBoxLayoutMarginTop doubleSpinBoxLayoutMarginLeft diff --git a/src/app/puzzle/vpiececarrousel.cpp b/src/app/puzzle/vpiececarrousel.cpp new file mode 100644 index 000000000..11e90d577 --- /dev/null +++ b/src/app/puzzle/vpiececarrousel.cpp @@ -0,0 +1,128 @@ +#include "vpiececarrousel.h" +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +VPieceCarrousel::VPieceCarrousel(QWidget *parent) : + QWidget(parent), + comboBoxLayer(new QComboBox), + mainScrollArea(new QScrollArea(this)), + layers(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); +} + +//--------------------------------------------------------------------------------------------------------------------- +VPieceCarrousel::~VPieceCarrousel() +{ + delete comboBoxLayer; + delete mainScrollArea; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrousel::ActiveLayerChanged(int index) +{ + int j=0; + for (QWidget *widget: layers) { + widget->setVisible(j == index); + j++; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceCarrousel::setOrientation(Qt::Orientation orientation) +{ + QBoxLayout::Direction direction = QBoxLayout::LeftToRight; + + if(orientation == Qt::Horizontal) + { + comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + } + else // Qt::Vertical + { + direction = QBoxLayout::TopToBottom; + comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + } + + QBoxLayout* mainScrollAreaLayout = qobject_cast(mainScrollArea->widget()->layout()); + mainScrollAreaLayout->setDirection(direction); + + for (QWidget *widget: layers) { + QBoxLayout* layerLayout = qobject_cast(widget->layout()); + layerLayout->setDirection(direction); + } +} + diff --git a/src/app/puzzle/vpiececarrousel.h b/src/app/puzzle/vpiececarrousel.h new file mode 100644 index 000000000..1de797ad2 --- /dev/null +++ b/src/app/puzzle/vpiececarrousel.h @@ -0,0 +1,31 @@ +#ifndef VPIECECARROUSEL_H +#define VPIECECARROUSEL_H + +#include +#include +#include + +class VPieceCarrousel : public QWidget +{ + Q_OBJECT +public: + explicit VPieceCarrousel(QWidget *parent = nullptr); + virtual ~VPieceCarrousel(); + + void setOrientation(Qt::Orientation orientation); +signals: + +public slots: + +private: + QComboBox *comboBoxLayer; + QScrollArea *mainScrollArea; + QList layers; + +private slots: + void ActiveLayerChanged(int index); + + +}; + +#endif // VPIECECARROUSEL_H