mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 08:43:08 -07:00
Improve Python detection
This commit is contained in:
parent
7c7bb14a93
commit
38a6f4cc34
2 changed files with 52 additions and 98 deletions
|
@ -1377,36 +1377,13 @@ void MainWindow::on_actionSearch_engine_triggered()
|
|||
|
||||
bool res = false;
|
||||
|
||||
if (pythonVersion == 2) {
|
||||
// Check if python 2.7.x or later
|
||||
QString version = Utils::Misc::pythonVersionComplete().trimmed();
|
||||
if ((pythonVersion == 2) || (pythonVersion == 3)) {
|
||||
// Check python minimum requirement: 2.7.0/3.3.0
|
||||
QString version = Utils::Misc::pythonVersionComplete();
|
||||
QStringList splitted = version.split('.');
|
||||
if (splitted.size() > 1) {
|
||||
int middleVer = splitted.at(1).toInt();
|
||||
if (middleVer < 7) {
|
||||
QMessageBox::information(this, tr("Old Python Interpreter"), tr("Your Python version is %1, which is too old. You need at least version 2.7.0 for python2 or 3.3.0 for python3.").arg(version));
|
||||
actionSearch_engine->setChecked(false);
|
||||
Preferences::instance()->setSearchEnabled(false);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox::information(this, tr("Undetermined Python version"), tr("Couldn't decode your Python version: %1").arg(version));
|
||||
actionSearch_engine->setChecked(false);
|
||||
Preferences::instance()->setSearchEnabled(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (pythonVersion == 3) {
|
||||
// Check if python 3.3.x or later
|
||||
QString version = Utils::Misc::pythonVersionComplete().trimmed();
|
||||
QStringList splitted = version.split('.');
|
||||
if (splitted.size() > 1) {
|
||||
int middleVer = splitted.at(1).toInt();
|
||||
if (middleVer < 3) {
|
||||
if ((pythonVersion == 2 && middleVer < 7) || (pythonVersion == 3 && middleVer < 3)) {
|
||||
QMessageBox::information(this, tr("Old Python Interpreter"), tr("Your Python version %1 is outdated. Please upgrade to latest version for search engines to work. Minimum requirement: 2.7.0/3.3.0.").arg(version));
|
||||
actionSearch_engine->setChecked(false);
|
||||
Preferences::instance()->setSearchEnabled(false);
|
||||
|
@ -1423,9 +1400,6 @@ void MainWindow::on_actionSearch_engine_triggered()
|
|||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = false;
|
||||
}
|
||||
|
||||
if (res) {
|
||||
has_python = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue