Check system locale.

This commit is contained in:
Roman Telezhynskyi 2022-08-03 12:17:04 +03:00
parent 7ae794e0b7
commit 36180a7c38
5 changed files with 19 additions and 5 deletions

View File

@ -397,6 +397,8 @@ void VPApplication::InitOptions()
qCDebug(pApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(", ")));
qCDebug(pApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid())));
CheckSystemLocale();
QPixmapCache::setCacheLimit(50 * 1024 /* 50 MB */);
LoadTranslation(QString());// By default the console version uses system locale

View File

@ -423,6 +423,8 @@ void MApplication::InitOptions()
qCDebug(mApp, "Command-line arguments: %s", qUtf8Printable(arguments().join(", ")));
qCDebug(mApp, "Process ID: %s", qUtf8Printable(QString().setNum(applicationPid())));
CheckSystemLocale();
LoadTranslation(QString());// By default the console version uses system locale
static const char * GENERIC_ICON_TO_CHECK = "document-open";

View File

@ -33,9 +33,7 @@
#include "../ifc/exception/vexceptionemptyparameter.h"
#include "../ifc/exception/vexceptionwrongid.h"
#include "../ifc/exception/vexceptioninvalidnotch.h"
#include "../vwidgets/vmaingraphicsview.h"
#include "../version.h"
#include "../vmisc/vmath.h"
#include "../qmuparser/qmuparsererror.h"
#include "../mainwindow.h"
#include "../vmisc/qt_dispatch/qt_dispatch.h"
@ -617,6 +615,8 @@ void VApplication::InitOptions()
qDebug()<<"Command-line arguments:"<<arguments();
qDebug()<<"Process ID:"<<applicationPid();
CheckSystemLocale();
LoadTranslation(QString());// By default the console version uses system locale
// Create command line parser after loading translations to show localized version.
@ -628,7 +628,7 @@ void VApplication::InitOptions()
}
static const char * GENERIC_ICON_TO_CHECK = "document-open";
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
if (not QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK))
{
//If there is no default working icon theme then we should
//use an icon theme that we provide via a .qrc file

View File

@ -277,8 +277,6 @@ void VAbstractApplication::LoadTranslation(const QString &locale)
LoadQM(appTranslator, QStringLiteral("valentina_"), locale, appQmDir);
installTranslator(appTranslator);
const QString system = Settings()->GetPMSystemCode();
pmsTranslator = new QTranslator(this);
LoadQM(pmsTranslator, QStringLiteral("measurements_") + Settings()->GetPMSystemCode() + '_', locale, appQmDir);
installTranslator(pmsTranslator);
@ -355,3 +353,13 @@ QFileDialog::Options VAbstractApplication::NativeFileDialog(QFileDialog::Options
return options;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractApplication::CheckSystemLocale()
{
const QString defLocale = QLocale::system().name();
if (defLocale.startsWith(QLatin1String("ru")))
{
qFatal("Incompatible locale \"%s\"", qPrintable(defLocale));
}
}

View File

@ -106,6 +106,8 @@ protected:
virtual void InitTrVars()=0;
static void CheckSystemLocale();
protected slots:
virtual void AboutToQuit()=0;