From d2cb020a1be7307d1f9808f8bf851454b3ec2275 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 9 Nov 2024 11:23:34 +0300 Subject: [PATCH] allow building app without network module --- QTblEditor.pro | 3 ++- README.md | 2 ++ src/qtbleditor.cpp | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/QTblEditor.pro b/QTblEditor.pro index bd50c01..100da95 100644 --- a/QTblEditor.pro +++ b/QTblEditor.pro @@ -5,7 +5,8 @@ TEMPLATE = app TARGET = QTblEditor -QT += network +CONFIG(NO_NETWORK): DEFINES += NO_NETWORK +else: QT += network greaterThan(QT_MAJOR_VERSION, 4): { DEFINES += IS_QT5 diff --git a/README.md b/README.md index dc3d5bc..c796cd1 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,5 @@ http://d2mods.info/forum/viewtopic.php?f=7&t=57015 The project can be built with [Qt](https://www.qt.io/) 4 and later, code conforms to C++03 standard. Visual Studio project can be used to build with Qt 5 and later. + +To build without Qt network module, pass `CONFIG+=NO_NETWORK` to `qmake`. diff --git a/src/qtbleditor.cpp b/src/qtbleditor.cpp index 5d41540..29627ce 100644 --- a/src/qtbleditor.cpp +++ b/src/qtbleditor.cpp @@ -32,7 +32,9 @@ #endif #endif +#ifndef NO_NETWORK #include +#endif #ifndef QT_NO_DEBUG #include @@ -346,6 +348,9 @@ void QTblEditor::reopen() void QTblEditor::sendToServer() { +#ifdef NO_NETWORK + QMessageBox::critical(this, QString(), "App was built without network module"); +#else QSettings settings; QString url = settings.value("serverUrl").toString(); if (url.isEmpty()) @@ -377,6 +382,7 @@ void QTblEditor::sendToServer() else QMessageBox::information(this, tr("Success"), tr("Response:") + "\n" + reply->readAll()); reply->deleteLater(); +#endif } bool QTblEditor::loadFile(const QString &fileName, bool shouldShowOpenOptions)