1919#include < QtWidgets/QSpinBox>
2020#include < qrutils/graphicsUtils/abstractItem.h>
2121#include < qrkernel/settingsManager.h>
22-
22+ # include " popupMetricWidget.h "
2323#include " src/engine/view/scene/robotItem.h"
2424
2525using namespace twoDModel ::view;
@@ -30,19 +30,22 @@ RobotItemPopup::RobotItemPopup(graphicsUtils::AbstractScene &scene, QWidget *par
3030 initWidget ();
3131}
3232
33- RobotItemPopup::~RobotItemPopup ()
34- {
35- }
33+ RobotItemPopup::~RobotItemPopup () = default ;
3634
3735bool RobotItemPopup::suits (QGraphicsItem *item)
3836{
3937 return dynamic_cast <RobotItem *>(item) != nullptr ;
4038}
4139
40+ void RobotItemPopup::onSizeUnitChanged (const QSharedPointer<twoDModel::model::SizeUnit> &unit)
41+ {
42+ mSpinBox ->onSizeUnitChanged (unit);
43+ }
44+
4245bool RobotItemPopup::attachTo (QGraphicsItem *item)
4346{
4447 mCurrentItem = dynamic_cast <RobotItem *>(item);
45- mSpinBox ->setValue (mCurrentItem ->pen ().width ());
48+ mSpinBox ->setCurrentValue (mCurrentItem ->pen ().widthF ());
4649
4750 const bool followingEnabled = qReal::SettingsManager::value (" 2dFollowingRobot" ).toBool ();
4851 mFollowButton ->setChecked (followingEnabled);
@@ -57,7 +60,7 @@ bool RobotItemPopup::attachTo(const QList<QGraphicsItem *> &items)
5760
5861void RobotItemPopup::initWidget ()
5962{
60- QGridLayout * const layout = new QGridLayout (this );
63+ auto * const layout = new QGridLayout (this );
6164 layout->addWidget (initFollowButton (), 0 , 0 , Qt::AlignCenter);
6265 layout->addWidget (initReturnButton (), 0 , 1 );
6366 layout->addWidget (initSpinBox (), 1 , 0 );
@@ -94,7 +97,7 @@ QWidget *RobotItemPopup::initSetStartButton()
9497
9598QAbstractButton *RobotItemPopup::initButton (const QString &icon, const QString &toolTip)
9699{
97- QPushButton * const result = new QPushButton (
100+ auto * const result = new QPushButton (
98101 graphicsUtils::AbstractItem::loadThemedIcon (icon, Qt::red), QString (), this
99102 );
100103 result->setToolTip (toolTip);
@@ -105,14 +108,13 @@ QAbstractButton *RobotItemPopup::initButton(const QString &icon, const QString &
105108
106109QWidget *RobotItemPopup::initSpinBox ()
107110{
108- QSpinBox * const spinBox = new QSpinBox (this );
109- spinBox->setRange (1 , 30 );
111+ auto * const spinBox = new PopupMetricWidget (this );
110112 spinBox->setToolTip (tr (" Marker thickness" ));
111113 QPalette spinBoxPalette;
112114 spinBoxPalette.setColor (QPalette::Window, Qt::transparent);
113115 spinBoxPalette.setColor (QPalette::Base, Qt::transparent);
114116 spinBox->setPalette (spinBoxPalette);
115- connect (spinBox, static_cast < void (QSpinBox::*)( int )>(&QSpinBox ::valueChanged) , this , [=](int value) {
117+ connect (spinBox, &PopupMetricWidget ::valueChanged, this , [=](qreal value) {
116118 mCurrentItem ->setPenWidth (value);
117119 });
118120
0 commit comments