further implementing InputField and UnitsCalculator
This commit is contained in:
parent
3d6743a13b
commit
46db0c24e8
|
@ -51,10 +51,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::InputField" name="ValueOutput">
|
||||
<widget class="QLineEdit" name="ValueOutput">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
|
|
|
@ -51,6 +51,9 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WFlags fl )
|
|||
connect(this->pushButton_Close, SIGNAL(pressed()), this, SLOT(accept()));
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -81,16 +84,40 @@ void DlgUnitsCalculator::unitValueChanged(const Base::Quantity& unit)
|
|||
}
|
||||
|
||||
void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
|
||||
{
|
||||
{
|
||||
|
||||
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{
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
//TODO: copy the value to the clipboard
|
||||
|
|
|
@ -52,6 +52,8 @@ protected Q_SLOTS:
|
|||
void copy(void);
|
||||
void help(void);
|
||||
|
||||
void parseError(const QString& errorText);
|
||||
|
||||
private:
|
||||
Base::Quantity actValue;
|
||||
Base::Quantity actUnit;
|
||||
|
|
Loading…
Reference in New Issue
Block a user