Various improvements to ShellIntegration code.
This commit is contained in:
parent
027f4d519d
commit
3b5ff71a27
@ -3284,12 +3284,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -3303,12 +3303,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>LameXP Audiodatei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>Datei mit LameXP v%1 umwandeln</translation>
|
||||
</message>
|
||||
|
@ -3303,12 +3303,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>Archivo de audio soportado por LameXP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>Convertir este archivo con LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3313,12 +3313,12 @@ Ouvrir le dossier récursivement...</translation>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>Fichier audio pris en charge par LameXP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>Convertir ce fichier avec LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3284,12 +3284,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>LameXP által támogatott hangfájl</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>A fájl konvertálása a LameXP v%1 változatával</translation>
|
||||
</message>
|
||||
|
@ -3303,12 +3303,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>File audio supportati da LameXP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>Convertire il file con LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3284,12 +3284,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation type="unfinished">LameXP에서 지원되는 오디오 파일</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation type="unfinished">이 파일을 LameXP v%1(으)로 변환</translation>
|
||||
</message>
|
||||
|
@ -3321,12 +3321,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation type="unfinished">Pliki dźwiękowe wspierane przez LameXP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation type="unfinished">Kompresuj ten plik z LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3328,12 +3328,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>Аудио файл, поддерживаемый LameXP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>Конвертировать этот файл, используя LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3304,12 +3304,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>Ljudfilen stöds av LameXP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>Konvertera denna fil med LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3284,12 +3284,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>LameXP支持的音頻文件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>轉換此文件與LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3321,12 +3321,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>Аудіофайл, що підтримується LameXP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>Конвертувати файл за допомогою LameXP v%1</translation>
|
||||
</message>
|
||||
|
@ -3284,12 +3284,12 @@
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="87"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="82"/>
|
||||
<source>Audio File supported by LameXP</source>
|
||||
<translation>LameXP支持的音频文件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="88"/>
|
||||
<location filename="../../src/ShellIntegration.cpp" line="83"/>
|
||||
<source>Convert this file with LameXP v%1</source>
|
||||
<translation>用LameXP v%1转换此文件</translation>
|
||||
</message>
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 2
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 1
|
||||
#define VER_LAMEXP_BUILD 1716
|
||||
#define VER_LAMEXP_BUILD 1719
|
||||
#define VER_LAMEXP_CONFG 1700
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -49,6 +49,14 @@ static const char *g_lamexpFileType = "LameXP.SupportedAudioFile";
|
||||
//Mutex
|
||||
QMutex ShellIntegration::m_mutex;
|
||||
|
||||
//State values
|
||||
static const int STATE_ENABLED = 1;
|
||||
static const int STATE_UNKNOWN = 0;
|
||||
static const int STATE_DISABLD = -1;
|
||||
|
||||
//State
|
||||
volatile int ShellIntegration::m_state = STATE_UNKNOWN;
|
||||
|
||||
//Macros
|
||||
#define REG_WRITE_STRING(KEY, STR) RegSetValueEx(key, NULL, NULL, REG_SZ, reinterpret_cast<const BYTE*>(STR.utf16()), (STR.size() + 1) * sizeof(wchar_t))
|
||||
|
||||
@ -77,6 +85,12 @@ void ShellIntegration::install(bool async)
|
||||
//Serialize
|
||||
QMutexLocker lock(&m_mutex);
|
||||
|
||||
//Checking
|
||||
if(m_state == STATE_ENABLED)
|
||||
{
|
||||
return; /*already enabled, don't enable again!*/
|
||||
}
|
||||
|
||||
//Init some consts
|
||||
const QString lamexpFileType(g_lamexpFileType);
|
||||
const QString lamexpFileInfo(tr("Audio File supported by LameXP"));
|
||||
@ -85,25 +99,30 @@ void ShellIntegration::install(bool async)
|
||||
const QString lamexpShellAction(g_lamexpShellAction);
|
||||
|
||||
//Register the LameXP file type
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1") .arg(lamexpFileType), QString(), lamexpFileInfo);
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell") .arg(lamexpFileType), QString(), lamexpShellAction);
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2") .arg(lamexpFileType, lamexpShellAction), QString(), lamexpShellText);
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2\\command").arg(lamexpFileType, lamexpShellAction), QString(), lamexpShellCommand);
|
||||
const bool ok1 = MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1") .arg(lamexpFileType), QString(), lamexpFileInfo);
|
||||
const bool ok2 = MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell") .arg(lamexpFileType), QString(), lamexpShellAction);
|
||||
const bool ok3 = MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2") .arg(lamexpFileType, lamexpShellAction), QString(), lamexpShellText);
|
||||
const bool ok4 = MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2\\command").arg(lamexpFileType, lamexpShellAction), QString(), lamexpShellCommand);
|
||||
if(!(ok1 && ok2 && ok3 && ok4))
|
||||
{
|
||||
qWarning("Failed to create LameXP file type!");
|
||||
return;
|
||||
}
|
||||
|
||||
//Detect supported file types
|
||||
QStringList types;
|
||||
detectTypes(lamexpFileType, lamexpShellAction, types);
|
||||
|
||||
//Add LameXP shell action to all supported file types
|
||||
while(!types.isEmpty())
|
||||
for(QStringList::ConstIterator iter = types.constBegin(); iter != types.constEnd(); iter++)
|
||||
{
|
||||
QString currentType = types.takeFirst();
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2") .arg(currentType, lamexpShellAction), QString(), lamexpShellText);
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2\\command").arg(currentType, lamexpShellAction), QString(), lamexpShellCommand);
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2") .arg((*iter), lamexpShellAction), QString(), lamexpShellText);
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2\\command").arg((*iter), lamexpShellAction), QString(), lamexpShellCommand);
|
||||
}
|
||||
|
||||
//Shell notification
|
||||
MUtils::OS::shell_change_notification();
|
||||
m_state = STATE_ENABLED;
|
||||
}
|
||||
|
||||
void ShellIntegration::remove(bool async)
|
||||
@ -118,6 +137,12 @@ void ShellIntegration::remove(bool async)
|
||||
//Serialize
|
||||
QMutexLocker lock(&m_mutex);
|
||||
|
||||
//Checking
|
||||
if(m_state == STATE_DISABLD)
|
||||
{
|
||||
return; /*already enabled, don't enable again!*/
|
||||
}
|
||||
|
||||
//Init some consts
|
||||
const QString lamexpFileType(g_lamexpFileType);
|
||||
const QString lamexpShellAction(g_lamexpShellAction);
|
||||
@ -133,16 +158,28 @@ void ShellIntegration::remove(bool async)
|
||||
}
|
||||
|
||||
//Remove shell action from all file types
|
||||
while(!fileTypes.isEmpty())
|
||||
for(QStringList::ConstIterator iter = fileTypes.constBegin(); iter != fileTypes.constEnd(); iter++)
|
||||
{
|
||||
MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2").arg(fileTypes.takeFirst(), lamexpShellAction));
|
||||
MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\shell\\%2").arg((*iter), lamexpShellAction));
|
||||
|
||||
//Remove from sub-tree too
|
||||
QStringList subTypes;
|
||||
if(MUtils::Registry::reg_enum_subkeys(MUtils::Registry::root_user, QString("Software\\Classes\\%1").arg(*iter), subTypes))
|
||||
{
|
||||
for(QStringList::ConstIterator iter2 = subTypes.constBegin(); iter2 != subTypes.constEnd(); iter2++)
|
||||
{
|
||||
MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, QString("Software\\Classes\\%1\\%2\\shell\\%3").arg((*iter), (*iter2), lamexpShellAction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Unregister LameXP file type
|
||||
MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, QString("Software\\Classes\\%1").arg(lamexpFileType));
|
||||
|
||||
//Shell notification
|
||||
MUtils::OS::shell_change_notification();
|
||||
m_state = STATE_DISABLD;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -152,33 +189,36 @@ void ShellIntegration::remove(bool async)
|
||||
void ShellIntegration::detectTypes(const QString &lamexpFileType, const QString &lamexpShellAction, QStringList &nativeTypes)
|
||||
{
|
||||
nativeTypes.clear();
|
||||
QStringList supportedTypes = DecoderRegistry::getSupportedTypes();
|
||||
QStringList extensions;
|
||||
const QStringList supportedTypes = DecoderRegistry::getSupportedTypes();
|
||||
const QString progId = "Progid";
|
||||
|
||||
QRegExp regExp1("\\((.+)\\)");
|
||||
QRegExp regExp2("(\\.\\w+)");
|
||||
|
||||
//Find all supported file extensions
|
||||
while(!supportedTypes.isEmpty())
|
||||
QStringList extensions;
|
||||
for(QStringList::ConstIterator iter = supportedTypes.constBegin(); iter != supportedTypes.constEnd(); iter++)
|
||||
{
|
||||
if(regExp1.lastIndexIn(supportedTypes.takeFirst()) > 0)
|
||||
if(regExp1.lastIndexIn(*iter) > 0)
|
||||
{
|
||||
int lastIndex = 0;
|
||||
while((lastIndex = regExp2.indexIn(regExp1.cap(1), lastIndex) + 1) >= 1)
|
||||
{
|
||||
extensions.append(regExp2.cap(1));
|
||||
if(!extensions.contains(regExp2.cap(1), Qt::CaseInsensitive))
|
||||
{
|
||||
extensions.append(regExp2.cap(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Map supported extensions to native types
|
||||
while(!extensions.isEmpty())
|
||||
for(QStringList::ConstIterator iter = extensions.constBegin(); iter != extensions.constEnd(); iter++)
|
||||
{
|
||||
const QString currentExt = extensions.takeFirst();
|
||||
|
||||
QString currentType;
|
||||
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_classes, currentExt, QString(), currentType))
|
||||
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_classes, (*iter), QString(), currentType))
|
||||
{
|
||||
currentType = QDir::toNativeSeparators(currentType);
|
||||
if((currentType.compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains(currentType, Qt::CaseInsensitive)))
|
||||
{
|
||||
nativeTypes.append(currentType);
|
||||
@ -186,22 +226,28 @@ void ShellIntegration::detectTypes(const QString &lamexpFileType, const QString
|
||||
}
|
||||
else
|
||||
{
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, currentExt, QString(), lamexpFileType);
|
||||
MUtils::Registry::reg_value_write(MUtils::Registry::root_user, (*iter), QString(), lamexpFileType);
|
||||
}
|
||||
|
||||
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_user, QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\UserChoice").arg(currentExt), QString(), currentType))
|
||||
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_user, QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\UserChoice").arg(*iter), progId, currentType))
|
||||
{
|
||||
currentType = QDir::toNativeSeparators(currentType);
|
||||
if((currentType.compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains(currentType, Qt::CaseInsensitive)))
|
||||
{
|
||||
nativeTypes.append(currentType);
|
||||
}
|
||||
}
|
||||
|
||||
if(MUtils::Registry::reg_value_read(MUtils::Registry::root_user, QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\OpenWithProgids").arg(currentExt), QString(), currentType))
|
||||
QStringList progids;
|
||||
if(MUtils::Registry::reg_enum_values(MUtils::Registry::root_user, QString("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\%1\\OpenWithProgids").arg(*iter), progids))
|
||||
{
|
||||
if((currentType.compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains(currentType, Qt::CaseInsensitive)))
|
||||
for(QStringList::ConstIterator iter2 = progids.constBegin(); iter2 != progids.constEnd(); iter2++)
|
||||
{
|
||||
nativeTypes.append(currentType);
|
||||
currentType = QDir::toNativeSeparators(currentType);
|
||||
if((iter2->compare(lamexpFileType, Qt::CaseInsensitive) != 0) && (!nativeTypes.contains((*iter2), Qt::CaseInsensitive)))
|
||||
{
|
||||
nativeTypes.append(*iter2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,4 +41,5 @@ private:
|
||||
|
||||
static void detectTypes(const QString &lamexpFileType, const QString &lamexpShellAction, QStringList &nativeTypes);
|
||||
static QMutex m_mutex;
|
||||
static volatile int m_state;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user