markers: reimplemented copy/paste

This commit is contained in:
itsmattkc
2022-05-01 22:33:58 -07:00
parent 6a0b5856c9
commit f7396de121
26 changed files with 452 additions and 424 deletions
@@ -30,7 +30,7 @@
namespace olive {
KeyframePropertiesDialog::KeyframePropertiesDialog(const QVector<NodeKeyframe*> &keys, const rational &timebase, QWidget *parent) :
KeyframePropertiesDialog::KeyframePropertiesDialog(const std::vector<NodeKeyframe*> &keys, const rational &timebase, QWidget *parent) :
QDialog(parent),
keys_(keys),
timebase_(timebase)
@@ -91,7 +91,7 @@ KeyframePropertiesDialog::KeyframePropertiesDialog(const QVector<NodeKeyframe*>
bool all_same_bezier_out_x = true;
bool all_same_bezier_out_y = true;
for (int i=0;i<keys_.size();i++) {
for (size_t i=0;i<keys_.size();i++) {
if (i > 0) {
NodeKeyframe* prev_key = keys_.at(i-1);
NodeKeyframe* this_key = keys_.at(i);
@@ -126,7 +126,7 @@ KeyframePropertiesDialog::KeyframePropertiesDialog(const QVector<NodeKeyframe*>
// Determine if any keyframes are on the same track (in which case we can't set the time)
if (can_set_time) {
for (int j=0;j<keys_.size();j++) {
for (size_t j=0;j<keys_.size();j++) {
if (i != j
&& keys_.at(j)->track() == keys_.at(i)->track()) {
can_set_time = false;
@@ -147,7 +147,7 @@ KeyframePropertiesDialog::KeyframePropertiesDialog(const QVector<NodeKeyframe*>
}
if (all_same_time) {
time_slider_->SetValue(keys_.first()->time());
time_slider_->SetValue(keys_.front()->time());
} else {
time_slider_->SetTristate();
}
@@ -169,7 +169,7 @@ KeyframePropertiesDialog::KeyframePropertiesDialog(const QVector<NodeKeyframe*>
if (all_same_type) {
// If all keyframes are the same type, set it here
for (int i=0;i<type_select_->count();i++) {
if (type_select_->itemData(i).toInt() == keys_.first()->type()) {
if (type_select_->itemData(i).toInt() == keys_.front()->type()) {
type_select_->setCurrentIndex(i);
// Ensure UI updates for this index
@@ -179,10 +179,10 @@ KeyframePropertiesDialog::KeyframePropertiesDialog(const QVector<NodeKeyframe*>
}
}
SetUpBezierSlider(bezier_in_x_slider_, all_same_bezier_in_x, keys_.first()->bezier_control_in().x());
SetUpBezierSlider(bezier_in_y_slider_, all_same_bezier_in_y, keys_.first()->bezier_control_in().y());
SetUpBezierSlider(bezier_out_x_slider_, all_same_bezier_out_x, keys_.first()->bezier_control_out().x());
SetUpBezierSlider(bezier_out_y_slider_, all_same_bezier_out_y, keys_.first()->bezier_control_out().y());
SetUpBezierSlider(bezier_in_x_slider_, all_same_bezier_in_x, keys_.front()->bezier_control_in().x());
SetUpBezierSlider(bezier_in_y_slider_, all_same_bezier_in_y, keys_.front()->bezier_control_in().y());
SetUpBezierSlider(bezier_out_x_slider_, all_same_bezier_out_x, keys_.front()->bezier_control_out().x());
SetUpBezierSlider(bezier_out_y_slider_, all_same_bezier_out_y, keys_.front()->bezier_control_out().y());
row++;
@@ -35,7 +35,7 @@ class KeyframePropertiesDialog : public QDialog
{
Q_OBJECT
public:
KeyframePropertiesDialog(const QVector<NodeKeyframe*>& keys, const rational& timebase, QWidget* parent = nullptr);
KeyframePropertiesDialog(const std::vector<NodeKeyframe*>& keys, const rational& timebase, QWidget* parent = nullptr);
public slots:
virtual void accept() override;
@@ -43,7 +43,7 @@ public slots:
private:
void SetUpBezierSlider(FloatSlider *slider, bool all_same, double value);
const QVector<NodeKeyframe*>& keys_;
const std::vector<NodeKeyframe*>& keys_;
rational timebase_;
@@ -32,7 +32,7 @@ namespace olive {
#define super QDialog
MarkerPropertiesDialog::MarkerPropertiesDialog(const QVector<TimelineMarker *> &markers, const rational &timebase, QWidget *parent) :
MarkerPropertiesDialog::MarkerPropertiesDialog(const std::vector<TimelineMarker *> &markers, const rational &timebase, QWidget *parent) :
super(parent),
markers_(markers)
{
@@ -60,10 +60,10 @@ MarkerPropertiesDialog::MarkerPropertiesDialog(const QVector<TimelineMarker *> &
}
if (markers.size() == 1) {
in_slider_->SetValue(markers.first()->time_range().in());
in_slider_->SetValue(markers.front()->time_range().in());
in_slider_->SetDisplayType(RationalSlider::kTime);
in_slider_->SetTimebase(timebase);
out_slider_->SetValue(markers.first()->time_range().out());
out_slider_->SetValue(markers.front()->time_range().out());
out_slider_->SetDisplayType(RationalSlider::kTime);
out_slider_->SetTimebase(timebase);
} else {
@@ -83,8 +83,8 @@ MarkerPropertiesDialog::MarkerPropertiesDialog(const QVector<TimelineMarker *> &
color_menu_ = new ColorCodingComboBox();
layout->addWidget(color_menu_, row, 1);
color_menu_->SetColor(markers.first()->color());
for (int i=1; i<markers.size(); i++) {
color_menu_->SetColor(markers.front()->color());
for (size_t i=1; i<markers.size(); i++) {
if (markers.at(i)->color() != color_menu_->GetSelectedColor()) {
color_menu_->SetColor(-1);
break;
@@ -102,8 +102,8 @@ MarkerPropertiesDialog::MarkerPropertiesDialog(const QVector<TimelineMarker *> &
layout->addWidget(label_edit_, row, 1);
// Determine what the startup label text should be
label_edit_->setText(markers.first()->name());
for (int i=1; i<markers.size(); i++) {
label_edit_->setText(markers.front()->name());
for (size_t i=1; i<markers.size(); i++) {
if (markers.at(i)->name() != label_edit_->text()) {
label_edit_->clear();
label_edit_->setPlaceholderText(tr("(multiple)"));
@@ -141,7 +141,7 @@ void MarkerPropertiesDialog::accept()
}
if (markers_.size() == 1) {
command->add_child(new MarkerChangeTimeCommand(markers_.first(), TimeRange(in_slider_->GetValue(), out_slider_->GetValue())));
command->add_child(new MarkerChangeTimeCommand(markers_.front(), TimeRange(in_slider_->GetValue(), out_slider_->GetValue())));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
@@ -55,13 +55,13 @@ class MarkerPropertiesDialog : public QDialog
{
Q_OBJECT
public:
MarkerPropertiesDialog(const QVector<TimelineMarker*> &markers, const rational &timebase, QWidget *parent = nullptr);
MarkerPropertiesDialog(const std::vector<TimelineMarker*> &markers, const rational &timebase, QWidget *parent = nullptr);
public slots:
virtual void accept() override;
private:
QVector<TimelineMarker*> markers_;
std::vector<TimelineMarker*> markers_;
LineEditWithFocusSignal *label_edit_;