Instead of method QLocale::system() better to use the default constructor.

Usefull in case we will deside change default locale.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-01-03 10:46:28 +02:00
parent 704f44feeb
commit 86f4b21879
26 changed files with 38 additions and 38 deletions

View File

@ -193,7 +193,7 @@ QGroupBox *TapeConfigurationPage::LangGroup()
//-------------------- Decimal separator setup //-------------------- Decimal separator setup
separatorLabel = new QLabel(tr("Decimal separator parts:")); separatorLabel = new QLabel(tr("Decimal separator parts:"));
osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale().decimalPoint()));
osOptionCheck->setChecked(settings->GetOsSeparator()); osOptionCheck->setChecked(settings->GetOsSeparator());
langLayout->addRow(separatorLabel, osOptionCheck); langLayout->addRow(separatorLabel, osOptionCheck);
@ -322,7 +322,7 @@ void TapeConfigurationPage::RetranslateUi()
langGroup->setTitle(tr("Language")); langGroup->setTitle(tr("Language"));
guiLabel->setText(tr("GUI language:")); guiLabel->setText(tr("GUI language:"));
separatorLabel->setText(tr("Decimal separator parts:")); separatorLabel->setText(tr("Decimal separator parts:"));
osOptionCheck->setText(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); osOptionCheck->setText(tr("With OS options (%1)").arg(QLocale().decimalPoint()));
pmSystemGroup->setTitle(tr("Pattern making system")); pmSystemGroup->setTitle(tr("Pattern making system"));
systemLabel->setText(tr("Pattern making system:")); systemLabel->setText(tr("Pattern making system:"));

View File

@ -47,7 +47,7 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
//mApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); //mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
RetranslateUi(); RetranslateUi();
connect(ui->pushButton_Web_Site, &QPushButton::clicked, RECEIVER(this)[this]() connect(ui->pushButton_Web_Site, &QPushButton::clicked, RECEIVER(this)[this]()

View File

@ -105,7 +105,7 @@ TapeConfigDialog::TapeConfigDialog(QWidget *parent)
setWindowTitle(tr("Config Dialog")); setWindowTitle(tr("Config Dialog"));
qApp->TapeSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->TapeSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -193,7 +193,7 @@ void TapeConfigDialog::Apply()
configurationPage->Apply(); configurationPage->Apply();
pathPage->Apply(); pathPage->Apply();
qApp->TapeSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->TapeSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
emit UpdateProperties(); emit UpdateProperties();
setResult(QDialog::Accepted); setResult(QDialog::Accepted);
} }

View File

@ -392,7 +392,7 @@ void MApplication::InitOptions()
qCDebug(mApp, "Command-line arguments: %s", qUtf8Printable(this->arguments().join(", "))); qCDebug(mApp, "Command-line arguments: %s", qUtf8Printable(this->arguments().join(", ")));
qCDebug(mApp, "Process ID: %s", qUtf8Printable(QString().setNum(this->applicationPid()))); qCDebug(mApp, "Process ID: %s", qUtf8Printable(QString().setNum(this->applicationPid())));
LoadTranslation(QLocale::system().name());// By default the console version uses system locale LoadTranslation(QLocale().name());// By default the console version uses system locale
static const char * GENERIC_ICON_TO_CHECK = "document-open"; static const char * GENERIC_ICON_TO_CHECK = "document-open";
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false) if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)

View File

