src/ui/circletooloptionswidget.cpp

changeset 250
2837b549e616
parent 233
5509bec02c81
child 264
76a025db4948
equal deleted inserted replaced
249:37d3c819cafa 250:2837b549e616
38 { 38 {
39 } 39 }
40 40
41 unsigned int CircleToolOptionsWidget::segments() const 41 unsigned int CircleToolOptionsWidget::segments() const
42 { 42 {
43 return this->ui.segments->value(); 43 return unsigned_cast(this->ui.segments->value());
44 } 44 }
45 45
46 unsigned int CircleToolOptionsWidget::divisions() const 46 unsigned int CircleToolOptionsWidget::divisions() const
47 { 47 {
48 bool ok; 48 bool ok;
49 const int divs = this->ui.divisions->currentText().toInt(&ok); 49 const unsigned int divs = this->ui.divisions->currentText().toUInt(&ok);
50 if (ok) { 50 if (ok) {
51 return divs; 51 return divs;
52 } 52 }
53 else { 53 else {
54 return 16; 54 return 16;
60 return this->ui.type->currentData().value<CircularPrimitive::Type>(); 60 return this->ui.type->currentData().value<CircularPrimitive::Type>();
61 } 61 }
62 62
63 void CircleToolOptionsWidget::handleInputChange() 63 void CircleToolOptionsWidget::handleInputChange()
64 { 64 {
65 const int olddivs = this->ui.segments->maximum(); 65 const unsigned int olddivs = unsigned_cast(this->ui.segments->maximum());
66 const int newdivs = this->divisions(); 66 const unsigned int newdivs = this->divisions();
67 if (olddivs != newdivs) { 67 if (olddivs != newdivs) {
68 this->ui.segments->setMaximum(newdivs); 68 this->ui.segments->setMaximum(signed_cast(newdivs));
69 this->ui.segments->setValue(this->segments() * newdivs / olddivs); 69 this->ui.segments->setValue(signed_cast(this->segments() * newdivs / olddivs));
70 } 70 }
71 const qreal ratio = static_cast<qreal>(this->segments()) / newdivs; 71 const qreal ratio = static_cast<qreal>(this->segments()) / newdivs;
72 this->ui.ratio->setText(QString::number(ratio, 'g', 4)); 72 this->ui.ratio->setText(QString::number(ratio, 'g', 4));
73 Q_EMIT this->optionsChanged(CircleToolOptions{ 73 Q_EMIT this->optionsChanged(CircleToolOptions{
74 .fraction = CircularFraction{this->segments(), this->divisions()}, 74 .fraction = CircularFraction{this->segments(), this->divisions()},

mercurial