Changeset View
Standalone View
lib/mpris2/mprismediaplayer2.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Gwenview: an image viewer | ||||
3 | Copyright 2018 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
4 | | ||||
5 | This program is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU General Public License | ||||
7 | as published by the Free Software Foundation; either version 2 | ||||
8 | of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This program 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 | ||||
13 | GNU General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU General Public License | ||||
16 | along with this program; if not, write to the Free Software | ||||
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | #include "mprismediaplayer2.h" | ||||
21 | | ||||
22 | // Qt | ||||
23 | #include <QGuiApplication> | ||||
24 | #include <QAction> | ||||
25 | | ||||
26 | namespace Gwenview | ||||
27 | { | ||||
28 | | ||||
29 | MprisMediaPlayer2::MprisMediaPlayer2(const QString &objectDBusPath, | ||||
30 | QAction* fullScreenAction, | ||||
31 | QObject* parent) | ||||
32 | : DBusAbstractAdaptor(objectDBusPath, parent) | ||||
33 | , mFullScreenAction(fullScreenAction) | ||||
34 | { | ||||
35 | connect(mFullScreenAction, &QAction::toggled, | ||||
36 | this, &MprisMediaPlayer2::onFullScreenActionToggled); | ||||
37 | } | ||||
38 | | ||||
39 | MprisMediaPlayer2::~MprisMediaPlayer2() | ||||
40 | { | ||||
41 | } | ||||
42 | | ||||
43 | bool MprisMediaPlayer2::canQuit() const | ||||
44 | { | ||||
45 | return true; | ||||
46 | } | ||||
47 | | ||||
48 | bool MprisMediaPlayer2::canRaise() const | ||||
49 | { | ||||
50 | // spec: "If true, calling Raise will cause the media application to attempt to bring its user interface to the front, | ||||
rkflx: Is there a fundamental reason for that, or is this just a `TODO`?
Also wouldn't it be good to… | |||||
More a TODO, had not yet started to think about how and where this could be useful. Also not yet seen how existing controllers make use of this feature. To call this on "Play" would be a decision of the controller. From my reading of the spec this seems more about bringing any specific media app controller UI onto the screen, not the actually rendered media (though usually apps have the bundled in their UI). But room for interpretation. Then in Wayland apps might not be able to autoraise their windows. Added an explicit todo comment now, so future code reader can continue from here. kossebau: More a TODO, had not yet started to think about how and where this could be useful. Also not… | |||||
51 | // Which seems to be about the app specific control UI, less about the rendered media (display). | ||||
52 | // Could perhaps be supported by pulling in the toppanel when invoked? | ||||
53 | return false; | ||||
54 | } | ||||
55 | | ||||
56 | bool MprisMediaPlayer2::canSetFullscreen() const | ||||
57 | { | ||||
58 | return true; | ||||
Why is this connected to the notion of a (auto-advancing) slideshow? If this is only about a fullscreen toggle, this could be set to true. Switching tracks already works fine in windowed mode. In windowed mode, it would probably still make sense to make the "Play" action enter fullscreen like the corresponding "Start Slideshow" action in Gwenview does (see other part of the reply). Conversely, switching back to windowed mode from fullscreen should stop the slideshow, just like Gwenview does. rkflx: Why is this connected to the notion of a (auto-advancing) slideshow? If this is only about a… | |||||
It was connected to things as by my initial mind model of gwenview states :) https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:Fullscreen does not specify whether requesting a change of fullscreen state should result also in playbackmodus change, so should be fine to do as you prefer. Not aware of an controllers which make use of this, so only tested via qtdbusviewer. kossebau: It was connected to things as by my initial mind model of gwenview states :)
https… | |||||
59 | } | ||||
60 | | ||||
61 | bool MprisMediaPlayer2::hasTrackList() const | ||||
62 | { | ||||
63 | return false; | ||||
64 | } | ||||
65 | | ||||
66 | void MprisMediaPlayer2::Quit() | ||||
67 | { | ||||
68 | QGuiApplication::quit(); | ||||
69 | } | ||||
70 | | ||||
71 | void MprisMediaPlayer2::Raise() | ||||
72 | { | ||||
73 | } | ||||
74 | | ||||
75 | QString MprisMediaPlayer2::identity() const | ||||
76 | { | ||||
77 | return QGuiApplication::applicationDisplayName(); | ||||
78 | } | ||||
79 | | ||||
80 | QString MprisMediaPlayer2::desktopEntry() const | ||||
81 | { | ||||
82 | return QGuiApplication::desktopFileName(); | ||||
83 | } | ||||
This is the only part which prevents compiling with Qt 5.6 as found on Leap 42.3 and elsewhere, which would be kinda nice. Are there any alternatives? Or could we return QString() for older Qts? The basic functionality still seemed fine to me when testing, so perhaps this is not strictly needed? Otherwise we'd have to bite the bullet and bump the Qt version to 5.7. rkflx: This is the only part which prevents compiling with Qt 5.6 as found on Leap 42.3 and elsewhere… | |||||
Ah, missed the Qt 5.6 min dep, right. https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry says that "[t]This property is optional.". So I would simply "if version > 5.6" this part, okay? kossebau: Ah, missed the Qt 5.6 min dep, right.
https://specifications.freedesktop.org/mpris… | |||||
rkflx: Yup. | |||||
84 | | ||||
85 | QStringList MprisMediaPlayer2::supportedUriSchemes() const | ||||
86 | { | ||||
87 | return QStringList(); | ||||
88 | } | ||||
89 | | ||||
90 | QStringList MprisMediaPlayer2::supportedMimeTypes() const | ||||
91 | { | ||||
92 | return QStringList(); | ||||
93 | } | ||||
94 | | ||||
95 | bool MprisMediaPlayer2::isFullscreen() const | ||||
96 | { | ||||
97 | return mFullScreenAction->isChecked(); | ||||
98 | } | ||||
99 | | ||||
100 | void MprisMediaPlayer2::setFullscreen(bool isFullscreen) | ||||
101 | { | ||||
102 | if (isFullscreen == mFullScreenAction->isChecked()) { | ||||
103 | return; | ||||
104 | } | ||||
105 | | ||||
106 | mFullScreenAction->trigger(); | ||||
107 | } | ||||
108 | | ||||
109 | void MprisMediaPlayer2::onFullScreenActionToggled(bool checked) | ||||
110 | { | ||||
111 | signalPropertyChange("Fullscreen", checked); | ||||
112 | } | ||||
113 | | ||||
114 | } |
Is there a fundamental reason for that, or is this just a TODO?
Also wouldn't it be good to call this upon "Play"?