1 /* 2 SPDX-FileCopyrightText: 2018 Jean-Baptiste Mardelle <jb@kdenlive.org> 3 This file is part of Kdenlive. See www.kdenlive.org. 4 5 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 6 */ 7 8 #ifndef MONITORPROXY_H 9 #define MONITORPROXY_H 10 11 #include "definitions.h" 12 #include <QImage> 13 #include <QUrl> 14 #include <QObject> 15 16 class GLWidget; 17 class TimecodeDisplay; 18 19 /** @class MonitorProxy 20 @brief This class is a wrapper around the monitor / glwidget and handles communication 21 with the qml overlay through its properties. 22 */ 23 class MonitorProxy : public QObject 24 { 25 Q_OBJECT 26 // Q_PROPERTY(int consumerPosition READ consumerPosition NOTIFY consumerPositionChanged) 27 Q_PROPERTY(int position MEMBER m_position WRITE setPosition NOTIFY positionChanged) 28 Q_PROPERTY(QPoint profile READ profile NOTIFY profileChanged) 29 Q_PROPERTY(int seekFinished MEMBER m_seekFinished NOTIFY seekFinishedChanged) 30 Q_PROPERTY(int zoneIn READ zoneIn WRITE setZoneIn NOTIFY zoneChanged) 31 Q_PROPERTY(int zoneOut READ zoneOut WRITE setZoneOut NOTIFY zoneChanged) 32 Q_PROPERTY(int rulerHeight READ rulerHeight WRITE setRulerHeight NOTIFY rulerHeightChanged) 33 Q_PROPERTY(QString markerComment MEMBER m_markerComment NOTIFY markerChanged) 34 Q_PROPERTY(QColor markerColor MEMBER m_markerColor NOTIFY markerChanged) 35 Q_PROPERTY(QString timecode READ timecode NOTIFY timecodeChanged) 36 Q_PROPERTY(QString trimmingTC1 READ trimmingTC1 NOTIFY trimmingTC1Changed) 37 Q_PROPERTY(QString trimmingTC2 READ trimmingTC2 NOTIFY trimmingTC2Changed) 38 Q_PROPERTY(QList <int> audioStreams MEMBER m_audioStreams NOTIFY audioThumbChanged) 39 Q_PROPERTY(QList <int> audioChannels MEMBER m_audioChannels NOTIFY audioThumbChanged) 40 Q_PROPERTY(int clipBounds MEMBER m_boundsCount NOTIFY clipBoundsChanged) 41 Q_PROPERTY(int overlayType READ overlayType WRITE setOverlayType NOTIFY overlayTypeChanged) 42 Q_PROPERTY(double speed MEMBER m_speed NOTIFY speedChanged) 43 Q_PROPERTY(QColor thumbColor1 READ thumbColor1 NOTIFY colorsChanged) 44 Q_PROPERTY(QColor thumbColor2 READ thumbColor2 NOTIFY colorsChanged) 45 Q_PROPERTY(bool autoKeyframe READ autoKeyframe NOTIFY autoKeyframeChanged) 46 Q_PROPERTY(bool audioThumbFormat READ audioThumbFormat NOTIFY audioThumbFormatChanged) 47 Q_PROPERTY(bool audioThumbNormalize READ audioThumbNormalize NOTIFY audioThumbNormalizeChanged) 48 /** @brief Returns true if current clip in monitor has Audio and Video 49 * */ 50 Q_PROPERTY(bool clipHasAV MEMBER m_hasAV NOTIFY clipHasAVChanged) 51 /** @brief Contains the name of clip currently displayed in monitor 52 * */ 53 Q_PROPERTY(QString clipName MEMBER m_clipName NOTIFY clipNameChanged) 54 Q_PROPERTY(QString clipStream MEMBER m_clipStream NOTIFY clipStreamChanged) 55 /** @brief Contains the name of clip currently displayed in monitor 56 * */ 57 Q_PROPERTY(int clipType MEMBER m_clipType NOTIFY clipTypeChanged) 58 Q_PROPERTY(int clipId MEMBER m_clipId NOTIFY clipIdChanged) 59 60 public: 61 MonitorProxy(GLWidget *parent); 62 /** brief: Returns true if we are still in a seek operation 63 * */ 64 int rulerHeight() const; 65 int overlayType() const; 66 void setOverlayType(int ix); 67 const QString trimmingTC1() const; 68 const QString trimmingTC2() const; 69 const QString timecode() const; 70 int getPosition() const; 71 /** @brief update position and end seeking if we reached the requested seek position. 72 * returns true if the position was unchanged, false otherwise 73 * */ 74 Q_INVOKABLE bool setPosition(int pos); 75 bool setPositionAdvanced(int pos, bool noAudioScrub); 76 Q_INVOKABLE void seek(int delta, uint modifiers); 77 Q_INVOKABLE QColor thumbColor1() const; 78 Q_INVOKABLE QColor thumbColor2() const; 79 Q_INVOKABLE QByteArray getUuid() const; 80 Q_INVOKABLE const QPoint clipBoundary(int ix); 81 bool audioThumbFormat() const; 82 bool audioThumbNormalize() const; 83 void positionFromConsumer(int pos, bool playing); 84 void setMarker(const QString &comment, const QColor &color); 85 int zoneIn() const; 86 int zoneOut() const; 87 void setZoneIn(int pos); 88 void setZoneOut(int pos); 89 Q_INVOKABLE void setZone(int in, int out, bool sendUpdate = true); 90 /** brief: Activate clip monitor if param is true, project monitor otherwise 91 * */ 92 Q_INVOKABLE void activateClipMonitor(bool isClipMonitor); 93 void setZone(QPoint zone, bool sendUpdate = true); 94 void resetZone(); 95 QPoint zone() const; 96 QImage extractFrame(int frame_position, const QString &path = QString(), int width = -1, int height = -1, bool useSourceProfile = false); 97 Q_INVOKABLE QString toTimecode(int frames) const; 98 Q_INVOKABLE void startZoneMove(); 99 Q_INVOKABLE void endZoneMove(); 100 Q_INVOKABLE double fps() const; 101 Q_INVOKABLE void switchAutoKeyframe(); 102 Q_INVOKABLE bool autoKeyframe() const; 103 Q_INVOKABLE void setWidgetKeyBinding(const QString &text = QString()) const; 104 QPoint profile(); 105 void setClipProperties(int clipId, ClipType::ProducerType type, bool hasAV, const QString clipName); 106 void setAudioThumb(const QList <int> streamIndexes = QList <int>(), QList <int> channels = QList <int>()); 107 void setAudioStream(const QString &name); 108 void setRulerHeight(int height); 109 /** @brief Store a reference to the timecode display */ 110 void setTimeCode(TimecodeDisplay *td); 111 /** @brief Set position in frames to be displayed in the monitor overlay for preview tile one 112 * @param frames Position in frames 113 * @param isRelative Whether @p frames is the absoulute position (overwrite current) or an offset position (subtract from current) 114 */ 115 void setTrimmingTC1(int frames, bool isRelativ = false); 116 /** @brief Set position in frames to be displayed in the monitor overlay for preview tile two 117 * @see setTrimmingTC1 118 */ 119 void setTrimmingTC2(int frames, bool isRelativ = false); 120 /** @brief When the producer changes, ensure we reset the stored position*/ 121 void resetPosition(); 122 /** @brief Used to display qml info about speed*/ 123 void setSpeed(double speed); 124 125 signals: 126 void positionChanged(int); 127 void seekFinishedChanged(); 128 void requestSeek(int pos, bool noAudioScrub); 129 void zoneChanged(); 130 void saveZone(const QPoint zone); 131 void saveZoneWithUndo(const QPoint, const QPoint&); 132 void markerChanged(); 133 void rulerHeightChanged(); 134 void addSnap(int); 135 void removeSnap(int); 136 void triggerAction(const QString &name); 137 void overlayTypeChanged(); 138 void seekNextKeyframe(); 139 void seekPreviousKeyframe(); 140 void addRemoveKeyframe(); 141 void seekToKeyframe(); 142 void clipHasAVChanged(); 143 void clipNameChanged(); 144 void clipStreamChanged(); 145 void clipTypeChanged(); 146 void clipIdChanged(); 147 void audioThumbChanged(); 148 void colorsChanged(); 149 void audioThumbFormatChanged(); 150 void audioThumbNormalizeChanged(); 151 void profileChanged(); 152 void autoKeyframeChanged(); 153 void timecodeChanged(); 154 void trimmingTC1Changed(); 155 void trimmingTC2Changed(); 156 void speedChanged(); 157 void clipBoundsChanged(); 158 159 private: 160 GLWidget *q; 161 int m_position; 162 int m_zoneIn; 163 int m_zoneOut; 164 bool m_hasAV; 165 double m_speed; 166 QList <int> m_audioStreams; 167 QList <int> m_audioChannels; 168 QString m_markerComment; 169 QColor m_markerColor; 170 QString m_clipName; 171 QString m_clipStream; 172 int m_clipType; 173 int m_clipId; 174 bool m_seekFinished; 175 QPoint m_undoZone; 176 TimecodeDisplay *m_td; 177 int m_trimmingFrames1; 178 int m_trimmingFrames2; 179 QVector <QPoint> m_clipBounds; 180 int m_boundsCount; 181 182 public slots: 183 void updateClipBounds(QVector <QPoint>bounds); 184 }; 185 186 #endif 187