rework units dialog
This commit is contained in:
parent
4ee1bbcabe
commit
e5d8871fea
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DlgUnitCalculator</class>
|
||||
<widget class="QWidget" name="DlgUnitCalculator">
|
||||
<class>Gui::Dialog::DlgUnitCalculator</class>
|
||||
<widget class="QWidget" name="Gui::Dialog::DlgUnitCalculator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>375</width>
|
||||
<height>139</height>
|
||||
<width>425</width>
|
||||
<height>148</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#endif
|
||||
|
||||
#include "DlgUnitsCalculatorImp.h"
|
||||
#include <Base/UnitsApi.h>
|
||||
#include "ui_DlgUnitsCalculator.h"
|
||||
#include <Base/UnitsApi.h>
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
|
@ -43,25 +44,25 @@ using namespace Gui::Dialog;
|
|||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgUnitsCalculator::DlgUnitsCalculator( QWidget* parent, Qt::WindowFlags fl )
|
||||
: QDialog( parent, fl )
|
||||
: QDialog(parent, fl), ui(new Ui_DlgUnitCalculator)
|
||||
{
|
||||
// create widgets
|
||||
setupUi(this);
|
||||
ui->setupUi(this);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(this->ValueInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(valueChanged(Base::Quantity)));
|
||||
connect(this->ValueInput, SIGNAL(returnPressed () ), this, SLOT(returnPressed()));
|
||||
connect(this->UnitInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(unitValueChanged(Base::Quantity)));
|
||||
connect(this->UnitInput, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
|
||||
connect(ui->ValueInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(valueChanged(Base::Quantity)));
|
||||
connect(ui->ValueInput, SIGNAL(returnPressed () ), this, SLOT(returnPressed()));
|
||||
connect(ui->UnitInput, SIGNAL(valueChanged(Base::Quantity)), this, SLOT(unitValueChanged(Base::Quantity)));
|
||||
connect(ui->UnitInput, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
|
||||
|
||||
connect(this->pushButton_Help, SIGNAL(clicked()), this, SLOT(help()));
|
||||
connect(this->pushButton_Close, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
connect(this->pushButton_Copy, SIGNAL(clicked()), this, SLOT(copy()));
|
||||
connect(ui->pushButton_Help, SIGNAL(clicked()), this, SLOT(help()));
|
||||
connect(ui->pushButton_Close, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
connect(ui->pushButton_Copy, SIGNAL(clicked()), this, SLOT(copy()));
|
||||
|
||||
connect(this->ValueInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));
|
||||
connect(this->UnitInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));
|
||||
connect(ui->ValueInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));
|
||||
connect(ui->UnitInput, SIGNAL(parseError(QString)), this, SLOT(parseError(QString)));
|
||||
|
||||
this->ValueInput->setParamGrpPath(QByteArray("User parameter:BaseApp/History/UnitsCalculator"));
|
||||
ui->ValueInput->setParamGrpPath(QByteArray("User parameter:BaseApp/History/UnitsCalculator"));
|
||||
actUnit.setInvalid();
|
||||
}
|
||||
|
||||
|
@ -90,19 +91,19 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
|
|||
{
|
||||
if (actUnit.isValid()) {
|
||||
if (actUnit.getUnit() != quant.getUnit()) {
|
||||
this->ValueOutput->setText(tr("Unit mismatch"));
|
||||
this->pushButton_Copy->setEnabled(false);
|
||||
ui->ValueOutput->setText(tr("Unit mismatch"));
|
||||
ui->pushButton_Copy->setEnabled(false);
|
||||
} else {
|
||||
double value = quant.getValue()/actUnit.getValue();
|
||||
QString val = QLocale::system().toString(value, 'f', Base::UnitsApi::getDecimals());
|
||||
QString out = QString::fromLatin1("%1 %2").arg(val).arg(this->UnitInput->text());
|
||||
this->ValueOutput->setText(out);
|
||||
this->pushButton_Copy->setEnabled(true);
|
||||
QString out = QString::fromLatin1("%1 %2").arg(val).arg(ui->UnitInput->text());
|
||||
ui->ValueOutput->setText(out);
|
||||
ui->pushButton_Copy->setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
//this->ValueOutput->setValue(quant);
|
||||
this->ValueOutput->setText(quant.getUserString());
|
||||
this->pushButton_Copy->setEnabled(true);
|
||||
//ui->ValueOutput->setValue(quant);
|
||||
ui->ValueOutput->setText(quant.getUserString());
|
||||
ui->pushButton_Copy->setEnabled(true);
|
||||
}
|
||||
|
||||
actValue = quant;
|
||||
|
@ -110,14 +111,14 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
|
|||
|
||||
void DlgUnitsCalculator::parseError(const QString& errorText)
|
||||
{
|
||||
this->pushButton_Copy->setEnabled(false);
|
||||
this->ValueOutput->setText(errorText);
|
||||
ui->pushButton_Copy->setEnabled(false);
|
||||
ui->ValueOutput->setText(errorText);
|
||||
}
|
||||
|
||||
void DlgUnitsCalculator::copy(void)
|
||||
{
|
||||
QClipboard *cb = QApplication::clipboard();
|
||||
cb->setText(ValueOutput->text());
|
||||
cb->setText(ui->ValueOutput->text());
|
||||
}
|
||||
|
||||
void DlgUnitsCalculator::help(void)
|
||||
|
@ -127,9 +128,9 @@ void DlgUnitsCalculator::help(void)
|
|||
|
||||
void DlgUnitsCalculator::returnPressed(void)
|
||||
{
|
||||
if (this->pushButton_Copy->isEnabled()) {
|
||||
this->textEdit->append(this->ValueInput->text() + QString::fromLatin1(" = ") + this->ValueOutput->text());
|
||||
this->ValueInput->pushToHistory();
|
||||
if (ui->pushButton_Copy->isEnabled()) {
|
||||
ui->textEdit->append(ui->ValueInput->text() + QString::fromLatin1(" = ") + ui->ValueOutput->text());
|
||||
ui->ValueInput->pushToHistory();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,21 +24,23 @@
|
|||
#ifndef GUI_DIALOG_DlgActivateWindowImp_H
|
||||
#define GUI_DIALOG_DlgActivateWindowImp_H
|
||||
|
||||
#include "ui_DlgUnitsCalculator.h"
|
||||
#include <memory>
|
||||
#include <Base/Quantity.h>
|
||||
|
||||
namespace Gui {
|
||||
namespace Dialog {
|
||||
class Ui_DlgUnitCalculator;
|
||||
|
||||
/**
|
||||
* The DlgUnitsCalculator provides a unit conversion dialog
|
||||
* \author Juergen Riegel
|
||||
*/
|
||||
class DlgUnitsCalculator : public QDialog, public Ui_DlgUnitCalculator
|
||||
class DlgUnitsCalculator : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgUnitsCalculator( QWidget* parent = 0, Qt::WindowFlags fl = 0 );
|
||||
DlgUnitsCalculator(QWidget* parent = 0, Qt::WindowFlags fl = 0);
|
||||
~DlgUnitsCalculator();
|
||||
|
||||
protected:
|
||||
|
@ -58,8 +60,7 @@ protected Q_SLOTS:
|
|||
private:
|
||||
Base::Quantity actValue;
|
||||
Base::Quantity actUnit;
|
||||
|
||||
|
||||
std::auto_ptr<Ui_DlgUnitCalculator> ui;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
|
|
Loading…
Reference in New Issue
Block a user