Commit 59ccb630 authored by CABEL Tristan's avatar CABEL Tristan

add advanced on parameters widgets (to hide, show them) + example

parent b81f3ce8
......@@ -129,17 +129,32 @@ void setup(dtkApplication *application)
dtkWidgetsParameterMenuBarGenerator menubar_generator_1(":parameters_menu.json", ":parameters_definition.json");
application->window()->menubar()->addMenu(menu_1);
application->window()->menubar()->addMenu(menu_2);
application->window()->menubar()->addMenu(menu_3);
dtkWidgetsMenuBar *menu_bar = application->window()->menubar();
menubar_generator_1.populate(application->window()->menubar());
menu_bar->addMenu(menu_1);
menu_bar->addMenu(menu_2);
menu_bar->addMenu(menu_3);
menubar_generator_1.populate(menu_bar);
auto params = menubar_generator_1.parameters();
application->window()->populate();
application->window()->setCentralWidget(area);
application->window()->menubar()->touch();
menu_bar->touch();
params["tohideme"]->connect( [=] (QVariant v) {
bool run = v.value<dtk::d_bool>();
if(run) {
params["tohide"]->setAdvanced(false);
} else {
qDebug() << "hiding the param";
params["tohide"]->setAdvanced(true);
}
});
QObject::connect(application->window()->menubar(), &dtkWidgetsMenuBar::entered, [=] (dtkWidgetsMenu *target) {
qDebug() << "Entered:" << target->title();
......
......@@ -21,6 +21,21 @@
"max": 7.0,
"decimals": 5
},
"tohideme": {
"doc": "button to show/hide the parameter tohide",
"type": "dtk::d_bool",
"value": false,
"label": "tohideme"
},
"tohide": {
"type": "dtk::d_real",
"doc": "I dont want to be shown",
"label": "I will be hidden",
"min": -1.0,
"value": 666666.6,
"max": 70000000.0,
"decimals": 5
},
"hyp": {
"min": 0,
"doc": "documentation",
......
......@@ -126,6 +126,20 @@
{
"group": {
"contents": [
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "tohide",
"advanced": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolPushButton",
"uid": "tohideme",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
......
......@@ -20,6 +20,7 @@
#include <dtkFonts/dtkFontAwesome>
#include <dtkThemes/dtkThemesEngine>
#include <dtkCore/dtkCoreParameter.h>
#include <QtGui>
......@@ -234,6 +235,17 @@ dtkWidgetsMenuItemParameterFacade::dtkWidgetsMenuItemParameterFacade(dtkWidgetsM
QFormLayout *layout = new QFormLayout(this);
layout->addRow(source->title(), source->widget());
if(source->parameter()->advanced()) {
this->hide();
}
connect(source->parameter(), &dtkCoreParameter::advancedChanged, [=] (bool advanced) {
if(advanced)
this->hide();
else
this->show();
});
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
}
......
......@@ -48,6 +48,7 @@ void dtkWidgetsParameterMenuBarGeneratorPrivate::parseParameter(dtkWidgetsMenu *
QString widget_string = parameter_object["widget"].toString();
QString parameter_uid = parameter_object["uid"].toString();
dtkCoreParameter *parameter = this->parameters[parameter_uid];
parameter->setAdvanced(parameter_object["advanced"].toBool());
menu->addParameter(parameter->label(), parameter, widget_string);
}
......
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