Improved lamexp_themes_enabled() function.

This commit is contained in:
LoRd_MuldeR 2013-02-25 23:12:14 +01:00
parent c71f535c35
commit a69a1f6dbe
7 changed files with 66 additions and 45 deletions

View File

@ -3304,23 +3304,23 @@
<context> <context>
<name>QApplication</name> <name>QApplication</name>
<message> <message>
<location filename="../../src/Global.cpp" line="855"/> <location filename="../../src/Global.cpp" line="864"/>
<source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source> <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1109"/> <location filename="../../src/Global.cpp" line="1118"/>
<source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source> <source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1114"/> <location filename="../../src/Global.cpp" line="1123"/>
<source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source> <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1127"/> <location filename="../../src/Global.cpp" line="1136"/>
<location filename="../../src/Global.cpp" line="1154"/> <location filename="../../src/Global.cpp" line="1163"/>
<source>Executable &apos;%1&apos; requires Windows 2000 or later.</source> <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -3341,23 +3341,23 @@
<context> <context>
<name>QApplication</name> <name>QApplication</name>
<message> <message>
<location filename="../../src/Global.cpp" line="855"/> <location filename="../../src/Global.cpp" line="864"/>
<source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source> <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
<translation type="unfinished">Plik wykonywalny &apos;%1&apos; nie działa w trybie kompatybilności z Windows.</translation> <translation type="unfinished">Plik wykonywalny &apos;%1&apos; nie działa w trybie kompatybilności z Windows.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1109"/> <location filename="../../src/Global.cpp" line="1118"/>
<source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source> <source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
<translation type="unfinished">Plik wykonywalny &apos;%1&apos; wymaga Qt v%2, znaleziono jednak Qt v%3.</translation> <translation type="unfinished">Plik wykonywalny &apos;%1&apos; wymaga Qt v%2, znaleziono jednak Qt v%3.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1114"/> <location filename="../../src/Global.cpp" line="1123"/>
<source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source> <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
<translation type="unfinished">Plik wykonywalny &quot;%1&quot; został skompilowany dla Qt &quot;%2&quot;, znaleziono &quot;%3&quot;.</translation> <translation type="unfinished">Plik wykonywalny &quot;%1&quot; został skompilowany dla Qt &quot;%2&quot;, znaleziono &quot;%3&quot;.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1127"/> <location filename="../../src/Global.cpp" line="1136"/>
<location filename="../../src/Global.cpp" line="1154"/> <location filename="../../src/Global.cpp" line="1163"/>
<source>Executable &apos;%1&apos; requires Windows 2000 or later.</source> <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
<translation type="unfinished">Plik wykonywalny &apos;%1&apos; wymaga do uruchomienia Windows 2000 lub nowszego.</translation> <translation type="unfinished">Plik wykonywalny &apos;%1&apos; wymaga do uruchomienia Windows 2000 lub nowszego.</translation>
</message> </message>

View File

@ -3324,23 +3324,23 @@
<context> <context>
<name>QApplication</name> <name>QApplication</name>
<message> <message>
<location filename="../../src/Global.cpp" line="855"/> <location filename="../../src/Global.cpp" line="864"/>
<source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source> <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
<translation>EXE-filen &apos;%1&apos; stöder inte Windows kompatibilitetsläge.</translation> <translation>EXE-filen &apos;%1&apos; stöder inte Windows kompatibilitetsläge.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1109"/> <location filename="../../src/Global.cpp" line="1118"/>
<source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source> <source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
<translation>EXE-filen &apos;%1&apos; kräver Qt v%2, du har Qt v%3.</translation> <translation>EXE-filen &apos;%1&apos; kräver Qt v%2, du har Qt v%3.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1114"/> <location filename="../../src/Global.cpp" line="1123"/>
<source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source> <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
<translation>EXE-filen &apos;%1&apos; är byggd för Qt &apos;%2&apos;, du har Qt &apos;%3&apos;.</translation> <translation>EXE-filen &apos;%1&apos; är byggd för Qt &apos;%2&apos;, du har Qt &apos;%3&apos;.</translation>
</message> </message>
<message> <message>
<location filename="../../src/Global.cpp" line="1127"/> <location filename="../../src/Global.cpp" line="1136"/>
<location filename="../../src/Global.cpp" line="1154"/> <location filename="../../src/Global.cpp" line="1163"/>
<source>Executable &apos;%1&apos; requires Windows 2000 or later.</source> <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
<translation>EXE-filen &apos;%1&apos; kräver Windows 2000 eller senare.</translation> <translation>EXE-filen &apos;%1&apos; kräver Windows 2000 eller senare.</translation>
</message> </message>

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 7 #define VER_LAMEXP_MINOR_LO 7
#define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 7 #define VER_LAMEXP_PATCH 7
#define VER_LAMEXP_BUILD 1248 #define VER_LAMEXP_BUILD 1250
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)

View File

@ -247,7 +247,7 @@ void CueImportDialog::browseButtonClicked(void)
if(pos > 0) currentDir.left(pos - 1); else break; 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); newOutDir = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory"), currentDir);
} }

