|
|
@ -257,8 +257,8 @@ void Preferences::setWinStartup(bool b) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); |
|
|
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); |
|
|
|
if (b) { |
|
|
|
if (b) { |
|
|
|
const QString bin_path = "\"" + Utils::Fs::toNativePath(qApp->applicationFilePath()) + "\""; |
|
|
|
const QString binPath = "\"" + Utils::Fs::toNativePath(qApp->applicationFilePath()) + "\""; |
|
|
|
settings.setValue("qBittorrent", bin_path); |
|
|
|
settings.setValue("qBittorrent", binPath); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
settings.remove("qBittorrent"); |
|
|
|
settings.remove("qBittorrent"); |
|
|
@ -555,24 +555,24 @@ void Preferences::setWebUiUsername(const QString &username) |
|
|
|
|
|
|
|
|
|
|
|
QString Preferences::getWebUiPassword() const |
|
|
|
QString Preferences::getWebUiPassword() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString pass_ha1 = value("Preferences/WebUI/Password_ha1").toString(); |
|
|
|
QString passHa1 = value("Preferences/WebUI/Password_ha1").toString(); |
|
|
|
if (pass_ha1.isEmpty()) { |
|
|
|
if (passHa1.isEmpty()) { |
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5); |
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5); |
|
|
|
md5.addData("adminadmin"); |
|
|
|
md5.addData("adminadmin"); |
|
|
|
pass_ha1 = md5.result().toHex(); |
|
|
|
passHa1 = md5.result().toHex(); |
|
|
|
} |
|
|
|
} |
|
|
|
return pass_ha1; |
|
|
|
return passHa1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Preferences::setWebUiPassword(const QString &new_password) |
|
|
|
void Preferences::setWebUiPassword(const QString &newPassword) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Do not overwrite current password with its hash
|
|
|
|
// Do not overwrite current password with its hash
|
|
|
|
if (new_password == getWebUiPassword()) |
|
|
|
if (newPassword == getWebUiPassword()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// Encode to md5 and save
|
|
|
|
// Encode to md5 and save
|
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5); |
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5); |
|
|
|
md5.addData(new_password.toLocal8Bit()); |
|
|
|
md5.addData(newPassword.toLocal8Bit()); |
|
|
|
|
|
|
|
|
|
|
|
setValue("Preferences/WebUI/Password_ha1", md5.result().toHex()); |
|
|
|
setValue("Preferences/WebUI/Password_ha1", md5.result().toHex()); |
|
|
|
} |
|
|
|
} |
|
|
@ -1041,9 +1041,9 @@ void Preferences::setTorrentFileAssoc(bool set) |
|
|
|
|
|
|
|
|
|
|
|
// .Torrent association
|
|
|
|
// .Torrent association
|
|
|
|
if (set) { |
|
|
|
if (set) { |
|
|
|
QString old_progid = settings.value(".torrent/Default").toString(); |
|
|
|
QString oldProgId = settings.value(".torrent/Default").toString(); |
|
|
|
if (!old_progid.isEmpty() && (old_progid != "qBittorrent")) |
|
|
|
if (!oldProgId.isEmpty() && (oldProgId != "qBittorrent")) |
|
|
|
settings.setValue(".torrent/OpenWithProgids/" + old_progid, ""); |
|
|
|
settings.setValue(".torrent/OpenWithProgids/" + oldProgId, ""); |
|
|
|
settings.setValue(".torrent/Default", "qBittorrent"); |
|
|
|
settings.setValue(".torrent/Default", "qBittorrent"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (isTorrentFileAssocSet()) { |
|
|
|
else if (isTorrentFileAssocSet()) { |
|
|
@ -1059,15 +1059,15 @@ void Preferences::setMagnetLinkAssoc(bool set) |
|
|
|
|
|
|
|
|
|
|
|
// Magnet association
|
|
|
|
// Magnet association
|
|
|
|
if (set) { |
|
|
|
if (set) { |
|
|
|
const QString command_str = "\"" + qApp->applicationFilePath() + "\" \"%1\""; |
|
|
|
const QString commandStr = "\"" + qApp->applicationFilePath() + "\" \"%1\""; |
|
|
|
const QString icon_str = "\"" + qApp->applicationFilePath() + "\",1"; |
|
|
|
const QString iconStr = "\"" + qApp->applicationFilePath() + "\",1"; |
|
|
|
|
|
|
|
|
|
|
|
settings.setValue("magnet/Default", "URL:Magnet link"); |
|
|
|
settings.setValue("magnet/Default", "URL:Magnet link"); |
|
|
|
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", Utils::Fs::toNativePath(icon_str)); |
|
|
|
settings.setValue("magnet/DefaultIcon/Default", Utils::Fs::toNativePath(iconStr)); |
|
|
|
settings.setValue("magnet/shell/Default", "open"); |
|
|
|
settings.setValue("magnet/shell/Default", "open"); |
|
|
|
settings.setValue("magnet/shell/open/command/Default", Utils::Fs::toNativePath(command_str)); |
|
|
|
settings.setValue("magnet/shell/open/command/Default", Utils::Fs::toNativePath(commandStr)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (isMagnetLinkAssocSet()) { |
|
|
|
else if (isMagnetLinkAssocSet()) { |
|
|
|
settings.remove("magnet"); |
|
|
|
settings.remove("magnet"); |
|
|
|