Piece carrousel
This commit is contained in:
parent
ed6cc7f5d9
commit
95101b6ac3
|
@ -32,20 +32,21 @@
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
PuzzleMainWindow::PuzzleMainWindow(QWidget *parent) :
|
PuzzleMainWindow::PuzzleMainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::PuzzleMainWindow)
|
ui(new Ui::PuzzleMainWindow),
|
||||||
|
pieceCarrousel(new VPieceCarrousel)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
InitMenuBar();
|
InitMenuBar();
|
||||||
|
InitProperties();
|
||||||
InitPropertyTabs();
|
InitPieceCarrousel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
PuzzleMainWindow::~PuzzleMainWindow()
|
PuzzleMainWindow::~PuzzleMainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
delete pieceCarrousel;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -58,7 +59,7 @@ bool PuzzleMainWindow::LoadFile(const QString &path)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void PuzzleMainWindow::InitMenuBar()
|
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->actionNew, &QAction::triggered, this, &PuzzleMainWindow::New);
|
||||||
connect(ui->actionOpen, &QAction::triggered, this, &PuzzleMainWindow::Open);
|
connect(ui->actionOpen, &QAction::triggered, this, &PuzzleMainWindow::Open);
|
||||||
connect(ui->actionSave, &QAction::triggered, this, &PuzzleMainWindow::Save);
|
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->actionImportRawLayout, &QAction::triggered, this, &PuzzleMainWindow::ImportRawLayout);
|
||||||
connect(ui->actionExit, &QAction::triggered, this, &PuzzleMainWindow::close);
|
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
|
// 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
|
// TODO : initialise the entries for the different windows
|
||||||
connect(ui->actionCloseLayout, &QAction::triggered, this, &PuzzleMainWindow::CloseLayout);
|
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
|
// connects the action for the Help Menu
|
||||||
connect(ui->actionAboutQt, &QAction::triggered, this, &PuzzleMainWindow::AboutQt);
|
connect(ui->actionAboutQt, &QAction::triggered, this, &PuzzleMainWindow::AboutQt);
|
||||||
connect(ui->actionAboutPuzzle, &QAction::triggered, this, &PuzzleMainWindow::AboutPuzzle);
|
connect(ui->actionAboutPuzzle, &QAction::triggered, this, &PuzzleMainWindow::AboutPuzzle);
|
||||||
|
@ -80,7 +85,7 @@ void PuzzleMainWindow::InitMenuBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void PuzzleMainWindow::InitPropertyTabs()
|
void PuzzleMainWindow::InitProperties()
|
||||||
{
|
{
|
||||||
InitPropertyTabCurrentPiece();
|
InitPropertyTabCurrentPiece();
|
||||||
InitPropertyTabLayout();
|
InitPropertyTabLayout();
|
||||||
|
@ -202,6 +207,18 @@ void PuzzleMainWindow::InitPropertyTabLayers()
|
||||||
ui->tabWidgetProperties->removeTab(3); // remove layers
|
ui->tabWidgetProperties->removeTab(3); // remove layers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void PuzzleMainWindow::InitPieceCarrousel()
|
||||||
|
{
|
||||||
|
ui->dockWidgetPieceCarrousel->setWidget(pieceCarrousel);
|
||||||
|
|
||||||
|
connect(ui->dockWidgetPieceCarrousel, QOverload<Qt::DockWidgetArea>::of(&QDockWidget::dockLocationChanged), this,
|
||||||
|
&PuzzleMainWindow::PieceCarrouselLocationChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void PuzzleMainWindow::New()
|
void PuzzleMainWindow::New()
|
||||||
{
|
{
|
||||||
|
@ -525,3 +542,21 @@ void PuzzleMainWindow::CurrentPiecePositionChanged()
|
||||||
|
|
||||||
// TODO
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include "vpiececarrousel.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class PuzzleMainWindow;
|
class PuzzleMainWindow;
|
||||||
|
@ -50,14 +51,15 @@ public:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(PuzzleMainWindow)
|
Q_DISABLE_COPY(PuzzleMainWindow)
|
||||||
Ui::PuzzleMainWindow *ui;
|
Ui::PuzzleMainWindow *ui;
|
||||||
|
VPieceCarrousel *pieceCarrousel;
|
||||||
|
|
||||||
void InitMenuBar();
|
void InitMenuBar();
|
||||||
void InitPropertyTabs();
|
void InitProperties();
|
||||||
void InitPropertyTabCurrentPiece();
|
void InitPropertyTabCurrentPiece();
|
||||||
void InitPropertyTabLayout();
|
void InitPropertyTabLayout();
|
||||||
void InitPropertyTabTiles();
|
void InitPropertyTabTiles();
|
||||||
void InitPropertyTabLayers();
|
void InitPropertyTabLayers();
|
||||||
|
void InitPieceCarrousel();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void New();
|
void New();
|
||||||
|
@ -88,6 +90,8 @@ private slots:
|
||||||
void CurrentPieceAngleChanged(double value);
|
void CurrentPieceAngleChanged(double value);
|
||||||
void CurrentPiecePositionChanged();
|
void CurrentPiecePositionChanged();
|
||||||
|
|
||||||
|
void PieceCarrouselLocationChanged(Qt::DockWidgetArea area);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PUZZLEMAINWINDOW_H
|
#endif // PUZZLEMAINWINDOW_H
|
||||||
|
|
|
@ -20,13 +20,139 @@
|
||||||
<property name="layoutDirection">
|
<property name="layoutDirection">
|
||||||
<enum>Qt::LeftToRight</enum>
|
<enum>Qt::LeftToRight</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayoutMainWidget">
|
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGraphicsView" name="graphicsView"/>
|
<widget class="QGraphicsView" name="graphicsView"/>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menuBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1427</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuFile">
|
||||||
|
<property name="title">
|
||||||
|
<string>&File</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionNew"/>
|
||||||
|
<addaction name="actionOpen"/>
|
||||||
|
<addaction name="actionSave"/>
|
||||||
|
<addaction name="actionSaveAs"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionImportRawLayout"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionExit"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuEdit">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Edit</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuWindows">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Windows</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionCloseLayout"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuHelp">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Help</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionAboutQt"/>
|
||||||
|
<addaction name="actionAboutPuzzle"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuFile"/>
|
||||||
|
<addaction name="menuEdit"/>
|
||||||
|
<addaction name="menuWindows"/>
|
||||||
|
<addaction name="menuHelp"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="mainToolBar">
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
|
<widget class="QDockWidget" name="dockWidgetPieceCarrousel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>160</width>
|
||||||
|
<height>208</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="features">
|
||||||
|
<set>QDockWidget::DockWidgetMovable</set>
|
||||||
|
</property>
|
||||||
|
<property name="allowedAreas">
|
||||||
|
<set>Qt::AllDockWidgetAreas</set>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Piece Carrousel</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>1</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="widgetPieceCarrousel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_10"/>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QDockWidget" name="dockWidgetProperties">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>378</width>
|
||||||
|
<height>524287</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="features">
|
||||||
|
<set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable</set>
|
||||||
|
</property>
|
||||||
|
<property name="allowedAreas">
|
||||||
|
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Properties</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>2</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetPropertiesContents">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidgetProperties">
|
<widget class="QTabWidget" name="tabWidgetProperties">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -103,7 +229,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>356</width>
|
<width>356</width>
|
||||||
<height>779</height>
|
<height>760</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
@ -316,7 +442,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>356</width>
|
<width>356</width>
|
||||||
<height>779</height>
|
<height>760</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
@ -725,7 +851,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>356</width>
|
<width>356</width>
|
||||||
<height>779</height>
|
<height>760</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
@ -805,7 +931,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>356</width>
|
<width>356</width>
|
||||||
<height>779</height>
|
<height>760</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
@ -845,81 +971,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1427</width>
|
|
||||||
<height>22</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<widget class="QMenu" name="menuFile">
|
|
||||||
<property name="title">
|
|
||||||
<string>&File</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionNew"/>
|
|
||||||
<addaction name="actionOpen"/>
|
|
||||||
<addaction name="actionSave"/>
|
|
||||||
<addaction name="actionSaveAs"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionImportRawLayout"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionExit"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menuEdit">
|
|
||||||
<property name="title">
|
|
||||||
<string>&Edit</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menuWindows">
|
|
||||||
<property name="title">
|
|
||||||
<string>&Windows</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionCloseLayout"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menuHelp">
|
|
||||||
<property name="title">
|
|
||||||
<string>&Help</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionAboutQt"/>
|
|
||||||
<addaction name="actionAboutPuzzle"/>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menuFile"/>
|
|
||||||
<addaction name="menuEdit"/>
|
|
||||||
<addaction name="menuWindows"/>
|
|
||||||
<addaction name="menuHelp"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QToolBar" name="mainToolBar">
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
|
||||||
<widget class="QDockWidget" name="dockWidgetPieceCarroussel">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>160</width>
|
|
||||||
<height>160</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="features">
|
|
||||||
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
|
|
||||||
</property>
|
|
||||||
<property name="allowedAreas">
|
|
||||||
<set>Qt::AllDockWidgetAreas</set>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Piece Carrousel</string>
|
|
||||||
</property>
|
|
||||||
<attribute name="dockWidgetArea">
|
|
||||||
<number>1</number>
|
|
||||||
</attribute>
|
|
||||||
<widget class="QWidget" name="dockWidget"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -988,11 +1039,21 @@
|
||||||
<string>About &Puzzle</string>
|
<string>About &Puzzle</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionProperties">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Properties</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>graphicsView</tabstop>
|
<tabstop>graphicsView</tabstop>
|
||||||
<tabstop>tabWidgetProperties</tabstop>
|
|
||||||
<tabstop>scrollAreaLayout</tabstop>
|
<tabstop>scrollAreaLayout</tabstop>
|
||||||
<tabstop>doubleSpinBoxLayoutMarginTop</tabstop>
|
<tabstop>doubleSpinBoxLayoutMarginTop</tabstop>
|
||||||
<tabstop>doubleSpinBoxLayoutMarginLeft</tabstop>
|
<tabstop>doubleSpinBoxLayoutMarginLeft</tabstop>
|
||||||
|
|
128
src/app/puzzle/vpiececarrousel.cpp
Normal file
128
src/app/puzzle/vpiececarrousel.cpp
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
#include "vpiececarrousel.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPieceCarrousel::VPieceCarrousel(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
comboBoxLayer(new QComboBox),
|
||||||
|
mainScrollArea(new QScrollArea(this)),
|
||||||
|
layers(QList<QWidget *>())
|
||||||
|
{
|
||||||
|
|
||||||
|
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<int>::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<QBoxLayout*>(mainScrollArea->widget()->layout());
|
||||||
|
mainScrollAreaLayout->setDirection(direction);
|
||||||
|
|
||||||
|
for (QWidget *widget: layers) {
|
||||||
|
QBoxLayout* layerLayout = qobject_cast<QBoxLayout*>(widget->layout());
|
||||||
|
layerLayout->setDirection(direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
31
src/app/puzzle/vpiececarrousel.h
Normal file
31
src/app/puzzle/vpiececarrousel.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef VPIECECARROUSEL_H
|
||||||
|
#define VPIECECARROUSEL_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QScrollArea>
|
||||||
|
|
||||||
|
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<QWidget *> layers;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ActiveLayerChanged(int index);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VPIECECARROUSEL_H
|
Loading…
Reference in New Issue
Block a user