Commit 0d0e34c5 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port QNetworkConfigurationManager

parent 1312394b
......@@ -1281,9 +1281,14 @@ GenericObserver::GenericObserver(QObject *parent)
m_save(nullptr),
m_finishAction(nullptr)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QNetworkInformation::load(QNetworkInformation::Feature::Reachability);
KGet::setHasNetworkConnection(QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online);
#else
//check if there is a connection
KGet::setHasNetworkConnection(m_networkConfig.isOnline());
#endif
connect(KGet::model(), &TransferTreeModel::groupRemovedEvent, this, &GenericObserver::groupRemovedEvent);
connect(KGet::model(), SIGNAL(transfersAddedEvent(QList<TransferHandler*>)),
SLOT(transfersAddedEvent(QList<TransferHandler*>)));
......@@ -1296,8 +1301,13 @@ GenericObserver::GenericObserver(QObject *parent)
SLOT(groupsChangedEvent(QMap<TransferGroupHandler*,TransferGroup::ChangesFlags>)));
connect(KGet::model(), &TransferTreeModel::transferMovedEvent,
this, &GenericObserver::transferMovedEvent);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(&m_networkConfig, &QNetworkConfigurationManager::onlineStateChanged,
this, &GenericObserver::slotNetworkStatusChanged);
#else
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, &GenericObserver::slotNetworkStatusChanged);
#endif
}
......@@ -1492,10 +1502,17 @@ void GenericObserver::slotNotificationClosed()
m_notifications.remove(notification);
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void GenericObserver::slotNetworkStatusChanged(bool online)
{
KGet::setHasNetworkConnection(online);
}
#else
void GenericObserver::slotNetworkStatusChanged(QNetworkInformation::Reachability reachability)
{
KGet::setHasNetworkConnection(reachability == QNetworkInformation::Reachability::Online);
}
#endif
void GenericObserver::groupsChangedEvent(QMap<TransferGroupHandler*, TransferGroup::ChangesFlags> groups)
{
......
......@@ -23,7 +23,11 @@
#include <KLocalizedString>
#include <KPluginFactory>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QNetworkConfigurationManager>
#else
#include <QNetworkInformation>
#endif
#include <QDomElement>
#include "kuiserverjobs.h"
......@@ -466,7 +470,7 @@ class GenericObserver : public QObject
{
Q_OBJECT
public:
GenericObserver(QObject *parent = nullptr);
explicit GenericObserver(QObject *parent = nullptr);
~GenericObserver () override;
public Q_SLOTS:
......@@ -484,7 +488,11 @@ class GenericObserver : public QObject
void slotAbortAfterFinishAction();
void slotResolveTransferError();
void slotNotificationClosed();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void slotNetworkStatusChanged(bool online);
#else
void slotNetworkStatusChanged(QNetworkInformation::Reachability reachability);
#endif
private:
bool allTransfersFinished();
......@@ -495,6 +503,8 @@ class GenericObserver : public QObject
QTimer *m_save;
QTimer *m_finishAction;
QHash<KNotification*, TransferHandler*> m_notifications;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QNetworkConfigurationManager m_networkConfig;
#endif
};
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment