File indexing completed on 2024-04-28 04:48:36

0001 /*
0002     SPDX-FileCopyrightText: 2004 Max Howell <max.howell@methylblue.com>
0003     SPDX-FileCopyrightText: 2007 Ian Monroe <ian@monroe.nu>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #ifndef DRAGONPLAYERACTIONS_H
0009 #define DRAGONPLAYERACTIONS_H
0010 
0011 #include <KActionCollection> //convenience
0012 #include <KDualAction> //baseclass
0013 #include <KToggleAction> //baseclass
0014 
0015 namespace Dragon
0016 {
0017 KActionCollection *actionCollection(); /// defined in mainWindow.cpp, part.cpp
0018 QAction *action(const char *); /// defined in mainWindow.cpp, part.cpp
0019 inline KToggleAction *toggleAction(const char *name)
0020 {
0021     return (KToggleAction *)action(name);
0022 }
0023 
0024 class PlayAction : public KDualAction
0025 {
0026     Q_OBJECT
0027 public:
0028     template<class Receiver, class Func>
0029     inline PlayAction(const Receiver *receiver, Func slot, KActionCollection *ac)
0030         : PlayAction(ac)
0031     {
0032         connect(this, &QAction::triggered, receiver, slot);
0033     }
0034     void setPlaying(bool playing);
0035 
0036 private:
0037     explicit PlayAction(KActionCollection *ac);
0038 };
0039 
0040 class VolumeAction : public KToggleAction
0041 {
0042     Q_OBJECT
0043 public:
0044     template<class Receiver, class Func>
0045     inline VolumeAction(const Receiver *receiver, Func slot, KActionCollection *ac)
0046         : VolumeAction(ac)
0047     {
0048         connect(this, &QAction::triggered, receiver, slot);
0049     }
0050 private Q_SLOTS:
0051     void mutedChanged(bool);
0052 
0053 private:
0054     explicit VolumeAction(KActionCollection *ac);
0055 };
0056 }
0057 
0058 #endif