File indexing completed on 2025-02-23 04:35:15

0001 // SPDX-FileCopyrightText: 2021 Linus Jahn <lnj@kaidan.im>
0002 // SPDX-License-Identifier: GPL-3.0-or-later
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 
0008 #include <optional>
0009 
0010 class SubscriptionWatcher : public QObject
0011 {
0012     Q_OBJECT
0013     Q_PROPERTY(QString channelId READ channelId WRITE setChannelId NOTIFY channelIdChanged)
0014     Q_PROPERTY(bool isSubscribed READ isSubscribed NOTIFY isSubscribedChanged)
0015 
0016 public:
0017     explicit SubscriptionWatcher(QObject *parent = nullptr);
0018 
0019     QString channelId() const;
0020     void setChannelId(const QString &channelId);
0021 
0022     bool isSubscribed() const;
0023 
0024 Q_SIGNALS:
0025     void channelIdChanged();
0026     void isSubscribedChanged();
0027 
0028 protected:
0029     void setIsSubscribed(bool isSubscribed);
0030     void setIsSubscribed(std::optional<bool> isSubscribed);
0031     void setIsSubscribed();
0032 
0033 private:
0034     QString m_channelId;
0035     bool m_isSubscribed = false;
0036 };