Log available network information backends in the error case

This commit is contained in:
Martchus 2024-02-17 02:06:38 +01:00
parent 00d3a8198a
commit 274a220c2c
1 changed files with 13 additions and 0 deletions

View File

@ -4,6 +4,8 @@
#include "../settings/settings.h"
#include <c++utilities/io/ansiescapecodes.h>
#include <QtConcurrentRun>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
@ -13,6 +15,7 @@
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <string_view>
@ -65,6 +68,16 @@ SyncthingLauncher::SyncthingLauncher(QObject *parent)
networkInformation && networkInformation->supports(QNetworkInformation::Feature::Metered)) {
connect(networkInformation, &QNetworkInformation::isMeteredChanged, this, [this](bool isMetered) { setNetworkConnectionMetered(isMetered); });
setNetworkConnectionMetered(networkInformation->isMetered());
} else {
std::cerr << EscapeCodes::Phrases::Error << "Unable to load network information backend to monitor metered connections, available backends:" << EscapeCodes::Phrases::End;
const auto availableBackends = QNetworkInformation::availableBackends();
if (availableBackends.isEmpty()) {
std::cerr << "none\n";
} else {
for (const auto &backend : availableBackends) {
std::cerr << " - " << backend.toStdString() << '\n';
}
}
}
#endif
}