//main.cpp
qint32 main(qint32 argc, char *argv[])
{
//
app.setApplicationName("RE8000");
app.setApplicationVersion(APP_VERSION);
app.setOrganizationName("XXXX");
app.setOrganizationDomain("http://www.xxxx.com.br/");
app.
thread()->setPriority
(QThread::HighestPriority);
if (!setTranslation())
CFG_ED.setProfileLanguage(CFG::Language_English);
//Starts creating the widgets
g_mainSplashScreen
= new SplashScreen
(QPixmap(":/Images/EntraceImage.bmp"), Qt
::WindowStaysOnTopHint);
g_mainSplashScreen
->setGeometry
((QApplication::desktop()->width
() - g_mainSplashScreen
->pixmap
().
width())/2,
(QApplication::desktop()->height
() - g_mainSplashScreen
->height
())/2,
g_mainSplashScreen->pixmap().width(),g_mainSplashScreen->height());
}
//...
static bool setTranslation()
{
const CFG::AvailableLanguages currLanguage = CFG_ED.profileLanguage();
Settings::Profile::ProfileCenterView::setDefaultLocale(currLanguage);
if (Q_UNLIKELY(!Settings::Profile::ProfileCenterView::installLanguage(currLanguage)))
{
mLog("An error occured while trying to load the translation file (static bool setTranslation(QApplication&))");
return false;
}
return true;
}
//Other files
void ProfileCenterView::setDefaultLocale(const Config::UserCfgSingletom::AvailableLanguages language) (static)
{
switch (language)
{
}
}
bool ProfileCenterView::installLanguage(const Config::UserCfgSingletom::AvailableLanguages language) (static)
{
if (language == CFG::Language_English)
return true;
//
QDir translationDir
(DEFAULT_TRANSLATION_PATH
);
if (Q_UNLIKELY(fileNameList.isEmpty()))
{
mDebugS("Error while trying to install translator: no translator files were found (ProfileCenterView::installLanguage))");
mLog("No translation files were found");
return false;
}
//![] Install selected translation
if (Q_UNLIKELY
(!translator.
load(QLocale(),
"re8000",
"_",DEFAULT_TRANSLATION_PATH,
".qm"))) {
mDebugS("Error while trying to install translator: error while loading file (ProfileCenterView::installLanguage)");
mLog("Error when trying to load the translation file");
return false;
}
qApp->installTranslator(&translator);
return true;
}
//main.cpp
qint32 main(qint32 argc, char *argv[])
{
QApplication::setGraphicsSystem("raster");
//
QApplication app(argc, argv);
app.setApplicationName("RE8000");
app.setApplicationVersion(APP_VERSION);
app.setOrganizationName("XXXX");
app.setOrganizationDomain("http://www.xxxx.com.br/");
app.thread()->setPriority(QThread::HighestPriority);
if (!setTranslation())
CFG_ED.setProfileLanguage(CFG::Language_English);
//Starts creating the widgets
g_mainSplashScreen = new SplashScreen(QPixmap(":/Images/EntraceImage.bmp"), Qt::WindowStaysOnTopHint);
g_mainSplashScreen->setGeometry((QApplication::desktop()->width() - g_mainSplashScreen->pixmap().width())/2,
(QApplication::desktop()->height() - g_mainSplashScreen->height())/2,
g_mainSplashScreen->pixmap().width(),g_mainSplashScreen->height());
}
//...
static bool setTranslation()
{
const CFG::AvailableLanguages currLanguage = CFG_ED.profileLanguage();
Settings::Profile::ProfileCenterView::setDefaultLocale(currLanguage);
if (Q_UNLIKELY(!Settings::Profile::ProfileCenterView::installLanguage(currLanguage)))
{
mLog("An error occured while trying to load the translation file (static bool setTranslation(QApplication&))");
return false;
}
return true;
}
//Other files
void ProfileCenterView::setDefaultLocale(const Config::UserCfgSingletom::AvailableLanguages language) (static)
{
switch (language)
{
case CFG::Language_English: QLocale::setDefault(QLocale(QLocale::English,QLocale::UnitedStates)); break;
case CFG::Language_Espanol: QLocale::setDefault(QLocale(QLocale::Spanish,QLocale::LatinAmericaAndTheCaribbean)); break;
case CFG::Language_PortugueseBR: QLocale::setDefault(QLocale(QLocale::Portuguese,QLocale::Brazil)); break;
default: QLocale::setDefault(QLocale::c()); break;
}
}
bool ProfileCenterView::installLanguage(const Config::UserCfgSingletom::AvailableLanguages language) (static)
{
if (language == CFG::Language_English)
return true;
//
QDir translationDir(DEFAULT_TRANSLATION_PATH);
QStringList fileNameList = translationDir.entryList(QStringList("*.qm"),QDir::Files,QDir::Name);
if (Q_UNLIKELY(fileNameList.isEmpty()))
{
mDebugS("Error while trying to install translator: no translator files were found (ProfileCenterView::installLanguage))");
mLog("No translation files were found");
return false;
}
//![] Install selected translation
QTranslator translator;
if (Q_UNLIKELY(!translator.load(QLocale(),"re8000","_",DEFAULT_TRANSLATION_PATH,".qm")))
{
mDebugS("Error while trying to install translator: error while loading file (ProfileCenterView::installLanguage)");
mLog("Error when trying to load the translation file");
return false;
}
qApp->installTranslator(&translator);
return true;
}
To copy to clipboard, switch view to plain text mode
Bookmarks