mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Use a new icon for torrents on Windows
Clean up registry access code
This commit is contained in:
parent
62f579fdbe
commit
8113f8df63
@ -1068,30 +1068,26 @@ public:
|
|||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
static QString getPythonPath() {
|
static QString getPythonPath() {
|
||||||
QIniSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QIniSettings::NativeFormat);
|
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QIniSettings::NativeFormat);
|
||||||
QStringList versions = reg_python.childGroups();
|
QStringList versions = reg_python.childGroups();
|
||||||
if(versions.isEmpty()) {
|
|
||||||
reg_python = QIniSettings("HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore", QIniSettings::NativeFormat);
|
|
||||||
versions = reg_python.childGroups();
|
|
||||||
}
|
|
||||||
qDebug("Python versions nb: %d", versions.size());
|
qDebug("Python versions nb: %d", versions.size());
|
||||||
versions = versions.filter(QRegExp("2\\..*"));
|
versions = versions.filter(QRegExp("2\\..*"));
|
||||||
versions.sort();
|
versions.sort();
|
||||||
while(!versions.empty()) {
|
while(!versions.empty()) {
|
||||||
const QString version = versions.takeLast();
|
const QString version = versions.takeLast();
|
||||||
qDebug("Detected possible Python v%s location", qPrintable(version));
|
qDebug("Detected possible Python v%s location", qPrintable(version));
|
||||||
QString path = reg_python.value(version+"\\InstallPath\\Default", "").toString().replace("/", "\\");
|
QString path = reg_python.value(version+"/InstallPath/Default", "").toString().replace("/", "\\");
|
||||||
if(!path.isEmpty() && QDir(path).exists("python.exe")) {
|
if(!path.isEmpty() && QDir(path).exists("python.exe")) {
|
||||||
qDebug("Found python.exe at %s", qPrintable(path));
|
qDebug("Found python.exe at %s", qPrintable(path));
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(QFile::exists("C:/Python26/python.exe")) {
|
if(QFile::exists("C:/Python26/python.exe")) {
|
||||||
reg_python.setValue("2.6\\InstallPath\\Default", "C:\\Python26");
|
reg_python.setValue("2.6/InstallPath/Default", "C:\\Python26");
|
||||||
return "C:\\Python26";
|
return "C:\\Python26";
|
||||||
}
|
}
|
||||||
if(QFile::exists("C:/Python25/python.exe")) {
|
if(QFile::exists("C:/Python25/python.exe")) {
|
||||||
reg_python.setValue("2.5\\InstallPath\\Default", "C:\\Python26");
|
reg_python.setValue("2.5/InstallPath/Default", "C:\\Python26");
|
||||||
return "C:\\Python25";
|
return "C:\\Python25";
|
||||||
}
|
}
|
||||||
return QString::null;
|
return QString::null;
|
||||||
@ -1108,13 +1104,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool isFileAssocOk() {
|
static bool isFileAssocOk() {
|
||||||
QIniSettings settings("HKEY_CLASSES_ROOT", QIniSettings::NativeFormat);
|
QSettings settings("HKEY_CLASSES_ROOT", QIniSettings::NativeFormat);
|
||||||
if(settings.value(".torrent\\Default").toString() != "qBittorrent" && settings.value(".torrent/Default").toString() != "qBittorrent") {
|
if(settings.value(".torrent/Default").toString() != "qBittorrent") {
|
||||||
qDebug(".torrent != qBittorrent");
|
qDebug(".torrent != qBittorrent");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qDebug("Checking shell command");
|
qDebug("Checking shell command");
|
||||||
QString shell_command = settings.value("qBittorrent\\shell\\open\\command\\Default", "").toString();
|
QString shell_command = settings.value("qBittorrent/shell/open/command/Default", "").toString();
|
||||||
qDebug("Shell command is: %s", qPrintable(shell_command));
|
qDebug("Shell command is: %s", qPrintable(shell_command));
|
||||||
QRegExp exe_reg("\"([^\"]+)\".*");
|
QRegExp exe_reg("\"([^\"]+)\".*");
|
||||||
if(exe_reg.indexIn(shell_command) < 0)
|
if(exe_reg.indexIn(shell_command) < 0)
|
||||||
@ -1123,8 +1119,12 @@ public:
|
|||||||
qDebug("exe: %s", qPrintable(assoc_exe));
|
qDebug("exe: %s", qPrintable(assoc_exe));
|
||||||
if(assoc_exe.compare(qApp->applicationFilePath().replace("/", "\\"), Qt::CaseInsensitive) != 0)
|
if(assoc_exe.compare(qApp->applicationFilePath().replace("/", "\\"), Qt::CaseInsensitive) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
// Icon
|
||||||
|
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
||||||
|
if(settings.value("qBittorrent/DefaultIcon/Default", icon_str).toString().compare(icon_str, Qt::CaseInsensitive) != 0)
|
||||||
|
return false;
|
||||||
// Check magnet link assoc
|
// Check magnet link assoc
|
||||||
shell_command = settings.value("Magnet\\shell\\open\\command\\Default", "").toString();
|
shell_command = settings.value("Magnet/shell/open/command/Default", "").toString();
|
||||||
if(exe_reg.indexIn(shell_command) < 0)
|
if(exe_reg.indexIn(shell_command) < 0)
|
||||||
return false;
|
return false;
|
||||||
assoc_exe = exe_reg.cap(1);
|
assoc_exe = exe_reg.cap(1);
|
||||||
@ -1135,23 +1135,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void setFileAssoc() {
|
static void setFileAssoc() {
|
||||||
QIniSettings settings("HKEY_CLASSES_ROOT", QIniSettings::NativeFormat);
|
QSettings settings("HKEY_CLASSES_ROOT", QSettings::NativeFormat);
|
||||||
// .Torrent association
|
// .Torrent association
|
||||||
settings.setValue(".torrent\\Default", "qBittorrent");
|
settings.setValue(".torrent/Default", "qBittorrent");
|
||||||
settings.setValue(".torrent\\Content Type", "application/x-bittorrent");
|
settings.setValue(".torrent/Content Type", "application/x-bittorrent");
|
||||||
settings.setValue("qBittorrent\\shell\\Default", "open");
|
settings.setValue("qBittorrent/shell/Default", "open");
|
||||||
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
|
const QString command_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\" \"%1\"";
|
||||||
settings.setValue("qBittorrent\\shell\\open\\command\\Default", command_str);
|
settings.setValue("qBittorrent/shell/open/command/Default", command_str);
|
||||||
settings.setValue("qBittorrent\\Content Type\\Default", "application/x-bittorrent");
|
settings.setValue("qBittorrent/Content Type/Default", "application/x-bittorrent");
|
||||||
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",0";
|
const QString icon_str = "\""+qApp->applicationFilePath().replace("/", "\\")+"\",1";
|
||||||
settings.setValue("qBittorrent\\DefaultIcon\\Default", icon_str);
|
settings.setValue("qBittorrent/DefaultIcon/Default", icon_str);
|
||||||
// Magnet association
|
// Magnet association
|
||||||
settings.setValue("Magnet\\Default", "Magnet URI");
|
settings.setValue("Magnet/Default", "Magnet URI");
|
||||||
settings.setValue("Magnet\\Content Type", "application/x-magnet");
|
settings.setValue("Magnet/Content Type", "application/x-magnet");
|
||||||
settings.setValue("Magnet\\URL Protocol", "");
|
settings.setValue("Magnet/URL Protocol", "");
|
||||||
settings.setValue("Magnet\\DefaultIcon\\Default", icon_str);
|
settings.setValue("Magnet/DefaultIcon\\Default", icon_str);
|
||||||
settings.setValue("Magnet\\shell\\Default", "open");
|
settings.setValue("Magnet/shell/Default", "open");
|
||||||
settings.setValue("Magnet\\shell\\open\\command\\Default", command_str);
|
settings.setValue("Magnet/shell/open/command/Default", command_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1 +1,2 @@
|
|||||||
IDI_ICON1 ICON DISCARDABLE "qbittorrent.ico"
|
IDI_ICON1 ICON DISCARDABLE "qbittorrent.ico"
|
||||||
|
IDI_ICON2 ICON DISCARDABLE "qbittorrent_file.ico"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user