File indexing completed on 2024-04-14 04:46:48
0001 /* 0002 SPDX-FileCopyrightText: 2007 Jean-Baptiste Mardelle <jb@kdenlive.org> 0003 0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "monitor.h" 0010 0011 #include <QDir> 0012 #include <QMutex> 0013 #include <QTimer> 0014 0015 class KdenliveDoc; 0016 class KDualAction; 0017 0018 namespace Mlt { 0019 class Profile; 0020 } 0021 0022 class MonitorManager : public QObject 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit MonitorManager(QObject *parent = nullptr); 0028 void initMonitors(Monitor *clipMonitor, Monitor *projectMonitor); 0029 void appendMonitor(AbstractMonitor *monitor); 0030 void removeMonitor(AbstractMonitor *monitor); 0031 Timecode timecode() const; 0032 void resetProfiles(); 0033 /** @brief delete and rebuild consumer, for example when external display is switched */ 0034 void resetConsumers(bool fullReset); 0035 void stopActiveMonitor(); 0036 void pauseActiveMonitor(); 0037 AbstractMonitor *activeMonitor(); 0038 /** Searches for a monitor with the given name. 0039 @return nullptr, if no monitor could be found, or the monitor otherwise. 0040 */ 0041 AbstractMonitor *monitor(Kdenlive::MonitorId monitorName); 0042 bool isActive(Kdenlive::MonitorId id) const; 0043 void updateScopeSource(); 0044 void clearScopeSource(); 0045 /** @brief Change an MLT consumer property for both monitors. */ 0046 void setConsumerProperty(const QString &name, const QString &value); 0047 /** @brief Return a mainwindow action from its id name. */ 0048 QAction *getAction(const QString &name); 0049 Monitor *clipMonitor(); 0050 Monitor *projectMonitor(); 0051 void lockMonitor(Kdenlive::MonitorId name, bool); 0052 void refreshIcons(); 0053 void resetDisplay(); 0054 QDir getCacheFolder(CacheType type); 0055 /** @brief Returns true if multitrack view is enabled in project monitor. */ 0056 bool isMultiTrack() const; 0057 /** @brief Enable/disable multitrack view in project monitor. */ 0058 void switchMultiTrackView(bool enable); 0059 /** @brief Returns true if the project monitor shows a trimming preview. */ 0060 bool isTrimming() const; 0061 /** @brief Returns true if the project monitor is visible (and not tabbed under another dock. */ 0062 bool projectMonitorVisible() const; 0063 /** @brief Returns true if the clip monitor is visible (and not tabbed under another dock. */ 0064 bool clipMonitorVisible() const; 0065 /** @brief Refresh both monitors. */ 0066 void refreshMonitors(); 0067 QTimer refreshTimer; 0068 static const double speedArray[6]; 0069 0070 public Q_SLOTS: 0071 0072 /** @brief Activates a monitor. 0073 * @param name name of the monitor to activate 0074 * @param name raiseMonitor, will raise (bring to front) the monitor if true */ 0075 bool activateMonitor(Kdenlive::MonitorId name, bool raiseMonitor = true); 0076 void slotPlay(); 0077 void slotPause(); 0078 void slotPlayZone(); 0079 void slotLoopZone(); 0080 void slotRewind(double speed = 0); 0081 void slotForward(double speed = 0); 0082 void slotRewindOneFrame(); 0083 void slotForwardOneFrame(); 0084 void slotRewindOneSecond(); 0085 void slotForwardOneSecond(); 0086 void slotStart(); 0087 void slotEnd(); 0088 void slotZoneStart(); 0089 void slotZoneEnd(); 0090 void slotSetInPoint(); 0091 void slotSetOutPoint(); 0092 void focusProjectMonitor(); 0093 void refreshProjectMonitor(bool directUpdate = false); 0094 /** @brief Refresh project monitor if the timeline cursor is inside the range. */ 0095 void refreshProjectRange(QPair<int, int> range, bool forceRefresh = false); 0096 void refreshClipMonitor(bool directUpdate = false); 0097 0098 /** @brief Switch current monitor to fullscreen. */ 0099 void slotSwitchFullscreen(); 0100 0101 /** @brief Switches between project and clip monitor. 0102 * @ref activateMonitor 0103 * @param activateClip whether to activate the clip monitor */ 0104 void slotSwitchMonitors(bool activateClip); 0105 void slotUpdateAudioMonitoring(); 0106 /** @brief Export the current monitor's frame to image file. */ 0107 void slotExtractCurrentFrame(); 0108 /** @brief Export the current monitor's frame to image file and add it to the current project */ 0109 void slotExtractCurrentFrameToProject(); 0110 /** @brief Refresh monitor background color */ 0111 void updateBgColor(); 0112 /** @brief Start multitrack operation */ 0113 void slotStartMultiTrackMode(); 0114 /** @brief Stop multitrack operation */ 0115 void slotStopMultiTrackMode(); 0116 void slotPerformMultiTrackMode(); 0117 0118 private Q_SLOTS: 0119 /** @brief Set MLT's consumer deinterlace method */ 0120 void slotSetDeinterlacer(int ix); 0121 /** @brief Set MLT's consumer interpolation method */ 0122 void slotSetInterpolation(int ix); 0123 /** @brief Switch muting on/off */ 0124 void slotMuteCurrentMonitor(bool active); 0125 /** @brief Toggle progressive play on/off */ 0126 void slotProgressivePlay(bool active); 0127 /** @brief Zoom in active monitor */ 0128 void slotZoomIn(); 0129 /** @brief Zoom out active monitor */ 0130 void slotZoomOut(); 0131 /** @brief Trigger refresh of both monitors */ 0132 void forceProjectMonitorRefresh(); 0133 /** @brief Enables / disables effect scene*/ 0134 void slotToggleEffectScene(bool enable); 0135 0136 private: 0137 /** @brief Make sure 2 monitors cannot be activated simultaneously*/ 0138 QMutex m_refreshMutex; 0139 QMutex m_switchMutex; 0140 /** @brief Sets up all the actions and attaches them to the collection of MainWindow. */ 0141 void setupActions(); 0142 Monitor *m_clipMonitor{nullptr}; 0143 Monitor *m_projectMonitor{nullptr}; 0144 AbstractMonitor *m_activeMonitor{nullptr}; 0145 QList<AbstractMonitor *> m_monitorsList; 0146 KDualAction *m_muteAction; 0147 QAction *m_multiTrack{nullptr}; 0148 /** @brief The currently active track for multitrack mode */ 0149 int m_activeMultiTrack; 0150 0151 Q_SIGNALS: 0152 /** @brief When the monitor changed, update the visible color scopes */ 0153 void checkColorScopes(); 0154 /** @brief When the active monitor renderer was deleted, reset color scopes */ 0155 void clearScopes(); 0156 /** @brief Check if we still need to send frame for scopes */ 0157 void checkScopes(); 0158 void addEffect(const QDomElement &); 0159 /** @brief Monitor activated, refresh overlay options actions */ 0160 void updateOverlayInfos(int, int); 0161 /** @brief info is available for audio spectrum widget */ 0162 void frameDisplayed(const SharedFrame &); 0163 /** @brief Triggered when the project monitor is paused (used to reset stored audiomixer data */ 0164 void cleanMixer(); 0165 /** @brief Update monitor preview resolution */ 0166 void updatePreviewScaling(); 0167 /** @brief monitor scaling was changed, update select action */ 0168 void scalingChanged(); 0169 };