Commit 59d76cdc authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

Use TimecodeDisplay in *.ui files where possible

parent bbcc2771
Pipeline #243576 passed with stage
in 8 minutes and 11 seconds
......@@ -4061,11 +4061,6 @@ void Bin::renameSubClip(const QString &id, const QString &newName, int in, int o
emit itemUpdated(sub);
}
Timecode Bin::projectTimecode() const
{
return m_doc->timecode();
}
void Bin::slotStartFilterJob(const ItemInfo &info, const QString &id, QMap<QString, QString> &filterParams, QMap<QString, QString> &consumerParams,
QMap<QString, QString> &extraParams)
{
......
......@@ -283,8 +283,6 @@ public:
void renameSubClipCommand(const QString &id, const QString &newName, const QString &oldName, int in, int out);
/** @brief Rename a clip zone (subclip). */
void renameSubClip(const QString &id, const QString &newName, int in, int out);
/** @brief Returns current project's timecode. */
Timecode projectTimecode() const;
/** @brief Edit an effect settings to a bin clip. */
void editMasterEffect(const std::shared_ptr<AbstractProjectItem> &clip);
......
......@@ -672,8 +672,7 @@ bool MarkerListModel::editMarkerGui(const GenTime &pos, QWidget *parent, bool cr
marker = CommentedTime(pos, clip == nullptr ? i18n("guide") : QString());
}
QScopedPointer<MarkerDialog> dialog(
new MarkerDialog(clip, marker, pCore->bin()->projectTimecode(), m_guide ? i18n("Edit Guide") : i18n("Edit Marker"), parent));
QScopedPointer<MarkerDialog> dialog(new MarkerDialog(clip, marker, m_guide ? i18n("Edit Guide") : i18n("Edit Marker"), parent));
if (dialog->exec() == QDialog::Accepted) {
marker = dialog->newMarker();
......
......@@ -140,16 +140,14 @@ 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(dia.get()));
t->setValue(KdenliveSettings::color_duration());
dia_ui.clip_durationBox->addWidget(t.data());
dia_ui.clip_duration->setValue(KdenliveSettings::color_duration());
dia_ui.clip_color->setColor(KdenliveSettings::colorclipcolor());
if (dia->exec() == QDialog::Accepted) {
QString color = dia_ui.clip_color->color().name();
KdenliveSettings::setColorclipcolor(color);
color = color.replace(0, 1, QStringLiteral("0x")) + "ff";
int duration = doc->getFramePos(doc->timecode().getTimecode(t->gentime()));
int duration = doc->getFramePos(doc->timecode().getTimecode(dia_ui.clip_duration->gentime()));
QString name = dia_ui.clip_name->text();
ClipCreator::createColorClip(color, duration, name, parentFolder, std::move(model));
......@@ -255,8 +253,6 @@ 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(dia.data());
dia_ui.formLayout->addRow(i18n("Duration:"), duration);
dia->setWindowTitle(i18nc("@title:window", "Text Clip"));
dia_ui.fgColor->setAlphaChannelEnabled(true);
dia_ui.lineColor->setAlphaChannelEnabled(true);
......@@ -273,7 +269,7 @@ void ClipCreationDialog::createQTextClip(KdenliveDoc *doc, const QString &parent
dia_ui.fontSize->setValue(clip->getProducerProperty(QStringLiteral("size")).toInt());
dia_ui.weight->setValue(clip->getProducerProperty(QStringLiteral("weight")).toInt());
dia_ui.italic->setChecked(clip->getProducerProperty(QStringLiteral("style")) == QStringLiteral("italic"));
duration->setValue(clip->frameDuration());
dia_ui.duration->setValue(clip->frameDuration());
} else {
dia_ui.name->setText(i18n("Text Clip"));
dia_ui.fgColor->setColor(titleConfig.readEntry(QStringLiteral("font_color")));
......@@ -292,14 +288,14 @@ void ClipCreationDialog::createQTextClip(KdenliveDoc *doc, const QString &parent
if (!parentId.isEmpty()) {
properties.insert(QStringLiteral("kdenlive:folderid"), parentId);
}
if (duration->getValue() != clip->getFramePlaytime()) {
int newDuration = dia_ui.duration->getValue();
if (clip && (newDuration != clip->getFramePlaytime())) {
// duration changed, we need to update duration
properties.insert(QStringLiteral("out"), clip->framesToTime(duration->getValue() - 1));
properties.insert(QStringLiteral("out"), clip->framesToTime(newDuration - 1));
int currentLength = clip->getProducerDuration();
if (currentLength != duration->getValue()) {
properties.insert(QStringLiteral("kdenlive:duration"), clip->framesToTime(duration->getValue()));
properties.insert(QStringLiteral("length"), QString::number(duration->getValue()));
if (currentLength != newDuration) {
properties.insert(QStringLiteral("kdenlive:duration"), clip->framesToTime(newDuration));
properties.insert(QStringLiteral("length"), QString::number(newDuration));
}
}
......@@ -327,7 +323,7 @@ void ClipCreationDialog::createQTextClip(KdenliveDoc *doc, const QString &parent
prod.setAttribute(QStringLiteral("id"), QString::number(id));
prod.setAttribute(QStringLiteral("in"), QStringLiteral("0"));
prod.setAttribute(QStringLiteral("out"), duration->getValue());
prod.setAttribute(QStringLiteral("out"), newDuration);
Xml::addXmlProperties(prod, properties);
QString clipId = QString::number(id);
pCore->projectItemModel()->requestAddBinClip(clipId, xml.documentElement(), parentId, i18n("Create Text clip"));
......
......@@ -20,7 +20,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "klocalizedstring.h"
MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const Timecode &tc, const QString &caption, QWidget *parent)
MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const QString &caption, QWidget *parent)
: QDialog(parent)
, m_clip(clip)
{
......@@ -38,8 +38,6 @@ MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const T
}
marker_type->setCurrentIndex(t.markerType());
m_in = new TimecodeDisplay(this);
inputLayout->addWidget(m_in);
m_in->setValue(t.time());
m_previewTimer = new QTimer(this);
......
......@@ -27,7 +27,7 @@ class MarkerDialog : public QDialog, public Ui::MarkerDialog_UI
Q_OBJECT
public:
explicit MarkerDialog(ClipController *clip, const CommentedTime &t, const Timecode &tc, const QString &caption, QWidget *parent = nullptr);
explicit MarkerDialog(ClipController *clip, const CommentedTime &t, const QString &caption, QWidget *parent = nullptr);
~MarkerDialog() override;
CommentedTime newMarker();
......@@ -38,7 +38,6 @@ private slots:
private:
ClipController *m_clip;
TimecodeDisplay *m_in;
QTimer *m_previewTimer;
signals:
......
......@@ -61,22 +61,10 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
connect(buttonStyle, &QToolButton::toggled, this, [this](bool toggle) { stackedWidget->setCurrentIndex(toggle ? 1 : 0); });
m_position = new TimecodeDisplay(this);
m_endPosition = new TimecodeDisplay(this);
m_duration = new TimecodeDisplay(this);
frame_position->setEnabled(false);
buttonDelete->setEnabled(false);
position_box->addWidget(m_position);
auto *spacer = new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
position_box->addSpacerItem(spacer);
spacer = new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
end_box->addWidget(m_endPosition);
end_box->addSpacerItem(spacer);
duration_box->addWidget(m_duration);
spacer = new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
duration_box->addSpacerItem(spacer);
connect(m_position, &TimecodeDisplay::timeCodeEditingFinished, this, [this](int value) {
connect(tc_position, &TimecodeDisplay::timeCodeEditingFinished, this, [this](int value) {
updateSubtitle();
if (buttonLock->isChecked()) {
// Perform a move instead of a resize
......@@ -86,7 +74,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
m_model->requestResize(m_activeSub, duration.frames(pCore->getCurrentFps()), false);
}
});
connect(m_endPosition, &TimecodeDisplay::timeCodeEditingFinished, this, [this](int value) {
connect(tc_end, &TimecodeDisplay::timeCodeEditingFinished, this, [this](int value) {
updateSubtitle();
if (buttonLock->isChecked()) {
// Perform a move instead of a resize
......@@ -96,7 +84,7 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
m_model->requestResize(m_activeSub, duration.frames(pCore->getCurrentFps()), true);
}
});
connect(m_duration, &TimecodeDisplay::timeCodeEditingFinished, this, [this](int value) {
connect(tc_duration, &TimecodeDisplay::timeCodeEditingFinished, this, [this](int value) {
updateSubtitle();
m_model->requestResize(m_activeSub, value, true);
});
......@@ -326,23 +314,23 @@ void SubtitleEdit::setActiveSubtitle(int id)
QSignalBlocker bk(subText);
stackedWidget->widget(0)->setEnabled(true);
buttonDelete->setEnabled(true);
QSignalBlocker bk2(m_position);
QSignalBlocker bk3(m_endPosition);
QSignalBlocker bk4(m_duration);
QSignalBlocker bk2(tc_position);
QSignalBlocker bk3(tc_end);
QSignalBlocker bk4(tc_duration);
subText->setPlainText(m_model->getText(id));
m_startPos = m_model->getStartPosForId(id);
GenTime duration = GenTime(m_model->getSubtitlePlaytime(id), pCore->getCurrentFps());
m_endPos = m_startPos + duration;
m_position->setValue(m_startPos);
m_endPosition->setValue(m_endPos);
m_duration->setValue(duration);
m_position->setEnabled(true);
m_endPosition->setEnabled(true);
m_duration->setEnabled(true);
tc_position->setValue(m_startPos);
tc_end->setValue(m_endPos);
tc_duration->setValue(duration);
tc_position->setEnabled(true);
tc_end->setEnabled(true);
tc_duration->setEnabled(true);
} else {
m_position->setEnabled(false);
m_endPosition->setEnabled(false);
m_duration->setEnabled(false);
tc_position->setEnabled(false);
tc_end->setEnabled(false);
tc_duration->setEnabled(false);
stackedWidget->widget(0)->setEnabled(false);
buttonDelete->setEnabled(false);
QSignalBlocker bk(subText);
......
......@@ -51,9 +51,6 @@ private slots:
private:
std::shared_ptr<SubtitleModel> m_model;
int m_activeSub{-1};
TimecodeDisplay *m_position;
TimecodeDisplay *m_endPosition;
TimecodeDisplay *m_duration;
GenTime m_startPos;
GenTime m_endPos;
......
......@@ -1661,10 +1661,6 @@ 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(this);
inLayout->addWidget(m_in);
m_out = new TimecodeDisplay(this);
outLayout->addWidget(m_out);
m_view = new RemapView(this);
speedBefore->setKeyboardTracking(false);
speedAfter->setKeyboardTracking(false);
......
......@@ -162,8 +162,6 @@ private slots:
private:
std::shared_ptr<Mlt::Link> m_splitRemap;
TimecodeDisplay *m_in;
TimecodeDisplay *m_out;
RemapView *m_view;
int m_lastLength;
int m_cid;
......
......@@ -22,16 +22,6 @@ ClipDurationDialog::ClipDurationDialog(int clipId, int pos, int minpos, int in,
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
setupUi(this);
m_pos = new TimecodeDisplay(this);
m_cropStart = new TimecodeDisplay(this);
m_dur = new TimecodeDisplay(this);
m_cropEnd = new TimecodeDisplay(this);
clip_position_box->addWidget(m_pos);
crop_start_box->addWidget(m_cropStart);
clip_duration_box->addWidget(m_dur);
crop_end_box->addWidget(m_cropEnd);
bool allowCrop = length != -1;
if (!allowCrop) {
......@@ -55,14 +45,6 @@ ClipDurationDialog::ClipDurationDialog(int clipId, int pos, int minpos, int in,
adjustSize();
}
ClipDurationDialog::~ClipDurationDialog()
{
delete m_pos;
delete m_dur;
delete m_cropStart;
delete m_cropEnd;
}
void ClipDurationDialog::slotCheckStart()
{
GenTime start = m_pos->gentime();
......
......@@ -19,7 +19,6 @@ class ClipDurationDialog : public QDialog, public Ui::ClipDurationDialog_UI
public:
explicit ClipDurationDialog(int clipId, int pos, int minpos, int in, int out, int length, int maxpos, QWidget *parent = nullptr);
~ClipDurationDialog() override;
GenTime startPos() const;
GenTime cropStart() const;
GenTime duration() const;
......@@ -33,10 +32,6 @@ private slots:
private:
int m_clipId;
double m_fps;
TimecodeDisplay *m_pos;
TimecodeDisplay *m_dur;
TimecodeDisplay *m_cropStart;
TimecodeDisplay *m_cropEnd;
GenTime m_min;
GenTime m_max;
GenTime m_crop;
......
......@@ -165,11 +165,7 @@ TitleWidget::TitleWidget(const QUrl &url, QString projectTitlePath, Monitor *mon
splitter->setStretchFactor(0, 20);
m_duration = new TimecodeDisplay(this);
m_duration->setValue(KdenliveSettings::title_duration());
duration_box->addWidget(m_duration);
auto *spacer = new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
duration_box->addSpacerItem(spacer);
connect(backgroundColor, &KColorButton::changed, this, &TitleWidget::slotChangeBackground);
connect(backgroundAlpha, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &TitleWidget::slotChangeBackground);
......
......@@ -121,7 +121,6 @@ private:
/** @brief Project path for storing title documents. */
QString m_projectTitlePath;
TimecodeDisplay *m_duration;
/** @brief The project framerate. */
double m_fps;
......
......@@ -6,23 +6,23 @@
<rect>
<x>0</x>
<y>0</y>
<width>226</width>
<height>117</height>
<width>230</width>
<height>156</height>
</rect>
</property>
<property name="windowTitle">
<string>Duration</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="position_label">
<property name="text">
<string>Position:</string>
<item row="4" column="1">
<widget class="TimecodeDisplay" name="m_cropEnd">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="clip_position_box"/>
<item row="1" column="1">
<widget class="TimecodeDisplay" name="m_cropStart"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="crop_label">
......@@ -31,28 +31,32 @@
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="crop_start_box"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="duration_label">
<item row="0" column="0">
<widget class="QLabel" name="position_label">
<property name="text">
<string>Duration:</string>
<string>Position:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="clip_duration_box"/>
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="end_label">
<item row="2" column="0">
<widget class="QLabel" name="duration_label">
<property name="text">
<string>Crop end:</string>
<string>Duration:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="crop_end_box"/>
<item row="0" column="1">
<widget class="TimecodeDisplay" name="m_pos"/>
</item>
<item row="5" column="0" colspan="2">
<spacer name="verticalSpacer">
......@@ -67,18 +71,25 @@
</property>
</spacer>
</item>
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<item row="2" column="1">
<widget class="TimecodeDisplay" name="m_dur"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="end_label">
<property name="text">
<string>Crop end:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TimecodeDisplay</class>
<extends>QWidget</extends>
<header>widgets/timecodedisplay.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>124</height>
<width>239</width>
<height>152</height>
</rect>
</property>
<property name="windowTitle">
......@@ -15,7 +15,7 @@
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_name">
<property name="text">
<string>Name:</string>
</property>
......@@ -25,14 +25,14 @@
<widget class="QLineEdit" name="clip_name"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="label_color">
<property name="text">
<string>Clip color:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_duration">
<property name="text">
<string>Duration:</string>
</property>
......@@ -48,9 +48,6 @@
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="clip_durationBox"/>
</item>
<item row="1" column="1">
<widget class="KColorCombo" name="clip_color"/>
</item>
......@@ -67,19 +64,22 @@
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="TimecodeDisplay" name="clip_duration"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TimecodeDisplay</class>
<extends>QWidget</extends>
<header>widgets/timecodedisplay.h</header>
</customwidget>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
<customwidget>
<class>QLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
......
......@@ -39,7 +39,8 @@
<string>...</string>
</property>
<property name="icon">
<iconset theme="list-add"/>
<iconset theme="list-add">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
......@@ -49,7 +50,8 @@
<string>...</string>
</property>
<property name="icon">
<iconset theme="edit-cut"/>
<iconset theme="edit-cut">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
......@@ -59,7 +61,8 @@
<string>...</string>
</property>
<property name="icon">
<iconset theme="dialog-ok-apply"/>
<iconset theme="dialog-ok-apply">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
......@@ -69,7 +72,8 @@
<string>...</string>
</property>
<property name="icon">
<iconset theme="format-text-color"/>
<iconset theme="format-text-color">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>true</bool>
......@@ -118,49 +122,60 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0" colspan="3">
<widget class="KTextEdit" name="subText">
<property name="tabChangesFocus">
<bool>true</bool>
</property>
<property name="acceptRichText">
<bool>false</bool>
<item row="2" column="2">
<widget class="TimecodeDisplay" name="tc_end"/>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="buttonIn">
<property name="text">
<string>...</string>
</property>
<property name="checkSpellingEnabled">
<bool>true</bool>
<property name="icon">
<iconset theme="zone-in">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="position_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_end">
<property name="text">
<string>Position:</string>
<string>End:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="buttonIn">
<item row="3" column="2">
<widget class="TimecodeDisplay" name="tc_duration"/>
</item>
<item row="3" column="1">
<widget class="QToolButton" name="buttonLock">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="zone-in"/>
<iconset theme="kdenlive-lock">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">