Skip to content

Commit

Permalink
Load locale from settings with default to C.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kjell Morgenstern committed May 30, 2024
1 parent e5f8eb6 commit a7811ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/items/paletteitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,13 +985,11 @@ QWidget * PaletteItem::createHoleSettings(QWidget * parent, HoleSettings & holeS

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

QLocale cLocale(QLocale::C);
QLocale locale;
holeSettings.diameterEdit = new QLineEdit(subFrame);
holeSettings.diameterEdit->setMinimumHeight(RowHeight);
holeSettings.diameterValidator = new QDoubleValidator(holeSettings.diameterEdit);
holeSettings.diameterValidator->setNotation(QDoubleValidator::StandardNotation);
holeSettings.diameterValidator->setLocale(cLocale);
holeSettings.diameterValidator->setLocale(getLocale());
holeSettings.diameterEdit->setValidator(holeSettings.diameterValidator);
gridLayout->addWidget(holeSettings.diameterEdit, 0, 1);
holeSettings.diameterEdit->setObjectName("infoViewLineEdit");
Expand All @@ -1005,7 +1003,7 @@ QWidget * PaletteItem::createHoleSettings(QWidget * parent, HoleSettings & holeS
holeSettings.thicknessEdit->setMinimumHeight(RowHeight);
holeSettings.thicknessValidator = new QDoubleValidator(holeSettings.thicknessEdit);
holeSettings.thicknessValidator->setNotation(QDoubleValidator::StandardNotation);
holeSettings.thicknessValidator->setLocale(cLocale);
holeSettings.thicknessValidator->setLocale(getLocale());
holeSettings.thicknessEdit->setValidator(holeSettings.thicknessValidator);
gridLayout->addWidget(holeSettings.thicknessEdit, 1, 1);
holeSettings.thicknessEdit->setObjectName("infoViewLineEdit");
Expand Down Expand Up @@ -1454,8 +1452,7 @@ void PaletteItem::changeThickness()
{
if (changeThickness(m_holeSettings, sender())) {
auto * edit = qobject_cast<QLineEdit *>(sender());
QLocale locale(QLocale::C);
changeHoleSize(m_holeSettings.holeDiameter + "," + QString::number(locale.toDouble(edit->text())) + m_holeSettings.currentUnits());
changeHoleSize(m_holeSettings.holeDiameter + "," + QString::number(getLocale().toDouble(edit->text())) + m_holeSettings.currentUnits());
}
}

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

QLocale locale(QLocale::C);
double newValue = locale.toDouble(edit->text());
double newValue = getLocale().toDouble(edit->text());
QString temp = holeSettings.ringThickness;
temp.chop(2);
double oldValue = temp.toDouble();
Expand All @@ -1476,8 +1472,7 @@ void PaletteItem::changeDiameter()
{
if (changeDiameter(m_holeSettings, sender())) {
auto * edit = qobject_cast<QLineEdit *>(sender());
QLocale locale(QLocale::C);
changeHoleSize(QString::number(locale.toDouble(edit->text())) + m_holeSettings.currentUnits() + "," + m_holeSettings.ringThickness);
changeHoleSize(QString::number(getLocale().toDouble(edit->text())) + m_holeSettings.currentUnits() + "," + m_holeSettings.ringThickness);

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

QLocale locale(QLocale::C);
double newValue = locale.toDouble(edit->text());
double newValue = getLocale().toDouble(edit->text());
QString temp = holeSettings.holeDiameter;
temp.chop(2);
double oldValue = temp.toDouble();
Expand Down Expand Up @@ -1623,3 +1617,10 @@ void PaletteItem::retransform(const QTransform & chiefTransform) {
}
}
}

QLocale PaletteItem::getLocale()
{
QSettings settings;
QString localeName = settings.value("locale", "C").toString();
return QLocale(localeName);
}
2 changes: 2 additions & 0 deletions src/items/paletteitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ protected Q_SLOTS:
static QString hackSvgHoleSize(QDomDocument & domDocument, const QString & holeDiameter, const QString & ringThickness);
static QString hackSvgHoleSizeAux(const QString & svg, const QString & expectedFileName);
virtual void changeHoleSize(const QString &);
static QLocale getLocale();


protected Q_SLOTS:
virtual void changeHoleSize(int);
Expand Down

0 comments on commit a7811ba

Please sign in to comment.