Skip to content

Commit

Permalink
+ support units in draft panel
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jul 22, 2014
1 parent 3585403 commit 57cdb8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
21 changes: 12 additions & 9 deletions src/Mod/PartDesign/Gui/TaskDraftParameters.cpp
Expand Up @@ -60,7 +60,7 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDraft *DraftView,QWidget *p
ui->setupUi(proxy);
QMetaObject::connectSlotsByName(this);

connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
connect(ui->draftAngle, SIGNAL(valueChanged(double)),
this, SLOT(onAngleChanged(double)));
connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onReversedChanged(bool)));
Expand All @@ -78,12 +78,11 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDraft *DraftView,QWidget *p
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
double a = pcDraft->Angle.getValue();

ui->doubleSpinBox->setDecimals(Base::UnitsApi::getDecimals());
ui->doubleSpinBox->setMinimum(0.0);
ui->doubleSpinBox->setMaximum(89.99);
ui->doubleSpinBox->setValue(a);
ui->doubleSpinBox->selectAll();
QMetaObject::invokeMethod(ui->doubleSpinBox, "setFocus", Qt::QueuedConnection);
ui->draftAngle->setMinimum(0.0);
ui->draftAngle->setMaximum(89.99);
ui->draftAngle->setValue(a);
ui->draftAngle->selectAll();
QMetaObject::invokeMethod(ui->draftAngle, "setFocus", Qt::QueuedConnection);

bool r = pcDraft->Reversed.getValue();
ui->checkReverse->setChecked(r);
Expand Down Expand Up @@ -295,7 +294,7 @@ void TaskDraftParameters::onAngleChanged(double angle)

const double TaskDraftParameters::getAngle(void) const
{
return ui->doubleSpinBox->value();
return ui->draftAngle->value().getValue();
}

void TaskDraftParameters::onReversedChanged(const bool on) {
Expand Down Expand Up @@ -360,7 +359,11 @@ TaskDlgDraftParameters::~TaskDlgDraftParameters()

void TaskDlgDraftParameters::open()
{

// a transaction is already open at creation time of the draft
if (!Gui::Command::hasPendingCommand()) {
QString msg = QObject::tr("Edit draft");
Gui::Command::openCommand((const char*)msg.toUtf8());
}
}

void TaskDlgDraftParameters::clicked(int)
Expand Down
16 changes: 12 additions & 4 deletions src/Mod/PartDesign/Gui/TaskDraftParameters.ui
Expand Up @@ -51,12 +51,15 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox">
<widget class="Gui::QuantitySpinBox" name="draftAngle">
<property name="unit" stdset="0">
<string>deg</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>89.000000000000000</double>
<double>89.999999999999986</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
Expand Down Expand Up @@ -112,9 +115,14 @@
</layout>
<zorder>checkReverse</zorder>
<zorder>listWidgetFaces</zorder>
<zorder>buttonFaceAdd</zorder>
<zorder>buttonFaceRemove</zorder>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit 57cdb8a

Please sign in to comment.