Skip to content

Commit

Permalink
allow building app without network module
Browse files Browse the repository at this point in the history
  • Loading branch information
kambala-decapitator committed Nov 9, 2024
1 parent d07de88 commit d2cb020
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion QTblEditor.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
6 changes: 6 additions & 0 deletions src/qtbleditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#endif
#endif

#ifndef NO_NETWORK
#include <QNetworkReply>
#endif

#ifndef QT_NO_DEBUG
#include <QDebug>
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d2cb020

Please sign in to comment.