CuteLogger
Fast and simple logging solution for Qt based applications
keyframesdock.h
1 /*
2  * Copyright (c) 2016-2023 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef KEYFRAMESDOCK_H
19 #define KEYFRAMESDOCK_H
20 
21 #include "qmltypes/qmlfilter.h"
22 #include "models/keyframesmodel.h"
23 
24 #include <QDockWidget>
25 #include <QQuickWidget>
26 #include <QScopedPointer>
27 
28 class QmlFilter;
29 class QmlMetadata;
30 class AttachedFiltersModel;
31 class QmlProducer;
32 class QMenu;
33 
34 class KeyframesDock : public QDockWidget
35 {
36  Q_OBJECT
37  Q_PROPERTY(double timeScale READ timeScale WRITE setTimeScale NOTIFY timeScaleChanged)
38 
39 public:
40  explicit KeyframesDock(QmlProducer *qmlProducer, QWidget *parent = 0);
41 
42  KeyframesModel &model()
43  {
44  return m_model;
45  }
46  Q_INVOKABLE int seekPrevious();
47  Q_INVOKABLE int seekNext();
48  int currentParameter() const;
49  double timeScale() const
50  {
51  return m_timeScale;
52  }
53  void setTimeScale(double value);
54 
55 signals:
56  void changed();
57  void setZoom(double value);
58  void zoomIn();
59  void zoomOut();
60  void zoomToFit();
61  void resetZoom();
62  void seekPreviousSimple();
63  void seekNextSimple();
64  void newFilter(); // Notifies when the filter itself has been changed
65  void timeScaleChanged();
66  void dockClicked();
67 
68 public slots:
69  void setCurrentFilter(QmlFilter *filter, QmlMetadata *meta);
70  void load(bool force = false);
71  void reload();
72  void onProducerModified();
73 
74 protected:
75  bool event(QEvent *event);
76  void keyPressEvent(QKeyEvent *event);
77  void keyReleaseEvent(QKeyEvent *event);
78 
79 private slots:
80  void onDockRightClicked();
81  void onKeyframeRightClicked();
82  void onClipRightClicked();
83 
84 private:
85  void setupActions();
86  QQuickWidget m_qview;
87  KeyframesModel m_model;
88  QmlMetadata *m_metadata;
89  QmlFilter *m_filter;
90  QmlProducer *m_qmlProducer;
91  QMenu *m_mainMenu;
92  QMenu *m_keyMenu;
93  QMenu *m_keyTypePrevMenu;
94  QMenu *m_keyTypeNextMenu;
95  QMenu *m_clipMenu;
96  double m_timeScale {1.0};
97 };
98 
99 #endif // KEYFRAMESDOCK_H