Commit c09e6d05 authored by Pierre Fernique's avatar Pierre Fernique

Add showTitle

parent eeb67417
......@@ -29,6 +29,7 @@ public:
QWidget *widget = nullptr;
QSizePolicy::Policy policy = QSizePolicy::Fixed;
bool show_title = true;
};
// ///////////////////////////////////////////////////////////////////
......@@ -38,15 +39,6 @@ public:
dtkWidgetsMenuItemDIY::dtkWidgetsMenuItemDIY(const QString& title, QWidget *widget) : dtkWidgetsMenuItemCustom(title), d(new dtkWidgetsMenuItemDIYPrivate)
{
d->source = widget;
if (title.isEmpty()) {
d->widget = widget;
} else {
d->widget = new QWidget;
QFormLayout *layout = new QFormLayout;
layout->addRow(this->title(), widget);
d->widget->setLayout(layout);
}
}
dtkWidgetsMenuItemDIY::~dtkWidgetsMenuItemDIY(void)
......@@ -56,6 +48,17 @@ dtkWidgetsMenuItemDIY::~dtkWidgetsMenuItemDIY(void)
QWidget *dtkWidgetsMenuItemDIY::widget(void)
{
if (!d->widget) {
if (!this->showTitle() || this->title().isEmpty()) {
d->widget = d->source;
} else {
d->widget = new QWidget;
QFormLayout *layout = new QFormLayout;
layout->addRow(this->title(), d->source);
d->widget->setLayout(layout);
}
}
return d->widget;
}
......@@ -69,6 +72,16 @@ QSizePolicy::Policy dtkWidgetsMenuItemDIY::policy(void)
return d->policy;
}
void dtkWidgetsMenuItemDIY::setShowTitle(bool show_title)
{
d->show_title = show_title;
}
bool dtkWidgetsMenuItemDIY::showTitle(void)
{
return d->show_title;
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemWorkspacePrivate
// ///////////////////////////////////////////////////////////////////
......
......@@ -31,6 +31,10 @@ public:
public:
QWidget *widget(void) override;
public:
void setShowTitle(bool);
bool showTitle(void);
public:
void setSizePolicy(QSizePolicy::Policy);
QSizePolicy::Policy policy(void);
......
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