mirror of
https://github.com/KDE/kasts.git
synced 2025-01-05 04:56:38 +01:00
54 lines
1.7 KiB
C++
54 lines
1.7 KiB
C++
/**
|
|
* SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QQmlEngine>
|
|
|
|
class NetworkConnectionManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
QML_SINGLETON
|
|
|
|
Q_PROPERTY(bool networkReachable READ networkReachable NOTIFY networkReachableChanged)
|
|
Q_PROPERTY(bool feedUpdatesAllowed READ feedUpdatesAllowed NOTIFY feedUpdatesAllowedChanged)
|
|
Q_PROPERTY(bool episodeDownloadsAllowed READ episodeDownloadsAllowed NOTIFY episodeDownloadsAllowedChanged)
|
|
Q_PROPERTY(bool imageDownloadsAllowed READ imageDownloadsAllowed NOTIFY imageDownloadsAllowedChanged)
|
|
Q_PROPERTY(bool streamingAllowed READ streamingAllowed NOTIFY streamingAllowedChanged)
|
|
|
|
public:
|
|
static NetworkConnectionManager &instance()
|
|
{
|
|
static NetworkConnectionManager _instance;
|
|
return _instance;
|
|
}
|
|
static NetworkConnectionManager *create(QQmlEngine *engine, QJSEngine *)
|
|
{
|
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
|
return &instance();
|
|
}
|
|
|
|
[[nodiscard]] bool networkReachable() const;
|
|
[[nodiscard]] bool feedUpdatesAllowed() const;
|
|
[[nodiscard]] bool episodeDownloadsAllowed() const;
|
|
[[nodiscard]] bool imageDownloadsAllowed() const;
|
|
[[nodiscard]] bool streamingAllowed() const;
|
|
|
|
Q_SIGNALS:
|
|
void networkReachableChanged();
|
|
void feedUpdatesAllowedChanged();
|
|
void episodeDownloadsAllowedChanged();
|
|
void imageDownloadsAllowedChanged();
|
|
void streamingAllowedChanged();
|
|
|
|
private:
|
|
NetworkConnectionManager(QObject *parent = nullptr);
|
|
|
|
bool m_backendAvailable = false;
|
|
};
|