Fix functions and macros using to support both Qt4 and Qt5.

This commit is contained in:
Vladimir Golovnev (Glassez)
2013-09-21 11:59:58 +04:00
committed by sledgehammer999
parent 763d8a392f
commit ce3aac5f9d
51 changed files with 260 additions and 181 deletions

View File

@@ -44,6 +44,7 @@
#include <QFileDialog>
#include <QDropEvent>
#include <QTemporaryFile>
#include <QMimeData>
enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
const QString UPDATE_URL = QString("https://raw.github.com/qbittorrent/qBittorrent/master/src/searchengine/") + (misc::pythonVersion() >= 3 ? "nova3" : "nova") + "/engines/";
@@ -76,7 +77,7 @@ engineSelectDlg::~engineSelectDlg() {
void engineSelectDlg::dropEvent(QDropEvent *event) {
event->acceptProposedAction();
QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n"));
QStringList files = event->mimeData()->text().split(QString::fromUtf8("\n"));
foreach (QString file, files) {
qDebug("dropped %s", qPrintable(file));
if (misc::isUrl(file)) {

View File

@@ -43,7 +43,7 @@
#include <QFileDialog>
#include <QDesktopServices>
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
#include <stdlib.h>
#endif
@@ -80,7 +80,7 @@ SearchEngine::SearchEngine(MainWindow* parent)
// Boolean initialization
search_stopped = false;
// Creating Search Process
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
has_python = addPythonPathToEnv();
#endif
searchProcess = new QProcess(this);
@@ -95,7 +95,7 @@ SearchEngine::SearchEngine(MainWindow* parent)
// Update nova.py search plugin if necessary
updateNova();
supported_engines = new SupportedEngines(
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
has_python
#endif
);
@@ -115,7 +115,7 @@ void SearchEngine::fillCatCombobox() {
}
}
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
bool SearchEngine::addPythonPathToEnv() {
QString python_path = Preferences::getPythonPath();
if (!python_path.isEmpty()) {
@@ -227,7 +227,7 @@ void SearchEngine::giveFocusToSearchInput() {
// Function called when we click on search button
void SearchEngine::on_search_button_clicked() {
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
if (!has_python) {
if (QMessageBox::question(this, tr("Missing Python Interpreter"),
tr("Python 2.x is required to use the search engine but it does not seem to be installed.\nDo you want to install it now?"),
@@ -239,7 +239,7 @@ void SearchEngine::on_search_button_clicked() {
}
#endif
if (searchProcess->state() != QProcess::NotRunning) {
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
searchProcess->kill();
#else
searchProcess->terminate();
@@ -492,7 +492,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
}
if (exitcode) {
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
search_status->setText(tr("Search aborted"));
#else
search_status->setText(tr("An error occurred during search..."));

View File

@@ -105,7 +105,7 @@ protected slots:
void downloadFinished(int exitcode, QProcess::ExitStatus);
void fillCatCombobox();
void searchTextEdited(QString);
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
bool addPythonPathToEnv();
void installPython();
void pythonDownloadSuccess(QString url, QString file_path);
@@ -130,7 +130,7 @@ private:
QList<QPointer<SearchTab> > all_tab; // To store all tabs
const SearchCategories full_cat_names;
MainWindow *mp_mainWindow;
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
bool has_python;
#endif
};