Added missing files.
This commit is contained in:
67
bcvaluewidget.cpp
Normal file
67
bcvaluewidget.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
#include <bcsliderstyle.h>
|
||||
#include <bcvaluewidget.h>
|
||||
|
||||
|
||||
|
||||
BCValueWidget::BCValueWidget(const BCValue& bcValue, QWidget *parent )
|
||||
: QWidget(parent), _bcValue{bcValue}
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
_slider->setStyle(new BCSliderStyle());
|
||||
setAutoFillBackground(true);
|
||||
|
||||
|
||||
/*
|
||||
_slider = new QSlider(Qt::Horizontal, this);
|
||||
_slider->setRange(0, 100);
|
||||
_slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
|
||||
_slider->setSingleStep(1);
|
||||
_slider->setPageStep(10);
|
||||
_slider->setStyle(new BCSliderStyle());
|
||||
|
||||
_commitButton = new QPushButton(this);
|
||||
_commitButton->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton));
|
||||
_commitButton->setFixedSize(32, 32);
|
||||
|
||||
auto *layout = new QHBoxLayout(this);
|
||||
// Deine gewünschten Margins für 36px Zeilenhöhe
|
||||
layout->setContentsMargins(2, 2, 2, 2);
|
||||
layout->setSpacing(4);
|
||||
|
||||
layout->addWidget(_slider);
|
||||
layout->addWidget(_commitButton);
|
||||
setLayout(layout);
|
||||
*/
|
||||
// Wenn Slider bewegt wird -> Signal nach außen senden
|
||||
connect(_slider, &QSlider::valueChanged, this, [this](int val)
|
||||
{
|
||||
emit valueChanged(val);
|
||||
});
|
||||
|
||||
// Wenn Reset gedrückt wird -> Slider auf 0 (löst auch valueChanged aus)
|
||||
connect(_commitButton, &QPushButton::clicked, this, [this](){
|
||||
_slider->setValue(0);
|
||||
});
|
||||
_commitButton->setVisible( false);
|
||||
}
|
||||
|
||||
int BCValueWidget::getValue() const
|
||||
{
|
||||
return _slider->value();
|
||||
}
|
||||
|
||||
void BCValueWidget::setValue(int val)
|
||||
{
|
||||
// WICHTIG: Block Signals verhindern Endlosschleifen, falls das Model
|
||||
// das Widget während des Updates neu setzt (passiert manchmal bei Live-Updates).
|
||||
if (val != _slider->value())
|
||||
{
|
||||
bool blocked = _slider->blockSignals(true);
|
||||
_slider->setValue(val);
|
||||
_slider->blockSignals(blocked);
|
||||
}
|
||||
}
|
||||
|
||||
32
bcvaluewidget.h
Normal file
32
bcvaluewidget.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef BCVALUEWIDGET_H
|
||||
#define BCVALUEWIDGET_H
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include <ui_bcvaluewidget.h>
|
||||
|
||||
class QSlider;
|
||||
class QPushButton;
|
||||
class BCValue;
|
||||
|
||||
class BCValueWidget : public QWidget, private Ui::BCValueWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit BCValueWidget(const BCValue& bcValue, QWidget *parent = nullptr);
|
||||
|
||||
int getValue() const;
|
||||
void setValue(int val);
|
||||
|
||||
signals:
|
||||
|
||||
void valueChanged(int value);
|
||||
|
||||
private:
|
||||
|
||||
const BCValue& _bcValue;
|
||||
|
||||
};
|
||||
#endif // BCVALUEWIDGET_H
|
||||
95
bcvaluewidget.ui
Normal file
95
bcvaluewidget.ui
Normal file
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BCValueWidget</class>
|
||||
<widget class="QWidget" name="BCValueWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>60</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSlider" name="_slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="_commitButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777212</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="bionxcontrol.qrc">
|
||||
<normaloff>:/update.png</normaloff>:/update.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::ToolButtonPopupMode::InstantPopup</enum>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonStyle::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="bionxcontrol.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
BIN
resources/update.png
Normal file
BIN
resources/update.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Reference in New Issue
Block a user