Commit e1ee9789 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Make timecode display listen to profile change and automatically adjust fps.

Fixes !345
parent 84d9a747
......@@ -148,16 +148,16 @@ KeyframeImport::KeyframeImport(const QString &animData, std::shared_ptr<AssetPar
}
out = qMin(out, m_model->data(m_indexes.first(), AssetParameterModel::ParentInRole).toInt() +
m_model->data(m_indexes.first(), AssetParameterModel::ParentDurationRole).toInt() - 1);
m_inPoint = new PositionWidget(i18n("In"), in, 0, out, pCore->currentDoc()->timecode(), QString(), this);
m_inPoint = new PositionWidget(i18n("In"), in, 0, out, QString(), this);
connect(m_inPoint, &PositionWidget::valueChanged, this, &KeyframeImport::updateDisplay);
lay->addWidget(m_inPoint);
m_outPoint = new PositionWidget(i18n("Out"), out, in, out, pCore->currentDoc()->timecode(), QString(), this);
m_outPoint = new PositionWidget(i18n("Out"), out, in, out, QString(), this);
connect(m_outPoint, &PositionWidget::valueChanged, this, &KeyframeImport::updateDisplay);
lay->addWidget(m_outPoint);
// Output offset
int clipIn = parentIn;
m_offsetPoint = new PositionWidget(i18n("Time offset:"), clipIn, 0, clipIn + parentDuration, pCore->currentDoc()->timecode(), "", this);
m_offsetPoint = new PositionWidget(i18n("Time offset:"), clipIn, 0, clipIn + parentDuration, "", this);
lay->addWidget(m_offsetPoint);
int count = 0;
......
......@@ -112,7 +112,7 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
connect(monitor, &Monitor::seekPosition, this, &KeyframeWidget::monitorSeek, Qt::UniqueConnection);
connect(pCore.get(), &Core::disconnectEffectStack, this, &KeyframeWidget::disconnectEffectStack);
m_time = new TimecodeDisplay(pCore->timecode(), this);
m_time = new TimecodeDisplay(true, this);
m_time->setRange(0, duration - 1);
m_toolbar->addAction(previousKFAction);
......@@ -440,11 +440,6 @@ int KeyframeWidget::getPosition() const
return m_time->getValue() + pCore->getItemIn(m_model->getOwnerId());
}
void KeyframeWidget::updateTimecodeFormat()
{
m_time->slotUpdateTimeCodeFormat();
}
void KeyframeWidget::slotAtKeyframe(bool atKeyframe, bool singleKeyframe)
{
m_addDeleteAction->setActive(!atKeyframe);
......
......@@ -39,7 +39,6 @@ public:
/** @brief Returns the monitor scene required for this asset
*/
MonitorSceneType requiredScene() const;
void updateTimecodeFormat();
/** @brief Show / hide keyframe related widgets
*/
void showKeyframes(bool enable);
......
......@@ -24,7 +24,7 @@ PositionEditWidget::PositionEditWidget(std::shared_ptr<AssetParameterModel> mode
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
m_display = new TimecodeDisplay(pCore->timecode(), this);
m_display = new TimecodeDisplay(true, this);
m_display->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
layout->addWidget(label);
......@@ -54,11 +54,6 @@ PositionEditWidget::PositionEditWidget(std::shared_ptr<AssetParameterModel> mode
PositionEditWidget::~PositionEditWidget() = default;
void PositionEditWidget::updateTimecodeFormat()
{
m_display->slotUpdateTimeCodeFormat();
}
int PositionEditWidget::getPosition() const
{
return m_slider->value();
......
......@@ -26,9 +26,7 @@ public:
/** @brief set position
*/
void setPosition(int pos);
/** @brief Call this when the timecode has been changed project-wise
*/
void updateTimecodeFormat();
/** @brief checks that the allowed time interval is valid
*/
bool isValid() const;
......
......@@ -3024,7 +3024,6 @@ void Bin::showClipProperties(const std::shared_ptr<ProjectClip> &clip, bool forc
m_propertiesPanel->setLayout(lay);
}
ClipPropertiesController *panel = clip->buildProperties(m_propertiesPanel);
connect(this, &Bin::refreshTimeCode, panel, &ClipPropertiesController::slotRefreshTimeCode);
connect(this, &Bin::deleteMarkers, panel, &ClipPropertiesController::slotDeleteSelectedMarkers);
connect(this, &Bin::selectMarkers, panel, &ClipPropertiesController::slotSelectAllMarkers);
connect(panel, &ClipPropertiesController::updateClipProperties, this, &Bin::slotEditClipCommand);
......@@ -4181,11 +4180,6 @@ void Bin::openExternalApp(QString appPath, QString url)
QProcess::startDetached(appPath, args);
}
void Bin::updateTimecodeFormat()
{
emit refreshTimeCode();
}
/*
void Bin::slotGotFilterJobResults(const QString &id, int startPos, int track, const stringMap &results, const stringMap &filterInfo)
{
......
......@@ -285,8 +285,7 @@ public:
void renameSubClip(const QString &id, const QString &newName, int in, int out);
/** @brief Returns current project's timecode. */
Timecode projectTimecode() const;
/** @brief Trigger timecode format refresh where needed. */
void updateTimecodeFormat();
/** @brief Edit an effect settings to a bin clip. */
void editMasterEffect(const std::shared_ptr<AbstractProjectItem> &clip);
/** @brief An effect setting was changed, update stack if displayed. */
......@@ -592,8 +591,6 @@ signals:
/** @brief Save folder info into MLT. */
void storeFolder(const QString &folderId, const QString &parentId, const QString &oldParentId, const QString &folderName);
void gotFilterJobResults(const QString &, int, int, stringMap, stringMap);
/** @brief Trigger timecode format refresh where needed. */
void refreshTimeCode();
/** @brief Request display of effect stack for a Bin clip. */
void requestShowEffectStack(const QString &clipName, std::shared_ptr<EffectStackModel>, QSize frameSize, bool showKeyframes);
void requestShowClipProperties(const std::shared_ptr<ProjectClip> &clip, bool forceRefresh = false);
......
......@@ -54,7 +54,7 @@ Generators::Generators(const QString &path, QWidget *parent)
m_preview->setPixmap(m_pixmap.scaledToWidth(m_preview->width()));
auto *hlay = new QHBoxLayout;
hlay->addWidget(new QLabel(i18n("Duration:")));
m_timePos = new TimecodeDisplay(pCore->timecode(), this);
m_timePos = new TimecodeDisplay(true, this);
if (base.hasAttribute(QStringLiteral("updateonduration"))) {
connect(m_timePos, &TimecodeDisplay::timeCodeEditingFinished, this, &Generators::updateDuration);
}
......
......@@ -473,6 +473,7 @@ bool Core::setCurrentProfile(const QString &profilePath)
if (m_currentProfile == profilePath) {
// no change required, ensure timecode has correct fps
m_timecode.setFormat(getCurrentProfile()->fps());
emit updateProjectTimecode();
return true;
}
if (ProfileRepository::get()->profileExists(profilePath)) {
......@@ -503,6 +504,7 @@ bool Core::setCurrentProfile(const QString &profilePath)
checkProfileValidity();
emit m_mainWindow->getCurrentTimeline()->controller()->frameFormatChanged();
}
emit updateProjectTimecode();
}
return true;
}
......
......@@ -391,4 +391,6 @@ signals:
void switchTimelineRecord(bool on);
/** @brief Launch audio recording on track tid*/
void recordAudio(int tid, bool record);
/** @brief Inform widgets that the project profile (and possibly fps) changed */
void updateProjectTimecode();
};
......@@ -140,7 +140,7 @@ void ClipCreationDialog::createColorClip(KdenliveDoc *doc, const QString &parent
dia->setWindowTitle(i18nc("@title:window", "Color Clip"));
dia_ui.clip_name->setText(i18n("Color Clip"));
QScopedPointer<TimecodeDisplay> t(new TimecodeDisplay(doc->timecode(), dia.get()));
QScopedPointer<TimecodeDisplay> t(new TimecodeDisplay(true, dia.get()));
t->setValue(KdenliveSettings::color_duration());
dia_ui.clip_durationBox->addWidget(t.data());
dia_ui.clip_color->setColor(KdenliveSettings::colorclipcolor());
......@@ -255,7 +255,7 @@ void ClipCreationDialog::createQTextClip(KdenliveDoc *doc, const QString &parent
QScopedPointer<QDialog> dia(new QDialog(bin));
Ui::QTextClip_UI dia_ui;
dia_ui.setupUi(dia.data());
TimecodeDisplay *duration = new TimecodeDisplay(pCore->timecode(), dia.data());
TimecodeDisplay *duration = new TimecodeDisplay(true, dia.data());
dia_ui.formLayout->addRow(i18n("Duration:"), duration);
dia->setWindowTitle(i18nc("@title:window", "Text Clip"));
dia_ui.fgColor->setAlphaChannelEnabled(true);
......
......@@ -38,7 +38,7 @@ MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const T
}
marker_type->setCurrentIndex(t.markerType());
m_in = new TimecodeDisplay(tc, this);
m_in = new TimecodeDisplay(true, this);
inputLayout->addWidget(m_in);
m_in->setValue(t.time());
......
......@@ -69,9 +69,9 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
connect(buttonStyle, &QToolButton::toggled, this, [this](bool toggle) { stackedWidget->setCurrentIndex(toggle ? 1 : 0); });
m_position = new TimecodeDisplay(pCore->timecode(), this);
m_endPosition = new TimecodeDisplay(pCore->timecode(), this);
m_duration = new TimecodeDisplay(pCore->timecode(), this);
m_position = new TimecodeDisplay(true, this);
m_endPosition = new TimecodeDisplay(true, this);
m_duration = new TimecodeDisplay(true, this);
frame_position->setEnabled(false);
buttonDelete->setEnabled(false);
......
......@@ -1661,9 +1661,9 @@ TimeRemap::TimeRemap(QWidget *parent)
QMetaObject::invokeMethod(pCore->bin(), "requestTranscoding", Qt::QueuedConnection, Q_ARG(QString, QString()), Q_ARG(QString, m_binId), Q_ARG(int, 0),
Q_ARG(bool, false));
});
m_in = new TimecodeDisplay(pCore->timecode(), this);
m_in = new TimecodeDisplay(true, this);
inLayout->addWidget(m_in);
m_out = new TimecodeDisplay(pCore->timecode(), this);
m_out = new TimecodeDisplay(true, this);
outLayout->addWidget(m_out);
m_view = new RemapView(this);
speedBefore->setKeyboardTracking(false);
......
......@@ -129,7 +129,7 @@ CollapsibleEffectView::CollapsibleEffectView(const std::shared_ptr<EffectItemMod
setIn->setAutoRaise(true);
setIn->setToolTip(i18n("Set zone in"));
layZone->addWidget(setIn);
m_inPos = new TimecodeDisplay(pCore->timecode(), this);
m_inPos = new TimecodeDisplay(true, this);
layZone->addWidget(m_inPos);
layZone->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding, QSizePolicy::Maximum));
QLabel *out = new QLabel(i18n("Out:"), this);
......@@ -140,7 +140,7 @@ CollapsibleEffectView::CollapsibleEffectView(const std::shared_ptr<EffectItemMod
setOut->setAutoRaise(true);
setOut->setToolTip(i18n("Set zone out"));
layZone->addWidget(setOut);
m_outPos = new TimecodeDisplay(pCore->timecode(), this);
m_outPos = new TimecodeDisplay(true, this);
layZone->addWidget(m_outPos);
connect(setIn, &QToolButton::clicked, this, [=]() {
......
......@@ -3729,12 +3729,9 @@ void MainWindow::slotSetDocumentRenderProfile(const QMap<QString, QString> &prop
void MainWindow::slotUpdateTimecodeFormat(int ix)
{
KdenliveSettings::setFrametimecode(ix == 1);
emit pCore->updateProjectTimecode();
m_clipMonitor->updateTimecodeFormat();
m_projectMonitor->updateTimecodeFormat();
// TODO refac: reimplement ?
// m_effectStack->transitionConfig()->updateTimecodeFormat();
// m_effectStack->updateTimecodeFormat();
pCore->bin()->updateTimecodeFormat();
emit getMainTimeline()->controller()->frameFormatChanged();
m_timeFormatButton->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
}
......
......@@ -199,7 +199,6 @@ private:
ClipPropertiesController::ClipPropertiesController(ClipController *controller, QWidget *parent)
: QWidget(parent)
, m_controller(controller)
, m_tc(Timecode(Timecode::HH_MM_SS_HH, pCore->getCurrentFps()))
, m_id(controller->binId())
, m_type(controller->clipType())
, m_properties(new Mlt::Properties(controller->properties()))
......@@ -327,7 +326,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
QCheckBox *box = new QCheckBox(i18n("Duration:"), this);
box->setObjectName(QStringLiteral("force_duration"));
hlay->addWidget(box);
auto *timePos = new TimecodeDisplay(m_tc, this);
auto *timePos = new TimecodeDisplay(true, this);
timePos->setObjectName(QStringLiteral("force_duration_value"));
timePos->setValue(kdenlive_length > 0 ? kdenlive_length : m_properties->get_int("length"));
int original_length = m_properties->get_int("kdenlive:original_length");
......@@ -341,7 +340,6 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
connect(box, &QAbstractButton::toggled, timePos, &QWidget::setEnabled);
connect(box, &QCheckBox::stateChanged, this, &ClipPropertiesController::slotEnableForce);
connect(timePos, &TimecodeDisplay::timeCodeEditingFinished, this, &ClipPropertiesController::slotDurationChanged);
connect(this, &ClipPropertiesController::updateTimeCodeFormat, timePos, &TimecodeDisplay::slotUpdateTimeCodeFormat);
connect(this, SIGNAL(modified(int)), timePos, SLOT(setValue(int)));
// Autorotate
......@@ -1066,11 +1064,6 @@ void ClipPropertiesController::updateTab(int ix)
KdenliveSettings::setProperties_panel_page(ix);
}
void ClipPropertiesController::slotRefreshTimeCode()
{
emit updateTimeCodeFormat();
}
void ClipPropertiesController::slotReloadProperties()
{
mlt_color color;
......@@ -1472,7 +1465,7 @@ void ClipPropertiesController::slotDeleteMarker()
void ClipPropertiesController::slotAddMarker()
{
auto markerModel = m_controller->getMarkerModel();
GenTime pos(m_controller->originalProducer()->position(), m_tc.fps());
GenTime pos(m_controller->originalProducer()->position(), pCore->getCurrentFps());
markerModel->editMarkerGui(pos, this, true, m_controller, true);
}
......
......@@ -8,7 +8,6 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include "definitions.h"
#include "utils/timecode.h"
#include <KMessageWidget>
......@@ -79,7 +78,6 @@ public:
public slots:
void slotReloadProperties();
void slotRefreshTimeCode();
void slotFillMeta(QTreeWidget *tree);
void slotFillAnalysisData();
void slotDeleteSelectedMarkers();
......@@ -110,7 +108,6 @@ private:
ClipController *m_controller;
QTabWidget *m_tabWidget;
ElidedLinkLabel *m_clipLabel;
Timecode m_tc;
QString m_id;
ClipType::ProducerType m_type;
/** @brief: the properties of the active producer (can be a proxy) */
......
......@@ -393,7 +393,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
connect(this, &Monitor::scopesClear, m_glMonitor, &GLWidget::releaseAnalyse, Qt::DirectConnection);
connect(m_glMonitor, &GLWidget::analyseFrame, this, &Monitor::frameUpdated);
m_timePos = new TimecodeDisplay(pCore->timecode(), this);
m_timePos = new TimecodeDisplay(true, this);
if (id == Kdenlive::ProjectMonitor) {
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::saveZone, this, &Monitor::zoneUpdated);
......@@ -1894,7 +1894,6 @@ void Monitor::slotPreviewResource(const QString &path, const QString &title)
void Monitor::resetProfile()
{
m_timePos->updateTimeCode(pCore->timecode());
m_glMonitor->reloadProfile();
m_glMonitor->rootObject()->setProperty("framesize", QRect(0, 0, m_glMonitor->profileSize().width(), m_glMonitor->profileSize().height()));
// Update drop frame info
......@@ -1948,7 +1947,6 @@ void Monitor::slotEditMarker()
void Monitor::updateTimecodeFormat()
{
m_timePos->slotUpdateTimeCodeFormat();
m_glMonitor->rootObject()->setProperty("timecode", m_timePos->displayText());
}
......
......@@ -12,7 +12,7 @@
#include <klocalizedstring.h>
SimpleKeyframeWidget::SimpleKeyframeWidget(const Timecode &t, int duration, QWidget *parent)
SimpleKeyframeWidget::SimpleKeyframeWidget(int duration, QWidget *parent)
: QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
......@@ -37,7 +37,7 @@ SimpleKeyframeWidget::SimpleKeyframeWidget(const Timecode &t, int duration, QWid
m_buttonNext->setIcon(QIcon::fromTheme(QStringLiteral("media-skip-forward")));
m_buttonNext->setToolTip(i18n("Go to next keyframe"));
m_time = new TimecodeDisplay(t, this);
m_time = new TimecodeDisplay(true, this);
m_time->setRange(0, duration);
l->addWidget(m_timeline, 0, 0, 1, -1);
......
Supports Markdown
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