OSSIA
Open Scenario System for Interactive Application
qml_exec.hpp
1 #pragma once
2 #include <ossia/editor/scenario/clock.hpp>
3 
4 #include <ossia-qt/score/qml_interval.hpp>
5 #include <ossia-qt/score/qml_util.hpp>
6 
7 #include <QPointer>
8 #include <QQuickItem>
9 
10 #include <readerwriterqueue.h>
11 
12 #include <verdigris>
13 namespace ossia
14 {
15 namespace qt
16 {
17 
18 class qml_exec : public QObject
19 {
20  W_OBJECT(qml_exec)
21 public:
22  static qml_exec& instance();
23  static qml_exec* get(QObject* obj);
24  void submitCommand(std::function<void()>);
25 
26 public:
27  void play(qml_interval* itvl);
28  W_SLOT(play);
29  void pause(qml_interval* itvl);
30  W_SLOT(pause);
31  void stop(qml_interval* itvl);
32  W_SLOT(stop);
33 
34 private:
35  qml_exec();
36  ~qml_exec() override;
37 
38  void timerEvent(QTimerEvent* event) override;
39 
40  QPointer<qml_interval> m_cur{};
41  moodycamel::ReaderWriterQueue<std::function<void()>> m_queue;
42  std::optional<int> m_timer;
43  std::chrono::high_resolution_clock::time_point m_cur_t;
44 };
45 
46 }
47 }
Definition: git_info.h:7