File indexing completed on 2025-01-19 04:01:47

0001 /*
0002 Gwenview: an image viewer
0003 Copyright 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
0004 
0005 This program is free software; you can redistribute it and/or
0006 modify it under the terms of the GNU General Public License
0007 as published by the Free Software Foundation; either version 2
0008 of the License, or (at your option) any later version.
0009 
0010 This program is distributed in the hope that it will be useful,
0011 but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 GNU General Public License for more details.
0014 
0015 You should have received a copy of the GNU General Public License
0016 along with this program; if not, write to the Free Software
0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018 */
0019 
0020 #ifndef MPRISMEDIAPLAYER2_H
0021 #define MPRISMEDIAPLAYER2_H
0022 
0023 #include "dbusabstractadaptor.h"
0024 // Qt
0025 #include <QStringList>
0026 
0027 class QAction;
0028 
0029 namespace Gwenview
0030 {
0031 // https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html
0032 class MprisMediaPlayer2 : public DBusAbstractAdaptor
0033 {
0034     Q_OBJECT
0035     Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2")
0036 
0037     Q_PROPERTY(bool CanQuit READ canQuit CONSTANT)
0038     Q_PROPERTY(bool CanRaise READ canRaise CONSTANT)
0039     Q_PROPERTY(bool CanSetFullscreen READ canSetFullscreen CONSTANT)
0040 
0041     Q_PROPERTY(QString Identity READ identity CONSTANT)
0042     Q_PROPERTY(QString DesktopEntry READ desktopEntry CONSTANT)
0043 
0044     Q_PROPERTY(bool HasTrackList READ hasTrackList CONSTANT)
0045     Q_PROPERTY(bool Fullscreen READ isFullscreen WRITE setFullscreen)
0046 
0047     Q_PROPERTY(QStringList SupportedUriSchemes READ supportedUriSchemes CONSTANT)
0048     Q_PROPERTY(QStringList SupportedMimeTypes READ supportedMimeTypes CONSTANT)
0049 
0050 public:
0051     MprisMediaPlayer2(const QString &objectDBusPath, QAction *fullScreenAction, QObject *parent);
0052     ~MprisMediaPlayer2() override;
0053 
0054 public Q_SLOTS: // D-Bus API
0055     void Quit();
0056     void Raise();
0057 
0058 private:
0059     bool canQuit() const;
0060     bool canRaise() const;
0061     bool canSetFullscreen() const;
0062     bool hasTrackList() const;
0063 
0064     QString identity() const;
0065     QString desktopEntry() const;
0066     bool isFullscreen() const;
0067     void setFullscreen(bool isFullscreen);
0068 
0069     QStringList supportedUriSchemes() const;
0070     QStringList supportedMimeTypes() const;
0071 
0072     void onFullScreenActionToggled(bool checked);
0073 
0074 private:
0075     QAction *const mFullScreenAction;
0076 };
0077 
0078 }
0079 
0080 #endif