File indexing completed on 2024-05-12 04:19:46

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 #include "mprismediaplayer2.h"
0021 
0022 // Qt
0023 #include <QAction>
0024 #include <QGuiApplication>
0025 
0026 namespace Gwenview
0027 {
0028 MprisMediaPlayer2::MprisMediaPlayer2(const QString &objectDBusPath, QAction *fullScreenAction, QObject *parent)
0029     : DBusAbstractAdaptor(objectDBusPath, parent)
0030     , mFullScreenAction(fullScreenAction)
0031 {
0032     connect(mFullScreenAction, &QAction::toggled, this, &MprisMediaPlayer2::onFullScreenActionToggled);
0033 }
0034 
0035 MprisMediaPlayer2::~MprisMediaPlayer2() = default;
0036 
0037 bool MprisMediaPlayer2::canQuit() const
0038 {
0039     return true;
0040 }
0041 
0042 bool MprisMediaPlayer2::canRaise() const
0043 {
0044     // spec: "If true, calling Raise will cause the media application to attempt to bring its user interface to the front,
0045     // Which seems to be about the app specific control UI, less about the rendered media (display).
0046     // Could perhaps be supported by pulling in the toppanel when invoked?
0047     return false;
0048 }
0049 
0050 bool MprisMediaPlayer2::canSetFullscreen() const
0051 {
0052     return true;
0053 }
0054 
0055 bool MprisMediaPlayer2::hasTrackList() const
0056 {
0057     return false;
0058 }
0059 
0060 void MprisMediaPlayer2::Quit()
0061 {
0062     QGuiApplication::quit();
0063 }
0064 
0065 void MprisMediaPlayer2::Raise()
0066 {
0067 }
0068 
0069 QString MprisMediaPlayer2::identity() const
0070 {
0071     return QGuiApplication::applicationDisplayName();
0072 }
0073 
0074 QString MprisMediaPlayer2::desktopEntry() const
0075 {
0076     return QGuiApplication::desktopFileName();
0077 }
0078 
0079 QStringList MprisMediaPlayer2::supportedUriSchemes() const
0080 {
0081     return {};
0082 }
0083 
0084 QStringList MprisMediaPlayer2::supportedMimeTypes() const
0085 {
0086     return {};
0087 }
0088 
0089 bool MprisMediaPlayer2::isFullscreen() const
0090 {
0091     return mFullScreenAction->isChecked();
0092 }
0093 
0094 void MprisMediaPlayer2::setFullscreen(bool isFullscreen)
0095 {
0096     if (isFullscreen == mFullScreenAction->isChecked()) {
0097         return;
0098     }
0099 
0100     mFullScreenAction->trigger();
0101 }
0102 
0103 void MprisMediaPlayer2::onFullScreenActionToggled(bool checked)
0104 {
0105     signalPropertyChange(QStringLiteral("Fullscreen"), checked);
0106 }
0107 
0108 }
0109 
0110 #include "moc_mprismediaplayer2.cpp"