Move related functions to Utils::Python

This commit is contained in:
Chocobo1
2018-06-19 20:04:54 +08:00
committed by sledgehammer999
parent bfad14d552
commit 54f080b755
11 changed files with 198 additions and 116 deletions

View File

@@ -66,6 +66,7 @@
#include "base/rss/rss_folder.h"
#include "base/rss/rss_session.h"
#include "base/settingsstorage.h"
#include "base/utils/foreignapps.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "aboutdialog.h"
@@ -1742,7 +1743,7 @@ void MainWindow::on_actionRSSReader_triggered()
void MainWindow::on_actionSearchWidget_triggered()
{
if (!m_hasPython && m_ui->actionSearchWidget->isChecked()) {
int pythonVersion = Utils::Misc::pythonVersion();
int pythonVersion = Utils::ForeignApps::Python::pythonVersion();
// Check if python is already in PATH
if (pythonVersion > 0)
@@ -1751,14 +1752,14 @@ void MainWindow::on_actionSearchWidget_triggered()
.arg("PATH", qgetenv("PATH").constData()), Log::INFO);
#ifdef Q_OS_WIN
else if (addPythonPathToEnv())
pythonVersion = Utils::Misc::pythonVersion();
pythonVersion = Utils::ForeignApps::Python::pythonVersion();
#endif
bool res = false;
if ((pythonVersion == 2) || (pythonVersion == 3)) {
// Check Python minimum requirement: 2.7.9 / 3.3.0
QString version = Utils::Misc::pythonVersionComplete();
QString version = Utils::ForeignApps::Python::pythonVersionComplete();
QStringList splitted = version.split('.');
if (splitted.size() > 2) {
int middleVer = splitted.at(1).toInt();
@@ -2085,7 +2086,7 @@ void MainWindow::pythonDownloadSuccess(const QString &url, const QString &filePa
m_hasPython = addPythonPathToEnv();
if (m_hasPython) {
// Make it print the version to Log
Utils::Misc::pythonVersion();
Utils::ForeignApps::Python::pythonVersion();
m_ui->actionSearchWidget->setChecked(true);
displaySearchTab(true);
}

View File

@@ -56,8 +56,8 @@
#include "base/preferences.h"
#include "base/search/searchpluginmanager.h"
#include "base/search/searchhandler.h"
#include "base/utils/foreignapps.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "addnewtorrentdialog.h"
#include "guiiconprovider.h"
#include "mainwindow.h"
@@ -285,7 +285,7 @@ void SearchWidget::giveFocusToSearchInput()
// Function called when we click on search button
void SearchWidget::on_searchButton_clicked()
{
if (Utils::Misc::pythonVersion() < 0) {
if (Utils::ForeignApps::Python::pythonVersion() < 0) {
m_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Please install Python to use the Search Engine."));
return;
}