Move language file initialization to InitializationThread.
This commit is contained in:
parent
6ab3f195b0
commit
efc0765dea
@ -25,7 +25,7 @@
|
|||||||
#define VER_LAMEXP_MAJOR 4
|
#define VER_LAMEXP_MAJOR 4
|
||||||
#define VER_LAMEXP_MINOR_HI 0
|
#define VER_LAMEXP_MINOR_HI 0
|
||||||
#define VER_LAMEXP_MINOR_LO 0
|
#define VER_LAMEXP_MINOR_LO 0
|
||||||
#define VER_LAMEXP_BUILD 215
|
#define VER_LAMEXP_BUILD 217
|
||||||
#define VER_LAMEXP_SUFFIX TechPreview
|
#define VER_LAMEXP_SUFFIX TechPreview
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -446,6 +446,8 @@ void MainWindow::changeEvent(QEvent *e)
|
|||||||
m_previewContextAction->setText(tr("Open File in External Application"));
|
m_previewContextAction->setText(tr("Open File in External Application"));
|
||||||
m_findFileContextAction->setText(tr("Browse File Location"));
|
m_findFileContextAction->setText(tr("Browse File Location"));
|
||||||
m_showFolderContextAction->setText(tr("Browse Selected Folder"));
|
m_showFolderContextAction->setText(tr("Browse Selected Folder"));
|
||||||
|
|
||||||
|
m_metaInfoModel->clearData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ static QMap<QString, unsigned int> g_lamexp_tool_versions;
|
|||||||
//Languages
|
//Languages
|
||||||
static QMap<QString, QString> g_lamexp_translation_files;
|
static QMap<QString, QString> g_lamexp_translation_files;
|
||||||
static QMap<QString, QString> g_lamexp_translation_names;
|
static QMap<QString, QString> g_lamexp_translation_names;
|
||||||
static QMap<QString, WORD> g_lamexp_translation_sysid;
|
static QMap<QString, unsigned int> g_lamexp_translation_sysid;
|
||||||
static QTranslator *g_lamexp_currentTranslator = NULL;
|
static QTranslator *g_lamexp_currentTranslator = NULL;
|
||||||
|
|
||||||
//Shared memory
|
//Shared memory
|
||||||
@ -461,51 +461,6 @@ static bool lamexp_check_elevation(void)
|
|||||||
return !bIsProcessElevated;
|
return !bIsProcessElevated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize translation files
|
|
||||||
*/
|
|
||||||
static void lamexp_init_translations(void)
|
|
||||||
{
|
|
||||||
//Add default translations
|
|
||||||
g_lamexp_translation_files.insert(LAMEXP_DEFAULT_LANGID, "");
|
|
||||||
g_lamexp_translation_names.insert(LAMEXP_DEFAULT_LANGID, "English");
|
|
||||||
|
|
||||||
//Search for language files
|
|
||||||
QStringList qmFiles = QDir(":/localization").entryList(QStringList() << "LameXP_??.qm", QDir::Files, QDir::Name);
|
|
||||||
|
|
||||||
//Add all available translations
|
|
||||||
while(!qmFiles.isEmpty())
|
|
||||||
{
|
|
||||||
QString langId, langName;
|
|
||||||
WORD systemId = 0;
|
|
||||||
QString qmFile = qmFiles.takeFirst();
|
|
||||||
|
|
||||||
QRegExp langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive);
|
|
||||||
if(langIdExp.indexIn(qmFile) >= 0)
|
|
||||||
{
|
|
||||||
langId = langIdExp.cap(1).toLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
QResource langRes = (QString(":/localization/%1.txt").arg(qmFile));
|
|
||||||
if(langRes.isValid() && langRes.size() > 0)
|
|
||||||
{
|
|
||||||
QStringList langInfo = QString::fromUtf8(reinterpret_cast<const char*>(langRes.data()), langRes.size()).simplified().split(",", QString::SkipEmptyParts);
|
|
||||||
if(langInfo.count() == 2)
|
|
||||||
{
|
|
||||||
systemId = langInfo.at(0).toUInt();
|
|
||||||
langName = langInfo.at(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!langId.isEmpty() && systemId > 0 && !langName.isEmpty())
|
|
||||||
{
|
|
||||||
g_lamexp_translation_files.insert(langId, qmFile);
|
|
||||||
g_lamexp_translation_names.insert(langId, langName);
|
|
||||||
g_lamexp_translation_sysid.insert(langId, systemId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize Qt framework
|
* Initialize Qt framework
|
||||||
*/
|
*/
|
||||||
@ -578,8 +533,12 @@ bool lamexp_init_qt(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Add default translations
|
||||||
|
g_lamexp_translation_files.insert(LAMEXP_DEFAULT_LANGID, "");
|
||||||
|
g_lamexp_translation_names.insert(LAMEXP_DEFAULT_LANGID, "English");
|
||||||
|
|
||||||
//Init language files
|
//Init language files
|
||||||
lamexp_init_translations();
|
//lamexp_init_translations();
|
||||||
|
|
||||||
//Check for process elevation
|
//Check for process elevation
|
||||||
if(!lamexp_check_elevation())
|
if(!lamexp_check_elevation())
|
||||||
@ -910,6 +869,23 @@ const QString lamexp_version2string(const QString &pattern, unsigned int version
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register a new translation
|
||||||
|
*/
|
||||||
|
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId)
|
||||||
|
{
|
||||||
|
if(qmFile.isEmpty() || langName.isEmpty() || systemId < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_lamexp_translation_files.insert(langId, qmFile);
|
||||||
|
g_lamexp_translation_names.insert(langId, langName);
|
||||||
|
g_lamexp_translation_sysid.insert(langId, systemId);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get list of all translations
|
* Get list of all translations
|
||||||
*/
|
*/
|
||||||
@ -929,7 +905,7 @@ QString lamexp_translation_name(const QString &langId)
|
|||||||
/*
|
/*
|
||||||
* Get translation system id
|
* Get translation system id
|
||||||
*/
|
*/
|
||||||
WORD lamexp_translation_sysid(const QString &langId)
|
unsigned int lamexp_translation_sysid(const QString &langId)
|
||||||
{
|
{
|
||||||
return g_lamexp_translation_sysid.value(langId.toLower(), 0);
|
return g_lamexp_translation_sysid.value(langId.toLower(), 0);
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,9 @@ lamexp_cpu_t lamexp_detect_cpu_features(void);
|
|||||||
|
|
||||||
//Translation support
|
//Translation support
|
||||||
QStringList lamexp_query_translations(void);
|
QStringList lamexp_query_translations(void);
|
||||||
|
bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId);
|
||||||
QString lamexp_translation_name(const QString &language);
|
QString lamexp_translation_name(const QString &language);
|
||||||
WORD lamexp_translation_sysid(const QString &langId);
|
unsigned int lamexp_translation_sysid(const QString &langId);
|
||||||
bool lamexp_install_translator(const QString &language);
|
bool lamexp_install_translator(const QString &language);
|
||||||
static const char* LAMEXP_DEFAULT_LANGID = "en";
|
static const char* LAMEXP_DEFAULT_LANGID = "en";
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
|
#include <QResource>
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
@ -54,8 +55,8 @@ static const struct lamexp_tool_t g_lamexp_tools[] =
|
|||||||
{"d837bf6ee4dab557d8b02d46c75a24e58980fffa", "gpgv.gpg", UINT_MAX},
|
{"d837bf6ee4dab557d8b02d46c75a24e58980fffa", "gpgv.gpg", UINT_MAX},
|
||||||
{"143fc001a2f6c56fe1b9e6f8a2eb2b53b9e1e504", "lame.exe", 39910},
|
{"143fc001a2f6c56fe1b9e6f8a2eb2b53b9e1e504", "lame.exe", 39910},
|
||||||
{"775b260b3f64101beaeb317b74746f9bccdab842", "MAC.exe", UINT_MAX},
|
{"775b260b3f64101beaeb317b74746f9bccdab842", "MAC.exe", UINT_MAX},
|
||||||
{"7ea28a2ff8aa6ec2f0a8d59600519b696e915946", "mediainfo_i386.exe", 739},
|
{"61d584ffaf428e9afb0ed9bd32706a954af492b0", "mediainfo_i386.exe", 739},
|
||||||
{"91d3247fa75be2efb532a0711966057684532235", "mediainfo_x64.exe", 739},
|
{"81fb728cbc6057906fa1b637738e6aefe5dccf54", "mediainfo_x64.exe", 739},
|
||||||
{"55c293a80475f7aeccf449ac9487a4626e5139cb", "mpcdec.exe", UINT_MAX},
|
{"55c293a80475f7aeccf449ac9487a4626e5139cb", "mpcdec.exe", UINT_MAX},
|
||||||
{"8bbf4a3fffe2ff143eb5ba2cf82ca16d676e865d", "mpg123.exe", UINT_MAX},
|
{"8bbf4a3fffe2ff143eb5ba2cf82ca16d676e865d", "mpg123.exe", UINT_MAX},
|
||||||
{"8dd7138714c3bcb39f5a3213413addba13d06f1e", "oggdec.exe", UINT_MAX},
|
{"8dd7138714c3bcb39f5a3213413addba13d06f1e", "oggdec.exe", UINT_MAX},
|
||||||
@ -150,6 +151,9 @@ void InitializationThread::run()
|
|||||||
|
|
||||||
qDebug("All extracted.\n");
|
qDebug("All extracted.\n");
|
||||||
|
|
||||||
|
//Register all translations
|
||||||
|
initTranslations();
|
||||||
|
|
||||||
//Look for Nero encoder
|
//Look for Nero encoder
|
||||||
initNeroAac();
|
initNeroAac();
|
||||||
|
|
||||||
@ -178,6 +182,55 @@ void InitializationThread::delay(void)
|
|||||||
printf("Done\n\n");
|
printf("Done\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializationThread::initTranslations(void)
|
||||||
|
{
|
||||||
|
//Search for language files
|
||||||
|
QStringList qmFiles = QDir(":/localization").entryList(QStringList() << "LameXP_??.qm", QDir::Files, QDir::Name);
|
||||||
|
|
||||||
|
//Make sure we found at least one translation
|
||||||
|
if(qmFiles.count() < 1)
|
||||||
|
{
|
||||||
|
qFatal("Could not find any translation files!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add all available translations
|
||||||
|
while(!qmFiles.isEmpty())
|
||||||
|
{
|
||||||
|
QString langId, langName;
|
||||||
|
unsigned int systemId = 0;
|
||||||
|
QString qmFile = qmFiles.takeFirst();
|
||||||
|
|
||||||
|
QRegExp langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive);
|
||||||
|
if(langIdExp.indexIn(qmFile) >= 0)
|
||||||
|
{
|
||||||
|
langId = langIdExp.cap(1).toLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
QResource langRes = (QString(":/localization/%1.txt").arg(qmFile));
|
||||||
|
if(langRes.isValid() && langRes.size() > 0)
|
||||||
|
{
|
||||||
|
QStringList langInfo = QString::fromUtf8(reinterpret_cast<const char*>(langRes.data()), langRes.size()).simplified().split(",", QString::SkipEmptyParts);
|
||||||
|
if(langInfo.count() == 2)
|
||||||
|
{
|
||||||
|
systemId = langInfo.at(0).toUInt();
|
||||||
|
langName = langInfo.at(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lamexp_translation_register(langId, qmFile, langName, systemId))
|
||||||
|
{
|
||||||
|
qDebug("Registering translation: %s = %s (%u)", qmFile.toLatin1().constData(), langName.toLatin1().constData(), systemId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning("Failed to register: %s", qmFile.toLatin1().constData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("All registered.\n");
|
||||||
|
}
|
||||||
|
|
||||||
void InitializationThread::initNeroAac(void)
|
void InitializationThread::initNeroAac(void)
|
||||||
{
|
{
|
||||||
QFileInfo neroFileInfo[3];
|
QFileInfo neroFileInfo[3];
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void delay(void);
|
void delay(void);
|
||||||
|
void initTranslations(void);
|
||||||
void initNeroAac(void);
|
void initNeroAac(void);
|
||||||
void initWmaDec(void);
|
void initWmaDec(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user