diff --git a/src/app/application.cpp b/src/app/application.cpp index 127aaab28..c87a430e2 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -357,7 +357,7 @@ void Application::initializeTranslation() } if (m_qtTranslator.load( -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 QString::fromUtf8("qtbase_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) || m_qtTranslator.load( #endif diff --git a/src/app/main.cpp b/src/app/main.cpp index e14bff9cb..9bfe0d6ee 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -42,7 +42,7 @@ #include #ifdef QBT_STATIC_QT #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 Q_IMPORT_PLUGIN(QICOPlugin) #else Q_IMPORT_PLUGIN(qico) diff --git a/src/core/http/requestparser.cpp b/src/core/http/requestparser.cpp index ba083d2bf..eb26dbc5c 100644 --- a/src/core/http/requestparser.cpp +++ b/src/core/http/requestparser.cpp @@ -31,7 +31,7 @@ #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #endif #include @@ -117,7 +117,7 @@ bool RequestParser::parseStartingLine(const QString &line) m_request.path = url.path(); // Path // Parse GET parameters -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 QListIterator > i(url.queryItems()); #else QListIterator > i(QUrlQuery(url).queryItems()); @@ -216,7 +216,7 @@ bool RequestParser::parseContent(const QByteArray& data) // Parse url-encoded POST data if (m_request.headers["content-type"].startsWith("application/x-www-form-urlencoded")) { QUrl url; -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 url.setEncodedQuery(data); QListIterator > i(url.queryItems()); #else diff --git a/src/core/http/server.cpp b/src/core/http/server.cpp index f9f58e10c..0895b5f57 100644 --- a/src/core/http/server.cpp +++ b/src/core/http/server.cpp @@ -67,7 +67,7 @@ void Server::disableHttps() } #endif -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 void Server::incomingConnection(qintptr socketDescriptor) #else void Server::incomingConnection(int socketDescriptor) diff --git a/src/core/http/server.h b/src/core/http/server.h index 87d62fe92..64920e2e8 100644 --- a/src/core/http/server.h +++ b/src/core/http/server.h @@ -59,7 +59,7 @@ namespace Http #endif private: - #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + #ifdef QBT_USES_QT5 void incomingConnection(qintptr socketDescriptor); #else void incomingConnection(int socketDescriptor); diff --git a/src/core/net/dnsupdater.cpp b/src/core/net/dnsupdater.cpp index 0a410e66e..97dde9f30 100644 --- a/src/core/net/dnsupdater.cpp +++ b/src/core/net/dnsupdater.cpp @@ -32,7 +32,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #endif @@ -160,7 +160,7 @@ QUrl DNSUpdater::getUpdateUrl() const } url.setPath("/nic/update"); -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 url.addQueryItem("hostname", m_domain); url.addQueryItem("myip", m_lastIP.toString()); #else diff --git a/src/core/net/private/geoipdatabase.cpp b/src/core/net/private/geoipdatabase.cpp index 3c8ed6cce..6eaa5728e 100644 --- a/src/core/net/private/geoipdatabase.cpp +++ b/src/core/net/private/geoipdatabase.cpp @@ -66,7 +66,7 @@ namespace Float = 15 }; -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 Q_IPV6ADDR createMappedAddress(quint32 ip4); #endif } @@ -166,7 +166,7 @@ QDateTime GeoIPDatabase::buildEpoch() const QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const { -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 Q_IPV6ADDR addr = hostAddr.protocol() == QAbstractSocket::IPv4Protocol ? createMappedAddress(hostAddr.toIPv4Address()) : hostAddr.toIPv6Address(); @@ -499,7 +499,7 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, quint32 count) const namespace { -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 Q_IPV6ADDR createMappedAddress(quint32 ip4) { Q_IPV6ADDR ip6; diff --git a/src/core/preferences.cpp b/src/core/preferences.cpp index 91cb2daf7..08c6e5c36 100644 --- a/src/core/preferences.cpp +++ b/src/core/preferences.cpp @@ -1976,7 +1976,7 @@ void Preferences::setTrayIconStyle(TrayIcon::Style style) // in the same file. QByteArray Preferences::getAddNewTorrentDialogState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("AddNewTorrentDialog/qt5/treeHeaderState").toByteArray(); #else return value("AddNewTorrentDialog/treeHeaderState").toByteArray(); @@ -1985,7 +1985,7 @@ QByteArray Preferences::getAddNewTorrentDialogState() const void Preferences::setAddNewTorrentDialogState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("AddNewTorrentDialog/qt5/treeHeaderState", state); #else setValue("AddNewTorrentDialog/treeHeaderState", state); @@ -2074,7 +2074,7 @@ void Preferences::setMainGeometry(const QByteArray &geometry) QByteArray Preferences::getMainVSplitterState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("MainWindow/qt5/vsplitterState").toByteArray(); #else return value("MainWindow/vsplitterState").toByteArray(); @@ -2083,7 +2083,7 @@ QByteArray Preferences::getMainVSplitterState() const void Preferences::setMainVSplitterState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("MainWindow/qt5/vsplitterState", state); #else setValue("MainWindow/vsplitterState", state); @@ -2134,7 +2134,7 @@ void Preferences::setPrefHSplitterSizes(const QStringList &sizes) QByteArray Preferences::getPeerListState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("TorrentProperties/Peers/qt5/PeerListState").toByteArray(); #else return value("TorrentProperties/Peers/PeerListState").toByteArray(); @@ -2143,7 +2143,7 @@ QByteArray Preferences::getPeerListState() const void Preferences::setPeerListState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("TorrentProperties/Peers/qt5/PeerListState", state); #else setValue("TorrentProperties/Peers/PeerListState", state); @@ -2162,7 +2162,7 @@ void Preferences::setPropSplitterSizes(const QString &sizes) QByteArray Preferences::getPropFileListState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("TorrentProperties/qt5/FilesListState").toByteArray(); #else return value("TorrentProperties/FilesListState").toByteArray(); @@ -2171,7 +2171,7 @@ QByteArray Preferences::getPropFileListState() const void Preferences::setPropFileListState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("TorrentProperties/qt5/FilesListState", state); #else setValue("TorrentProperties/FilesListState", state); @@ -2200,7 +2200,7 @@ void Preferences::setPropVisible(const bool visible) QByteArray Preferences::getPropTrackerListState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("TorrentProperties/Trackers/qt5/TrackerListState").toByteArray(); #else return value("TorrentProperties/Trackers/TrackerListState").toByteArray(); @@ -2209,7 +2209,7 @@ QByteArray Preferences::getPropTrackerListState() const void Preferences::setPropTrackerListState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("TorrentProperties/Trackers/qt5/TrackerListState", state); #else setValue("TorrentProperties/Trackers/TrackerListState", state); @@ -2228,7 +2228,7 @@ void Preferences::setRssGeometry(const QByteArray &geometry) QByteArray Preferences::getRssHSplitterSizes() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("RssFeedDownloader/qt5/hsplitterSizes").toByteArray(); #else return value("RssFeedDownloader/hsplitterSizes").toByteArray(); @@ -2237,7 +2237,7 @@ QByteArray Preferences::getRssHSplitterSizes() const void Preferences::setRssHSplitterSizes(const QByteArray &sizes) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes); #else setValue("RssFeedDownloader/hsplitterSizes", sizes); @@ -2256,7 +2256,7 @@ void Preferences::setRssOpenFolders(const QStringList &folders) QByteArray Preferences::getRssHSplitterState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("Rss/qt5/splitter_h").toByteArray(); #else return value("Rss/splitter_h").toByteArray(); @@ -2265,7 +2265,7 @@ QByteArray Preferences::getRssHSplitterState() const void Preferences::setRssHSplitterState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("Rss/qt5/splitter_h", state); #else setValue("Rss/splitter_h", state); @@ -2274,7 +2274,7 @@ void Preferences::setRssHSplitterState(const QByteArray &state) QByteArray Preferences::getRssVSplitterState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("Rss/qt5/splitter_v").toByteArray(); #else return value("Rss/splitter_v").toByteArray(); @@ -2283,7 +2283,7 @@ QByteArray Preferences::getRssVSplitterState() const void Preferences::setRssVSplitterState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("Rss/qt5/splitter_v", state); #else setValue("Rss/splitter_v", state); @@ -2422,7 +2422,7 @@ void Preferences::setTransSelFilter(const int &index) QByteArray Preferences::getTransHeaderState() const { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 return value("TransferList/qt5/HeaderState").toByteArray(); #else return value("TransferList/HeaderState").toByteArray(); @@ -2431,7 +2431,7 @@ QByteArray Preferences::getTransHeaderState() const void Preferences::setTransHeaderState(const QByteArray &state) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 setValue("TransferList/qt5/HeaderState", state); #else setValue("TransferList/HeaderState", state); diff --git a/src/core/utils/fs.cpp b/src/core/utils/fs.cpp index 30728d501..da5349511 100644 --- a/src/core/utils/fs.cpp +++ b/src/core/utils/fs.cpp @@ -55,7 +55,7 @@ #include #endif -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 #ifndef DISABLE_GUI #include @@ -182,7 +182,7 @@ bool Utils::Fs::forceRemove(const QString& file_path) */ void Utils::Fs::removeDirRecursive(const QString& dirName) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 QDir(dirName).removeRecursively(); #else QDir dir(dirName); @@ -439,7 +439,7 @@ QString Utils::Fs::QDesktopServicesCacheLocation() QString Utils::Fs::QDesktopServicesDownloadLocation() { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #if defined(Q_OS_WIN) if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath( diff --git a/src/gui/ico.cpp b/src/gui/ico.cpp index a2184e626..1d4c43b33 100644 --- a/src/gui/ico.cpp +++ b/src/gui/ico.cpp @@ -424,7 +424,7 @@ bool ICOHandler::canRead(QIODevice *device) class ICOPlugin : public QImageIOPlugin { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 Q_PLUGIN_METADATA(IID "org.qbittorrent.ICOPlugin") #endif public: @@ -461,7 +461,7 @@ QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format) return handler; } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 Q_EXPORT_STATIC_PLUGIN(ICOPlugin) Q_EXPORT_PLUGIN2(ico, ICOPlugin) #endif diff --git a/src/gui/lineedit/src/lineedit.cpp b/src/gui/lineedit/src/lineedit.cpp index 78dc6870c..0335944bf 100644 --- a/src/gui/lineedit/src/lineedit.cpp +++ b/src/gui/lineedit/src/lineedit.cpp @@ -27,7 +27,7 @@ LineEdit::LineEdit(QWidget *parent) int clearButtonSizeHintWidth = 0; int clearButtonSizeHintHeight = 0; -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 QPixmap pixmap2(":/lineeditimages/clear_left.png"); clearButton = new QToolButton(this); clearButton->setIcon(QIcon(pixmap2)); @@ -58,13 +58,13 @@ void LineEdit::resizeEvent(QResizeEvent *e) QSize sz = searchButton->sizeHint(); searchButton->move(frameWidth, (e->size().height() - sz.height()) / 2); -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 QSize cz = clearButton->sizeHint(); clearButton->move((e->size().width() - frameWidth - cz.width()), (e->size().height() - sz.height()) / 2); #endif } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 void LineEdit::updateCloseButton(const QString &text) { clearButton->setVisible(!text.isEmpty()); diff --git a/src/gui/lineedit/src/lineedit.h b/src/gui/lineedit/src/lineedit.h index 84e0d5cf4..6b39d9088 100644 --- a/src/gui/lineedit/src/lineedit.h +++ b/src/gui/lineedit/src/lineedit.h @@ -24,14 +24,14 @@ public: protected: void resizeEvent(QResizeEvent *e); -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 private slots: void updateCloseButton(const QString &text); #endif private: QToolButton *searchButton; -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 QToolButton *clearButton; #endif }; diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index a3d2dc705..c1b6b1e03 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -90,7 +90,7 @@ options_imp::options_imp(QWidget *parent) } } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 scanFoldersView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); #else scanFoldersView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); diff --git a/src/gui/previewlistdelegate.h b/src/gui/previewlistdelegate.h index 10849be2d..0330c045a 100644 --- a/src/gui/previewlistdelegate.h +++ b/src/gui/previewlistdelegate.h @@ -42,7 +42,7 @@ #include "previewselect.h" #ifdef Q_OS_WIN -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 #include #else #include @@ -80,7 +80,7 @@ class PreviewListDelegate: public QItemDelegate { QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); #else // XXX: To avoid having the progress text on the right of the bar -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 QPlastiqueStyle st; #else QProxyStyle st("fusion"); diff --git a/src/gui/previewselect.cpp b/src/gui/previewselect.cpp index 11f937ab4..f37fe3654 100644 --- a/src/gui/previewselect.cpp +++ b/src/gui/previewselect.cpp @@ -32,7 +32,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #endif @@ -54,7 +54,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name")); previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size")); previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress")); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 QTableView unused; diff --git a/src/gui/properties/peersadditiondlg.cpp b/src/gui/properties/peersadditiondlg.cpp index 172c8d671..77444935a 100644 --- a/src/gui/properties/peersadditiondlg.cpp +++ b/src/gui/properties/peersadditiondlg.cpp @@ -39,7 +39,7 @@ PeersAdditionDlg::PeersAdditionDlg(QWidget *parent) setupUi(this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput())); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 label_format->hide(); peers_txt->setPlaceholderText("Format: IPv4:port / [IPv6]:port"); #endif diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index e03c1cc79..b3f2cefb5 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -100,7 +100,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra connect(filesList->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); connect(filesList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#ifdef QBT_USES_QT5 // set bar height relative to screen dpi int barHeight = devicePixelRatio() * 18; #else diff --git a/src/gui/properties/proplistdelegate.cpp b/src/gui/properties/proplistdelegate.cpp index dbd18ecda..5afd028a7 100644 --- a/src/gui/properties/proplistdelegate.cpp +++ b/src/gui/properties/proplistdelegate.cpp @@ -38,7 +38,7 @@ #include #ifdef Q_OS_WIN -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 #include #else #include @@ -82,7 +82,7 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); #else // XXX: To avoid having the progress text on the right of the bar -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 QPlastiqueStyle st; #else QProxyStyle st("fusion"); diff --git a/src/gui/properties/trackerlist.cpp b/src/gui/properties/trackerlist.cpp index 2c0548637..fb9bf8d91 100644 --- a/src/gui/properties/trackerlist.cpp +++ b/src/gui/properties/trackerlist.cpp @@ -37,7 +37,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #include #endif @@ -85,7 +85,7 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie deleteHotkey = new QShortcut(QKeySequence(QKeySequence::Delete), this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut); copyHotkey = new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_C), this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 QTableView unused; diff --git a/src/gui/torrentcontenttreeview.cpp b/src/gui/torrentcontenttreeview.cpp index 1427866f2..9c0ce06a8 100644 --- a/src/gui/torrentcontenttreeview.cpp +++ b/src/gui/torrentcontenttreeview.cpp @@ -32,7 +32,7 @@ #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #include #endif @@ -42,7 +42,7 @@ TorrentContentTreeView::TorrentContentTreeView(QWidget* parent) : QTreeView(parent) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 QTableView unused; diff --git a/src/gui/transferlistdelegate.cpp b/src/gui/transferlistdelegate.cpp index 06ec193f2..099cc3170 100644 --- a/src/gui/transferlistdelegate.cpp +++ b/src/gui/transferlistdelegate.cpp @@ -42,7 +42,7 @@ #include "core/unicodestrings.h" #ifdef Q_OS_WIN -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 #include #else #include @@ -214,7 +214,7 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); #else // XXX: To avoid having the progress text on the right of the bar -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 QPlastiqueStyle st; #else QProxyStyle st("fusion"); diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 909ba7cd8..1a6524467 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -40,7 +40,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #endif @@ -156,7 +156,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window) editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut); deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTorrents()), 0, Qt::WidgetShortcut); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 QTableView unused; diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index 1afbadf6e..4e16e81e8 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -47,7 +47,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #endif @@ -60,7 +60,7 @@ engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_en { setupUi(this); setAttribute(Qt::WA_DeleteOnClose); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 QTableView unused; diff --git a/src/searchengine/searchtab.cpp b/src/searchengine/searchtab.cpp index 8eeea89da..3d1ce051c 100644 --- a/src/searchengine/searchtab.cpp +++ b/src/searchengine/searchtab.cpp @@ -33,7 +33,7 @@ #include #include #include -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 #include #endif @@ -48,7 +48,7 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent) box = new QVBoxLayout(); results_lbl = new QLabel(); resultsBrowser = new QTreeView(); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 QTableView unused; diff --git a/src/src.pro b/src/src.pro index 059dce5df..95d19914c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -5,6 +5,7 @@ CONFIG += qt thread silent # C++11 support CONFIG += c++11 DEFINES += BOOST_NO_CXX11_RVALUE_REFERENCES +greaterThan(QT_MAJOR_VERSION, 4): DEFINES += QBT_USES_QT5 # Windows specific configuration win32: include(../winconf.pri) diff --git a/src/webui/abstractwebapplication.cpp b/src/webui/abstractwebapplication.cpp index 34323573a..2824780a5 100644 --- a/src/webui/abstractwebapplication.cpp +++ b/src/webui/abstractwebapplication.cpp @@ -260,7 +260,7 @@ void AbstractWebApplication::translateDocument(QString& data) if (isTranslationNeeded) { size_t context_index = 0; while ((context_index < context_count) && (translation == word)) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#ifndef QBT_USES_QT5 translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1); #else translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1); diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index cf20fb223..342683709 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -41,7 +41,7 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#ifndef QBT_USES_QT5 #include #endif #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) @@ -188,7 +188,7 @@ public: QTorrentCompare(QString key, bool greaterThan = false) : key_(key) , greaterThan_(greaterThan) -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#ifndef QBT_USES_QT5 , type_(QVariant::Invalid) #endif { @@ -196,7 +196,7 @@ public: bool operator()(QVariant torrent1, QVariant torrent2) { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#ifndef QBT_USES_QT5 if (type_ == QVariant::Invalid) type_ = torrent1.toMap().value(key_).type(); @@ -229,7 +229,7 @@ public: private: QString key_; bool greaterThan_; -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#ifndef QBT_USES_QT5 QVariant::Type type_; #endif }; @@ -793,7 +793,7 @@ QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantM lastAcceptedData.clear(); syncData = data; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) +#if (QBT_USES_QT5 && QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) // QJsonDocument::fromVariant() supports QVariantHash only // since Qt5.5, so manually convert data["torrents"] QVariantMap torrentsMap; diff --git a/src/webui/jsonutils.h b/src/webui/jsonutils.h index 55288278e..a8375c3b7 100644 --- a/src/webui/jsonutils.h +++ b/src/webui/jsonutils.h @@ -30,7 +30,7 @@ #define JSONUTILS_H #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#ifdef QBT_USES_QT5 #include #include #include @@ -49,7 +49,7 @@ namespace json { inline QByteArray toJson(const QVariant& var) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#ifdef QBT_USES_QT5 return QJsonDocument::fromVariant(var).toJson(QJsonDocument::Compact); #else QJson::Serializer serializer; @@ -60,7 +60,7 @@ namespace json { inline QVariant fromJson(const QString& json) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#ifdef QBT_USES_QT5 return QJsonDocument::fromJson(json.toUtf8()).toVariant(); #else return QJson::Parser().parse(json.toUtf8());