Show unit near formula result in dialogs.
--HG-- branch : feature
This commit is contained in:
parent
37d2dd667f
commit
bc545db1dc
|
@ -34,6 +34,8 @@
|
|||
#include "../../geometry/vsplinepath.h"
|
||||
#include "../../tools/vabstracttool.h"
|
||||
#include "../../../libs/qmuparser/qmuparsererror.h"
|
||||
#include "../../widgets/vapplication.h"
|
||||
#include "../../xml/vdomdocument.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -454,12 +456,12 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
|
|||
if (osSeparatorValue)
|
||||
{
|
||||
QLocale loc = QLocale::system();
|
||||
label->setText(loc.toString(result));
|
||||
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||
}
|
||||
else
|
||||
{
|
||||
QLocale loc = QLocale(QLocale::C);
|
||||
label->setText(loc.toString(result));
|
||||
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||
}
|
||||
flag = true;
|
||||
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
||||
|
@ -515,12 +517,12 @@ void DialogTool::Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *l
|
|||
if (osSeparatorValue)
|
||||
{
|
||||
QLocale loc = QLocale::system();
|
||||
label->setText(loc.toString(result));
|
||||
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||
}
|
||||
else
|
||||
{
|
||||
QLocale loc = QLocale(QLocale::C);
|
||||
label->setText(loc.toString(result));
|
||||
label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||
}
|
||||
flag = true;
|
||||
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
||||
|
|
|
@ -367,22 +367,58 @@ Unit VDomDocument::StrToUnits(const QString &unit)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VDomDocument::UnitsToStr(const Unit &unit)
|
||||
/**
|
||||
* @brief UnitsToStr translate unit to string.
|
||||
*
|
||||
* This method used when need write unit in xml file and for showing unit in dialogs.
|
||||
* @param unit curent unit
|
||||
* @param translate true if need show translated name. Default value false.
|
||||
* @return string reprezantation for unit.
|
||||
*/
|
||||
QString VDomDocument::UnitsToStr(const Unit &unit, const bool translate)
|
||||
{
|
||||
QString result;
|
||||
switch (unit)
|
||||
{
|
||||
case Unit::Mm:
|
||||
if (translate)
|
||||
{
|
||||
result = QObject::tr("mm");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "mm";
|
||||
}
|
||||
break;
|
||||
case Unit::Cm:
|
||||
if (translate)
|
||||
{
|
||||
result = QObject::tr("cm");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "cm";
|
||||
}
|
||||
break;
|
||||
case Unit::Inch:
|
||||
result = "inch";
|
||||
if (translate)
|
||||
{
|
||||
result = QObject::tr("in", "inch abbreviation");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "inch";//I decided use full name in xml file.
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (translate)
|
||||
{
|
||||
result = QObject::tr("cm");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "cm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -141,7 +141,7 @@ public:
|
|||
static void ValidateXML(const QString &schema, const QString &fileName);
|
||||
void setContent(const QString &fileName);
|
||||
static Unit StrToUnits(const QString &unit);
|
||||
static QString UnitsToStr(const Unit &unit);
|
||||
static QString UnitsToStr(const Unit &unit, const bool translate = false);
|
||||
virtual bool SaveDocument(const QString &fileName);
|
||||
QString Major() const;
|
||||
QString Minor() const;
|
||||
|
|
Loading…
Reference in New Issue
Block a user