src/ui/circletooloptionswidget.cpp

changeset 379
8d88adffb779
parent 264
76a025db4948
equal deleted inserted replaced
378:01537fbe096e 379:8d88adffb779
1 #include "src/ui/circletooloptionswidget.h" 1 #include "src/ui/circletooloptionswidget.h"
2 2
3 static QString circularPrimitiveTypeName(CircularPrimitive::Type type) 3 static QString circularPrimitiveTypeName(circular_primitive_type_e type)
4 { 4 {
5 switch (type) { 5 switch (type) {
6 case CircularPrimitive::Circle: 6 case circular_primitive_type_e::circle:
7 return CircleToolOptionsWidget::tr("Circle"); 7 return CircleToolOptionsWidget::tr("Circle");
8 case CircularPrimitive::Disc: 8 case circular_primitive_type_e::disc:
9 return CircleToolOptionsWidget::tr("Disc"); 9 return CircleToolOptionsWidget::tr("Disc");
10 case CircularPrimitive::Cylinder: 10 case circular_primitive_type_e::cylinder:
11 return CircleToolOptionsWidget::tr("Cylinder"); 11 return CircleToolOptionsWidget::tr("Cylinder");
12 case CircularPrimitive::CylinderOpen: 12 case circular_primitive_type_e::cylinder_open:
13 return CircleToolOptionsWidget::tr("Cylinder open"); 13 return CircleToolOptionsWidget::tr("Cylinder open");
14 case CircularPrimitive::CylinderClosed: 14 case circular_primitive_type_e::cylinder_closed:
15 return CircleToolOptionsWidget::tr("Cylinder closed"); 15 return CircleToolOptionsWidget::tr("Cylinder closed");
16 case CircularPrimitive::DiscNegative: 16 case circular_primitive_type_e::disc_negative:
17 return CircleToolOptionsWidget::tr("Disc negative"); 17 return CircleToolOptionsWidget::tr("Disc negative");
18 case CircularPrimitive::Chord: 18 case circular_primitive_type_e::chord:
19 return CircleToolOptionsWidget::tr("Chord"); 19 return CircleToolOptionsWidget::tr("Chord");
20 } 20 }
21 return ""; 21 return "";
22 } 22 }
23 23
24 CircleToolOptionsWidget::CircleToolOptionsWidget(QWidget *parent) : 24 CircleToolOptionsWidget::CircleToolOptionsWidget(QWidget *parent) :
25 QWidget{parent} 25 QWidget{parent}
26 { 26 {
27 this->ui.setupUi(this); 27 this->ui.setupUi(this);
28 for (int i = 0; i < CircularPrimitive::NUM_TYPES; ++i) { 28 for (int i = 0; i < circular_primitive::NUM_TYPES; ++i) {
29 const auto type = static_cast<CircularPrimitive::Type>(i); 29 const auto type = static_cast<circular_primitive_type_e>(i);
30 this->ui.type->addItem(circularPrimitiveTypeName(type), type); 30 this->ui.type->addItem(circularPrimitiveTypeName(type), QVariant::fromValue(type));
31 } 31 }
32 connect(ui.segments, qOverload<int>(&QSpinBox::valueChanged), this, &CircleToolOptionsWidget::handleInputChange); 32 connect(ui.segments, qOverload<int>(&QSpinBox::valueChanged), this, &CircleToolOptionsWidget::handleInputChange);
33 connect(ui.divisions, &QComboBox::currentTextChanged, this, &CircleToolOptionsWidget::handleInputChange); 33 connect(ui.divisions, &QComboBox::currentTextChanged, this, &CircleToolOptionsWidget::handleInputChange);
34 connect(ui.type, &QComboBox::currentTextChanged, this, &CircleToolOptionsWidget::handleInputChange); 34 connect(ui.type, &QComboBox::currentTextChanged, this, &CircleToolOptionsWidget::handleInputChange);
35 } 35 }
53 else { 53 else {
54 return 16; 54 return 16;
55 } 55 }
56 } 56 }
57 57
58 CircularPrimitive::Type CircleToolOptionsWidget::type() const 58 circular_primitive_type_e CircleToolOptionsWidget::type() const
59 { 59 {
60 return this->ui.type->currentData().value<CircularPrimitive::Type>(); 60 return this->ui.type->currentData().value<circular_primitive_type_e>();
61 } 61 }
62 62
63 void CircleToolOptionsWidget::handleInputChange() 63 void CircleToolOptionsWidget::handleInputChange()
64 { 64 {
65 const unsigned int olddivs = unsigned_cast(this->ui.segments->maximum()); 65 const unsigned int olddivs = unsigned_cast(this->ui.segments->maximum());

mercurial