Commit a7d20d76 authored by LE BRETON Come's avatar LE BRETON Come

WIP.

parent 3a9baeee
......@@ -202,16 +202,27 @@ dtkWidgetsMenuItemParameterFacade::dtkWidgetsMenuItemParameterFacade(dtkWidgetsM
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
dtkWidgetsMenuItemParameterFacade::~dtkWidgetsMenuItemParameterFacade(void)
{
this->layout()->itemAt(1)->widget()->setParent(nullptr);
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemWorkspaceFacade
// dtkWidgetsMenuItemCustomFacade
// ///////////////////////////////////////////////////////////////////
#include "dtkWidgetsMenuItem+custom.h"
dtkWidgetsMenuItemCustomFacade::dtkWidgetsMenuItemCustomFacade(dtkWidgetsMenuItemCustom *source, QWidget *parent) : dtkWidgetsMenuItemFacade(source, parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
this->s = source;
layout->addWidget(source->widget());
}
dtkWidgetsMenuItemCustomFacade::~dtkWidgetsMenuItemCustomFacade(void)
{
this->s->widget()->setParent(nullptr);
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuFacade
// ///////////////////////////////////////////////////////////////////
......
......@@ -177,6 +177,7 @@ class dtkWidgetsMenuItemParameterFacade : public dtkWidgetsMenuItemFacade
public:
dtkWidgetsMenuItemParameterFacade(dtkWidgetsMenuItemParameter *source, QWidget *parent = nullptr);
~dtkWidgetsMenuItemParameterFacade(void);
};
// ///////////////////////////////////////////////////////////////////
......@@ -189,6 +190,10 @@ class dtkWidgetsMenuItemCustomFacade : public dtkWidgetsMenuItemFacade
public:
dtkWidgetsMenuItemCustomFacade(dtkWidgetsMenuItemCustom *source, QWidget *parent = nullptr);
~dtkWidgetsMenuItemCustomFacade(void);
private:
dtkWidgetsMenuItemCustom *s = nullptr;
};
// ///////////////////////////////////////////////////////////////////
......
......@@ -136,10 +136,6 @@ dtkWidgetsMenu *dtkWidgetsMenu::addMenu(int icon_id, const QString& title)
dtkWidgetsMenuFacade *dtkWidgetsMenu::widget(void)
{
if( d->widget) {
while(d->widget->layout()->count()) {
d->widget->layout()->takeAt(0)->widget()->setParent(0);
}
delete d->widget;
}
......
......@@ -276,7 +276,7 @@ dtkWidgetsMenuBarContainerSlide::dtkWidgetsMenuBarContainerSlide(dtkWidgetsMenu
for (QWidget *item : menu->widget()->items()) {
::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, c, 0, menu);
// ::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, c, 0, menu);
i++;
}
......@@ -312,7 +312,7 @@ dtkWidgetsMenuBarContainerSlide::dtkWidgetsMenuBarContainerSlide(dtkWidgetsMenuB
for (QWidget *item : widget->items()) {
::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, c, mb, menu);
// ::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, c, mb, menu);
i++;
}
......@@ -352,7 +352,7 @@ void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenu *menu)
if(!got)
this->layout()->addWidget(item);
::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, dynamic_cast<dtkWidgetsMenuBarContainer *>(this->parentWidget()), 0, menu);
// ::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, dynamic_cast<dtkWidgetsMenuBarContainer *>(this->parentWidget()), 0, menu);
i++;
}
......@@ -360,28 +360,38 @@ void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenu *menu)
void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenuBar *bar)
{
// Hide unwanted widgets
// If a one of the formerly displayed widgets is not in the list of wanted menus, hide it.
QList<QWidget *> widgets;
for (dtkWidgetsMenu *menu : bar->menus()) {
widgets << menu->widget();
widgets << menu->header();
}
// Iterates on the formerly displayed widgets (are they all displayed ?)
for(int i = 0; i < this->layout()->count(); i++) {
// Hides the widget if not a wanted menu item (header or widget)
if(!widgets.contains(this->layout()->itemAt(i)->widget()))
this->layout()->itemAt(i)->widget()->hide();
}
// Show new widgets
for (dtkWidgetsMenu *menu : bar->menus()) {
dtkWidgetsMenuHeaderFacade *header = menu->header();
dtkWidgetsMenuFacade *widget = menu->widget();
bool got = 0;
for(int i = 0; i < this->layout()->count(); i++)
if(this->layout()->itemAt(i)->widget() == widget)
got = true;
if(!got) {
// qDebug() << "Widget" << widget;
bool found = 0;
// What if it was present then hidden then present again ?
for(int i = 0; i < this->layout()->count(); ++i) {
if( this->layout()->itemAt(i)->widget() == widget) {
found = true;
this->layout()->itemAt(i)->widget()->show();
}
}
// If the widget was not yet present, we add it
if(!found) {
this->layout()->addWidget(header);
this->layout()->addWidget(widget);
......@@ -398,9 +408,9 @@ void dtkWidgetsMenuBarContainerSlide::update(dtkWidgetsMenuBar *bar)
for (QWidget *item : widget->items()) {
::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, dynamic_cast<dtkWidgetsMenuBarContainer *>(this->parentWidget()), bar, menu);
// ::dtkWidgetsMenuBarHelper::handle(item, i, s, l, l_item, l_menu, dynamic_cast<dtkWidgetsMenuBarContainer *>(this->parentWidget()), bar, menu);
i++;
++i;
}
}
}
......
......@@ -50,10 +50,14 @@ dtkWidgetsMenuItemDIY::dtkWidgetsMenuItemDIY(const QString& title, QWidget *widg
dtkWidgetsMenuItemDIY::~dtkWidgetsMenuItemDIY(void)
{
d->source->setParent(nullptr);
delete d;
}
void dtkWidgetsMenuItemDIY::save(void)
{
// d->source->setParent(nullptr);
}
QWidget *dtkWidgetsMenuItemDIY::widget(void)
{
return d->widget;
......@@ -80,10 +84,14 @@ dtkWidgetsMenuItemWorkspace::dtkWidgetsMenuItemWorkspace(const QString& title, d
dtkWidgetsMenuItemWorkspace::~dtkWidgetsMenuItemWorkspace(void)
{
d->widget->setParent(nullptr);
delete d;
}
void dtkWidgetsMenuItemWorkspace::save(void)
{
// d->widget->setParent(nullptr);
}
QWidget *dtkWidgetsMenuItemWorkspace::widget(void)
{
return d->widget;
......@@ -115,7 +123,9 @@ dtkWidgetsMenuItemTheme::~dtkWidgetsMenuItemTheme(void)
{
delete d;
}
void dtkWidgetsMenuItemTheme::save(void)
{
}
QWidget *dtkWidgetsMenuItemTheme::widget(void)
{
if (!d->widget) {
......
......@@ -28,6 +28,9 @@ public:
dtkWidgetsMenuItemDIY(const QString& title, QWidget *widget);
~dtkWidgetsMenuItemDIY(void);
public:
void save(void) override;
public:
QWidget *widget(void) override;
......@@ -47,6 +50,9 @@ public:
dtkWidgetsMenuItemWorkspace(const QString& title, dtkWidgetsWorkspaceStackBar *bar);
~dtkWidgetsMenuItemWorkspace(void);
public:
void save(void) override;
public:
QWidget *widget(void) override;
......@@ -66,6 +72,9 @@ public:
dtkWidgetsMenuItemTheme(const QString& theme);
~dtkWidgetsMenuItemTheme(void);
public:
void save(void) override;
public:
QWidget *widget(void) override;
......
......@@ -74,7 +74,7 @@ int dtkWidgetsMenuItem::icon(void) const
class dtkWidgetsMenuItemParameterPrivate
{
public:
dtkCoreParameter *parameter;
dtkCoreParameter *parameter = nullptr;
dtkWidgetsParameter *widget = nullptr;
};
......@@ -90,6 +90,9 @@ dtkWidgetsMenuItemParameter::dtkWidgetsMenuItemParameter(const QString& title, d
dtkWidgetsMenuItemParameter::~dtkWidgetsMenuItemParameter(void)
{
if(d->widget)
delete d->widget;
delete d;
}
......
......@@ -92,6 +92,9 @@ public:
public:
virtual QWidget *widget(void) = 0;
public:
virtual void save(void) = 0;
signals:
void clicked(void);
......
......@@ -251,19 +251,20 @@ QWidget *dtkWidgetsOverlayPaneSliderArea::widget(int index)
if (dtkWidgetsOverlayPaneSliderViewPort *viewport = dynamic_cast<dtkWidgetsOverlayPaneSliderViewPort *>(QScrollArea::widget())) {
for (int i = 0; i < viewport->layout->count(); i++) {
for (int i = 0; i < viewport->layout->count(); ++i) {
if (dtkWidgetsMenuBarContainerSlide *slide = dynamic_cast<dtkWidgetsMenuBarContainerSlide *>(viewport->layout->itemAt(i)->widget())) {
int k = 0;
for (int j = 0; j < slide->layout()->count(); j++) {
for (int j = 0; j < slide->layout()->count(); ++j) {
if (dtkWidgetsMenuHeaderFacade *facade = dynamic_cast<dtkWidgetsMenuHeaderFacade *>(slide->layout()->itemAt(j)->widget())) {
if(k == index) {
for (int k = j; j < slide->layout()->count(); k++) {
for (int k = j; k < slide->layout()->count(); ++k) {
if (dtkWidgetsMenuFacade *facade = dynamic_cast<dtkWidgetsMenuFacade *>(slide->layout()->itemAt(k)->widget())) {
return facade;
......@@ -271,7 +272,7 @@ QWidget *dtkWidgetsOverlayPaneSliderArea::widget(int index)
}
}
k++;
++k;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment