Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 8b316f0c authored by Artur Grunau's avatar Artur Grunau
Browse files

Add support for boxed display of property widgets

Previously, property widgets have always had their components displayed
horizontally next to a label with the property name. However, that made
widgets consisting of many components (e.g. widgets for vector
properties) hard to use because their components were squeezed together.

Now AbstractPropertyWidget takes one additional optional argument,
displayBoxed. If it's false, the widget is displayed as before. When
it's true, the widget is laid out vertically in a QGroupBox. For now
only widgets for vector properties set displayBoxed to true.
parent e5e1bff3
......@@ -30,20 +30,32 @@
#include "abstractpropertywidget.h"
#include "core/properties/abstractproperty.h"
#include <QGroupBox>
namespace campvis {
AbstractPropertyWidget::AbstractPropertyWidget(AbstractProperty* property, QWidget* parent /*= 0*/)
AbstractPropertyWidget::AbstractPropertyWidget(AbstractProperty* property, bool displayBoxed /*= false*/,
QWidget* parent /*= 0*/)
: QWidget(parent)
, _property(property)
, _layout(0)
{
_ignorePropertyUpdates = 0;
_titleLabel = new QLabel(QString::fromStdString(_property->getTitle() + ":"), this);
if (displayBoxed) {
QBoxLayout* outerLayout = new QBoxLayout(QBoxLayout::LeftToRight, this);
QGroupBox* groupBox = new QGroupBox(QString::fromStdString(_property->getTitle()));
outerLayout->addWidget(groupBox);
_layout = new QBoxLayout(QBoxLayout::TopToBottom, groupBox);
}
else {
_titleLabel = new QLabel(QString::fromStdString(_property->getTitle() + ":"), this);
_layout = new QBoxLayout(QBoxLayout::LeftToRight, this);
_layout->setSpacing(8);
_layout->addWidget(_titleLabel, 0);
_layout = new QBoxLayout(QBoxLayout::LeftToRight, this);
_layout->setSpacing(8);
_layout->addWidget(_titleLabel, 0);
}
_property->s_changed.connect(this, &AbstractPropertyWidget::onPropertyChanged);
}
......@@ -60,4 +72,4 @@ namespace campvis {
if (_ignorePropertyUpdates == 0)
updateWidgetFromProperty();
}
}
\ No newline at end of file
}
......@@ -48,10 +48,14 @@ namespace campvis {
public:
/**
* Creates a new PropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*
* If displayBoxed is true, the widget is displayed vertically in a QGroupBox.
*
* \param property The property the widget shall handle
* \param displayBoxed Should the widget be displayed in a group box?
* \param parent Parent Qt widget
*/
AbstractPropertyWidget(AbstractProperty* property, QWidget* parent = 0);
AbstractPropertyWidget(AbstractProperty* property, bool displayBoxed = false, QWidget* parent = 0);
/**
* Destructor
......
......@@ -33,7 +33,7 @@
namespace campvis {
BoolPropertyWidget::BoolPropertyWidget(BoolProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _spinBox(0)
{
_spinBox = new QCheckBox(this);
......
......@@ -33,7 +33,7 @@
namespace campvis {
ButtonPropertyWidget::ButtonPropertyWidget(ButtonProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _button(0)
{
_button = new QPushButton(QString::fromStdString(property->getTitle()), this);
......
......@@ -35,7 +35,7 @@
namespace campvis {
CameraPropertyWidget::CameraPropertyWidget(CameraProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _lblCameraPosition(0)
, _lblLookDirection(0)
, _lblUpVector(0)
......
......@@ -36,7 +36,7 @@
namespace campvis {
DataNamePropertyWidget::DataNamePropertyWidget(DataNameProperty* property, DataContainer* dc, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _lineEdit(0)
, _combobox(0)
, _dc(dc)
......
......@@ -31,7 +31,7 @@
namespace campvis {
FloatPropertyWidget::FloatPropertyWidget(FloatProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _adjuster(0)
{
const float stepValue = 0.01f;
......
......@@ -144,7 +144,7 @@ namespace campvis {
template<size_t SIZE>
campvis::VecPropertyWidget<SIZE>::VecPropertyWidget(PropertyType* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, true, parent)
{
for (size_t i = 0; i < size; ++i) {
_adjusters[i] = new DoubleAdjusterWidget();
......
......@@ -36,7 +36,7 @@
namespace campvis {
IntPropertyWidget::IntPropertyWidget(IntProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _spinBox(0)
, _timer(0)
{
......
......@@ -150,7 +150,7 @@ namespace campvis {
template<size_t SIZE>
campvis::IVecPropertyWidget<SIZE>::IVecPropertyWidget(PropertyType* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
{
for (size_t i = 0; i < size; ++i) {
_spinBox[i] = new QSpinBox(this);
......
......@@ -34,7 +34,7 @@
namespace campvis {
OptionPropertyWidget::OptionPropertyWidget(AbstractOptionProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _comboBox(0)
{
_comboBox = new QComboBox(this);
......
......@@ -37,7 +37,7 @@
namespace campvis {
StringPropertyWidget::StringPropertyWidget(StringProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _lineEdit(0)
, _btnLoadFile(0)
{
......
......@@ -42,7 +42,7 @@
namespace campvis {
TransferFunctionPropertyWidget::TransferFunctionPropertyWidget(TransferFunctionProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
: AbstractPropertyWidget(property, false, parent)
, _widget(0)
, _gridLayout(0)
, _lblDomain(0)
......
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