View File

@ -152,7 +152,7 @@ while(0)
#define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "&minus;")) #define LINK(URL) QString("<a href=\"%1\">%2</a>").arg(URL).arg(QString(URL).replace("-", "&minus;"))
#define FSLINK(PATH) QString("<a href=\"file:///%1\">%2</a>").arg(PATH).arg(QString(PATH).replace("-", "&minus;")) #define FSLINK(PATH) QString("<a href=\"file:///%1\">%2</a>").arg(PATH).arg(QString(PATH).replace("-", "&minus;"))
#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())) #define CENTER_CURRENT_OUTPUT_FOLDER_DELAYED QTimer::singleShot(125, this, SLOT(centerOutputFolderModel()))
static const DWORD IDM_ABOUTBOX = 0xEFF0; static const DWORD IDM_ABOUTBOX = 0xEFF0;
@ -1931,7 +1931,7 @@ void MainWindow::importCueSheetActionTriggered(bool checked)
int result = 0; int result = 0;
QString selectedCueFile; 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"))); 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 TEMP_HIDE_DROPBOX
( (
if(USE_NATIVE_FILE_DIALOG) if(lamexp_themes_enabled())
{ {
QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes(); QStringList fileTypeFilters = DecoderRegistry::getSupportedTypes();
QStringList selectedFiles = QFileDialog::getOpenFileNames(this, tr("Add file(s)"), m_settings->mostRecentInputPath(), fileTypeFilters.join(";;")); 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 TEMP_HIDE_DROPBOX
( (
if(USE_NATIVE_FILE_DIALOG) if(lamexp_themes_enabled())
{ {
selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath()); selectedFolder = QFileDialog::getExistingDirectory(this, tr("Add Folder"), m_settings->mostRecentInputPath());
} }
@ -2459,7 +2459,7 @@ void MainWindow::exportCsvContextActionTriggered(void)
( (
QString selectedCsvFile; 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"))); 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; 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"))); 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; QString newTempFolder;
if(USE_NATIVE_FILE_DIALOG) if(lamexp_themes_enabled())
{ {
newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath()); newTempFolder = QFileDialog::getExistingDirectory(this, QString(), m_settings->customTempPath());
} }

View File

@ -265,7 +265,7 @@ static struct
} }
g_lamexp_argv; g_lamexp_argv;
//CLI Arguments //OS Version
static struct static struct
{ {
bool bInitialized; bool bInitialized;
@ -274,6 +274,15 @@ static struct
} }
g_lamexp_os_version; g_lamexp_os_version;
//Win32 Theme support
static struct
{
bool bInitialized;
bool bThemesEnabled;
QReadWriteLock lock;
}
g_lamexp_themes_enabled;
//Shared memory //Shared memory
static const struct static const struct
{ {
@ -2001,10 +2010,20 @@ bool lamexp_themes_enabled(void)
{ {
typedef int (WINAPI *IsAppThemedFun)(void); typedef int (WINAPI *IsAppThemedFun)(void);
static bool isAppThemed = false; QReadLocker readLock(&g_lamexp_themes_enabled.lock);
static bool isAppThemed_initialized = false; if(g_lamexp_themes_enabled.bInitialized)
{
return g_lamexp_themes_enabled.bThemesEnabled;
}
if(!isAppThemed_initialized) 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; IsAppThemedFun IsAppThemedPtr = NULL;
QLibrary uxTheme(QString("%1/UxTheme.dll").arg(lamexp_known_folder(lamexp_folder_systemfolder))); QLibrary uxTheme(QString("%1/UxTheme.dll").arg(lamexp_known_folder(lamexp_folder_systemfolder)));
@ -2014,16 +2033,17 @@ bool lamexp_themes_enabled(void)
} }
if(IsAppThemedPtr) if(IsAppThemedPtr)
{ {
isAppThemed = IsAppThemedPtr(); g_lamexp_themes_enabled.bThemesEnabled = IsAppThemedPtr();
if(!isAppThemed) if(!g_lamexp_themes_enabled.bThemesEnabled)
{ {
qWarning("Theme support is disabled for this process!"); qWarning("Theme support is disabled for this process!");
} }
} }
isAppThemed_initialized = true; }
g_lamexp_themes_enabled.bInitialized = true;
} }
return isAppThemed; return g_lamexp_themes_enabled.bThemesEnabled;
} }
/* /*
@ -2372,6 +2392,7 @@ extern "C"
LAMEXP_ZERO_MEMORY(g_lamexp_folder); LAMEXP_ZERO_MEMORY(g_lamexp_folder);
LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr); LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr);
LAMEXP_ZERO_MEMORY(g_lamexp_os_version); LAMEXP_ZERO_MEMORY(g_lamexp_os_version);
LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled);
//Make sure we will pass the check //Make sure we will pass the check
g_lamexp_entry_check_flag = ~g_lamexp_entry_check_flag; g_lamexp_entry_check_flag = ~g_lamexp_entry_check_flag;