File indexing completed on 2025-01-05 04:29:55
0001 /** 0002 * SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 #include <QQmlEngine> 0011 0012 class NetworkConnectionManager : public QObject 0013 { 0014 Q_OBJECT 0015 QML_ELEMENT 0016 QML_SINGLETON 0017 0018 Q_PROPERTY(bool networkReachable READ networkReachable NOTIFY networkReachableChanged) 0019 Q_PROPERTY(bool feedUpdatesAllowed READ feedUpdatesAllowed NOTIFY feedUpdatesAllowedChanged) 0020 Q_PROPERTY(bool episodeDownloadsAllowed READ episodeDownloadsAllowed NOTIFY episodeDownloadsAllowedChanged) 0021 Q_PROPERTY(bool imageDownloadsAllowed READ imageDownloadsAllowed NOTIFY imageDownloadsAllowedChanged) 0022 Q_PROPERTY(bool streamingAllowed READ streamingAllowed NOTIFY streamingAllowedChanged) 0023 0024 public: 0025 static NetworkConnectionManager &instance() 0026 { 0027 static NetworkConnectionManager _instance; 0028 return _instance; 0029 } 0030 static NetworkConnectionManager *create(QQmlEngine *engine, QJSEngine *) 0031 { 0032 engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership); 0033 return &instance(); 0034 } 0035 0036 [[nodiscard]] bool networkReachable() const; 0037 [[nodiscard]] bool feedUpdatesAllowed() const; 0038 [[nodiscard]] bool episodeDownloadsAllowed() const; 0039 [[nodiscard]] bool imageDownloadsAllowed() const; 0040 [[nodiscard]] bool streamingAllowed() const; 0041 0042 Q_SIGNALS: 0043 void networkReachableChanged(); 0044 void feedUpdatesAllowedChanged(); 0045 void episodeDownloadsAllowedChanged(); 0046 void imageDownloadsAllowedChanged(); 0047 void streamingAllowedChanged(); 0048 0049 private: 0050 NetworkConnectionManager(QObject *parent = nullptr); 0051 0052 bool m_backendAvailable = false; 0053 };