diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts new file mode 100644 index 00000000..413c4886 --- /dev/null +++ b/etc/Translation/LameXP_DE.ts @@ -0,0 +1,748 @@ + + + + + DropBox + + LameXP - DropBox + + + + <b>LameXP DropBox</b><br><nobr>You can add files to LameXP via Drag&amp;Drop here!</nobr><br><nobr>(Right-click to close the DropBox)</nobr> + + + + + LogViewDialog + + Log View + + + + <b>Log File</b><br>The log file shows detailed information about the selected job. + + + + C:\DOS +C:\DOS\RUN +RUN\DOS\RUN + + + + + Discard + + + + Save to File... + + + + Copy to Clipboard + + + + + MainWindow + + LameXP - Audio Encoder Front-end + LameXP - Audio Kodierer Oberfläche + + + Source Files + Quell Dateien + + + Add File(s) + Hinzufügen + + + Remove + Entfernen + + + Clear + Löschen + + + Show Details + Details Anzeigen + + + Output Directory + Ziel Verzeichnis + + + Goto Home Folder + Gehe zu Profil + + + Goto Music Folder + Gehe zu Musik + + + Goto Desktop Folder + Gehe zu Desktop + + + Make New Folder + Neuer Ordner + + + Save output files to the same location where the input file is located + + + + Prepend relative source file path to output file + + + + Meta Data + Meta Daten + + + Meta Information + Meta Informationen + + + Edit + Bearbeiten + + + Note: Meta information you enter here will <u>supersede</u> data from the source! + + + + Reset + Zurücksetzen + + + Options + + + + Automatically generate playlist file (.m3u) + + + + Write meta information to encoded files + + + + Compression + Kompression + + + Encoder / Format + Kodierer / Format + + + Lame MP3 + + + + Ogg Vorbis + + + + Nero AAC + + + + Wave (PCM) + + + + FLAC + + + + Rate Control Method + Bitraten Steuerungsmethode + + + Quality-based (VBR) + Qualitäts-basiert (VBR) + + + Average Bitrate (ABR) + Mittlere Bitrate (ABR) + + + Constant Bitrate (CBR) + Konstante Bitrate (CBR) + + + Quality / Bitrate + Qualität / Bitrate + + + Minimum + Minimum + + + Maximum + Maximum + + + Advanced Options + Erweiterte Optionen + + + More options will be added in a later version, stay tuned! + + + + Encode Now! + Jetzt Kodieren! + + + About... + Ãœber... + + + Exit Program + Programm Ende + + + File + Datei + + + ? + + + + View + Ansicht + + + Style + Design + + + Tools + Extras + + + Configuration + Konfiguration + + + Quit + Beenden + + + Open File(s)... + Datei(en) Öffnen... + + + Visit Official Web-Site + Offizielle Web-Seite + + + Check for Updates + Nach Updates Suchen + + + Open Folder... + Verzeichnis Öffnen... + + + Clear All + Alle Löschen + + + Plastique + + + + Cleanlooks + + + + Windows Vista ("Aero") + + + + Windows Classic + Windows Klassisch + + + Windows XP ("Luna") + + + + Disable Update Reminder + + + + Disable Sound Effects + + + + Install WMA Decoder + + + + Disable Nero AAC Notifications + + + + Disable WMA Decoder Notifications + + + + Show DropBox + + + + Language + Sprache + + + DEMO VERSION + + + + You can drop in audio files here! + Sie können hier Audio-Dateien per Drag&Drop einfügen! + + + Open File in External Application + + + + Browse File Location + + + + Browse Selected Folder + + + + License Declined + + + + You have declined the license. Consequently the application will exit now! + + + + Goodbye! + + + + LameXP - Expired + + + + This demo (pre-release) version of LameXP has expired at %1. +LameXP is free software and release versions won't expire. + + + + Exit Program + + + + Urgent Update + + + + Your version of LameXP is more than a year old. Time for an update! + + + + Update Reminer + + + + Your last update check was more than 14 days ago. Check for updates now? + + + + Your did not check for LameXP updates yet. Check for updates now? + + + + Postpone + + + + <nobr>LameXP detected that your version of the Nero AAC encoder is outdated!<br> + + + + The current version available is %1 (or later), but you still have version %2 installed.<br><br> + + + + You can download the latest version of the Nero AAC encoder from the Nero website at:<br> + + + + AAC Encoder Outdated + + + + <nobr>The Nero AAC encoder could not be found. AAC encoding support will be disabled.<br> + + + + Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!<br><br> + + + + Your LameXP directory is located here:<br> + + + + You can download the Nero AAC encoder for free from the official Nero website at:<br> + + + + AAC Support Disabled + + + + <nobr>LameXP has detected that the WMA File Decoder component is not currently installed on your system.<br> + + + + You won't be able to process WMA files as input unless the WMA File Decoder component is installed!</nobr> + + + + WMA Decoder Missing + + + + LameXP + + + + You must add at least one file to the list before proceeding! + + + + Low Diskspace Warning + + + + <nobr>There are less than %1 GB of free diskspace available on your system's TEMP folder.</nobr><br><nobr>It is highly recommend to free up more diskspace before proceeding with the encode!</nobr><br><br>Your TEMP folder is located at: + + + + Abort Encoding Process + + + + Clean Disk Now + + + + Ignore + + + + Low Diskspace + + + + You are proceeding with low diskspace. Problems might occur! + + + + Sorry, an unsupported encoder has been chosen! + + + + Cannot write to the selected output directory.<br><nobr>%1</nobr><br><br>Please choose a different directory! + + + + Add file(s) + + + + Add folder + + + + New Folder + + + + Enter the name of the new folder: + + + + Failed to create folder + + + + The new folder could not be created:<br><nobr>%1</nobr><br><br>Drive is read-only or insufficient access rights! + + + + Already running + + + + LameXP is already running, please use the running instance! + + + + Quality Level %1 + + + + Compression %1 + + + + Uncompressed + + + + Do you really want to disable the update reminder? + + + + Update Reminder + + + + The update reminder has been disabled.<br>Please remember to check for updates at regular intervals! + + + + The update reminder has been re-enabled. + + + + Do you really want to disable all sound effects? + + + + Sound Effects + + + + All sound effects have been disabled. + + + + The sound effects have been re-enabled. + + + + Nero AAC Notifications + + + + Do you really want to disable all Nero AAC Encoder notifications? + + + + All Nero AAC Encoder notifications have been disabled. + + + + The Nero AAC Encoder notifications have been re-enabled. + + + + WMA Decoder Notifications + + + + Do you really want to disable all WMA Decoder notifications? + + + + All WMA Decoder notifications have been disabled. + + + + The WMA Decoder notifications have been re-enabled. + + + + Do you want to download and install the WMA File Decoder component now? + + + + Download && Install + + + + Cancel + + + + Downloading WMA Decoder Setup, please wait... + + + + Download Failed + + + + Failed to download the WMA Decoder setup. Check your internet connection! + + + + Try Again + + + + The download seems to be corrupted. Please try again! + + + + WMA Decoder + + + + The WMA File Decoder has been installed. Please restart LameXP now! + + + + Quit LameXP + + + + Adding file(s), please wait... + + + + Access Denied + + + + <nobr>%1 file(s) have been rejected, because read access was not granted!<br>This usually means the file is locked by another process.</nobr> + + + + Files Rejected + + + + <nobr>%1 file(s) have been rejected, because the file format could not be recognized!<br>This usually means the file is damaged or the file format is not supported.</nobr> + + + + + MetaInfo + + Meta Information + + + + <b>Meta Information</b><br>The following meta information have been extracted from the original file. + + + + Edit + Bearbeiten + + + Close + + + + + ProcessingDialog + + LameXP - Processing + + + + <b>Encoding Files</b><br>Your files are being encoded, please be patient... + + + + Initializing, please wait... + + + + (VERSION_TAG) + + + + Abort + + + + Close + + + + + SplashScreen + + LameXP is launching... + + + + + UpdateDialog + + LameXP Update Manager + + + + Please wait... + + + + $(HINT_TEXT) + + + + Latest version available: + + + + (Unknown) + + + + Currently installed version: + + + + $(INFORMATION) + + + + Retry + + + + Show Log + + + + Download && Install + + + + Close + + + + + WorkingBanner + + Frame + + + + $(Status) + + + + diff --git a/etc/Translation/release.bat b/etc/Translation/release.bat new file mode 100644 index 00000000..df69e5e6 --- /dev/null +++ b/etc/Translation/release.bat @@ -0,0 +1,11 @@ +@echo off +REM --------------------------- +set "QTVARS=E:\Qt\MSVC\4.7.1\bin\qtvars.bat" +REM --------------------------- +call "%QTVARS%" +REM --------------------------- +for %%f in (*.ts) do ( + lrelease.exe %%f -qm ..\..\res\localization\%%~nf.qm +) +REM --------------------------- +pause diff --git a/etc/Translation/update.bat b/etc/Translation/update.bat index 296d582f..8b5ffba8 100644 --- a/etc/Translation/update.bat +++ b/etc/Translation/update.bat @@ -19,7 +19,7 @@ for %%f in (..\..\src\*.cpp) do ( ) REM --------------------------- for %%f in (*.ts) do ( - lupdate.exe @update.lst -ts %%f + lupdate.exe @update.lst -no-obsolete -ts %%f ) REM --------------------------- pause diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index 9d00b934..5cde6690 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -286,7 +286,7 @@ QFrame::Plain - ($OUTDIR) + ($OUTDIR) @@ -877,7 +877,7 @@ - (VALUE) + (VALUE) Qt::RichText @@ -1459,7 +1459,7 @@ true - English + English @@ -1571,6 +1571,12 @@ + + + + + + diff --git a/res/Localization.qrc b/res/Localization.qrc index fc2fb2d6..80bd0f3c 100644 --- a/res/Localization.qrc +++ b/res/Localization.qrc @@ -3,9 +3,11 @@ localization/LameXP_DE.qm localization/LameXP_DE.qm.txt - localization/LameXP_FR.qm - localization/LameXP_FR.qm.txt - localization/LameXP_IT.qm - localization/LameXP_IT.qm.txt + diff --git a/res/localization/LameXP_DE.qm b/res/localization/LameXP_DE.qm index 4afdc657..741f4828 100644 Binary files a/res/localization/LameXP_DE.qm and b/res/localization/LameXP_DE.qm differ diff --git a/res/localization/LameXP_DE.qm.txt b/res/localization/LameXP_DE.qm.txt index 176e5370..857b14c9 100644 --- a/res/localization/LameXP_DE.qm.txt +++ b/res/localization/LameXP_DE.qm.txt @@ -1 +1 @@ -Deutsch \ No newline at end of file +Deutsch \ No newline at end of file diff --git a/src/Config.h b/src/Config.h index f9d978ff..babdd3af 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 193 +#define VER_LAMEXP_BUILD 197 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 9edbd97e..8945ad23 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -82,16 +82,6 @@ private: int m_index; }; -//Helper class -class Tag: public QObjectUserData -{ -public: - Tag(const QString &text) : m_text(text) {} - QString text(void) { return m_text; } -private: - const QString m_text; -}; - //////////////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////////////// @@ -100,7 +90,6 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S : QMainWindow(parent), m_fileListModel(fileListModel), - m_currentTranslator(new QTranslator), m_metaData(metaInfo), m_settings(settingsModel), m_accepted(false), @@ -113,12 +102,6 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S //Register meta types qRegisterMetaType("AudioFileModel"); - //Update window title - if(lamexp_version_demo()) - { - setWindowTitle(windowTitle().append(" [DEMO VERSION]")); - } - //Enabled main buttons connect(buttonAbout, SIGNAL(clicked()), this, SLOT(aboutButtonClicked())); connect(buttonStart, SIGNAL(clicked()), this, SLOT(encodeButtonClicked())); @@ -135,14 +118,13 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S sourceFileView->setContextMenuPolicy(Qt::CustomContextMenu); m_dropNoteLabel = new QLabel(sourceFileView); m_dropNoteLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - m_dropNoteLabel->setText("» You can drop in audio files here! «"); SET_FONT_BOLD(m_dropNoteLabel, true); SET_TEXT_COLOR(m_dropNoteLabel, Qt::darkGray); m_sourceFilesContextMenu = new QMenu(); - QAction *showDetailsContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/zoom.png"), "Show Details"); - QAction *previewContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/sound.png"), "Open File in External Application"); - QAction *findFileContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/folder_go.png"), "Browse File Location"); - SET_FONT_BOLD(showDetailsContextAction, true); + m_showDetailsContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/zoom.png"), "N/A"); + m_previewContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/sound.png"), "N/A"); + m_findFileContextAction = m_sourceFilesContextMenu->addAction(QIcon(":/icons/folder_go.png"), "N/A"); + SET_FONT_BOLD(m_showDetailsContextAction, true); connect(buttonAddFiles, SIGNAL(clicked()), this, SLOT(addFilesButtonClicked())); connect(buttonRemoveFile, SIGNAL(clicked()), this, SLOT(removeFileButtonClicked())); connect(buttonClearFiles, SIGNAL(clicked()), this, SLOT(clearFilesButtonClicked())); @@ -153,9 +135,9 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(sourceModelChanged())); connect(m_fileListModel, SIGNAL(modelReset()), this, SLOT(sourceModelChanged())); connect(sourceFileView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(sourceFilesContextMenu(QPoint))); - connect(showDetailsContextAction, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked())); - connect(previewContextAction, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered())); - connect(findFileContextAction, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered())); + connect(m_showDetailsContextAction, SIGNAL(triggered(bool)), this, SLOT(showDetailsButtonClicked())); + connect(m_previewContextAction, SIGNAL(triggered(bool)), this, SLOT(previewContextActionTriggered())); + connect(m_findFileContextAction, SIGNAL(triggered(bool)), this, SLOT(findFileContextActionTriggered())); //Setup "Output" tab m_fileSystemModel = new QFileSystemModelEx(); @@ -185,9 +167,9 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S connect(saveToSourceFolderCheckBox, SIGNAL(clicked()), this, SLOT(saveToSourceFolderChanged())); connect(prependRelativePathCheckBox, SIGNAL(clicked()), this, SLOT(prependRelativePathChanged())); m_outputFolderContextMenu = new QMenu(); - QAction *showFolderContextAction = m_outputFolderContextMenu->addAction(QIcon(":/icons/zoom.png"), "Browse Selected Folder"); + m_showFolderContextAction = m_outputFolderContextMenu->addAction(QIcon(":/icons/zoom.png"), "N/A"); connect(outputFolderView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(outputFolderContextMenu(QPoint))); - connect(showFolderContextAction, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered())); + connect(m_showFolderContextAction, SIGNAL(triggered(bool)), this, SLOT(showFolderContextActionTriggered())); outputFolderLabel->installEventFilter(this); //Setup "Meta Data" tab @@ -268,19 +250,23 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S //Populate the language menu m_languageActionGroup = new QActionGroup(this); m_languageActionGroup->addAction(actionLanguageEnglish); - QStringList translations = QDir(":/localization").entryList(QStringList() << "*.qm", QDir::Files, QDir::Name); - for(int i = 0; i < translations.count(); i++) + actionLanguageEnglish->setChecked(true); + connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(languageActionActivated(QAction*))); + QStringList translations = lamexp_query_translations(); + while(translations.count() > 0) { QAction *currentLanguage = new QAction(this); currentLanguage->setCheckable(true); - currentLanguage->setText(QString::fromUtf8(reinterpret_cast(QResource(QString(":/localization/%1.txt").arg(translations.at(i))).data()))); - currentLanguage->setUserData(0, new Tag(translations.at(i))); + currentLanguage->setText(translations.takeFirst()); m_languageActionGroup->addAction(currentLanguage); menuLanguage->addAction(currentLanguage); + if(currentLanguage->text().compare(m_settings->currentLanguage(), Qt::CaseInsensitive) == 0) + { + currentLanguage->setChecked(true); + languageActionActivated(currentLanguage); + } } - connect(m_languageActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(languageActionActivated(QAction*))); - actionLanguageEnglish->setChecked(true); - + //Activate tools menu actions actionDisableUpdateReminder->setChecked(!m_settings->autoUpdateEnabled()); actionDisableSounds->setChecked(!m_settings->soundsEnabled()); @@ -324,6 +310,9 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S //Enable Drag & Drop this->setAcceptDrops(true); + + //Finally re-translate the UI + retranslateUi(this); } //////////////////////////////////////////////////////////// @@ -346,9 +335,6 @@ MainWindow::~MainWindow(void) //Unset models sourceFileView->setModel(NULL); metaDataView->setModel(NULL); - - //Uninstall translator - QApplication::removeTranslator(m_currentTranslator); //Free memory LAMEXP_DELETE(m_tabActionGroup); @@ -364,13 +350,32 @@ MainWindow::~MainWindow(void) LAMEXP_DELETE(m_encoderButtonGroup); LAMEXP_DELETE(m_sourceFilesContextMenu); LAMEXP_DELETE(m_dropBox); - LAMEXP_DELETE(m_currentTranslator); + } //////////////////////////////////////////////////////////// // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////// +/* + * Re-translate the UI + */ +void MainWindow::retranslateUi(QMainWindow *MainWindow) +{ + Ui::MainWindow::retranslateUi(MainWindow); + + if(lamexp_version_demo()) + { + setWindowTitle(QString("%1 [%2]").arg(windowTitle(), tr("DEMO VERSION"))); + } + + m_dropNoteLabel->setText(QString("» %1 «").arg(tr("You can drop in audio files here!"))); + m_showDetailsContextAction->setText(tr("Show Details")); + m_previewContextAction->setText(tr("Open File in External Application")); + m_findFileContextAction->setText(tr("Browse File Location")); + m_showFolderContextAction->setText(tr("Browse Selected Folder")); +} + /* * Add file to source list */ @@ -387,15 +392,15 @@ void MainWindow::addFiles(const QStringList &files) connect(analyzer, SIGNAL(fileSelected(QString)), m_banner, SLOT(setText(QString)), Qt::QueuedConnection); connect(analyzer, SIGNAL(fileAnalyzed(AudioFileModel)), m_fileListModel, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection); - m_banner->show("Adding file(s), please wait...", analyzer); + m_banner->show(tr("Adding file(s), please wait..."), analyzer); if(analyzer->filesDenied()) { - QMessageBox::warning(this, "Access Denied", QString("%1 file(s) have been rejected, because read access was not granted!
This usually means the file is locked by another process.
").arg(analyzer->filesDenied())); + QMessageBox::warning(this, tr("Access Denied"), tr("%1 file(s) have been rejected, because read access was not granted!
This usually means the file is locked by another process.
").arg(analyzer->filesDenied())); } if(analyzer->filesRejected()) { - QMessageBox::warning(this, "Files Rejected", QString("%1 file(s) have been rejected, because the file format could not be recognized!
This usually means the file is damaged or the file format is not supported.
").arg(analyzer->filesRejected())); + QMessageBox::warning(this, tr("Files Rejected"), tr("%1 file(s) have been rejected, because the file format could not be recognized!
This usually means the file is damaged or the file format is not supported.
").arg(analyzer->filesRejected())); } LAMEXP_DELETE(analyzer); @@ -526,11 +531,9 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) } break; case QEvent::Enter: - qDebug("QEvent::HoverEnter"); outputFolderLabel->setForegroundRole(QPalette::Link); break; case QEvent::Leave: - qDebug("QEvent::HoverLeave"); outputFolderLabel->setForegroundRole(QPalette::WindowText); break; } @@ -566,7 +569,7 @@ void MainWindow::windowShown(void) m_settings->licenseAccepted(-1); QApplication::processEvents(); PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); - QMessageBox::critical(this, "License Declined", "You have declined the license. Consequently the application will exit now!", "Goodbye!"); + QMessageBox::critical(this, tr("License Declined"), tr("You have declined the license. Consequently the application will exit now!"), tr("Goodbye!")); QProcess::startDetached(QString("%1/Uninstall.exe").arg(QApplication::applicationDirPath()), QStringList()); QApplication::quit(); return; @@ -584,7 +587,7 @@ void MainWindow::windowShown(void) { qWarning("Binary has expired !!!"); PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); - if(QMessageBox::warning(this, "LameXP - Expired", QString("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString(Qt::ISODate)), "Check for Updates", "Exit Program") == 0) + if(QMessageBox::warning(this, tr("LameXP - Expired"), tr("This demo (pre-release) version of LameXP has expired at %1.\nLameXP is free software and release versions won't expire.").arg(expireDate.toString(Qt::ISODate)), tr("Check for Updates"), tr("Exit Program")) == 0) { checkUpdatesActionActivated(); } @@ -597,7 +600,7 @@ void MainWindow::windowShown(void) if(QDate::currentDate() >= lamexp_version_date().addYears(1)) { qWarning("Binary is more than a year old, time to update!"); - if(QMessageBox::warning(this, "Urgent Update", "Your version of LameXP is more than a year old. Time for an update!", "Check for Updates", "Exit Program") == 0) + if(QMessageBox::warning(this, tr("Urgent Update"), tr("Your version of LameXP is more than a year old. Time for an update!"), tr("Check for Updates"), tr("Exit Program")) == 0) { checkUpdatesActionActivated(); } @@ -612,7 +615,7 @@ void MainWindow::windowShown(void) QDate lastUpdateCheck = QDate::fromString(m_settings->autoUpdateLastCheck(), Qt::ISODate); if(!lastUpdateCheck.isValid() || QDate::currentDate() >= lastUpdateCheck.addDays(14)) { - if(QMessageBox::information(this, "Update Reminer", (lastUpdateCheck.isValid() ? "Your last update check was more than 14 days ago. Check for updates now?" : "Your did not check for LameXP updates yet. Check for updates now?"), "Check for Updates", "Postpone") == 0) + if(QMessageBox::information(this, tr("Update Reminer"), (lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0) { checkUpdatesActionActivated(); } @@ -627,24 +630,24 @@ void MainWindow::windowShown(void) if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac()) { QString messageText; - messageText += "LameXP detected that your version of the Nero AAC encoder is outdated!
"; - messageText += "The current version available is " + lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac()) + " (or later), but you still have version " + lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe")) + " installed.

"; - messageText += "You can download the latest version of the Nero AAC encoder from the Nero website at:
"; + messageText += tr("
LameXP detected that your version of the Nero AAC encoder is outdated!
"); + messageText += tr("The current version available is %1 (or later), but you still have version %2 installed.

").arg(lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac()), lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe"))); + messageText += tr("You can download the latest version of the Nero AAC encoder from the Nero website at:
"); messageText += "" + LINK(AboutDialog::neroAacUrl) + "
"; - QMessageBox::information(this, "AAC Encoder Outdated", messageText); + QMessageBox::information(this, tr("AAC Encoder Outdated"), messageText); } } else { radioButtonEncoderAAC->setEnabled(false); QString messageText; - messageText += "The Nero AAC encoder could not be found. AAC encoding support will be disabled.
"; - messageText += "Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!

"; - messageText += "Your LameXP directory is located here:
"; + messageText += tr("
The Nero AAC encoder could not be found. AAC encoding support will be disabled.
"); + messageText += tr("Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory!

"); + messageText += tr("Your LameXP directory is located here:
"); messageText += QString("
%1

").arg(QDir::toNativeSeparators(QCoreApplication::applicationDirPath())); - messageText += "You can download the Nero AAC encoder for free from the official Nero website at:
"; + messageText += tr("You can download the Nero AAC encoder for free from the official Nero website at:
"); messageText += "" + LINK(AboutDialog::neroAacUrl) + "
"; - QMessageBox::information(this, "AAC Support Disabled", messageText); + QMessageBox::information(this, tr("AAC Support Disabled"), messageText); } } @@ -654,9 +657,9 @@ void MainWindow::windowShown(void) if(!lamexp_check_tool("wmawav.exe")) { QString messageText; - messageText += "LameXP has detected that the WMA File Decoder component is not currently installed on your system.
"; - messageText += "You won't be able to process WMA files as input unless the WMA File Decoder component is installed!
"; - QMessageBox::information(this, "WMA Decoder Missing", messageText); + messageText += tr("LameXP has detected that the WMA File Decoder component is not currently installed on your system.
"); + messageText += tr("You won't be able to process WMA files as input unless the WMA File Decoder component is installed!
"); + QMessageBox::information(this, tr("WMA Decoder Missing"), messageText); installWMADecoderActionTriggered(rand() % 2); } } @@ -710,7 +713,7 @@ void MainWindow::encodeButtonClicked(void) if(m_fileListModel->rowCount() < 1) { - QMessageBox::warning(this, "LameXP", "You must add at least one file to the list before proceeding!"); + QMessageBox::warning(this, tr("LameXP"), tr("You must add at least one file to the list before proceeding!")); tabWidget->setCurrentIndex(0); return; } @@ -722,7 +725,7 @@ void MainWindow::encodeButtonClicked(void) QStringList tempFolderParts = lamexp_temp_folder().split("/", QString::SkipEmptyParts, Qt::CaseInsensitive); tempFolderParts.takeLast(); if(m_settings->soundsEnabled()) PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); - switch(QMessageBox::warning(this, "Low Diskspace Warning", QString("There are less than %1 GB of free diskspace available on your system's TEMP folder.
It is highly recommend to free up more diskspace before proceeding with the encode!.

Your TEMP folder is located at:
%3
").arg(QString::number(minimumFreeDiskspaceMultiplier), tempFolderParts.join("\\")), "Abort Encoding Process", "Clean Disk Now", "Ignore")) + switch(QMessageBox::warning(this, tr("Low Diskspace Warning"), tr("There are less than %1 GB of free diskspace available on your system's TEMP folder.
It is highly recommend to free up more diskspace before proceeding with the encode!

Your TEMP folder is located at:").append("
%3
").arg(QString::number(minimumFreeDiskspaceMultiplier), tempFolderParts.join("\\")), tr("Abort Encoding Process"), tr("Clean Disk Now"), tr("Ignore"))) { case 1: QProcess::startDetached(QString("%1/cleanmgr.exe").arg(lamexp_known_folder(lamexp_folder_systemfolder)), QStringList() << "/D" << tempFolderParts.first()); @@ -730,7 +733,7 @@ void MainWindow::encodeButtonClicked(void) return; break; default: - QMessageBox::warning(this, "Low Diskspace", "You are proceeding with low diskspace. Problems might occur!"); + QMessageBox::warning(this, tr("Low Diskspace"), tr("You are proceeding with low diskspace. Problems might occur!")); break; } } @@ -744,7 +747,7 @@ void MainWindow::encodeButtonClicked(void) case SettingsModel::PCMEncoder: break; default: - QMessageBox::warning(this, "LameXP", "Sorry, an unsupported encoder has been chosen!"); + QMessageBox::warning(this, tr("LameXP"), tr("Sorry, an unsupported encoder has been chosen!")); tabWidget->setCurrentIndex(3); return; } @@ -754,7 +757,7 @@ void MainWindow::encodeButtonClicked(void) QFile writeTest(QString("%1/~%2.txt").arg(m_settings->outputDir(), QUuid::createUuid().toString())); if(!writeTest.open(QIODevice::ReadWrite)) { - QMessageBox::warning(this, "LameXP", QString("Cannot write to the selected output directory.
%1

Please choose a different directory!").arg(m_settings->outputDir())); + QMessageBox::warning(this, tr("LameXP"), tr("Cannot write to the selected output directory.
%1

Please choose a different directory!").arg(m_settings->outputDir())); tabWidget->setCurrentIndex(1); return; } @@ -785,7 +788,7 @@ void MainWindow::addFilesButtonClicked(void) { ABORT_IF_BUSY; QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes(); - QStringList selectedFiles = QFileDialog::getOpenFileNames(this, "Add file(s)", QString(), fileTypeFilters.join(";;")); + QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), QString(), fileTypeFilters.join(";;")); addFiles(selectedFiles); } @@ -795,7 +798,7 @@ void MainWindow::addFilesButtonClicked(void) void MainWindow::openFolderActionActivated(void) { ABORT_IF_BUSY; - QString selectedFolder = QFileDialog::getExistingDirectory(this, "Add folder", QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + QString selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add folder"), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); if(!selectedFolder.isEmpty()) { @@ -959,14 +962,21 @@ void MainWindow::styleActionActivated(QAction *action) */ void MainWindow::languageActionActivated(QAction *action) { - QApplication::removeTranslator(m_currentTranslator); - if(action->userData(0)) + if(action != actionLanguageEnglish) { - if(m_currentTranslator->load(QString(":/localization/%1").arg(dynamic_cast(action->userData(0))->text()))) + if(lamexp_install_translator(action->text())) { - QApplication::installTranslator(m_currentTranslator); + m_settings->currentLanguage(action->text()); } } + else + { + if(lamexp_install_translator(QString())) + { + m_settings->currentLanguage(action->text()); + } + } + retranslateUi(this); } @@ -1061,7 +1071,7 @@ void MainWindow::makeFolderButtonClicked(void) ABORT_IF_BUSY; QDir basePath(m_fileSystemModel->fileInfo(outputFolderView->currentIndex()).absoluteFilePath()); - QString suggestedName = "New Folder"; + QString suggestedName = tr("New Folder"); if(!m_metaData->fileArtist().isEmpty() && !m_metaData->fileAlbum().isEmpty()) { @@ -1102,7 +1112,7 @@ void MainWindow::makeFolderButtonClicked(void) while(true) { bool bApplied = false; - QString folderName = QInputDialog::getText(this, "New Folder", QString("Enter the name of the new folder:").leftJustified(96, ' '), QLineEdit::Normal, suggestedName, &bApplied, Qt::WindowStaysOnTopHint).simplified(); + QString folderName = QInputDialog::getText(this, tr("New Folder"), tr("Enter the name of the new folder:").leftJustified(96, ' '), QLineEdit::Normal, suggestedName, &bApplied, Qt::WindowStaysOnTopHint).simplified(); if(bApplied) { @@ -1142,7 +1152,7 @@ void MainWindow::makeFolderButtonClicked(void) } else { - QMessageBox::warning(this, "Failed to create folder", QString("The new folder could not be created:
%1

Drive is read-only or insufficient access rights!").arg(basePath.absoluteFilePath(newFolder))); + QMessageBox::warning(this, tr("Failed to create folder"), tr("The new folder could not be created:
%1

Drive is read-only or insufficient access rights!").arg(basePath.absoluteFilePath(newFolder))); } } break; @@ -1202,7 +1212,7 @@ void MainWindow::notifyOtherInstance(void) { if(!m_banner->isVisible()) { - QMessageBox msgBox(QMessageBox::Warning, "Already running", "LameXP is already running, please use the running instance!", QMessageBox::NoButton, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint); + QMessageBox msgBox(QMessageBox::Warning, tr("Already running"), tr("LameXP is already running, please use the running instance!"), QMessageBox::NoButton, this, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowStaysOnTopHint); msgBox.exec(); } } @@ -1382,19 +1392,19 @@ void MainWindow::updateBitrate(int value) switch(m_settings->compressionEncoder()) { case SettingsModel::MP3Encoder: - labelBitrate->setText(QString("Quality Level %1").arg(9 - value)); + labelBitrate->setText(tr("Quality Level %1").arg(9 - value)); break; case SettingsModel::VorbisEncoder: - labelBitrate->setText(QString("Quality Level %1").arg(value)); + labelBitrate->setText(tr("Quality Level %1").arg(value)); break; case SettingsModel::AACEncoder: - labelBitrate->setText(QString("Quality Level %1").arg(QString().sprintf("%.2f", static_cast(value * 5) / 100.0))); + labelBitrate->setText(tr("Quality Level %1").arg(QString().sprintf("%.2f", static_cast(value * 5) / 100.0))); break; case SettingsModel::FLACEncoder: - labelBitrate->setText(QString("Compression %1").arg(value)); + labelBitrate->setText(tr("Compression %1").arg(value)); break; case SettingsModel::PCMEncoder: - labelBitrate->setText("Uncompressed"); + labelBitrate->setText(tr("Uncompressed")); break; default: labelBitrate->setText(QString::number(value)); @@ -1408,10 +1418,10 @@ void MainWindow::updateBitrate(int value) labelBitrate->setText(QString("≈ %1 kbps").arg(SettingsModel::mp3Bitrates[value])); break; case SettingsModel::FLACEncoder: - labelBitrate->setText(QString("Compression %1").arg(value)); + labelBitrate->setText(tr("Compression %1").arg(value)); break; case SettingsModel::PCMEncoder: - labelBitrate->setText("Uncompressed"); + labelBitrate->setText(tr("Uncompressed")); break; default: labelBitrate->setText(QString("≈ %1 kbps").arg(min(500, value * 8))); @@ -1425,10 +1435,10 @@ void MainWindow::updateBitrate(int value) labelBitrate->setText(QString("%1 kbps").arg(SettingsModel::mp3Bitrates[value])); break; case SettingsModel::FLACEncoder: - labelBitrate->setText(QString("Compression %1").arg(value)); + labelBitrate->setText(tr("Compression %1").arg(value)); break; case SettingsModel::PCMEncoder: - labelBitrate->setText("Uncompressed"); + labelBitrate->setText(tr("Uncompressed")); break; default: labelBitrate->setText(QString("%1 kbps").arg(min(500, value * 8))); @@ -1595,9 +1605,9 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked) { if(checked) { - if(QMessageBox::Yes == QMessageBox::question(this, "Disable Update Reminder", "Do you really want to disable the update reminder?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) + if(QMessageBox::Yes == QMessageBox::question(this, tr("Disable Update Reminder"), tr("Do you really want to disable the update reminder?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { - QMessageBox::information(this, "Update Reminder", "The update reminder has been disabled.
Please remember to check for updates at regular intervals!"); + QMessageBox::information(this, tr("Update Reminder"), tr("The update reminder has been disabled.
Please remember to check for updates at regular intervals!")); m_settings->autoUpdateEnabled(false); } else @@ -1607,7 +1617,7 @@ void MainWindow::disableUpdateReminderActionTriggered(bool checked) } else { - QMessageBox::information(this, "Update Reminder", "The update reminder has been re-enabled."); + QMessageBox::information(this, tr("Update Reminder"), tr("The update reminder has been re-enabled.")); m_settings->autoUpdateEnabled(true); } @@ -1621,9 +1631,9 @@ void MainWindow::disableSoundsActionTriggered(bool checked) { if(checked) { - if(QMessageBox::Yes == QMessageBox::question(this, "Disable Sound Effects", "Do you really want to disable all sound effects?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) + if(QMessageBox::Yes == QMessageBox::question(this, tr("Disable Sound Effects"), tr("Do you really want to disable all sound effects?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { - QMessageBox::information(this, "Sound Effects", "All sound effects have been disabled."); + QMessageBox::information(this, tr("Sound Effects"), tr("All sound effects have been disabled.")); m_settings->soundsEnabled(false); } else @@ -1633,7 +1643,7 @@ void MainWindow::disableSoundsActionTriggered(bool checked) } else { - QMessageBox::information(this, "Sound Effects", "The sound effects have been re-enabled."); + QMessageBox::information(this, tr("Sound Effects"), tr("The sound effects have been re-enabled.")); m_settings->soundsEnabled(true); } @@ -1647,9 +1657,9 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked) { if(checked) { - if(QMessageBox::Yes == QMessageBox::question(this, "Nero AAC Notifications", "Do you really want to disable all Nero AAC Encoder notifications?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) + if(QMessageBox::Yes == QMessageBox::question(this, tr("Nero AAC Notifications"), tr("Do you really want to disable all Nero AAC Encoder notifications?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { - QMessageBox::information(this, "Nero AAC Notifications", "All Nero AAC Encoder notifications have been disabled."); + QMessageBox::information(this, tr("Nero AAC Notifications"), tr("All Nero AAC Encoder notifications have been disabled.")); m_settings->neroAacNotificationsEnabled(false); } else @@ -1659,7 +1669,7 @@ void MainWindow::disableNeroAacNotificationsActionTriggered(bool checked) } else { - QMessageBox::information(this, "Nero AAC Notifications", "The Nero AAC Encoder notifications have been re-enabled."); + QMessageBox::information(this, tr("Nero AAC Notifications"), tr("The Nero AAC Encoder notifications have been re-enabled.")); m_settings->neroAacNotificationsEnabled(true); } @@ -1673,9 +1683,9 @@ void MainWindow::disableWmaDecoderNotificationsActionTriggered(bool checked) { if(checked) { - if(QMessageBox::Yes == QMessageBox::question(this, "WMA Decoder Notifications", "Do you really want to disable all WMA Decoder notifications?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) + if(QMessageBox::Yes == QMessageBox::question(this, tr("WMA Decoder Notifications"), tr("Do you really want to disable all WMA Decoder notifications?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No)) { - QMessageBox::information(this, "WMA Decoder Notifications", "All WMA Decoder notifications have been disabled."); + QMessageBox::information(this, tr("WMA Decoder Notifications"), tr("All WMA Decoder notifications have been disabled.")); m_settings->wmaDecoderNotificationsEnabled(false); } else @@ -1685,7 +1695,7 @@ void MainWindow::disableWmaDecoderNotificationsActionTriggered(bool checked) } else { - QMessageBox::information(this, "WMA Decoder Notifications", "The WMA Decoder notifications have been re-enabled."); + QMessageBox::information(this, tr("WMA Decoder Notifications"), tr("The WMA Decoder notifications have been re-enabled.")); m_settings->wmaDecoderNotificationsEnabled(true); } @@ -1700,7 +1710,7 @@ void MainWindow::installWMADecoderActionTriggered(bool checked) static const char *download_url = "http://www.nch.com.au/components/wmawav.exe"; static const char *download_hash = "52a3b0e6690faf3f830c336d3c0eadfb7a4e9bc6"; - if(QMessageBox::question(this, "Install WMA Decoder", "Do you want to download and install the WMA File Decoder component now?", "Download && Install", "Cancel") != 0) + if(QMessageBox::question(this, tr("Install WMA Decoder"), tr("Do you want to download and install the WMA File Decoder component now?"), tr("Download && Install"), tr("Cancel")) != 0) { return; } @@ -1725,12 +1735,12 @@ void MainWindow::installWMADecoderActionTriggered(bool checked) connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit())); process.start(binaryWGet, QStringList() << "-O" << QFileInfo(setupFile).fileName() << download_url); - m_banner->show("Downloading WMA Decoder Setup, please wait...", &loop); + m_banner->show(tr("Downloading WMA Decoder Setup, please wait..."), &loop); if(process.exitCode() != 0 || QFileInfo(setupFile).size() < 10240) { QFile::remove(setupFile); - if(QMessageBox::critical(this, "Download Failed", "Failed to download the WMA Decoder setup. Check your internet connection!", "Try Again", "Cancel") == 0) + if(QMessageBox::critical(this, tr("Download Failed"), tr("Failed to download the WMA Decoder setup. Check your internet connection!"), tr("Try Again"), tr("Cancel")) == 0) { continue; } @@ -1751,7 +1761,7 @@ void MainWindow::installWMADecoderActionTriggered(bool checked) { qWarning("Hash miscompare:\n Expected %s\n Detected %s\n", download_hash, setupFileHash.result().toHex().constData()); QFile::remove(setupFile); - if(QMessageBox::critical(this, "Download Failed", "The download seems to be corrupted. Please try again!", "Try Again", "Cancel") == 0) + if(QMessageBox::critical(this, tr("Download Failed"), tr("The download seems to be corrupted. Please try again!"), tr("Try Again"), tr("Cancel")) == 0) { continue; } @@ -1764,7 +1774,7 @@ void MainWindow::installWMADecoderActionTriggered(bool checked) QFile::remove(setupFile); QApplication::restoreOverrideCursor(); - if(QMessageBox::information(this, "WMA Decoder", "The WMA File Decoder has been installed. Please restart LameXP now!", "Quit LameXP", "Postpone") == 0) + if(QMessageBox::information(this, tr("WMA Decoder"), tr("The WMA File Decoder has been installed. Please restart LameXP now!"), tr("Quit LameXP"), tr("Postpone")) == 0) { QApplication::quit(); } diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index a6cdc6ec..602ea7cc 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -35,7 +35,6 @@ class FileListModel; class AbstractEncoder; class QMenu; class DropBox; -class QTranslator; class MainWindow: public QMainWindow, private Ui::MainWindow { @@ -104,6 +103,7 @@ protected: void closeEvent(QCloseEvent *event); void resizeEvent(QResizeEvent *event); bool eventFilter(QObject *obj, QEvent *event); + void retranslateUi(QMainWindow *MainWindow); private: void addFiles(const QStringList &files); @@ -117,6 +117,10 @@ private: QActionGroup *m_languageActionGroup; QButtonGroup *m_encoderButtonGroup; QButtonGroup *m_modeButtonGroup; + QAction *m_showDetailsContextAction; + QAction *m_previewContextAction; + QAction *m_findFileContextAction; + QAction *m_showFolderContextAction; WorkingBanner *m_banner; MessageHandlerThread *m_messageHandler; QStringList *m_delayedFileList; @@ -128,5 +132,4 @@ private: QMenu *m_sourceFilesContextMenu; QMenu *m_outputFolderContextMenu; DropBox *m_dropBox; - QTranslator *m_currentTranslator; }; diff --git a/src/Global.cpp b/src/Global.cpp index 2c6bf5b5..dc88867b 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -39,6 +39,8 @@ #include #include #include +#include +#include //LameXP includes #include "Resource.h" @@ -118,6 +120,10 @@ static QString g_lamexp_temp_folder; static QMap g_lamexp_tool_registry; static QMap g_lamexp_tool_versions; +//Languages +static QMap g_lamexp_translations; +static QTranslator *g_lamexp_currentTranslator = NULL; + //Shared memory static const char *g_lamexp_sharedmem_uuid = "{21A68A42-6923-43bb-9CF6-64BF151942EE}"; static QSharedMemory *g_lamexp_sharedmem_ptr = NULL; @@ -514,6 +520,17 @@ bool lamexp_init_qt(int argc, char* argv[]) } } + //Init available translations + QStringList qmFiles = QDir(":/localization").entryList(QStringList() << "*.qm", QDir::Files, QDir::Name); + for(int i = 0; i < qmFiles.count(); i++) + { + QResource langName = (QString(":/localization/%1.txt").arg(qmFiles.at(i))); + if(langName.isValid() && langName.size() > 0) + { + g_lamexp_translations.insert(QString::fromUtf8(reinterpret_cast(langName.data()), langName.size()), qmFiles.at(i)); + } + } + //Check for process elevation if(!lamexp_check_elevation()) { @@ -523,11 +540,6 @@ bool lamexp_init_qt(int argc, char* argv[]) } } - //Load translation - //QTranslator *translator = new QTranslator(); - //translator->load(":/localization/LameXP_DE.qm"); - //application->installTranslator(translator); - //Done qt_initialized = true; return true; @@ -771,48 +783,6 @@ bool lamexp_clean_folder(const QString folderPath) return !tempFolder.exists(); } -/* - * Finalization function (final clean-up) - */ -void lamexp_finalization(void) -{ - //Free all tools - if(!g_lamexp_tool_registry.isEmpty()) - { - QStringList keys = g_lamexp_tool_registry.keys(); - for(int i = 0; i < keys.count(); i++) - { - LAMEXP_DELETE(g_lamexp_tool_registry[keys.at(i)]); - } - g_lamexp_tool_registry.clear(); - g_lamexp_tool_versions.clear(); - } - - //Delete temporary files - if(!g_lamexp_temp_folder.isEmpty()) - { - for(int i = 0; i < 100; i++) - { - if(lamexp_clean_folder(g_lamexp_temp_folder)) - { - break; - } - Sleep(125); - } - g_lamexp_temp_folder.clear(); - } - - //Destroy Qt application object - QApplication *application = dynamic_cast(QApplication::instance()); - LAMEXP_DELETE(application); - - //Detach from shared memory - if(g_lamexp_sharedmem_ptr) g_lamexp_sharedmem_ptr->detach(); - LAMEXP_DELETE(g_lamexp_sharedmem_ptr); - LAMEXP_DELETE(g_lamexp_semaphore_read_ptr); - LAMEXP_DELETE(g_lamexp_semaphore_write_ptr); -} - /* * Register tool */ @@ -896,6 +866,49 @@ const QString lamexp_version2string(const QString &pattern, unsigned int version return result; } +/* + * Get list of translations + */ +QStringList lamexp_query_translations(void) +{ + return g_lamexp_translations.keys(); +} + +/* + * Install a new translator + */ +bool lamexp_install_translator(const QString &language) +{ + bool success = false; + + if(!g_lamexp_currentTranslator) + { + g_lamexp_currentTranslator = new QTranslator(); + } + + if(language.isEmpty()) + { + QApplication::removeTranslator(g_lamexp_currentTranslator); + success = true; + } + else + { + QString qmFile = g_lamexp_translations.value(language, QString()); + if(!qmFile.isEmpty()) + { + QApplication::removeTranslator(g_lamexp_currentTranslator); + success = g_lamexp_currentTranslator->load(QString(":/localization/%1").arg(qmFile)); + QApplication::installTranslator(g_lamexp_currentTranslator); + } + else + { + qWarning("Translation '%s' not available!", language.toLatin1().constData()); + } + } + + return success; +} + /* * Locate known folder on local system */ @@ -1020,7 +1033,7 @@ bool lamexp_remove_file(const QString &filename) } /* - * Get number private bytes [debug only] + * Get number of free bytes on disk */ __int64 lamexp_free_diskspace(const QString &path) { @@ -1035,6 +1048,53 @@ __int64 lamexp_free_diskspace(const QString &path) } } +/* + * Finalization function (final clean-up) + */ +void lamexp_finalization(void) +{ + //Free all tools + if(!g_lamexp_tool_registry.isEmpty()) + { + QStringList keys = g_lamexp_tool_registry.keys(); + for(int i = 0; i < keys.count(); i++) + { + LAMEXP_DELETE(g_lamexp_tool_registry[keys.at(i)]); + } + g_lamexp_tool_registry.clear(); + g_lamexp_tool_versions.clear(); + } + + //Delete temporary files + if(!g_lamexp_temp_folder.isEmpty()) + { + for(int i = 0; i < 100; i++) + { + if(lamexp_clean_folder(g_lamexp_temp_folder)) + { + break; + } + Sleep(125); + } + g_lamexp_temp_folder.clear(); + } + + //Clear languages + lamexp_install_translator(QString()); + LAMEXP_DELETE(g_lamexp_currentTranslator); + g_lamexp_translations.clear(); + + //Destroy Qt application object + QApplication *application = dynamic_cast(QApplication::instance()); + LAMEXP_DELETE(application); + + //Detach from shared memory + if(g_lamexp_sharedmem_ptr) g_lamexp_sharedmem_ptr->detach(); + LAMEXP_DELETE(g_lamexp_sharedmem_ptr); + LAMEXP_DELETE(g_lamexp_semaphore_read_ptr); + LAMEXP_DELETE(g_lamexp_semaphore_write_ptr); +} + /* * Get number private bytes [debug only] */ diff --git a/src/Global.h b/src/Global.h index 31783591..926f2aed 100644 --- a/src/Global.h +++ b/src/Global.h @@ -33,8 +33,9 @@ //Declarations class QString; -class LockedFile; +class QStringList; class QDate; +class LockedFile; enum QtMsgType; //Types definitions @@ -90,6 +91,8 @@ const QString &lamexp_temp_folder(void); void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize); void lamexp_ipc_send(unsigned int command, const char* message); lamexp_cpu_t lamexp_detect_cpu_features(void); +QStringList lamexp_query_translations(void); +bool lamexp_install_translator(const QString &language); //Auxiliary functions bool lamexp_clean_folder(const QString folderPath); diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 2baa9fae..17d366eb 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -47,7 +47,7 @@ static const char *g_settingsId_soundsEnabled = "Flags/EnableSounds"; static const char *g_settingsId_neroAacNotificationsEnabled = "Flags/EnableNeroAacNotifications"; static const char *g_settingsId_wmaDecoderNotificationsEnabled = "Flags/EnableWmaDecoderNotifications"; static const char *g_settingsId_dropBoxWidgetEnabled = "Flags/EnableDropBoxWidget"; - +static const char *g_settingsId_currentLanguage = "Localization/Language"; //Macros #define MAKE_OPTION1(OPT,DEF) \ int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toInt(); } \ @@ -134,3 +134,4 @@ MAKE_OPTION3(soundsEnabled, true) MAKE_OPTION3(neroAacNotificationsEnabled, true) MAKE_OPTION3(wmaDecoderNotificationsEnabled, true) MAKE_OPTION3(dropBoxWidgetEnabled, true) +MAKE_OPTION2(currentLanguage, QString()); \ No newline at end of file diff --git a/src/Model_Settings.h b/src/Model_Settings.h index e6ccd189..fd39a109 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -78,6 +78,7 @@ public: MAKE_OPTION_DEC3(neroAacNotificationsEnabled) MAKE_OPTION_DEC3(wmaDecoderNotificationsEnabled) MAKE_OPTION_DEC3(dropBoxWidgetEnabled) + MAKE_OPTION_DEC2(currentLanguage); //Misc void validate(void);