Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Refresh project monitor on clip insert/delete/move

parent f4ea3c20
......@@ -280,3 +280,8 @@ QSize Core::getCurrentFrameSize() const
{
return QSize(getCurrentProfile()->width(), getCurrentProfile()->height());
}
void Core::requestMonitorRefresh()
{
m_monitorManager->refreshProjectMonitor();
}
......@@ -104,6 +104,8 @@ public:
QSize getCurrentFrameSize() const;
/** @brief Returns the frame display size (width x height) of current profile */
QSize getCurrentFrameDisplaySize() const;
/** @brief Request project monitor refresh */
void requestMonitorRefresh();
private:
explicit Core();
......
......@@ -109,6 +109,9 @@ GLWidget::GLWidget(int id, QObject *parent)
setResizeMode(QQuickView::SizeRootObjectToView);
m_monitorProfile = new Mlt::Profile();
m_refreshTimer.setSingleShot(true);
m_refreshTimer.setInterval(50);
connect(&m_refreshTimer, &QTimer::timeout, this, &GLWidget::refresh);
if (KdenliveSettings::gpu_accel()) {
m_glslManager = new Mlt::Filter(*m_monitorProfile, "glsl.manager");
......@@ -582,6 +585,24 @@ void GLWidget::seek(int pos)
}
}
void GLWidget::requestRefresh()
{
if ((m_producer != nullptr) && (m_producer->get_speed() == 0)) {
m_refreshTimer.start();
}
}
void GLWidget::refresh()
{
m_refreshTimer.stop();
QMutexLocker locker(&m_mutex);
if (m_consumer->is_stopped()) {
m_consumer->start();
}
m_consumer->purge();
m_consumer->set("refresh", 1);
}
bool GLWidget::checkFrameNumber(int pos)
{
emit seekPosition(pos);
......
......@@ -29,6 +29,7 @@
#include <QRect>
#include <QSemaphore>
#include <QThread>
#include <QTimer>
#include "definitions.h"
#include "scopes/sharedframe.h"
......@@ -104,6 +105,8 @@ public:
bool checkFrameNumber(int pos);
/** @brief Return current timeline position */
int getCurrentPos() const;
/** @brief Requests a monitor refresh */
void requestRefresh();
protected:
void mouseReleaseEvent(QMouseEvent *event) override;
......@@ -172,6 +175,7 @@ private:
int m_texCoordLocation;
int m_colorspaceLocation;
int m_textureLocation[3];
QTimer m_refreshTimer;
float m_zoom;
bool m_openGLSync;
bool m_sendFrame;
......@@ -195,6 +199,7 @@ private slots:
void updateTexture(GLuint yName, GLuint uName, GLuint vName);
void paintGL();
void onFrameDisplayed(const SharedFrame &frame);
void refresh();
protected:
void resizeEvent(QResizeEvent *event) override;
......
......@@ -1320,8 +1320,8 @@ void Monitor::slotRefreshMonitor(bool visible)
void Monitor::refreshMonitorIfActive()
{
if (isActive() && (render != nullptr)) {
render->doRefresh();
if (isActive()) {
m_glMonitor->requestRefresh();
}
}
......
......@@ -117,6 +117,11 @@ void MonitorManager::focusProjectMonitor()
activateMonitor(Kdenlive::ProjectMonitor);
}
void MonitorManager::refreshProjectMonitor()
{
m_projectMonitor->refreshMonitorIfActive();
}
bool MonitorManager::activateMonitor(Kdenlive::MonitorId name, bool forceRefresh)
{
if (m_clipMonitor == nullptr || m_projectMonitor == nullptr) {
......
......@@ -93,6 +93,7 @@ public slots:
void slotSetInPoint();
void slotSetOutPoint();
void focusProjectMonitor();
void refreshProjectMonitor();
/** @brief Switch current monitor to fullscreen. */
void slotSwitchFullscreen();
......
......@@ -132,6 +132,7 @@ public slots:
void adjustProjectDuration();
/** @brief Add an asset in timeline (effect, transition). */
void activateAsset(const QVariantMap data);
private slots:
void slotRevert();
/** @brief Open the project's backupdialog. */
......
......@@ -21,6 +21,7 @@
#include "timelinemodel.hpp"
#include "clipmodel.hpp"
#include "core.h"
#include "compositionmodel.hpp"
#include "groupsmodel.hpp"
#include "snapmodel.hpp"
......@@ -1398,3 +1399,10 @@ Mlt::Producer *TimelineModel::producer()
return prod;
}
void TimelineModel::checkRefresh(int start, int end) const
{
int currentPos = tractor()->position();
if (currentPos > start && currentPos < end) {
pCore->requestMonitorRefresh();
}
}
......@@ -480,6 +480,8 @@ protected:
/* @brief Returns snap model */
std::unique_ptr<SnapModel> &getSnapModel();
void checkRefresh(int start, int end) const;
protected:
std::unique_ptr<Mlt::Tractor> m_tractor;
......
......@@ -105,6 +105,11 @@ Fun TrackModel::requestClipInsertion_lambda(int clipId, int position, bool updat
int clip_index = getRowfromClip(clip->getId());
ptr->_beginInsertRows(ptr->makeTrackIndexFromID(getId()), clip_index, clip_index);
ptr->_endInsertRows();
int state = m_track.get_int("hide");
if ((state == 0 || state == 2) && m_track.get_int("kdenlive:audio_track") != 1) {
// only refresh monitor if not an audio track and not hidden
ptr->checkRefresh(new_in, new_out);
}
}
return true;
}
......@@ -187,6 +192,11 @@ Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView)
if (auto ptr = m_parent.lock()) {
ptr->m_snaps->removePoint(old_in);
ptr->m_snaps->removePoint(old_out);
int state = m_track.get_int("hide");
if ((state == 0 || state == 2) && m_track.get_int("kdenlive:audio_track") != 1) {
// only refresh monitor if not an audio track and not hidden
ptr->checkRefresh(old_in, old_out);
}
}
return true;
}
......
......@@ -226,7 +226,10 @@ Rectangle {
visible: !isAudio
iconName: isHidden ? 'kdenlive-hide-video' : 'kdenlive-show-video'
iconSource: isHidden? 'qrc:///pics/kdenlive-hide-video.svgz' : 'qrc:///pics/kdenlive-show-video.svgz'
onClicked: controller.setTrackProperty(trackId, "hide", isHidden ? isMute ? '2' : '0' : isMute ? '3' : '1')
onClicked: {
controller.setTrackProperty(trackId, "hide", isHidden ? isMute ? '2' : '0' : isMute ? '3' : '1')
timeline.requestRefresh()
}
tooltip: isHidden? i18n('Show') : i18n('Hide')
}
......
......@@ -462,3 +462,8 @@ void TimelineWidget::addAsset(const QVariantMap data)
}
}
}
void TimelineWidget::requestRefresh()
{
pCore->requestMonitorRefresh();
}
......@@ -155,6 +155,9 @@ public:
/* @brief Add a timeline guide
*/
Q_INVOKABLE void switchGuide(int frame);
/* @brief Request monitor refresh
*/
Q_INVOKABLE void requestRefresh();
/* @brief Seek to next snap point
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment