diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2021-06-03 13:27:56 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-06-08 14:54:16 +0200 |
commit | 14b74af0608dc833f836acac4ee93f905b449806 (patch) | |
tree | 84db5450f302d0de9ba140c8a9d223324e4fe988 /src/network/kernel | |
parent | c34b596119b1fd05082b69b77eb86a99f658a22b (diff) |
QNetworkInformation: Adjustments to captive portal API
Make it return bool since the TriState was really only used signify that
the property was unsupported but there is already a separate way to
check if it's supported. More importantly there is no different set of
actions available to a user if they're in the Unknown or False state.
Because of the change to bool, we also rename the property to have an
'is'-prefix.
Change-Id: Iaaaad5ac31e663c36e00223bf5b0e719f412fc69
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qnetworkinformation.cpp | 33 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinformation.h | 13 | ||||
-rw-r--r-- | src/network/kernel/qnetworkinformation_p.h | 7 |
3 files changed, 14 insertions, 39 deletions
diff --git a/src/network/kernel/qnetworkinformation.cpp b/src/network/kernel/qnetworkinformation.cpp index c1e184f961..42eb6cbb23 100644 --- a/src/network/kernel/qnetworkinformation.cpp +++ b/src/network/kernel/qnetworkinformation.cpp @@ -471,21 +471,6 @@ QNetworkInformationBackendFactory::~QNetworkInformationBackendFactory() */ /*! - \enum QNetworkInformation::TriState - \since 6.2 - - A bool with a 3rd, unknown, state. - - \value False - Known to be \c{false}. - \value True - Known to be \c{true}. - \value Unknown - The state cannot be determined at present, either because the query is - not supported on this platform or because the OS lacks the information. -*/ - -/*! \internal ctor */ QNetworkInformation::QNetworkInformation(QNetworkInformationBackend *backend) @@ -494,7 +479,7 @@ QNetworkInformation::QNetworkInformation(QNetworkInformationBackend *backend) connect(backend, &QNetworkInformationBackend::reachabilityChanged, this, [this]() { emit reachabilityChanged(d_func()->backend->reachability()); }); connect(backend, &QNetworkInformationBackend::behindCaptivePortalChanged, this, [this]() { - emit behindCaptivePortalChanged(d_func()->backend->behindCaptivePortal()); + emit isBehindCaptivePortalChanged(d_func()->backend->behindCaptivePortal()); }); } @@ -523,19 +508,17 @@ QNetworkInformation::Reachability QNetworkInformation::reachability() const } /*! - \property QNetworkInformation::behindCaptivePortal + \property QNetworkInformation::isBehindCaptivePortal \brief Lets you know if the user's device is behind a captive portal. \since 6.2 - This property indicates if the user's device is currently behind a captive - portal. This functionality relies on the operating system's detection of - captive portals and is not supported on systems that don't report this. - On systems where this is not supported this will always return - TriState::Unknown. - - \sa TriState + This property indicates if the user's device is currently known to be + behind a captive portal. This functionality relies on the operating system's + detection of captive portals and is not supported on systems that don't + report this. On systems where this is not supported this will always return + \c{false}. */ -QNetworkInformation::TriState QNetworkInformation::behindCaptivePortal() const +bool QNetworkInformation::isBehindCaptivePortal() const { return d_func()->backend->behindCaptivePortal(); } diff --git a/src/network/kernel/qnetworkinformation.h b/src/network/kernel/qnetworkinformation.h index 6e700747bb..7fa43a4187 100644 --- a/src/network/kernel/qnetworkinformation.h +++ b/src/network/kernel/qnetworkinformation.h @@ -55,7 +55,7 @@ class Q_NETWORK_EXPORT QNetworkInformation : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QNetworkInformation) Q_PROPERTY(Reachability reachability READ reachability NOTIFY reachabilityChanged) - Q_PROPERTY(TriState behindCaptivePortal READ behindCaptivePortal NOTIFY behindCaptivePortalChanged) + Q_PROPERTY(bool isBehindCaptivePortal READ isBehindCaptivePortal NOTIFY isBehindCaptivePortalChanged) public: enum class Reachability { Unknown, @@ -66,13 +66,6 @@ public: }; Q_ENUM(Reachability) - enum class TriState { - False, - True, - Unknown, - }; - Q_ENUM(TriState) - enum class Feature { Reachability = 0x1, CaptivePortal = 0x2, @@ -82,7 +75,7 @@ public: Reachability reachability() const; - TriState behindCaptivePortal() const; + bool isBehindCaptivePortal() const; QString backendName() const; @@ -95,7 +88,7 @@ public: Q_SIGNALS: void reachabilityChanged(Reachability newReachability); - void behindCaptivePortalChanged(TriState state); + void isBehindCaptivePortalChanged(bool state); private: friend struct QNetworkInformationDeleter; diff --git a/src/network/kernel/qnetworkinformation_p.h b/src/network/kernel/qnetworkinformation_p.h index c71e7787a4..73ef96e724 100644 --- a/src/network/kernel/qnetworkinformation_p.h +++ b/src/network/kernel/qnetworkinformation_p.h @@ -70,7 +70,7 @@ public: virtual QNetworkInformation::Features featuresSupported() const = 0; QNetworkInformation::Reachability reachability() const { return m_reachability; } - QNetworkInformation::TriState behindCaptivePortal() const { return m_behindCaptivePortal; } + bool behindCaptivePortal() const { return m_behindCaptivePortal; } Q_SIGNALS: void reachabilityChanged(); @@ -85,7 +85,7 @@ protected: } } - void setBehindCaptivePortal(QNetworkInformation::TriState behindPortal) + void setBehindCaptivePortal(bool behindPortal) { if (m_behindCaptivePortal != behindPortal) { m_behindCaptivePortal = behindPortal; @@ -95,8 +95,7 @@ protected: private: QNetworkInformation::Reachability m_reachability = QNetworkInformation::Reachability::Unknown; - QNetworkInformation::TriState m_behindCaptivePortal = - QNetworkInformation::TriState::Unknown; + bool m_behindCaptivePortal = false; Q_DISABLE_COPY_MOVE(QNetworkInformationBackend) friend class QNetworkInformation; |