Skip to content

Commit

Permalink
Add boolean type
Browse files Browse the repository at this point in the history
  • Loading branch information
snipercup committed Sep 19, 2023
1 parent 9d889d1 commit f78a228
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions object_creator/simple_property_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ creator::simple_property_widget::simple_property_widget( QWidget* parent, QStrin
[=]( ) { change_notify_widget(); } );
property_layout->addWidget( prop_number ) ;
break;

case property_type::BOOLEAN:
prop_bool = new QCheckBox;
prop_bool->setMinimumSize( QSize( 50, 24 ) );
prop_bool->setMaximumSize( QSize( 55, 24 ) );
prop_bool->setChecked( true );
connect( prop_bool, &QCheckBox::stateChanged, [&]() { change_notify_widget(); } );
property_layout->addWidget( prop_bool ) ;
break;

case property_type::NUM_TYPES: break;
}
Expand Down Expand Up @@ -108,6 +117,13 @@ void creator::simple_property_widget::get_json( JsonOut &jo ) {
jo.member( propertyName.toStdString() + "-max", max );
}
break;

case property_type::BOOLEAN:
if( !prop_bool->isChecked() ) {
jo.member( propertyName.toStdString(), false );
}
break;

case property_type::NUM_TYPES: break;
}
}
Expand Down
3 changes: 3 additions & 0 deletions object_creator/simple_property_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QComboBox>
#include "QtWidgets/qlabel.h"
#include <QtWidgets/qcheckbox.h>


namespace creator
Expand All @@ -23,6 +24,7 @@ namespace creator
LINEEDIT, // Just a label and a one-line text box
MINMAX, // Label, spinbox for minimum and a spinbox for maximum number
NUMBER, // Label and one spinbox holding a number
BOOLEAN, // Label and one checkbox
NUM_TYPES // always keep at the end, number of property types
};

Expand Down Expand Up @@ -58,6 +60,7 @@ namespace creator
QSpinBox* prop_number;
QSpinBox* prop_min;
QSpinBox* prop_max;
QCheckBox* prop_bool;
QLineEdit* prop_line;
QObject* widget_to_notify;
QPushButton* btnHide;
Expand Down

0 comments on commit f78a228

Please sign in to comment.