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

0001 // SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
0002 // SPDX-License-Identifier: GPL-3.0-or-later
0003 
0004 #pragma once
0005 
0006 #include "sourcemanager.h"
0007 #include "videocontroller.h"
0008 
0009 #include <QObject>
0010 #include <QQmlEngine>
0011 #include <QtQml>
0012 
0013 #include <optional>
0014 
0015 class PlasmaTube : public QObject
0016 {
0017     Q_OBJECT
0018     QML_ELEMENT
0019     QML_SINGLETON
0020 
0021     Q_PROPERTY(VideoController *videoController READ videoController CONSTANT)
0022     Q_PROPERTY(SourceManager *sourceManager READ sourceManager CONSTANT)
0023     Q_PROPERTY(VideoSource *selectedSource READ selectedSource NOTIFY sourceSelected)
0024 
0025 public:
0026     static PlasmaTube &instance();
0027 
0028     static PlasmaTube *create(QQmlEngine *, QJSEngine *)
0029     {
0030         auto inst = &instance();
0031         QJSEngine::setObjectOwnership(inst, QJSEngine::ObjectOwnership::CppOwnership);
0032         return inst;
0033     }
0034 
0035     VideoController *videoController() const;
0036     SourceManager *sourceManager() const;
0037 
0038     VideoSource *selectedSource();
0039 
0040     Q_INVOKABLE void setApplicationProxy();
0041 
0042 Q_SIGNALS:
0043     void openVideo(const QString &id);
0044     void errorOccurred(const QString &errorText);
0045     void finishedLoading();
0046     void sourceSelected();
0047 
0048 private:
0049     explicit PlasmaTube(QObject *parent = nullptr);
0050 
0051     VideoController *m_controller = nullptr;
0052     SourceManager *m_sourceManager = nullptr;
0053 };