Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
platformmediacontrol.h
Go to the documentation of this file.
1/*
2 * Sailfin: a Jellyfin client written using Qt
3 * Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#ifndef JELLYFIN_VIEWMODEL_PLATFORMMEDIACONTROL_H
20#define JELLYFIN_VIEWMODEL_PLATFORMMEDIACONTROL_H
21
22#include <QObject>
23#include <QQmlParserStatus>
24#include <QScopedPointer>
25
26namespace Jellyfin {
27namespace ViewModel {
28
29class PlatformMediaControlPrivate;
30class PlaybackManager;
31
35class PlatformMediaControl : public QObject, public QQmlParserStatus {
36 Q_OBJECT
37 Q_INTERFACES(QQmlParserStatus)
38public:
39 explicit PlatformMediaControl(QObject *parent = nullptr);
40
46 Q_PROPERTY(bool canQuit READ canQuit WRITE setCanQuit NOTIFY canQuitChanged)
47 Q_PROPERTY(bool canRaise READ canRaise WRITE setCanRaise NOTIFY canRaiseChanged)
48 Q_PROPERTY(QString playerName READ playerName WRITE setPlayerName NOTIFY playerNameChanged)
49 Q_PROPERTY(QString desktopFile READ playerName WRITE setPlayerName NOTIFY playerNameChanged)
50
51 PlaybackManager *playbackManager() const { return m_playbackManager; };
52
53 void setPlaybackManager(PlaybackManager *newPlaybackManager) {
54 m_playbackManager = newPlaybackManager;
55 emit playbackManagerChanged(newPlaybackManager);
56 };
57
58 bool canQuit() const { return m_canQuit; };
59 void setCanQuit(bool newCanQuit) {
60 m_canQuit = newCanQuit;
61 emit canQuitChanged(newCanQuit);
62 }
63
64 void requestQuit() {
65 emit quitRequested();
66 }
67
68 bool canRaise() const { return m_canRaise; };
69 void setCanRaise(bool newCanRaise) {
70 m_canRaise = newCanRaise;
71 emit canRaiseChanged(newCanRaise);
72 }
73
74 void requestRaise() {
75 emit raiseRequested();
76 };;
77
78 QString playerName() const { return m_playerName; }
79 void setPlayerName(QString newPlayerName) {
80 m_playerName = newPlayerName;
81 emit playerNameChanged(newPlayerName);
82 }
83
84 QString desktopFile() const { return m_desktopFile; }
85 void setDesktopFile(QString newDesktopFile) {
86 m_desktopFile = newDesktopFile;
87 emit desktopFileChanged(newDesktopFile);
88 }
89
90 void classBegin() override {
91 m_isParsing = true;
92 }
93 void componentComplete() override {
94 m_isParsing = false;
95 setup();
96 }
97
98
99
100signals:
101 void playbackManagerChanged(PlaybackManager *newPlaybackManager);
102 void canQuitChanged(bool newCanQuit);
103 void canRaiseChanged(bool newCanRaise);
104 void playerNameChanged(QString newPlayerName);
105 void desktopFileChanged(QString newDesktopFile);
106
109
110private:
111 Q_DECLARE_PRIVATE(PlatformMediaControl)
113 void setup();
114 bool m_isParsing = false;
115
116 PlaybackManager *m_playbackManager = nullptr;
117 bool m_canQuit = false;
118 bool m_canRaise = false;
119 QString m_playerName = QStringLiteral("JellyfinQt");
120 QString m_desktopFile = QStringLiteral("sailfin");
121};
122
123
124} // NS ViewModel
125} // NS Jellyfin
126
127#endif // PLATFORMMEDIACONTROL_H
Definition platformmediacontrol_freedesktop.cpp:34
Exposes media control and information to the OS. Uses MPRIS on FreeDesktop-enabled systems.
Definition platformmediacontrol.h:35
bool canQuit
Definition platformmediacontrol.h:46
QString playerName() const
Definition platformmediacontrol.h:78
bool canRaise() const
Definition platformmediacontrol.h:68
void playbackManagerChanged(PlaybackManager *newPlaybackManager)
PlatformMediaControl(QObject *parent=nullptr)
Definition platformmediacontrol_freedesktop.cpp:51
QString playerName
Definition platformmediacontrol.h:48
void requestQuit()
Definition platformmediacontrol.h:64
void setDesktopFile(QString newDesktopFile)
Definition platformmediacontrol.h:85
bool canRaise
Definition platformmediacontrol.h:47
void componentComplete() override
Definition platformmediacontrol.h:93
bool canQuit() const
Definition platformmediacontrol.h:58
void classBegin() override
Definition platformmediacontrol.h:90
void requestRaise()
Definition platformmediacontrol.h:74
void setPlaybackManager(PlaybackManager *newPlaybackManager)
Definition platformmediacontrol.h:53
Jellyfin::ViewModel::PlaybackManager * playbackManager
Definition platformmediacontrol.h:41
void desktopFileChanged(QString newDesktopFile)
QString desktopFile
Definition platformmediacontrol.h:49
void setCanQuit(bool newCanQuit)
Definition platformmediacontrol.h:59
void setPlayerName(QString newPlayerName)
Definition platformmediacontrol.h:79
void setCanRaise(bool newCanRaise)
Definition platformmediacontrol.h:69
QString desktopFile() const
Definition platformmediacontrol.h:84
void playerNameChanged(QString newPlayerName)
The PlaybackManager class manages the playback of Jellyfin items.
Definition playbackmanager.h:76