Skip to content

Commit

Permalink
+ Fix crash in units calculator, implement copy function
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 9, 2013
1 parent 26747be commit 047e8f8
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions src/Gui/DlgUnitsCalculatorImp.cpp
Expand Up @@ -23,6 +23,8 @@

#include "PreCompiled.h"
#ifndef _PreComp_
# include <QApplication>
# include <QClipboard>
#endif

#include "DlgUnitsCalculatorImp.h"
Expand All @@ -43,6 +45,7 @@ DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WFlags fl )
{
// create widgets
setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose);

connect(this->ValueInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(valueChanged(Base::Quantity)));
connect(this->UnitInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(unitValueChanged(Base::Quantity)));
Expand All @@ -62,19 +65,14 @@ DlgUnitsCalculator::~DlgUnitsCalculator()
{
}


void DlgUnitsCalculator::accept()
{

QDialog::accept();
delete this;
}

void DlgUnitsCalculator::reject()
{

QDialog::reject();
delete this;
}

void DlgUnitsCalculator::unitValueChanged(const Base::Quantity& unit)
Expand All @@ -84,54 +82,47 @@ void DlgUnitsCalculator::unitValueChanged(const Base::Quantity& unit)
}

void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
{

{
if(actUnit.isValid()){

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);

palette->setColor(QPalette::Base,QColor(200,255,200));
this->ValueOutput->setPalette(*palette);
}else{
//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);
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);
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
QDialog::accept();
delete this;

QClipboard *cb = QApplication::clipboard();
cb->setText(ValueOutput->text());
}

void DlgUnitsCalculator::help(void)
{
//TODO: call help page Std_UnitsCalculator
}




#include "moc_DlgUnitsCalculatorImp.cpp"

0 comments on commit 047e8f8

Please sign in to comment.