From a69a1f6dbe535163ad5bc210ba9b55aebcb02b75 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Mon, 25 Feb 2013 23:12:14 +0100 Subject: [PATCH] Improved lamexp_themes_enabled() function. --- etc/Translation/Blank.ts | 10 +++--- etc/Translation/LameXP_PL.ts | 10 +++--- etc/Translation/LameXP_SV.ts | 10 +++--- src/Config.h | 2 +- src/Dialog_CueImport.cpp | 2 +- src/Dialog_MainWindow.cpp | 14 ++++---- src/Global.cpp | 63 ++++++++++++++++++++++++------------ 7 files changed, 66 insertions(+), 45 deletions(-) diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index 87fca3e9..7de6f833 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -3304,23 +3304,23 @@ QApplication - + Executable '%1' doesn't support Windows compatibility mode. - + Executable '%1' requires Qt v%2, but found Qt v%3. - + Executable '%1' was built for Qt '%2', but found Qt '%3'. - - + + Executable '%1' requires Windows 2000 or later. diff --git a/etc/Translation/LameXP_PL.ts b/etc/Translation/LameXP_PL.ts index 17bfbd47..1514adca 100644 --- a/etc/Translation/LameXP_PL.ts +++ b/etc/Translation/LameXP_PL.ts @@ -3341,23 +3341,23 @@ QApplication - + Executable '%1' doesn't support Windows compatibility mode. Plik wykonywalny '%1' nie działa w trybie kompatybilności z Windows. - + Executable '%1' requires Qt v%2, but found Qt v%3. Plik wykonywalny '%1' wymaga Qt v%2, znaleziono jednak Qt v%3. - + Executable '%1' was built for Qt '%2', but found Qt '%3'. Plik wykonywalny "%1" został skompilowany dla Qt "%2", znaleziono "%3". - - + + Executable '%1' requires Windows 2000 or later. Plik wykonywalny '%1' wymaga do uruchomienia Windows 2000 lub nowszego. diff --git a/etc/Translation/LameXP_SV.ts b/etc/Translation/LameXP_SV.ts index fcc26243..cf811185 100644 --- a/etc/Translation/LameXP_SV.ts +++ b/etc/Translation/LameXP_SV.ts @@ -3324,23 +3324,23 @@ QApplication - + Executable '%1' doesn't support Windows compatibility mode. EXE-filen '%1' stöder inte Windows kompatibilitetsläge. - + Executable '%1' requires Qt v%2, but found Qt v%3. EXE-filen '%1' kräver Qt v%2, du har Qt v%3. - + Executable '%1' was built for Qt '%2', but found Qt '%3'. EXE-filen '%1' är byggd för Qt '%2', du har Qt '%3'. - - + + Executable '%1' requires Windows 2000 or later. EXE-filen '%1' kräver Windows 2000 eller senare. diff --git a/src/Config.h b/src/Config.h index efadb724..3eb5e405 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 7 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 7 -#define VER_LAMEXP_BUILD 1248 +#define VER_LAMEXP_BUILD 1250 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Dialog_CueImport.cpp b/src/Dialog_CueImport.cpp index 611c73ad..40e4f28d 100644 --- a/src/Dialog_CueImport.cpp +++ b/src/Dialog_CueImport.cpp @@ -247,7 +247,7 @@ void CueImportDialog::browseButtonClicked(void) if(pos > 0) currentDir.left(pos - 1); else break; } - if(lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP)) + if(lamexp_themes_enabled()) { newOutDir = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory"), currentDir); } diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index fa25d173..dfb460c1 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -152,7 +152,7 @@ while(0) #define LINK(URL) QString("%2").arg(URL).arg(QString(URL).replace("-", "−")) #define FSLINK(PATH) QString("%2").arg(PATH).arg(QString(PATH).replace("-", "−")) -#define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP)) +//#define USE_NATIVE_FILE_DIALOG (lamexp_themes_enabled() || ((QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) < QSysInfo::WV_XP)) #define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel())) static const DWORD IDM_ABOUTBOX = 0xEFF0; @@ -1931,7 +1931,7 @@ void MainWindow::importCueSheetActionTriggered(bool checked) int result = 0; QString selectedCueFile; - if(USE_NATIVE_FILE_DIALOG) + if(lamexp_themes_enabled()) { selectedCueFile = QFileDialog::getOpenFileName(this, tr("Open Cue Sheet"), m_settings->mostRecentInputPath(), QString("%1 (*.cue)").arg(tr("Cue Sheet File"))); } @@ -2155,7 +2155,7 @@ void MainWindow::addFilesButtonClicked(void) TEMP_HIDE_DROPBOX ( - if(USE_NATIVE_FILE_DIALOG) + if(lamexp_themes_enabled()) { QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes(); QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;")); @@ -2197,7 +2197,7 @@ void MainWindow::openFolderActionActivated(void) { TEMP_HIDE_DROPBOX ( - if(USE_NATIVE_FILE_DIALOG) + if(lamexp_themes_enabled()) { selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath()); } @@ -2459,7 +2459,7 @@ void MainWindow::exportCsvContextActionTriggered(void) ( QString selectedCsvFile; - if(USE_NATIVE_FILE_DIALOG) + if(lamexp_themes_enabled()) { selectedCsvFile = QFileDialog::getSaveFileName(this, tr("Save CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File"))); } @@ -2510,7 +2510,7 @@ void MainWindow::importCsvContextActionTriggered(void) ( QString selectedCsvFile; - if(USE_NATIVE_FILE_DIALOG) + if(lamexp_themes_enabled()) { selectedCsvFile = QFileDialog::getOpenFileName(this, tr("Open CSV file"), m_settings->mostRecentInputPath(), QString("%1 (*.csv)").arg(tr("CSV File"))); } @@ -3853,7 +3853,7 @@ void MainWindow::browseCustomTempFolderButtonClicked(void) { QString newTempFolder; - if(USE_NATIVE_FILE_DIALOG) + if(lamexp_themes_enabled()) { newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath()); } diff --git a/src/Global.cpp b/src/Global.cpp index 5851a1e6..e259aba4 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -265,7 +265,7 @@ static struct } g_lamexp_argv; -//CLI Arguments +//OS Version static struct { bool bInitialized; @@ -274,6 +274,15 @@ static struct } g_lamexp_os_version; +//Win32 Theme support +static struct +{ + bool bInitialized; + bool bThemesEnabled; + QReadWriteLock lock; +} +g_lamexp_themes_enabled; + //Shared memory static const struct { @@ -2001,29 +2010,40 @@ bool lamexp_themes_enabled(void) { typedef int (WINAPI *IsAppThemedFun)(void); - static bool isAppThemed = false; - static bool isAppThemed_initialized = false; - - if(!isAppThemed_initialized) + QReadLocker readLock(&g_lamexp_themes_enabled.lock); + if(g_lamexp_themes_enabled.bInitialized) { - IsAppThemedFun IsAppThemedPtr = NULL; - QLibrary uxTheme(QString("%1/UxTheme.dll").arg(lamexp_known_folder(lamexp_folder_systemfolder))); - if(uxTheme.load()) - { - IsAppThemedPtr = (IsAppThemedFun) uxTheme.resolve("IsAppThemed"); - } - if(IsAppThemedPtr) - { - isAppThemed = IsAppThemedPtr(); - if(!isAppThemed) - { - qWarning("Theme support is disabled for this process!"); - } - } - isAppThemed_initialized = true; + return g_lamexp_themes_enabled.bThemesEnabled; } - return isAppThemed; + readLock.unlock(); + QWriteLocker writeLock(&g_lamexp_themes_enabled.lock); + + if(!g_lamexp_themes_enabled.bInitialized) + { + g_lamexp_themes_enabled.bThemesEnabled = false; + const lamexp_os_version_t * osVersion = lamexp_get_os_version(); + if(LAMEXP_MIN_OS_VER(osVersion, 5, 1)) + { + IsAppThemedFun IsAppThemedPtr = NULL; + QLibrary uxTheme(QString("%1/UxTheme.dll").arg(lamexp_known_folder(lamexp_folder_systemfolder))); + if(uxTheme.load()) + { + IsAppThemedPtr = (IsAppThemedFun) uxTheme.resolve("IsAppThemed"); + } + if(IsAppThemedPtr) + { + g_lamexp_themes_enabled.bThemesEnabled = IsAppThemedPtr(); + if(!g_lamexp_themes_enabled.bThemesEnabled) + { + qWarning("Theme support is disabled for this process!"); + } + } + } + g_lamexp_themes_enabled.bInitialized = true; + } + + return g_lamexp_themes_enabled.bThemesEnabled; } /* @@ -2372,6 +2392,7 @@ extern "C" LAMEXP_ZERO_MEMORY(g_lamexp_folder); LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr); LAMEXP_ZERO_MEMORY(g_lamexp_os_version); + LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled); //Make sure we will pass the check g_lamexp_entry_check_flag = ~g_lamexp_entry_check_flag;