Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Workspace
Commits
3628ef1d
Commit
3628ef1d
authored
Mar 06, 2022
by
Volker Krause
Committed by
Nicolás Alvarez
Mar 26, 2022
Browse files
Port network online detection for Qt6
QNetworkConfigurationManager has been replaced by QNetworkInformation.
parent
65ef293c
Pipeline
#155123
passed with stage
in 5 minutes and 48 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
dataengines/weather/weatherengine.cpp
View file @
3628ef1d
...
...
@@ -25,7 +25,12 @@ WeatherEngine::WeatherEngine(QObject *parent, const QVariantList &args)
// Globally notify all plugins to remove their sources (and unload plugin)
connect
(
this
,
&
Plasma
::
DataEngine
::
sourceRemoved
,
this
,
&
WeatherEngine
::
removeIonSource
);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect
(
&
m_networkConfigurationManager
,
&
QNetworkConfigurationManager
::
onlineStateChanged
,
this
,
&
WeatherEngine
::
onOnlineStateChanged
);
#else
QNetworkInformation
::
load
(
QNetworkInformation
::
Feature
::
Reachability
);
connect
(
QNetworkInformation
::
instance
(),
&
QNetworkInformation
::
reachabilityChanged
,
this
,
&
WeatherEngine
::
onOnlineStateChanged
);
#endif
// Get the list of available plugins but don't load them
connect
(
KSycoca
::
self
(),
&
KSycoca
::
databaseChanged
,
this
,
&
WeatherEngine
::
updateIonList
);
...
...
@@ -117,8 +122,13 @@ bool WeatherEngine::sourceRequestEvent(const QString &source)
// is down. when it comes up again, then it will be refreshed
ion
->
connectSource
(
source
,
this
);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qCDebug
(
WEATHER
)
<<
"sourceRequestEvent(): Network is: "
<<
m_networkConfigurationManager
.
isOnline
();
if
(
!
m_networkConfigurationManager
.
isOnline
())
{
#else
qCDebug
(
WEATHER
)
<<
"sourceRequestEvent(): Network is: "
<<
QNetworkInformation
::
instance
()
->
reachability
();
if
(
QNetworkInformation
::
instance
()
->
reachability
()
!=
QNetworkInformation
::
Reachability
::
Online
)
{
#endif
setData
(
source
,
Data
());
return
true
;
}
...
...
@@ -136,9 +146,13 @@ bool WeatherEngine::sourceRequestEvent(const QString &source)
*/
bool
WeatherEngine
::
updateSourceEvent
(
const
QString
&
source
)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qCDebug
(
WEATHER
)
<<
"updateSourceEvent(): Network is: "
<<
m_networkConfigurationManager
.
isOnline
();
if
(
!
m_networkConfigurationManager
.
isOnline
())
{
#else
qCDebug
(
WEATHER
)
<<
"updateSourceEvent(): Network is: "
<<
QNetworkInformation
::
instance
()
->
reachability
();
if
(
QNetworkInformation
::
instance
()
->
reachability
()
!=
QNetworkInformation
::
Reachability
::
Online
)
{
#endif
return
false
;
}
...
...
@@ -151,9 +165,15 @@ bool WeatherEngine::updateSourceEvent(const QString &source)
return
ion
->
updateSourceEvent
(
source
);
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void
WeatherEngine
::
onOnlineStateChanged
(
bool
isOnline
)
{
if
(
isOnline
)
{
#else
void
WeatherEngine
::
onOnlineStateChanged
(
QNetworkInformation
::
Reachability
reachability
)
{
if
(
reachability
==
QNetworkInformation
::
Reachability
::
Online
)
{
#endif
qCDebug
(
WEATHER
)
<<
"starting m_reconnectTimer"
;
// allow the network to settle down and actually come up
m_reconnectTimer
.
start
(
1000
);
...
...
dataengines/weather/weatherengine.h
View file @
3628ef1d
...
...
@@ -7,7 +7,11 @@
#pragma once
#include
<QHash>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include
<QNetworkConfigurationManager>
#else
#include
<QNetworkInformation>
#endif
#include
<QTimer>
#include
<Plasma/DataEngine>
...
...
@@ -85,7 +89,11 @@ private Q_SLOTS:
/**
* Whenever networking changes, take action
*/
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void
onOnlineStateChanged
(
bool
isOnline
);
#else
void
onOnlineStateChanged
(
QNetworkInformation
::
Reachability
reachability
);
#endif
void
startReconnect
();
/**
...
...
@@ -103,5 +111,7 @@ private:
private:
QHash
<
QString
,
int
>
m_ionUsage
;
QTimer
m_reconnectTimer
;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QNetworkConfigurationManager
m_networkConfigurationManager
;
#endif
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment