Commit 852dbd93 authored by LE BRETON Come's avatar LE BRETON Come

Allows to specify a policy for the DIY item.

parent 5083df91
......@@ -15,6 +15,7 @@
#include "dtkWidgetsParameter.h" // TODO: Rename to dtkWidgetsParameterBase.h
#include "dtkWidgetsMenu+ux.h"
#include "dtkWidgetsParameter.h"
#include "dtkWidgetsMenuItem+custom.h"
#include <dtkFonts>
#include <dtkThemes>
......@@ -189,7 +190,7 @@ dtkWidgetsMenuItemFacade::dtkWidgetsMenuItemFacade(dtkWidgetsMenuItem *source, Q
connect(this, SIGNAL(clicked()), source, SIGNAL(clicked()));
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}
dtkWidgetsMenuItemFacade::~dtkWidgetsMenuItemFacade(void)
......@@ -246,6 +247,9 @@ dtkWidgetsMenuItemCustomFacade::dtkWidgetsMenuItemCustomFacade(dtkWidgetsMenuIte
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(source->widget());
if(dtkWidgetsMenuItemDIY *item = dynamic_cast<dtkWidgetsMenuItemDIY *>(source))
this->setSizePolicy(QSizePolicy::Expanding, item->policy());
}
dtkWidgetsMenuItemCustomFacade::~dtkWidgetsMenuItemCustomFacade(void)
......
......@@ -27,6 +27,8 @@ class dtkWidgetsMenuItemDIYPrivate
public:
QWidget *source = nullptr;
QWidget *widget = nullptr;
QSizePolicy::Policy policy = QSizePolicy::Fixed;
};
// ///////////////////////////////////////////////////////////////////
......@@ -38,7 +40,6 @@ dtkWidgetsMenuItemDIY::dtkWidgetsMenuItemDIY(const QString& title, QWidget *widg
d->source = widget;
if (title.isEmpty()) {
d->widget = widget;
} else {
d->widget = new QWidget;
......@@ -58,6 +59,16 @@ QWidget *dtkWidgetsMenuItemDIY::widget(void)
return d->widget;
}
void dtkWidgetsMenuItemDIY::setSizePolicy(QSizePolicy::Policy policy)
{
d->policy = policy;
}
QSizePolicy::Policy dtkWidgetsMenuItemDIY::policy(void)
{
return d->policy;
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemWorkspacePrivate
// ///////////////////////////////////////////////////////////////////
......
......@@ -31,6 +31,10 @@ public:
public:
QWidget *widget(void) override;
public:
void setSizePolicy(QSizePolicy::Policy);
QSizePolicy::Policy policy(void);
private:
class dtkWidgetsMenuItemDIYPrivate *d;
};
......
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