TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkdispatchmanager.h
Go to the documentation of this file.
1 #ifndef TTKDISPATCHMANAGER_H
2 #define TTKDISPATCHMANAGER_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2026 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QMutex>
23 #include "ttksingleton.h"
24 
25 class QTimer;
26 
30 class TTK_MODULE_EXPORT TTKDispatchManager : public QObject
31 {
32  Q_OBJECT
34 public:
35  enum class Module
36  {
37  Null = -1,
38  FileRemove
39  };
40 
44  void setInterval(int msec);
45 
46 public:
50  void dispatch(Module type);
51  void dispatch(Module type, void *funcs);
52  void dispatch(Module type, const TTKVariantList &args);
53 
54 public:
58  void dispatch(Module type, const QVariant &arg1);
59  void dispatch(Module type, const QVariant &arg1, const QVariant &arg2);
60  void dispatch(Module type, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3);
61  void dispatch(Module type, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, const QVariant &arg4);
62 
63 private Q_SLOTS:
67  void activeFunctions();
68 
69 private:
78 
79 private:
80  struct Data
81  {
82  int m_times;
85 
86  Data() noexcept
87  : m_times(0),
88  m_type(TTKDispatchManager::Module::Null)
89  {
90 
91  }
92 
93  inline bool isEmpty() const noexcept
94  {
95  return m_args.isEmpty();
96  }
97 
98  inline bool isValid() const noexcept
99  {
100  return m_times <= 5;
101  }
102  };
103 
104 private:
105  QMutex m_mutex;
106  QTimer *m_timer;
107  QList<Data*> m_observer;
108 
109 };
110 
111 #endif // TTKDISPATCHMANAGER_H
#define TTK_MODULE_EXPORT
QList< Data * > m_observer
#define TTK_DECLARE_SINGLETON_CLASS(Class)
// Singleton Macro // //
Definition: ttksingleton.h:86
The class of the functions dispatch manager.
QList< QVariant > TTKVariantList
Definition: ttkqtglobal.h:201
bool isValid() const noexcept
#define const
Definition: zconf.h:233
bool isEmpty() const noexcept
TTKDispatchManager::Module m_type