Skip to content

Commit a7811ba

Browse files
author
Kjell Morgenstern
committed
Load locale from settings with default to C.
1 parent e5f8eb6 commit a7811ba

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/items/paletteitem.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,11 @@ QWidget * PaletteItem::createHoleSettings(QWidget * parent, HoleSettings & holeS
985985

986986
gridLayout->addWidget(rbFrame, 0, 2, 2, 1, Qt::AlignVCenter);
987987

988-
QLocale cLocale(QLocale::C);
989-
QLocale locale;
990988
holeSettings.diameterEdit = new QLineEdit(subFrame);
991989
holeSettings.diameterEdit->setMinimumHeight(RowHeight);
992990
holeSettings.diameterValidator = new QDoubleValidator(holeSettings.diameterEdit);
993991
holeSettings.diameterValidator->setNotation(QDoubleValidator::StandardNotation);
994-
holeSettings.diameterValidator->setLocale(cLocale);
992+
holeSettings.diameterValidator->setLocale(getLocale());
995993
holeSettings.diameterEdit->setValidator(holeSettings.diameterValidator);
996994
gridLayout->addWidget(holeSettings.diameterEdit, 0, 1);
997995
holeSettings.diameterEdit->setObjectName("infoViewLineEdit");
@@ -1005,7 +1003,7 @@ QWidget * PaletteItem::createHoleSettings(QWidget * parent, HoleSettings & holeS
10051003
holeSettings.thicknessEdit->setMinimumHeight(RowHeight);
10061004
holeSettings.thicknessValidator = new QDoubleValidator(holeSettings.thicknessEdit);
10071005
holeSettings.thicknessValidator->setNotation(QDoubleValidator::StandardNotation);
1008-
holeSettings.thicknessValidator->setLocale(cLocale);
1006+
holeSettings.thicknessValidator->setLocale(getLocale());
10091007
holeSettings.thicknessEdit->setValidator(holeSettings.thicknessValidator);
10101008
gridLayout->addWidget(holeSettings.thicknessEdit, 1, 1);
10111009
holeSettings.thicknessEdit->setObjectName("infoViewLineEdit");
@@ -1454,8 +1452,7 @@ void PaletteItem::changeThickness()
14541452
{
14551453
if (changeThickness(m_holeSettings, sender())) {
14561454
auto * edit = qobject_cast<QLineEdit *>(sender());
1457-
QLocale locale(QLocale::C);
1458-
changeHoleSize(m_holeSettings.holeDiameter + "," + QString::number(locale.toDouble(edit->text())) + m_holeSettings.currentUnits());
1455+
changeHoleSize(m_holeSettings.holeDiameter + "," + QString::number(getLocale().toDouble(edit->text())) + m_holeSettings.currentUnits());
14591456
}
14601457
}
14611458

@@ -1464,8 +1461,7 @@ bool PaletteItem::changeThickness(HoleSettings & holeSettings, QObject * sender)
14641461
auto * edit = qobject_cast<QLineEdit *>(sender);
14651462
if (edit == nullptr) return false;
14661463

1467-
QLocale locale(QLocale::C);
1468-
double newValue = locale.toDouble(edit->text());
1464+
double newValue = getLocale().toDouble(edit->text());
14691465
QString temp = holeSettings.ringThickness;
14701466
temp.chop(2);
14711467
double oldValue = temp.toDouble();
@@ -1476,8 +1472,7 @@ void PaletteItem::changeDiameter()
14761472
{
14771473
if (changeDiameter(m_holeSettings, sender())) {
14781474
auto * edit = qobject_cast<QLineEdit *>(sender());
1479-
QLocale locale(QLocale::C);
1480-
changeHoleSize(QString::number(locale.toDouble(edit->text())) + m_holeSettings.currentUnits() + "," + m_holeSettings.ringThickness);
1475+
changeHoleSize(QString::number(getLocale().toDouble(edit->text())) + m_holeSettings.currentUnits() + "," + m_holeSettings.ringThickness);
14811476

14821477
}
14831478
}
@@ -1487,8 +1482,7 @@ bool PaletteItem::changeDiameter(HoleSettings & holeSettings, QObject * sender)
14871482
auto * edit = qobject_cast<QLineEdit *>(sender);
14881483
if (edit == nullptr) return false;
14891484

1490-
QLocale locale(QLocale::C);
1491-
double newValue = locale.toDouble(edit->text());
1485+
double newValue = getLocale().toDouble(edit->text());
14921486
QString temp = holeSettings.holeDiameter;
14931487
temp.chop(2);
14941488
double oldValue = temp.toDouble();
@@ -1623,3 +1617,10 @@ void PaletteItem::retransform(const QTransform & chiefTransform) {
16231617
}
16241618
}
16251619
}
1620+
1621+
QLocale PaletteItem::getLocale()
1622+
{
1623+
QSettings settings;
1624+
QString localeName = settings.value("locale", "C").toString();
1625+
return QLocale(localeName);
1626+
}

src/items/paletteitem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ protected Q_SLOTS:
163163
static QString hackSvgHoleSize(QDomDocument & domDocument, const QString & holeDiameter, const QString & ringThickness);
164164
static QString hackSvgHoleSizeAux(const QString & svg, const QString & expectedFileName);
165165
virtual void changeHoleSize(const QString &);
166+
static QLocale getLocale();
167+
166168

167169
protected Q_SLOTS:
168170
virtual void changeHoleSize(int);

0 commit comments

Comments
 (0)