Commit 79914934 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas
Browse files

Merge branch 'develop' of gitlab.inria.fr:dtk/dtk-widgets into develop

parents cc82e27b 660f08b6
Pipeline #133235 failed with stage
in 0 seconds
# ChangeLog
## version 2.20.0 - 2020-03-27
- Bugfix the main window size can not be decreased vertically: gnomon issue number 254.
- add parameters to an already existing menu with dtkWidgetParametersMenuBarGenerator
- added read-only state for DoubleSpinBox and SpinBox, CheckBox, PushButton...
- Bugfix: menu bar generation dtk-widgets issue #35
## version 2.19.1 - 2020-03-18
- ReadOnly parameter widgets
## version 2.19.0 - 2020-03-11
......
......@@ -23,8 +23,8 @@ project(dtkWidgets)
## ###################################################################
set(${PROJECT_NAME}_VERSION_MAJOR 2)
set(${PROJECT_NAME}_VERSION_MINOR 19)
set(${PROJECT_NAME}_VERSION_PATCH 1)
set(${PROJECT_NAME}_VERSION_MINOR 20)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
......
......@@ -106,6 +106,8 @@ void setup(dtkApplication *application)
menu_3->addItem(fa::circleo, "Sublevel 3-1");
menu_3->addItem(fa::circleo, "Sublevel 3-2");
dtkWidgetsMenu *menu_4 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 4");
QString placeholder = "SubSub";
dtkWidgetsMenu *m = menu_22->addMenu(fa::home, QString("%1Level3").arg(placeholder));
......@@ -130,13 +132,22 @@ void setup(dtkApplication *application)
bg->setPixmap(QPixmap(QString(":/main_%1.jpg").arg((count++ % 5) + 1)));
});
dtkWidgetsParameterMenuBarGenerator menubar_generator_1(":parameters_menu.json", ":parameters_definition.json");
dtkCoreParameters parameters_only;
dtk::d_int *int_parameter = new dtk::d_int("Int parameter", 1, 0, 2, "I am an int parameter, slightly limited by my bounds.");
parameters_only["int_parameter"] = int_parameter;
dtkWidgetsParameterMenuBarGenerator menubar_generator_2(":parameters_only_menu.json", parameters_only);
menubar_generator_2.populate(menu_4);
dtkWidgetsMenuBar *menu_bar = application->window()->menubar();
menu_bar->addMenu(menu_1);
menu_bar->addMenu(menu_2);
menu_bar->addMenu(menu_3);
menu_bar->addMenu(menu_4);
menubar_generator_1.populate(menu_bar);
......@@ -146,39 +157,30 @@ void setup(dtkApplication *application)
application->window()->setCentralWidget(area);
menu_bar->touch();
//menu_bar->touch();
params["tohideme"]->connect( [=] (QVariant v) {
params["button_hiding"]->connect( [=] (QVariant v) {
bool run = v.value<dtk::d_bool>();
if(run) {
params["tohide"]->setAdvanced(false);
params["spinbox_to_hide"]->setAdvanced(false);
} else {
qDebug() << "hiding the param";
params["tohide"]->setAdvanced(true);
params["spinbox_to_hide"]->setAdvanced(true);
}
});
// check the dtkWidgetsMenuBar::touch() bug
params["menubar_touch_bool"]->connect( [=] (QVariant v) {
qDebug() << Q_FUNC_INFO << "Clicked on menubar_touch_bool, waiting 0.5 sec";
QThread::usleep(500000);
qDebug() << Q_FUNC_INFO << "End of sleep in menubar_touch_bool";
menu_bar->touch();
});
// check the dtkWidgetsMenuBar::touch() bug
params["menubar_touch_int"]->connect( [=] (QVariant v) {
qDebug() << Q_FUNC_INFO << "Clicked on menubar_touch_int , waiting 0.5 sec";
QThread::usleep(500000);
qDebug() << Q_FUNC_INFO << "End of sleep in menubar_touch_int";
menu_bar->touch();
});
// this qDebug tests that the spinbox is updated upon losing focus.
params["prec"]->connect( [=] (QVariant v) {
double val = v.value<dtk::d_real>();
qDebug() << Q_FUNC_INFO << "new prec: " << val;
params["checkbox_ro_toggle"]->connect( [=] (QVariant v) {
bool visible = v.value<dtk::d_bool>();
if(visible) {
//params["slider_double_ro_and_rw"]->setReadOnly(false);
params["slider_double_ro_and_rw"]->setLabel("Slider READWRITE");
params["checkbox_ro_toggle"]->setDocumentation("Next widget is READWRITE");
} else {
//params["slider_double_ro_and_rw"]->setReadOnly(true);
params["slider_double_ro_and_rw"]->setLabel("Slider READONLY");
params["checkbox_ro_toggle"]->setDocumentation("Next widget is READONLY");
}
});
......@@ -189,6 +191,8 @@ void setup(dtkApplication *application)
QObject::connect(application->window()->menubar(), &dtkWidgetsMenuBar::left, [=] (dtkWidgetsMenu *source) {
qDebug() << "Left:" << source->title();
});
menu_bar->touch();
}
//
......
......@@ -9,5 +9,7 @@
<file>parameters_definition.json</file>
<file>parameters_menu.json</file>
<file>parameters_only_menu.json</file>
</qresource>
</RCC>
{
"contents": {
"res": {
"doc": "documentation",
"type": "dtk::d_bool",
"value": false,
"label": "res"
},
"dif": {
"doc": "documentation",
"type": "dtk::d_bool",
"value": false,
"label": "dif"
},
"prec": {
"spin_double": {
"type": "dtk::d_real",
"doc": "documentation",
"label": "prec",
"label": "Spinbox real",
"min": -1.0,
"value": 5.0,
"max": 7.0,
"decimals": 5
},
"prec_a": {
"type": "dtk::d_real",
"doc": "documentation",
"label": "prec A",
"min": -1.0,
"value": 5.0,
"max": 7.0,
"decimals": 5
},
"prec_b": {
"type": "dtk::d_real",
"spin_long": {
"type": "dtk::d_int",
"doc": "documentation",
"label": "prec B",
"label": "Spinbox int",
"min": -1.0,
"value": 5.0,
"max": 7.0,
......@@ -50,57 +29,108 @@
"Choice 3"
]
},
"tohideme": {
"doc": "button to show/hide the parameter tohide",
"type": "dtk::d_bool",
"value": false,
"label": "tohideme"
"line_edit":{
"label": "Line edit",
"doc": "Line edit",
"value": "Edit this line",
"type": "dtk::d_string"
},
"checkbox":{
"label": "Checkbox",
"doc": "It's a checkbox",
"value": true,
"type": "dtk::d_bool"
},
"push_button":{
"label": "Button",
"doc": "It's a button",
"type": "dtk::d_bool"
},
"file_browse": {
"label": "Open a file",
"doc": "Open a VTK file.",
"path": ".",
"filters": [
"VTK (*.vtk)",
"VTI (*.vti)",
"VTU (*.vtu)",
"VTP (*.vtp)"
],
"type": "dtk::d_path"
},
"slider_int": {
"type": "dtk::d_int",
"doc": "documentation",
"label": "Slinder int",
"min": -10.0,
"value": 0.0,
"max": 10.0
},
"slider_double": {
"type": "dtk::d_real",
"doc": "It's a slider of double",
"label": "Slider double",
"min": -10.0,
"value": 3.0,
"max": 10.0,
"decimals": 2
},
"tohide": {
"spin_double_ro": {
"type": "dtk::d_real",
"doc": "I dont want to be shown",
"label": "I will be hidden",
"doc": "documentation",
"label": "Spinbox real (Read Only)",
"min": -1.0,
"value": 666666.6,
"max": 70000000.0,
"value": 5.0,
"max": 7.0,
"decimals": 5
},
"hyp": {
"min": 0,
"spin_long_ro": {
"type": "dtk::d_int",
"doc": "documentation",
"value": 2,
"label": "hyp",
"max": 5,
"type": "dtk::d_int"
"label": "Spinbox int (Read Only)",
"min": -1.0,
"value": 5.0,
"max": 7.0,
"decimals": 5
},
"inf": {
"doc": "documentation",
"type": "dtk::d_bool",
"value": false,
"label": "inf"
"combo_box_ro":{
"label": "Input (Read Only)",
"doc": "Select a choice in the combo box",
"value": "Choice 1",
"type": "dtk::d_inliststring",
"values": [
"Choice 1",
"Choice 2",
"Choice 3"
]
},
"wind": {
"doc": "documentation",
"type": "dtk::d_bool",
"value": false,
"label": "wind"
},
"menubar_touch_bool": {
"doc": "check if menubar->touch() works",
"type": "dtk::d_bool",
"value": false,
"label": "menubar_touch_bool"
},
"menubar_touch_int": {
"doc": "check if menubar->touch() works",
"type": "dtk::d_int",
"value": 0,
"min" : 0,
"max" : 1,
"label": "menubar_touch_int"
"line_edit_ro":{
"label": "Line edit (Read Only)",
"doc": "Line edit",
"value": "Can't edit this line, but you can select it!",
"type": "dtk::d_string"
},
"checkbox_ro":{
"label": "Checkbox (Read Only)",
"doc": "It's a checkbox",
"value": true,
"type": "dtk::d_bool"
},
"push_button_ro":{
"label": "Button (Read Only)",
"doc": "It's a button",
"type": "dtk::d_bool"
},
"open": {
"label": "open",
"file_browse_ro": {
"label": "Open a file (Read Only)",
"doc": "Open a VTK file.",
"path": ".",
"filters": [
......@@ -110,6 +140,58 @@
"VTP (*.vtp)"
],
"type": "dtk::d_path"
},
"slider_int_ro": {
"type": "dtk::d_int",
"doc": "documentation",
"label": "Slinder int (Read Only)",
"min": -10.0,
"value": 0.0,
"max": 10.0
},
"slider_double_ro": {
"type": "dtk::d_real",
"doc": "It's a slider of double",
"label": "Slider double (Read Only)",
"min": -10.0,
"value": 3.0,
"max": 10.0,
"decimals": 2
},
"checkbox_ro_toggle":{
"label": "toggle RO/RW of next parameter",
"doc": "It's a checkbox",
"value": true,
"type": "dtk::d_bool"
},
"slider_double_ro_and_rw": {
"type": "dtk::d_real",
"doc": "It's a slider of double, which is READONLY or not",
"label": "Slider double (Read Write)",
"min": -10.0,
"value": 3.0,
"max": 10.0,
"decimals": 2
},
"button_hiding":{
"label": "Click on <Run> to hide/unhide a spinbox",
"doc": "It's a button",
"type": "dtk::d_bool"
},
"spinbox_to_hide":{
"type": "dtk::d_real",
"doc": "documentation",
"label": "Spinbox to hide with a button",
"min": -1.0,
"value": 5.0,
"max": 7.0,
"decimals": 5
}
}
}
......@@ -5,136 +5,96 @@
"contents": [
{
"parameter": {
"uid": "open",
"widget": "dtkWidgetsParameterFileBrowse",
"advanced": false
"widget": "dtkWidgetsParameterLongLongSpinBox",
"uid": "spin_long_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterStringListComboBox",
"uid": "combo_box",
"advanced": false
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "spin_double_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "prec_a",
"advanced": false
"widget": "dtkWidgetsParameterStringListComboBox",
"uid": "combo_box_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterIntSpinBox",
"uid": "hyp",
"advanced": false
"widget": "dtkWidgetsParameterStringLineEdit",
"uid": "line_edit_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "dif",
"advanced": false
"uid": "checkbox_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "res",
"advanced": false
"widget": "dtkWidgetsParameterBoolPushButton",
"uid": "push_button_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "prec_b",
"advanced": false
"widget": "dtkWidgetsParameterFileBrowse",
"uid": "file_browse_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "inf",
"advanced": false
"widget": "dtkWidgetsParameterIntSlider",
"uid": "slider_int_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "menubar_touch_bool",
"advanced": false
"widget": "dtkWidgetsParameterDoubleSlider",
"uid": "slider_double_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterIntSpinBox",
"uid": "menubar_touch_int",
"advanced": false
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "checkbox_ro_toggle",
"advanced": false,
"widget_read_only": false
}
},
{
"group": {
"contents": [
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "prec",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterIntSpinBox",
"uid": "hyp",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "dif",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "res",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "prec_b",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "inf",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolCheckBox",
"uid": "wind",
"advanced": false
}
}
],
"uid": "Model parameters 1.1",
"advanced": false,
"icon": "paw"
"parameter": {
"widget": "dtkWidgetsParameterDoubleSlider",
"uid": "slider_double_ro_and_rw",
"advanced": false,
"widget_read_only": false
}
}
],
"uid": "Model parameters 1",
"uid": "Read-only parameters",
"advanced": false,
"icon": "cogs"
"icon": "paw"
}
},
{
......@@ -142,71 +102,100 @@
"contents": [
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "tohide",
"advanced": true
"widget": "dtkWidgetsParameterLongLongSpinBox",
"uid": "spin_long",
"advanced": false,
"widget_read_only": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterBoolPushButton",
"uid": "tohideme",
"advanced": false
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "spin_double",
"advanced": false,
"widget_read_only": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterDoubleSpinBox",
"uid": "prec",
"widget": "dtkWidgetsParameterStringListComboBox",
"uid": "combo_box",
"advanced": false
}
},
{