Added PropertyDoubleSpinBox widget
Dieser Commit ist enthalten in:
Ursprung
4157fec500
Commit
3c8b8fd701
@ -38,6 +38,7 @@
|
|||||||
#include "../propertycheckbox.hpp"
|
#include "../propertycheckbox.hpp"
|
||||||
#include "../propertycombobox.hpp"
|
#include "../propertycombobox.hpp"
|
||||||
#include "../propertyspinbox.hpp"
|
#include "../propertyspinbox.hpp"
|
||||||
|
#include "../propertydoublespinbox.hpp"
|
||||||
#include "../propertylineedit.hpp"
|
#include "../propertylineedit.hpp"
|
||||||
#include "../propertytextedit.hpp"
|
#include "../propertytextedit.hpp"
|
||||||
#include "../propertyobjectedit.hpp"
|
#include "../propertyobjectedit.hpp"
|
||||||
@ -128,6 +129,8 @@ void ObjectEditWidget::buildForm()
|
|||||||
w = new PropertyCheckBox(*property);
|
w = new PropertyCheckBox(*property);
|
||||||
else if(property->type() == ValueType::Integer)
|
else if(property->type() == ValueType::Integer)
|
||||||
w = new PropertySpinBox(*property);
|
w = new PropertySpinBox(*property);
|
||||||
|
else if(property->type() == ValueType::Float)
|
||||||
|
w = new PropertyDoubleSpinBox(*property);
|
||||||
else if(property->type() == ValueType::String)
|
else if(property->type() == ValueType::String)
|
||||||
{
|
{
|
||||||
if(property->name() == "notes")
|
if(property->name() == "notes")
|
||||||
|
|||||||
54
client/src/widget/propertydoublespinbox.cpp
Normale Datei
54
client/src/widget/propertydoublespinbox.cpp
Normale Datei
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* client/src/widget/propertydoublespinbox.cpp
|
||||||
|
*
|
||||||
|
* This file is part of the traintastic source code.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 Reinder Feenstra
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "propertydoublespinbox.hpp"
|
||||||
|
#include "../network/abstractproperty.hpp"
|
||||||
|
|
||||||
|
PropertyDoubleSpinBox::PropertyDoubleSpinBox(AbstractProperty& property, QWidget* parent) :
|
||||||
|
QDoubleSpinBox(parent),
|
||||||
|
m_property{property}
|
||||||
|
{
|
||||||
|
Q_ASSERT(m_property.type() == ValueType::Float);
|
||||||
|
setEnabled(m_property.getAttributeBool(AttributeName::Enabled, true));
|
||||||
|
setVisible(m_property.getAttributeBool(AttributeName::Visible, true));
|
||||||
|
setRange(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max());
|
||||||
|
setValue(m_property.toDouble());
|
||||||
|
connect(&m_property, &AbstractProperty::valueChangedDouble, this, &PropertyDoubleSpinBox::setValue);
|
||||||
|
connect(&m_property, &AbstractProperty::attributeChanged,
|
||||||
|
[this](AttributeName name, const QVariant& value)
|
||||||
|
{
|
||||||
|
switch(name)
|
||||||
|
{
|
||||||
|
case AttributeName::Enabled:
|
||||||
|
setEnabled(value.toBool());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AttributeName::Visible:
|
||||||
|
setVisible(value.toBool());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(this, QOverload<double>::of(&PropertyDoubleSpinBox::valueChanged), &m_property, &AbstractProperty::setValueDouble);
|
||||||
|
}
|
||||||
39
client/src/widget/propertydoublespinbox.hpp
Normale Datei
39
client/src/widget/propertydoublespinbox.hpp
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* client/src/widget/propertydoublespinbox.hpp
|
||||||
|
*
|
||||||
|
* This file is part of the traintastic source code.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 Reinder Feenstra
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TRAINTASTIC_CLIENT_WIDGET_PROPERTYDOUBLESPINBOX_HPP
|
||||||
|
#define TRAINTASTIC_CLIENT_WIDGET_PROPERTYDOUBLESPINBOX_HPP
|
||||||
|
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
|
||||||
|
class AbstractProperty;
|
||||||
|
|
||||||
|
class PropertyDoubleSpinBox : public QDoubleSpinBox
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
AbstractProperty& m_property;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PropertyDoubleSpinBox(AbstractProperty& property, QWidget* parent = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren