File indexing completed on 2024-12-15 05:06:15

0001 /*
0002     SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QBindable>
0010 
0011 #include <KDEDModule>
0012 
0013 class PlayerContainer;
0014 class Multiplexer;
0015 class KActionCollection;
0016 
0017 /**
0018  * This service allows to control media players when there is no media controller widget
0019  */
0020 class MprisService : public KDEDModule
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     explicit MprisService(QObject *parent, const QList<QVariant> &);
0026     ~MprisService() override;
0027 
0028 private Q_SLOTS:
0029     void onPlayPause();
0030     void onNext();
0031     void onPrevious();
0032     void onStop();
0033     void onPause();
0034     void onPlay();
0035     void onVolumeUp();
0036     void onVolumeDown();
0037 
0038 private:
0039     void enableGlobalShortcuts();
0040 
0041     std::shared_ptr<Multiplexer> m_multiplexer;
0042     Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(MprisService, PlayerContainer *, m_activePlayer, nullptr)
0043     KActionCollection *m_actionCollection = nullptr;
0044 };