@ -101,7 +101,7 @@ TMainWindow::TMainWindow(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
ui->lineEditFind->setClearButtonEnabled(true); ui->lineEditFind->setClearButtonEnabled(true);
@ -476,7 +476,7 @@ void TMainWindow::changeEvent(QEvent *event)
{ {
if (event->type() == QEvent::LanguageChange) if (event->type() == QEvent::LanguageChange)
{ {
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
// retranslate designer form (single inheritance approach) // retranslate designer form (single inheritance approach)
ui->retranslateUi(this); ui->retranslateUi(this);
@ -570,7 +570,7 @@ bool TMainWindow::eventFilter(QObject *object, QEvent *event)
{ {
if (qApp->Settings()->GetOsSeparator()) if (qApp->Settings()->GetOsSeparator())
{ {
plainTextEdit->insertPlainText(QLocale::system().decimalPoint()); plainTextEdit->insertPlainText(QLocale().decimalPoint());
} }
else else
{ {
@ -589,7 +589,7 @@ bool TMainWindow::eventFilter(QObject *object, QEvent *event)
{ {
if (qApp->Settings()->GetOsSeparator()) if (qApp->Settings()->GetOsSeparator())
{ {
textEdit->insert(QLocale::system().decimalPoint()); textEdit->insert(QLocale().decimalPoint());
} }
else else
{ {
@ -1945,7 +1945,7 @@ void TMainWindow::InitWindow()
const qint32 index = ui->comboBoxGender->findData(static_cast<int>(m->Gender())); const qint32 index = ui->comboBoxGender->findData(static_cast<int>(m->Gender()));
ui->comboBoxGender->setCurrentIndex(index); ui->comboBoxGender->setCurrentIndex(index);
ui->dateEditBirthDate->setDisplayFormat(QLocale::system().dateFormat()); ui->dateEditBirthDate->setDisplayFormat(QLocale().dateFormat());
ui->dateEditBirthDate->setDate(m->BirthDate()); ui->dateEditBirthDate->setDate(m->BirthDate());
ui->lineEditEmail->setText(m->Email()); ui->lineEditEmail->setText(m->Email());

View File

@ -274,7 +274,7 @@ VApplication::VApplication(int &argc, char **argv)
// making sure will create new instance...just in case we will ever do 2 objects of VApplication // making sure will create new instance...just in case we will ever do 2 objects of VApplication
VCommandLine::Reset(); VCommandLine::Reset();
LoadTranslation(QLocale::system().name());// By default the console version uses system locale LoadTranslation(QLocale().name());// By default the console version uses system locale
VCommandLine::Get(*this); VCommandLine::Get(*this);
undoStack = new QUndoStack(this); undoStack = new QUndoStack(this);
} }

View File

@ -94,7 +94,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
setWindowTitle(tr("Config Dialog")); setWindowTitle(tr("Config Dialog"));
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -196,7 +196,7 @@ void ConfigDialog::Apply()
communityPage->Apply(); communityPage->Apply();
pathPage->Apply(); pathPage->Apply();
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
emit UpdateProperties(); emit UpdateProperties();
setResult(QDialog::Accepted); setResult(QDialog::Accepted);
} }

View File

@ -250,7 +250,7 @@ QGroupBox *ConfigurationPage::LangGroup()
//-------------------- Decimal separator setup //-------------------- Decimal separator setup
separatorLabel = new QLabel(tr("Decimal separator parts:")); separatorLabel = new QLabel(tr("Decimal separator parts:"));
osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); osOptionCheck = new QCheckBox(tr("With OS options (%1)").arg(QLocale().decimalPoint()));
osOptionCheck->setChecked(settings->GetOsSeparator()); osOptionCheck->setChecked(settings->GetOsSeparator());
langLayout->addRow(separatorLabel, osOptionCheck); langLayout->addRow(separatorLabel, osOptionCheck);
@ -448,7 +448,7 @@ void ConfigurationPage::RetranslateUi()
guiLabel->setText(tr("GUI language:")); guiLabel->setText(tr("GUI language:"));
separatorLabel->setText(tr("Decimal separator parts:")); separatorLabel->setText(tr("Decimal separator parts:"));
osOptionCheck->setText(tr("With OS options (%1)").arg(QLocale::system().decimalPoint().toLatin1())); osOptionCheck->setText(tr("With OS options (%1)").arg(QLocale().decimalPoint()));
unitLabel->setText(tr("Default unit:")); unitLabel->setText(tr("Default unit:"));
this->unitCombo->setItemText(0, tr("Centimeters")); this->unitCombo->setItemText(0, tr("Centimeters"));

View File

@ -45,7 +45,7 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION_STR)); ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION)); ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION));

View File

@ -55,7 +55,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
bOk = ui->buttonBox->button(QDialogButtonBox::Ok); bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted);

View File

@ -75,7 +75,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
formulaBaseHeight = ui->plainTextEditFormula->height(); formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
qCDebug(vDialog, "Showing variables."); qCDebug(vDialog, "Showing variables.");
ShowUnits(); ShowUnits();
@ -762,7 +762,7 @@ bool DialogIncrements::eventFilter(QObject *object, QEvent *event)
{ {
if (qApp->Settings()->GetOsSeparator()) if (qApp->Settings()->GetOsSeparator())
{ {
textEdit->insert(QLocale::system().decimalPoint()); textEdit->insert(QLocale().decimalPoint());
} }
else else
{ {

View File

@ -42,7 +42,7 @@ DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
ui->progressBar->setMaximum(maxCount); ui->progressBar->setMaximum(maxCount);
ui->progressBar->setValue(0); ui->progressBar->setValue(0);

View File

@ -60,7 +60,7 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
//moved from ReadSettings - well...it seems it can be done once only (i.e. constructor) because Init funcs dont //moved from ReadSettings - well...it seems it can be done once only (i.e. constructor) because Init funcs dont
//even cleanse lists before adding //even cleanse lists before adding

View File

@ -49,7 +49,7 @@ DialogNewPattern::DialogNewPattern(VContainer *data, const QString &patternPiece
ui->lineEditName->setClearButtonEnabled(true); ui->lineEditName->setClearButtonEnabled(true);
#endif #endif
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
QRect position = this->frameGeometry(); QRect position = this->frameGeometry();
position.moveCenter(QDesktopWidget().availableGeometry().center()); position.moveCenter(QDesktopWidget().availableGeometry().center());

View File

@ -71,7 +71,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
SCASSERT(doc != nullptr) SCASSERT(doc != nullptr)
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
if (m_filePath.isEmpty()) if (m_filePath.isEmpty())
{ {

View File

@ -46,7 +46,7 @@ DialogPatternXmlEdit::DialogPatternXmlEdit(QWidget *parent, VPattern *xmldoc)
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
this->xmlmodel = new VXMLTreeView(); this->xmlmodel = new VXMLTreeView();
this->doc=xmldoc; this->doc=xmldoc;

View File

@ -56,7 +56,7 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
ui->lineEditFileName->setClearButtonEnabled(true); ui->lineEditFileName->setClearButtonEnabled(true);
#endif #endif
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr) SCASSERT(bOk != nullptr)

View File

@ -4016,7 +4016,7 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::WindowsLocale() void MainWindow::WindowsLocale()
{ {
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -159,7 +159,7 @@ template <typename T>
inline QString VAbstractApplication::LocaleToString(const T &value) inline QString VAbstractApplication::LocaleToString(const T &value)
{ {
QLocale loc; QLocale loc;
qApp->Settings()->GetOsSeparator() ? loc = QLocale::system() : loc = QLocale::c(); qApp->Settings()->GetOsSeparator() ? loc = QLocale() : loc = QLocale::c();
return loc.toString(value); return loc.toString(value);
} }

View File

@ -263,7 +263,7 @@ void VCommonSettings::SetSendReportState(const bool &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetLocale() const QString VCommonSettings::GetLocale() const
{ {
return value(SettingConfigurationLocale, QLocale::system().name()).toString(); return value(SettingConfigurationLocale, QLocale().name()).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -90,7 +90,7 @@ VSettings::VSettings(Format format, Scope scope, const QString &organization, co
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetLabelLanguage() const QString VSettings::GetLabelLanguage() const
{ {
return value(SettingConfigurationLabelLanguage, QLocale::system().bcp47Name()).toString(); return value(SettingConfigurationLabelLanguage, QLocale().bcp47Name()).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -782,14 +782,14 @@ QString VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator
} }
} }
QLocale loc = QLocale::system(); // User locale QLocale loc = QLocale(); // User locale
if (loc != QLocale::c() && osSeparator) if (loc != QLocale::c() && osSeparator)
{// User want use Os separator {// User want use Os separator
QList<int> nKeys = numbers.keys();// Positions for all numbers in expression QList<int> nKeys = numbers.keys();// Positions for all numbers in expression
QList<QString> nValues = numbers.values(); QList<QString> nValues = numbers.values();
for (int i = 0; i < nKeys.size(); ++i) for (int i = 0; i < nKeys.size(); ++i)
{ {
loc = QLocale::system();// From system locale loc = QLocale();// From system locale
bool ok = false; bool ok = false;
const qreal d = loc.toDouble(nValues.at(i), &ok); const qreal d = loc.toDouble(nValues.at(i), &ok);
if (ok == false) if (ok == false)
@ -919,7 +919,7 @@ QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator)
} }
} }
QLocale loc = QLocale::system();// User locale QLocale loc = QLocale();// User locale
if (loc != QLocale::C && osSeparator) if (loc != QLocale::C && osSeparator)
{// User want use Os separator {// User want use Os separator
QList<int> nKeys = numbers.keys();// Positions for all numbers in expression QList<int> nKeys = numbers.keys();// Positions for all numbers in expression
@ -935,7 +935,7 @@ QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator)
continue;//Leave with out translation continue;//Leave with out translation
} }
loc = QLocale::system();// To user locale loc = QLocale();// To user locale
QString dStr = loc.toString(d);// Number string in user locale QString dStr = loc.toString(d);// Number string in user locale
const QChar thSep = loc.groupSeparator(); const QChar thSep = loc.groupSeparator();
if (thSep.isSpace()) if (thSep.isSpace())

View File

@ -166,7 +166,7 @@ bool VPE::VStringProperty::eventFilter(QObject *object, QEvent *event)
{ {
if (m_osSeparator) if (m_osSeparator)
{ {
textEdit->insert(QLocale::system().decimalPoint()); textEdit->insert(QLocale().decimalPoint());
} }
else else
{ {

View File

@ -46,7 +46,7 @@ DialogUndo::DialogUndo(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
bool opening = qApp->getOpeningPattern(); bool opening = qApp->getOpeningPattern();
if (opening) if (opening)

View File

@ -363,7 +363,7 @@ bool DialogTool::eventFilter(QObject *object, QEvent *event)
{ {
if (qApp->Settings()->GetOsSeparator()) if (qApp->Settings()->GetOsSeparator())
{ {
plainTextEdit->insertPlainText(QLocale::system().decimalPoint()); plainTextEdit->insertPlainText(QLocale().decimalPoint());
} }
else else
{ {

View File

@ -342,7 +342,7 @@ inline void DialogTool::InitOkCancel(T *ui)
SCASSERT(bCancel != nullptr) SCASSERT(bCancel != nullptr)
connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected); connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale::c()); qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------