CuteLogger
Fast and simple logging solution for Qt based applications
timelinedock.h
1 /*
2  * Copyright (c) 2013-2018 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 TIMELINEDOCK_H
19 #define TIMELINEDOCK_H
20 
21 #include <QDockWidget>
22 #include <QQuickWidget>
23 #include <QApplication>
24 #include "models/multitrackmodel.h"
25 #include "sharedframe.h"
26 
27 namespace Ui {
28 class TimelineDock;
29 }
30 namespace Timeline {
31 class UpdateCommand;
32 class TrimCommand;
33 }
34 class UndoHelper;
35 
36 class TimelineDock : public QDockWidget
37 {
38  Q_OBJECT
39  Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
40  Q_PROPERTY(int currentTrack READ currentTrack WRITE setCurrentTrack NOTIFY currentTrackChanged)
41  Q_PROPERTY(QList<int> selection READ selection WRITE setSelection NOTIFY selectionChanged)
42 
43 public:
44  explicit TimelineDock(QWidget *parent = 0);
45  ~TimelineDock();
46 
47  enum TrimLocation {
48  TrimInPoint,
49  TrimOutPoint
50  };
51 
52  MultitrackModel* model() { return &m_model; }
53  int position() const { return m_position; }
54  void setPosition(int position);
55  Mlt::ClipInfo* getClipInfo(int trackIndex, int clipIndex);
56  Mlt::Producer* producerForClip(int trackIndex, int clipIndex);
57  int clipIndexAtPlayhead(int trackIndex = -1);
58  int clipIndexAtPosition(int trackIndex, int position);
59  void chooseClipAtPosition(int position, int& trackIndex, int& clipIndex);
60  void setCurrentTrack(int currentTrack);
61  int currentTrack() const;
62  int clipCount(int trackIndex) const;
63  void zoomIn();
64  void zoomOut();
65  void resetZoom();
66  void makeTracksShorter();
67  void makeTracksTaller();
68  void setSelection(QList<int> selection = QList<int>(), int trackIndex = -1, bool isMultitrack = false);
69  QList<int> selection() const;
70  void saveAndClearSelection();
71  void restoreSelection();
72  void selectClipUnderPlayhead();
73  int centerOfClip(int trackIndex, int clipIndex);
74  bool isTrackLocked(int trackIndex) const;
75  void trimClipAtPlayhead(TrimLocation location, bool ripple);
76  bool isRipple() const;
77  Q_INVOKABLE bool isMultitrackSelected() const { return m_selection.isMultitrackSelected; }
78  Q_INVOKABLE int selectedTrack() const { return m_selection.selectedTrack; }
79  Q_INVOKABLE bool isFloating() const { return QDockWidget::isFloating(); }
80  Q_INVOKABLE void copyToSource();
81  Q_INVOKABLE static void openProperties();
82 
83 signals:
84  void currentTrackChanged();
85  void selectionChanged();
86  void seeked(int position);
87  void positionChanged();
88  void clipOpened(Mlt::Producer* producer);
89  void dragging(const QPointF& pos, int duration);
90  void dropped();
91  void dropAccepted(const QString &xml);
92  void fadeInChanged(int duration);
93  void fadeOutChanged(int duration);
94  void selected(Mlt::Producer* producer);
95  void clipClicked();
96  void showStatusMessage(QString);
97  void clipCopied();
98  void clipMoved(int fromTrack, int toTrack, int clipIndex, int position, bool ripple);
99  void filteredClicked();
100  void imageDurationChanged();
101  void transitionAdded(int trackIndex, int clipIndex, int position, bool ripple);
102 
103 public slots:
104  void addAudioTrack();
105  void addVideoTrack();
106  void onShowFrame(const SharedFrame& frame);
107  void onSeeked(int position);
108  void append(int trackIndex);
109  void remove(int trackIndex, int clipIndex);
110  bool mergeClipWithNext(int trackIndex, int clipIndex, bool dryrun);
111  void lift(int trackIndex, int clipIndex);
112  void removeSelection(bool withCopy = false);
113  void liftSelection();
114  void selectTrack(int by);
115  void selectTrackHead(int trackIndex);
116  void selectMultitrack();
117  void copyClip(int trackIndex, int clipIndex);
118  void setTrackName(int trackIndex, const QString& value);
119  void toggleTrackMute(int trackIndex);
120  void toggleTrackHidden(int trackIndex);
121  void setTrackComposite(int trackIndex, bool composite);
122  void setTrackLock(int trackIndex, bool lock);
123  bool moveClip(int fromTrack, int toTrack, int clipIndex, int position, bool ripple);
124  void onClipMoved(int fromTrack, int toTrack, int clipIndex, int position, bool ripple);
125  bool trimClipIn(int trackIndex, int clipIndex, int oldClipIndex, int delta, bool ripple);
126  bool trimClipOut(int trackIndex, int clipIndex, int delta, bool ripple);
127  void insert(int trackIndex, int position = -1, const QString &xml = QString());
128  void overwrite(int trackIndex, int position = -1, const QString &xml = QString());
129  void appendFromPlaylist(Mlt::Playlist* playlist);
130  void splitClip(int trackIndex = -1, int clipIndex = -1);
131  void fadeIn(int trackIndex, int clipIndex = -1, int duration = -1);
132  void fadeOut(int trackIndex, int clipIndex = -1, int duration = -1);
133  void seekPreviousEdit();
134  void seekNextEdit();
135  void seekInPoint(int clipIndex);
136  void clearSelectionIfInvalid();
137  void insertTrack();
138  void removeTrack();
139  void onProducerChanged(Mlt::Producer*);
140  void emitSelectedFromSelection();
141  void remakeAudioLevels(int trackIndex, int clipIndex, bool force = true);
142  void commitTrimCommand();
143  void onRowsInserted(const QModelIndex& parent, int first, int last);
144  void onRowsRemoved(const QModelIndex& parent, int first, int last);
145  void detachAudio(int trackIndex, int clipIndex);
146 
147 protected:
148  void dragEnterEvent(QDragEnterEvent* event);
149  void dragMoveEvent(QDragMoveEvent* event);
150  void dragLeaveEvent(QDragLeaveEvent* event);
151  void dropEvent(QDropEvent* event);
152  bool event(QEvent *event);
153  void keyPressEvent(QKeyEvent* event);
154  void keyReleaseEvent(QKeyEvent* event);
155 
156 private:
157  bool isBlank(int trackIndex, int clipIndex);
158  void pulseLockButtonOnTrack(int trackIndex);
159 
160  Ui::TimelineDock *ui;
161  QQuickWidget m_quickView;
162  MultitrackModel m_model;
163  int m_position;
164  QScopedPointer<Timeline::UpdateCommand> m_updateCommand;
165  bool m_ignoreNextPositionChange;
166  struct Selection {
167  QList<int> selectedClips;
168  int selectedTrack;
169  bool isMultitrackSelected;
170  };
171  Selection m_selection;
172  Selection m_savedSelection;
173  QScopedPointer<Timeline::TrimCommand> m_trimCommand;
174  QScopedPointer<UndoHelper> m_undoHelper;
175  int m_trimDelta;
176  int m_transitionDelta;
177 
178 private slots:
179  void load(bool force = false);
180  void onTopLevelChanged(bool floating);
181  void onTransitionAdded(int trackIndex, int clipIndex, int position, bool ripple);
182 };
183 
184 #endif // TIMELINEDOCK_H
Definition: addencodepresetdialog.h:24
Definition: timelinecommands.cpp:24
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:48