From 601a4a6d7ef5bb5e6d869ea625e30d73d7e22412 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Wed, 24 Apr 2013 23:58:07 +0200 Subject: [PATCH] Some tweaks to previewContextActionTriggered() function. --- etc/Translation/Blank.ts | 144 +++++++++++++++++------------------ etc/Translation/LameXP_EN.ts | 2 +- etc/Translation/LameXP_PL.ts | 144 +++++++++++++++++------------------ etc/Translation/LameXP_SV.ts | 144 +++++++++++++++++------------------ src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 69 +++++++++++------ 6 files changed, 265 insertions(+), 240 deletions(-) diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index b0f42653..8d815bc6 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -1754,7 +1754,7 @@ - + Access Denied @@ -1942,7 +1942,7 @@ - + Discard @@ -2350,266 +2350,266 @@ - - + + Save CSV file - - - - + + + + CSV File - - - - + + + + CSV Export - + Sorry, there are no meta tags that can be exported! - + Sorry, failed to open CSV file for writing! - + Sorry, failed to write to the CSV file! - + The CSV files was created successfully! - - + + Open CSV file - - - - - + + + + + CSV Import - + Sorry, failed to open CSV file for reading! - + Sorry, failed to read from the CSV file! - + Sorry, the CSV file does not contain any known fields! - + CSV file is incomplete. Not all files were updated! - + The CSV files was imported successfully! - - + + New Folder - + Enter the name of the new folder: - + Failed to create folder - + The new folder could not be created: - + Drive is read-only or insufficient access rights! - + QAAC (Apple) - + FHG AAC (Winamp) - + Nero AAC - + Not available! - + Current AAC Encoder: %1 - - - - - - + + + + + + Quality Level %1 - - - + + + Compression %1 - - - + + + Uncompressed - + Best Quality (Slow) - + High Quality (Recommended) - + Acceptable Quality (Fast) - + Poor Quality (Very Fast) - + File name without extension - + Track number with leading zero - + Track title - + Artist name - + Album name - + Year with (at least) four digits - + Comment - + Characters forbidden in file names: - + Rename Macros - + %n Instance(s) - + Cannot write to the selected directory. Please choose another directory! - + Overwrite Mode - + Warning: This mode may overwrite existing files with no way to revert! - + Continue - + Revert - + Already Running - + LameXP is already running, please use the running instance! diff --git a/etc/Translation/LameXP_EN.ts b/etc/Translation/LameXP_EN.ts index 17331739..a1e0a0e5 100644 --- a/etc/Translation/LameXP_EN.ts +++ b/etc/Translation/LameXP_EN.ts @@ -63,7 +63,7 @@ - + %n Instance(s) %n Instance diff --git a/etc/Translation/LameXP_PL.ts b/etc/Translation/LameXP_PL.ts index 0c0ac0a5..2be5ec0d 100644 --- a/etc/Translation/LameXP_PL.ts +++ b/etc/Translation/LameXP_PL.ts @@ -1761,7 +1761,7 @@ - + Access Denied Dostęp zablokowany @@ -1891,7 +1891,7 @@ - + Discard Zamknij @@ -2365,229 +2365,229 @@ Dodaj folder - - + + Save CSV file Zapisz plik CSV - - - - + + + + CSV File Plik CSV - - - - + + + + CSV Export Eksportowanie CSV - + Sorry, there are no meta tags that can be exported! Nie ma żadnych tagów, które można eksportować! - + Sorry, failed to open CSV file for writing! Nie można otworzyć pliku CSV aby go zapisać! - + Sorry, failed to write to the CSV file! Nie można zapisać do pliku CSV! - + The CSV files was created successfully! Pliki CSV utworzone pomyślnie! - - + + Open CSV file Otwórz plik CSV - + Sorry, failed to open CSV file for reading! Nie można otworzyć pliku CSV aby go wczytać! - - - - - + + + + + CSV Import Importowanie CSV - + Sorry, failed to read from the CSV file! Próba odczytania pliku CSV zakończona niepowodzeniem! - + Sorry, the CSV file does not contain any known fields! Plik CSV nie zawiera żadnych znanych pól! - + CSV file is incomplete. Not all files were updated! Plik CSV nie jest kompletny. Nie wszystkie pliki zostały zaktualizowane! - + The CSV files was imported successfully! Pliki CSV zaimportowano pomyślnie! - - + + New Folder Nowy folder - + Enter the name of the new folder: Wprowadź nazwę nowego folderu: - + Failed to create folder Utworzenie folderu zakończone niepowodzeniem - + The new folder could not be created: Nowy folder nie mógł zostać stworzony: - + Drive is read-only or insufficient access rights! Dysk tylko do odczytu lub brak praw dostępu! - + QAAC (Apple) QAAC (Apple) - + FHG AAC (Winamp) FHG AAC (Winamp) - + Nero AAC Nero AAC - + Not available! Niedostępny! - + Current AAC Encoder: %1 Obecny koder AAC: %1 - - - - - - + + + + + + Quality Level %1 Poziom jakości %1 - - - + + + Compression %1 Kompresja %1 - - - + + + Uncompressed Nieskompresowany - + Best Quality (Slow) - + Acceptable Quality (Fast) - + High Quality (Recommended) Wysoka jakość (Zalecane) - + Poor Quality (Very Fast) Najniższa jakość (Bardzo szybko) - + File name without extension Nazwa pliku bez rozszerzenia - + Track number with leading zero Numer ścieżki z zerem na początku - + Track title Nazwa ścieżki - + Artist name Nazwa Artysty - + Album name Nazwa Albumu - + Year with (at least) four digits Rok z (przynajmniej) czterema cyframi - + Comment Komentarz - + Characters forbidden in file names: Zabronione znaki w nazwach plików: - + Rename Macros Zmień nazwy makr - + %n Instance(s) %n wątek @@ -2596,37 +2596,37 @@ - + Cannot write to the selected directory. Please choose another directory! Nie można zapisać do wybranej lokalizacji. Prosze wybierz inną lokalizację! - + Overwrite Mode Tryb nadpisywania - + Warning: This mode may overwrite existing files with no way to revert! Ostrzeżenie: W tym trybie istniejące pliki będą nadpisywane bez możliwości ich odzyskania! - + Continue Kontynuuj - + Revert Cofnij - + Already Running Już działa - + LameXP is already running, please use the running instance! LameXP już działa, przejdź do działającego procesu! diff --git a/etc/Translation/LameXP_SV.ts b/etc/Translation/LameXP_SV.ts index cb7ddd60..80276b81 100644 --- a/etc/Translation/LameXP_SV.ts +++ b/etc/Translation/LameXP_SV.ts @@ -1758,7 +1758,7 @@ - + Access Denied Åtkomst nekad @@ -1950,7 +1950,7 @@ - + Discard Stäng @@ -2358,229 +2358,229 @@ Lägg till mapp - - + + Save CSV file Spara CSV-fil - - - - + + + + CSV File CSV-fil - - - - + + + + CSV Export CSV-export - + Sorry, there are no meta tags that can be exported! Det finns ingen meta-data som kan exporteras! - + Sorry, failed to open CSV file for writing! Kunde inte öppna CSV-filen för skrivning! - + Sorry, failed to write to the CSV file! Kunde inte skriva till CSV-filen! - + The CSV files was created successfully! CSV-filen skapades korrekt! - - + + Open CSV file Öppna CSV-fil - - - - - + + + + + CSV Import CSV-import - + Sorry, failed to open CSV file for reading! Kunde inte öppna CSV-filen för läsning! - + Sorry, failed to read from the CSV file! Kunde inte läsa från CSV-filen! - + Sorry, the CSV file does not contain any known fields! CSV-filen innehåller inga kända fält! - + CSV file is incomplete. Not all files were updated! CSV-filen är inte komplett. Alla filer uppdaterades inte! - + The CSV files was imported successfully! CSV-filen importerades korrekt! - - + + New Folder Ny mapp - + Enter the name of the new folder: Namn på den nya mappen: - + Failed to create folder Kunde inte skapa någon mapp - + The new folder could not be created: Den nya mappen kunde inte skapas: - + Drive is read-only or insufficient access rights! Diskenheten är skrivskyddad eller åtkomsträttigheter saknas! - + QAAC (Apple) QAAC (Apple) - + FHG AAC (Winamp) FHG AAC (Winamp) - + Nero AAC Nero AAC - + Not available! Ej tillgänglig! - + Current AAC Encoder: %1 Aktuell AAC-kodare: %1 - - - - - - + + + + + + Quality Level %1 Kvallitetsnivå %1 - - - + + + Compression %1 Kompression %1 - - - + + + Uncompressed Okomprimerad - + Best Quality (Slow) Bäst kvalitet (Långsam) - + Acceptable Quality (Fast) Acceptabel kvalitet (Snabb) - + High Quality (Recommended) Hög kvallitet (rekommenderas) - + Poor Quality (Very Fast) Dålig kvallitet (mycket snabb) - + File name without extension Filnamn utan filtillägg - + Track number with leading zero Spårnummer med inledande nolla - + Track title Spårtitel - + Artist name Artistnamn - + Album name Albumnamn - + Year with (at least) four digits Årtal med (minst) fyra siffror - + Comment Kommentar - + Characters forbidden in file names: Förbjudna tecken i filnamn: - + Rename Macros Namnändra macron - + %n Instance(s) %n instans @@ -2588,37 +2588,37 @@ - + Cannot write to the selected directory. Please choose another directory! Kan inte skriva till den specificerade mappen. Välj en annan destination! - + Overwrite Mode Överskrivningsläge - + Warning: This mode may overwrite existing files with no way to revert! Varning! Det här läget kan skriva över befintliga filer, utan möjlighet att återskapa! - + Continue Fortsätt - + Revert Återställ - + Already Running Körs redan - + LameXP is already running, please use the running instance! LameXP körs redan, använd den redan startade instansen! diff --git a/src/Config.h b/src/Config.h index 88a6f330..a19a2727 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 7 #define VER_LAMEXP_TYPE RC #define VER_LAMEXP_PATCH 4 -#define VER_LAMEXP_BUILD 1282 +#define VER_LAMEXP_BUILD 1284 /////////////////////////////////////////////////////////////////////////////// // LameXP Build Options diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 4aee18db..6ee1395f 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -2345,44 +2345,69 @@ void MainWindow::sourceFilesScrollbarMoved(int) */ void MainWindow::previewContextActionTriggered(void) { - const static char *appNames[3] = {"smplayer_portable.exe", "smplayer.exe", "mplayer.exe"}; - const static wchar_t *registryKey = L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}"; - + const static wchar_t *registryPrefix[2] = { L"SOFTWARE\\", L"SOFTWARE\\Wow6432Node\\" }; + const static wchar_t *registryKeys[3] = + { + L"Microsoft\\Windows\\CurrentVersion\\Uninstall\\{97D341C8-B0D1-4E4A-A49A-C30B52F168E9}", + L"Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DB9E4EAB-2717-499F-8D56-4CC8A644AB60}", + L"foobar2000" + }; + const static wchar_t *appNames[4] = { L"smplayer_portable.exe", L"smplayer.exe", L"MPUI.exe", L"foobar2000.exe" }; + const static wchar_t *valueNames[2] = { L"InstallLocation", L"InstallDir" }; + QModelIndex index = ui->sourceFileView->currentIndex(); if(!index.isValid()) { return; } - QString mplayerPath; - HKEY registryKeyHandle; - - if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryKey, 0, KEY_READ, ®istryKeyHandle) == ERROR_SUCCESS) + for(size_t i = 0; i < 3; i++) { - wchar_t Buffer[4096]; - DWORD BuffSize = sizeof(wchar_t*) * 4096; - if(RegQueryValueExW(registryKeyHandle, L"InstallLocation", 0, 0, reinterpret_cast(Buffer), &BuffSize) == ERROR_SUCCESS) + for(size_t j = 0; j < 2; j++) { - mplayerPath = QString::fromUtf16(reinterpret_cast(Buffer)); - } - } + QString mplayerPath; + HKEY registryKeyHandle = NULL; - if(!mplayerPath.isEmpty()) - { - QDir mplayerDir(mplayerPath); - if(mplayerDir.exists()) - { - for(int i = 0; i < 3; i++) + const QString currentKey = WCHAR2QSTR(registryPrefix[j]).append(WCHAR2QSTR(registryKeys[i])); + if(RegOpenKeyExW(HKEY_LOCAL_MACHINE, QWCHAR(currentKey), 0, KEY_READ, ®istryKeyHandle) == ERROR_SUCCESS) { - if(mplayerDir.exists(appNames[i])) + for(size_t k = 0; k < 2; k++) { - QProcess::startDetached(mplayerDir.absoluteFilePath(appNames[i]), QStringList() << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath())); - return; + wchar_t Buffer[4096]; + DWORD BuffSize = sizeof(wchar_t*) * 4096; + DWORD DataType = REG_NONE; + if(RegQueryValueExW(registryKeyHandle, valueNames[k], 0, &DataType, reinterpret_cast(Buffer), &BuffSize) == ERROR_SUCCESS) + { + if((DataType == REG_SZ) || (DataType == REG_EXPAND_SZ) || (DataType == REG_LINK)) + { + mplayerPath = WCHAR2QSTR(Buffer); + break; + } + } + } + RegCloseKey(registryKeyHandle); + } + + if(!mplayerPath.isEmpty()) + { + QDir mplayerDir(mplayerPath); + if(mplayerDir.exists()) + { + for(size_t k = 0; k < 4; k++) + { + if(mplayerDir.exists(WCHAR2QSTR(appNames[k]))) + { + qDebug("Player found at:\n%s\n", mplayerDir.absoluteFilePath(WCHAR2QSTR(appNames[k])).toUtf8().constData()); + QProcess::startDetached(mplayerDir.absoluteFilePath(WCHAR2QSTR(appNames[k])), QStringList() << QDir::toNativeSeparators(m_fileListModel->getFile(index).filePath())); + return; + } + } } } } } + qDebug("Player not found, falling back to default application..."); QDesktopServices::openUrl(QString("file:///").append(m_fileListModel->getFile(index).filePath())); }