diff --git a/include/core/network.h b/include/core/network.h index 321b3e99..23dc7eff 100644 --- a/include/core/network.h +++ b/include/core/network.h @@ -26,10 +26,14 @@ }); */ +#if __has_include() #include #include #include #include +#endif + +#ifdef QT_NETWORK_LIB class NetworkReplyData : public QObject { @@ -84,4 +88,6 @@ private: const QNetworkRequest getRequest(const QUrl &url); }; +#endif // QT_NETWORK_LIB + #endif // NETWORK_H diff --git a/include/mainwindow.h b/include/mainwindow.h index 77d05632..d15bde31 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -331,8 +331,11 @@ private: QPointer layoutListProxyModel = nullptr; QPointer layoutTreeModel = nullptr; +#ifdef QT_NETWORK_LIB QPointer updatePromoter = nullptr; QPointer networkAccessManager = nullptr; +#endif + QPointer aboutWindow = nullptr; QPointer wildMonChart = nullptr; QPointer wildMonSearch = nullptr; diff --git a/include/ui/updatepromoter.h b/include/ui/updatepromoter.h index de73bcdd..76157c4d 100644 --- a/include/ui/updatepromoter.h +++ b/include/ui/updatepromoter.h @@ -1,6 +1,8 @@ #ifndef UPDATEPROMOTER_H #define UPDATEPROMOTER_H +#ifdef QT_NETWORK_LIB + #include "network.h" #include @@ -47,4 +49,6 @@ signals: void changedPreferences(); }; +#endif // QT_NETWORK_LIB + #endif // UPDATEPROMOTER_H diff --git a/porymap.pro b/porymap.pro index 4777644f..50aa83e2 100644 --- a/porymap.pro +++ b/porymap.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui network +QT += core gui qtHaveModule(charts) { QT += charts @@ -16,6 +16,11 @@ qtHaveModule(qml) { } else { warning("Qt module 'qml' not found, disabling plug-in features.") } +qtHaveModule(network) { + QT += network +} else { + warning("Qt module 'network' not found, disabling network features.") +} greaterThan(QT_MAJOR_VERSION, 4): QT += widgets diff --git a/src/core/network.cpp b/src/core/network.cpp index 4f2a1c19..ce0d5124 100644 --- a/src/core/network.cpp +++ b/src/core/network.cpp @@ -1,3 +1,4 @@ +#ifdef QT_NETWORK_LIB #include "network.h" #include "config.h" @@ -148,3 +149,5 @@ void NetworkAccessManager::processReply(QNetworkReply * reply, NetworkReplyData cacheEntry->data = data->m_body = reply->readAll(); } + +#endif // QT_NETWORK_LIB diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 91d93df9..478ca878 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -51,9 +51,11 @@ // We only publish release binaries for Windows and macOS. // This is relevant for the update promoter, which alerts users of a new release. +#ifdef QT_NETWORK_LIB #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) #define RELEASE_PLATFORM #endif +#endif @@ -155,11 +157,14 @@ void MainWindow::initWindow() { this->initMapList(); this->initShortcuts(); + QStringList missingModules; + #ifndef RELEASE_PLATFORM ui->actionCheck_for_Updates->setVisible(false); #endif - - QStringList missingModules; +#ifndef QT_NETWORK_LIB + missingModules.append(" 'network'"); +#endif #ifndef QT_CHARTS_LIB ui->pushButton_SummaryChart->setVisible(false); @@ -2970,8 +2975,10 @@ void MainWindow::on_actionPreferences_triggered() { void MainWindow::togglePreferenceSpecificUi() { ui->actionOpen_Project_in_Text_Editor->setEnabled(!porymapConfig.textEditorOpenFolder.isEmpty()); +#ifdef QT_NETWORK_LIB if (this->updatePromoter) this->updatePromoter->updatePreferences(); +#endif } void MainWindow::openProjectSettingsEditor(int tab) { diff --git a/src/ui/updatepromoter.cpp b/src/ui/updatepromoter.cpp index 8afc8d9c..4b66fbff 100644 --- a/src/ui/updatepromoter.cpp +++ b/src/ui/updatepromoter.cpp @@ -1,3 +1,4 @@ +#ifdef QT_NETWORK_LIB #include "updatepromoter.h" #include "ui_updatepromoter.h" #include "log.h" @@ -188,3 +189,5 @@ void UpdatePromoter::dialogButtonClicked(QAbstractButton *button) { QDesktopServices::openUrl(this->downloadUrl); } } + +#endif // QT_NETWORK_LIB