Commit 10fef207 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

[Code Gardening] Remove unused code

parent 0bbc19c5
Pipeline #243488 failed with stage
in 4 minutes and 7 seconds
......@@ -61,7 +61,6 @@ add_subdirectory(project)
add_subdirectory(pythoninterfaces)
add_subdirectory(renderpresets)
add_subdirectory(scopes)
add_subdirectory(simplekeyframes)
add_subdirectory(timeline2)
add_subdirectory(titler)
add_subdirectory(transitions)
......
set(kdenlive_SRCS
${kdenlive_SRCS}
simplekeyframes/simpletimelinewidget.cpp
simplekeyframes/simplekeyframewidget.cpp
PARENT_SCOPE)
/*
SPDX-FileCopyrightText: 2011 Till Theato <root@ttill.de>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "simplekeyframewidget.h"
#include "simpletimelinewidget.h"
#include "widgets/timecodedisplay.h"
#include <QGridLayout>
#include <QToolButton>
#include <klocalizedstring.h>
SimpleKeyframeWidget::SimpleKeyframeWidget(int duration, QWidget *parent)
: QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
auto *l = new QGridLayout(this);
m_timeline = new SimpleTimelineWidget(this);
m_timeline->setDuration(duration);
m_buttonAddDelete = new QToolButton(this);
m_buttonAddDelete->setAutoRaise(true);
m_buttonAddDelete->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
m_buttonAddDelete->setToolTip(i18n("Add keyframe"));
m_buttonPrevious = new QToolButton(this);
m_buttonPrevious->setAutoRaise(true);
m_buttonPrevious->setIcon(QIcon::fromTheme(QStringLiteral("media-skip-backward")));
m_buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
m_buttonNext = new QToolButton(this);
m_buttonNext->setAutoRaise(true);
m_buttonNext->setIcon(QIcon::fromTheme(QStringLiteral("media-skip-forward")));
m_buttonNext->setToolTip(i18n("Go to next keyframe"));
m_time = new TimecodeDisplay(this);
m_time->setRange(0, duration);
l->addWidget(m_timeline, 0, 0, 1, -1);
l->addWidget(m_buttonPrevious, 1, 0);
l->addWidget(m_buttonAddDelete, 1, 1);
l->addWidget(m_buttonNext, 1, 2);
l->addWidget(m_time, 1, 3, Qt::AlignRight);
connect(m_time, SIGNAL(timeCodeEditingFinished()), this, SLOT(slotSetPosition()));
connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotSetPosition(int)));
connect(m_timeline, &SimpleTimelineWidget::atKeyframe, this, &SimpleKeyframeWidget::slotAtKeyframe);
connect(m_timeline, &SimpleTimelineWidget::keyframeAdded, this, &SimpleKeyframeWidget::keyframeAdded);
connect(m_timeline, &SimpleTimelineWidget::keyframeRemoved, this, &SimpleKeyframeWidget::keyframeRemoved);
connect(m_timeline, &SimpleTimelineWidget::keyframeMoved, this, &SimpleKeyframeWidget::keyframeMoved);
connect(m_buttonAddDelete, &QAbstractButton::pressed, m_timeline, &SimpleTimelineWidget::slotAddRemove);
connect(m_buttonPrevious, &QAbstractButton::pressed, m_timeline, &SimpleTimelineWidget::slotGoToPrev);
connect(m_buttonNext, &QAbstractButton::pressed, m_timeline, &SimpleTimelineWidget::slotGoToNext);
// no keyframes yet
setEnabled(false);
}
SimpleKeyframeWidget::~SimpleKeyframeWidget()
{
delete m_timeline;
delete m_buttonAddDelete;
delete m_buttonPrevious;
delete m_buttonNext;
delete m_time;
}
void SimpleKeyframeWidget::slotSetPosition(int pos, bool update)
{
if (pos < 0) {
pos = m_time->getValue();
m_timeline->slotSetPosition(pos);
} else {
m_time->setValue(pos);
m_timeline->slotSetPosition(pos);
}
if (update) {
emit positionChanged(pos);
}
}
int SimpleKeyframeWidget::getPosition() const
{
return m_time->getValue();
}
void SimpleKeyframeWidget::setKeyframes(const QList<int> &keyframes)
{
m_timeline->setKeyframes(keyframes);
setEnabled(true);
}
void SimpleKeyframeWidget::addKeyframe(int pos)
{
blockSignals(true);
m_timeline->slotAddKeyframe(pos);
blockSignals(false);
setEnabled(true);
}
void SimpleKeyframeWidget::updateTimecodeFormat()
{
m_time->slotUpdateTimeCodeFormat();
}
void SimpleKeyframeWidget::slotAtKeyframe(bool atKeyframe)
{
if (atKeyframe) {
m_buttonAddDelete->setIcon(QIcon::fromTheme(QStringLiteral("list-remove")));
m_buttonAddDelete->setToolTip(i18n("Delete keyframe"));
} else {
m_buttonAddDelete->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
m_buttonAddDelete->setToolTip(i18n("Add keyframe"));
}
}
/*
SPDX-FileCopyrightText: 2011 Till Theato <root@ttill.de>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#pragma once
#include "utils/timecode.h"
#include <QWidget>
class SimpleTimelineWidget;
class TimecodeDisplay;
class QToolButton;
class SimpleKeyframeWidget : public QWidget
{
Q_OBJECT
public:
explicit SimpleKeyframeWidget(int duration, QWidget *parent = nullptr);
~SimpleKeyframeWidget() override;
int getPosition() const;
void setKeyframes(const QList<int> &keyframes);
void addKeyframe(int pos = -1);
void updateTimecodeFormat();
public slots:
void slotSetPosition(int pos = -1, bool update = true);
private slots:
void slotAtKeyframe(bool atKeyframe);
signals:
void positionChanged(int pos);
void keyframeAdded(int pos);
void keyframeRemoved(int pos);
void keyframeMoved(int oldPos, int newPos);
private:
SimpleTimelineWidget *m_timeline;
QToolButton *m_buttonAddDelete;
QToolButton *m_buttonPrevious;
QToolButton *m_buttonNext;
TimecodeDisplay *m_time;
};
/*
SPDX-FileCopyrightText: 2011 Till Theato <root@ttill.de>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "simpletimelinewidget.h"
#include "kdenlivesettings.h"
#include <QMouseEvent>
#include <QStylePainter>
#include <KColorScheme>
#include <QFontDatabase>
SimpleTimelineWidget::SimpleTimelineWidget(QWidget *parent)
: QWidget(parent)
{
setMouseTracking(true);
setMinimumSize(QSize(150, 20));
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QPalette p = palette();
KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window);
m_colSelected = palette().highlight().color();
m_colKeyframe = scheme.foreground(KColorScheme::NormalText).color();
m_size = int(QFontInfo(font()).pixelSize() * 1.8);
m_lineHeight = m_size / 2;
setMinimumHeight(m_size);
setMaximumHeight(m_size);
}
void SimpleTimelineWidget::setKeyframes(const QList<int> &keyframes)
{
m_keyframes = keyframes;
std::sort(m_keyframes.begin(), m_keyframes.end());
m_currentKeyframe = m_currentKeyframeOriginal = -1;
emit atKeyframe(m_keyframes.contains(m_position));
update();
}
void SimpleTimelineWidget::slotSetPosition(int pos)
{
if (pos != m_position) {
m_position = pos;
emit atKeyframe(m_keyframes.contains(m_position));
update();
}
}
void SimpleTimelineWidget::slotAddKeyframe(int pos, int select)
{
if (pos < 0) {
pos = m_position;
}
m_keyframes.append(pos);
std::sort(m_keyframes.begin(), m_keyframes.end());
if (select != 0) {
m_currentKeyframe = m_currentKeyframeOriginal = pos;
}
update();
emit keyframeAdded(pos);
if (pos == m_position) {
emit atKeyframe(true);
}
}
void SimpleTimelineWidget::slotAddRemove()
{
if (m_keyframes.contains(m_position)) {
slotRemoveKeyframe(m_position);
} else {
slotAddKeyframe(m_position);
}
}
void SimpleTimelineWidget::slotRemoveKeyframe(int pos)
{
m_keyframes.removeAll(pos);
if (m_currentKeyframe == pos) {
m_currentKeyframe = m_currentKeyframeOriginal = -1;
}
update();
emit keyframeRemoved(pos);
if (pos == m_position) {
emit atKeyframe(false);
}
}
void SimpleTimelineWidget::setDuration(int dur)
{
m_duration = dur;
}
void SimpleTimelineWidget::slotGoToNext()
{
if (m_position == m_duration) {
return;
}
for (const int &keyframe : qAsConst(m_keyframes)) {
if (keyframe > m_position) {
slotSetPosition(keyframe);
emit positionChanged(keyframe);
emit atKeyframe(true);
return;
}
}
// no keyframe after current position
slotSetPosition(m_duration);
emit positionChanged(m_duration);
emit atKeyframe(false);
}
void SimpleTimelineWidget::slotGoToPrev()
{
if (m_position == 0) {
return;
}
for (int i = m_keyframes.count() - 1; i >= 0; --i) {
const int framePos(m_keyframes.at(i));
if (framePos < m_position) {
slotSetPosition(framePos);
emit positionChanged(framePos);
emit atKeyframe(true);
return;
}
}
// no keyframe before current position
slotSetPosition(0);
emit positionChanged(0);
emit atKeyframe(false);
}
void SimpleTimelineWidget::mousePressEvent(QMouseEvent *event)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
int pos = int(event->x() / m_scale);
if (event->y() < m_lineHeight && event->button() == Qt::LeftButton) {
#else
int pos = int(event->position().x() / m_scale);
if (event->position().y() < m_lineHeight && event->button() == Qt::LeftButton) {
#endif
for (const int &keyframe : qAsConst(m_keyframes)) {
if (qAbs(keyframe - pos) < 5) {
m_currentKeyframeOriginal = keyframe;
m_keyframes[m_keyframes.indexOf(keyframe)] = pos;
m_currentKeyframe = pos;
update();
return;
}
}
}
// no keyframe next to mouse
m_currentKeyframe = m_currentKeyframeOriginal = -1;
m_position = pos;
emit positionChanged(pos);
emit atKeyframe(m_keyframes.contains(pos));
update();
}
void SimpleTimelineWidget::mouseMoveEvent(QMouseEvent *event)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
int pos = qBound(0, int(event->x() / m_scale), m_duration);
#else
int pos = qBound(0, int(event->position().x() / m_scale), m_duration);
#endif
if ((event->buttons() & Qt::LeftButton) != 0u) {
if (m_currentKeyframe >= 0) {
if (!m_keyframes.contains(pos)) {
// snap to position cursor
if (KdenliveSettings::snaptopoints() && qAbs(pos - m_position) < 5 && !m_keyframes.contains(m_position)) {
pos = m_position;
}
// should we maybe sort here?
m_keyframes[m_keyframes.indexOf(m_currentKeyframe)] = pos;
m_currentKeyframe = pos;
emit keyframeMoving(m_currentKeyframeOriginal, m_currentKeyframe);
emit atKeyframe(m_keyframes.contains(m_position));
}
} else {
m_position = pos;
emit positionChanged(pos);
emit atKeyframe(m_keyframes.contains(pos));
}
update();
return;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (event->y() < m_lineHeight) {
#else
if (event->position().y() < m_lineHeight) {
#endif
for (const int &keyframe : qAsConst(m_keyframes)) {
if (qAbs(keyframe - pos) < 5) {
m_hoverKeyframe = keyframe;
setCursor(Qt::PointingHandCursor);
update();
return;
}
}
}
if (m_hoverKeyframe != -1) {
m_hoverKeyframe = -1;
setCursor(Qt::ArrowCursor);
update();
}
}
void SimpleTimelineWidget::mouseReleaseEvent(QMouseEvent *event)
{
Q_UNUSED(event)
if (m_currentKeyframe >= 0) {
std::sort(m_keyframes.begin(), m_keyframes.end());
emit keyframeMoved(m_currentKeyframeOriginal, m_currentKeyframe);
}
}
void SimpleTimelineWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (event->button() == Qt::LeftButton && event->y() < m_lineHeight) {
int pos = qBound(0, int(event->x() / m_scale), m_duration);
#else
if (event->button() == Qt::LeftButton && event->position().y() < m_lineHeight) {
int pos = qBound(0, int(event->position().x() / m_scale), m_duration);
#endif
for (const int &keyframe : qAsConst(m_keyframes)) {
if (qAbs(keyframe - pos) < 5) {
m_keyframes.removeAll(keyframe);
if (keyframe == m_currentKeyframe) {
m_currentKeyframe = m_currentKeyframeOriginal = -1;
}
emit keyframeRemoved(keyframe);
if (keyframe == m_position) {
emit atKeyframe(false);
}
return;
}
}
// add new keyframe
m_keyframes.append(pos);
std::sort(m_keyframes.begin(), m_keyframes.end());
emit keyframeAdded(pos);
if (pos == m_position) {
emit atKeyframe(true);
}
} else {
QWidget::mouseDoubleClickEvent(event);
}
}
void SimpleTimelineWidget::wheelEvent(QWheelEvent *event)
{
int change = event->angleDelta().y() < 0 ? 1 : -1;
/*if (m_currentKeyframe > 0) {
m_currentKeyframe = qBound(0, m_currentKeyframe + change, m_duration);
emit keyframeMoved(m_currentKeyframeOriginal, m_currentKeyframe);
} else { */
m_position = qBound(0, m_position + change, m_duration);
emit positionChanged(m_position);
// }
emit atKeyframe(m_keyframes.contains(m_position));
update();
}
void SimpleTimelineWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QStylePainter p(this);
m_scale = double(width()) / m_duration;
// p.translate(0, m_lineHeight);
int headOffset = int(m_lineHeight / 1.5);
/*
* keyframes
*/
for (const int &pos : qAsConst(m_keyframes)) {
if (pos == m_currentKeyframe || pos == m_hoverKeyframe) {
p.setBrush(m_colSelected);
} else {
p.setBrush(m_colKeyframe);
}
int scaledPos = int(pos * m_scale);
p.drawLine(scaledPos, headOffset, scaledPos, m_lineHeight + (headOffset / 2));
p.drawEllipse(scaledPos - headOffset / 2, 0, headOffset, headOffset);
}
p.setPen(palette().dark().color());
/*
* Time-"line"
*/
p.setPen(m_colKeyframe);
p.drawLine(0, m_lineHeight + (headOffset / 2), width(), m_lineHeight + (headOffset / 2));
/*
* current position
*/
QPolygon pa(3);
int cursorwidth = (m_size - (m_lineHeight + headOffset / 2)) / 2 + 1;
QPolygonF position = QPolygonF() << QPointF(-cursorwidth, m_size) << QPointF(cursorwidth, m_size) << QPointF(0, m_lineHeight + (headOffset / 2) + 1);
position.translate(m_position * m_scale, 0);
p.setBrush(m_colKeyframe);
p.drawPolygon(position);
}
/*
SPDX-FileCopyrightText: 2011 Till Theato <root@ttill.de>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#pragma once
#include <QWidget>
class SimpleTimelineWidget : public QWidget
{
Q_OBJECT
public:
explicit SimpleTimelineWidget(QWidget *parent = nullptr);
void setKeyframes(const QList<int> &keyframes);
void setDuration(int dur);
public slots:
void slotSetPosition(int pos);
void slotRemoveKeyframe(int pos);
void slotAddKeyframe(int pos = -1, int select = false);
void slotAddRemove();
void slotGoToNext();
void slotGoToPrev();
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
private:
int m_duration{1};
int m_position{0};
int m_currentKeyframe{-1};
int m_currentKeyframeOriginal{-1};
int m_hoverKeyframe{-1};
QList<int> m_keyframes;
int m_lineHeight;
double m_scale{1};
int m_size;
QColor m_colSelected;
QColor m_colKeyframe;
QColor m_colKeyframeBg;
signals:
void positionChanged(int pos);
void atKeyframe(bool);
void keyframeSelected();
void keyframeMoving(int oldPos, int currentPos);
void keyframeMoved(int oldPos, int newPos);
void keyframeAdded(int pos);
void keyframeRemoved(int pos);
};
......@@ -14,30 +14,6 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "klocalizedstring.h"
// deprecated
SpacerDialog::SpacerDialog(const GenTime &duration, const Timecode &tc, int track, const QList<TrackInfo> &tracks, QWidget *parent)
: QDialog(parent)
, m_in(nullptr, tc)
{
Q_UNUSED(track)
Q_UNUSED(tracks)
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
setupUi(this);
inputLayout->addWidget(&m_in);
m_in.setValue(duration);
/*QIcon videoIcon = QIcon::fromTheme(QStringLiteral("kdenlive-show-video"));
QIcon audioIcon = QIcon::fromTheme(QStringLiteral("kdenlive-show-audio"));
track_number->addItem(i18n("All tracks"), -1);
for (int i = tracks.count() - 1; i > 0; i--) {
TrackInfo info = tracks.at(i);
track_number->addItem(info.type == VideoTrack ? videoIcon : audioIcon, info.trackName.isEmpty() ? QString::number(i) : info.trackName, i);
}
track_number->setCurrentIndex(track == 0 ? 0 : tracks.count() - track);
*/
adjustSize();
}
SpacerDialog::SpacerDialog(const GenTime &duration, const Timecode &tc, QWidget *parent)
: QDialog(parent)
, m_in(nullptr, tc)
......