further implementing InputField and UnitsCalculator
This commit is contained in:
parent
3d6743a13b
commit
46db0c24e8
|
@ -51,10 +51,10 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Gui::InputField" name="ValueOutput">
|
<widget class="QLineEdit" name="ValueOutput">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>150</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -51,6 +51,9 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WFlags fl )
|
||||||
connect(this->pushButton_Close, SIGNAL(pressed()), this, SLOT(accept()));
|
connect(this->pushButton_Close, SIGNAL(pressed()), this, SLOT(accept()));
|
||||||
connect(this->pushButton_Copy, SIGNAL(pressed()), this, SLOT(copy()));
|
connect(this->pushButton_Copy, SIGNAL(pressed()), this, SLOT(copy()));
|
||||||
|
|
||||||
|
connect(this->ValueInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));
|
||||||
|
connect(this->UnitInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));
|
||||||
|
|
||||||
actUnit.setInvalid();
|
actUnit.setInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,15 +85,39 @@ void DlgUnitsCalculator::unitValueChanged(const Base::Quantity& unit)
|
||||||
|
|
||||||
void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
|
void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(actUnit.isValid()){
|
if(actUnit.isValid()){
|
||||||
this->ValueOutput->setValue(Base::Quantity(quant.getValue()/actUnit.getValue(),actUnit.getUnit()));
|
|
||||||
|
double value = quant.getValue()/actUnit.getValue();
|
||||||
|
QString out(QString::fromAscii("%1 %2"));
|
||||||
|
out = out.arg(value).arg(this->UnitInput->text());
|
||||||
|
this->ValueOutput->setText(out);
|
||||||
|
QPalette *palette = new QPalette();
|
||||||
|
palette->setColor(QPalette::Base,QColor(200,255,200));
|
||||||
|
this->ValueOutput->setPalette(*palette);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
this->ValueOutput->setValue(quant);
|
//this->ValueOutput->setValue(quant);
|
||||||
|
this->ValueOutput->setText(QString::fromAscii(quant.getUserString().c_str()));
|
||||||
|
QPalette *palette = new QPalette();
|
||||||
|
palette->setColor(QPalette::Base,QColor(200,255,200));
|
||||||
|
this->ValueOutput->setPalette(*palette);
|
||||||
}
|
}
|
||||||
actValue = quant;
|
actValue = quant;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DlgUnitsCalculator::parseError(const QString& errorText)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
QPalette *palette = new QPalette();
|
||||||
|
palette->setColor(QPalette::Base,QColor(255,200,200));
|
||||||
|
this->ValueOutput->setPalette(*palette);
|
||||||
|
|
||||||
|
this->ValueOutput->setText(QString());
|
||||||
|
|
||||||
|
}
|
||||||
void DlgUnitsCalculator::copy(void)
|
void DlgUnitsCalculator::copy(void)
|
||||||
{
|
{
|
||||||
//TODO: copy the value to the clipboard
|
//TODO: copy the value to the clipboard
|
||||||
|
|
|
@ -52,6 +52,8 @@ protected Q_SLOTS:
|
||||||
void copy(void);
|
void copy(void);
|
||||||
void help(void);
|
void help(void);
|
||||||
|
|
||||||
|
void parseError(const QString& errorText);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Base::Quantity actValue;
|
Base::Quantity actValue;
|
||||||
Base::Quantity actUnit;
|
Base::Quantity actUnit;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user