diff options
author | Chris Xiong <chirs241097@gmail.com> | 2023-11-26 01:10:36 -0500 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2023-11-26 01:10:36 -0500 |
commit | 60989e52b3f3bc0a95d3e61bd8e59fa4d9b7ab83 (patch) | |
tree | af08e5b6f7019c6f70bf3800a419ec78db140988 /mpris-plugin/qmpriswrapper.hpp | |
parent | 382d85b15ce9cc4580a2522b39f5dd4ce43a24b0 (diff) | |
download | QMidiPlayer-60989e52b3f3bc0a95d3e61bd8e59fa4d9b7ab83.tar.xz |
The 2 year constipation. (mpris plugin)
Probably buggy as hell.
Diffstat (limited to 'mpris-plugin/qmpriswrapper.hpp')
-rw-r--r-- | mpris-plugin/qmpriswrapper.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mpris-plugin/qmpriswrapper.hpp b/mpris-plugin/qmpriswrapper.hpp new file mode 100644 index 0000000..54186d2 --- /dev/null +++ b/mpris-plugin/qmpriswrapper.hpp @@ -0,0 +1,53 @@ +#ifndef QMPRISWRAPPER_HPP +#define QMPRISWRAPPER_HPP + +#include <QObject> + +class QMPrisMediaPlayer2; +class QMPrisPlayer; +class QMPrisTrackList; +class qmpPluginAPI; + +class QMPrisWrapper : public QObject +{ + Q_OBJECT +public: + ~QMPrisWrapper(); + + template <class TP, class TM, class TT> + static QMPrisWrapper *create(QString serviceSuffix, qmpPluginAPI *api, QObject *parent = nullptr) + { + static_assert(std::is_base_of<QMPrisPlayer, TP>(), "TP must be a subclass of QMPrisPlayer"); + static_assert(std::is_base_of<QMPrisMediaPlayer2, TM>(), "TM must be a subclass of QMPrisMediaPlayer2"); + static_assert(std::is_base_of<QMPrisTrackList, TT>(), "TT must be a subclass of QMPrisTrackList"); + + auto w = new QMPrisWrapper(serviceSuffix, api, parent); + auto p = new TP(api, w); + auto t = new TT(api, w); + auto mp = new TM(api, w); + w->player = p; + w->tracklist = t; + w->mediaplayer = mp; + w->post_creation(); + + return w; + } + + static void notifyPropertyChange(QString intf, QString prop, QVariant val); + +private: + explicit QMPrisWrapper(QString serviceSuffix, qmpPluginAPI *_api, QObject *parent = nullptr); + void post_creation(); + QMPrisPlayer *player = nullptr; + QMPrisMediaPlayer2 *mediaplayer = nullptr; + QMPrisTrackList *tracklist = nullptr; + QString svcsuffix; + qmpPluginAPI *api; + + const QString PLAYER_INTERFACE = "org.mpris.MediaPlayer2.Player"; + + friend class QMPrisPlayer; + friend class QMPrisMediaPlayer2; +}; + +#endif // QMPRISWRAPPER_HPP |