implemented undos for effect fields that aren't keyframed
This commit is contained in:
@@ -536,6 +536,7 @@ void ExportDialog::on_compressionTypeCombobox_currentIndexChanged(int) {
|
||||
ui->videobitrateSpinbox->setMaximum(99.99);
|
||||
switch (ui->compressionTypeCombobox->currentData().toInt()) {
|
||||
case COMPRESSION_TYPE_CBR:
|
||||
case COMPRESSION_TYPE_TARGETBR:
|
||||
ui->videoBitrateLabel->setText("Bitrate (Mbps):");
|
||||
ui->videobitrateSpinbox->setValue(qMax(0.5, (double) qRound((0.01528 * sequence->height) - 4.5)));
|
||||
break;
|
||||
@@ -549,9 +550,5 @@ void ExportDialog::on_compressionTypeCombobox_currentIndexChanged(int) {
|
||||
ui->videoBitrateLabel->setText("Target File Size (MB):");
|
||||
ui->videobitrateSpinbox->setValue(100);
|
||||
break;
|
||||
case COMPRESSION_TYPE_TARGETBR:
|
||||
ui->videoBitrateLabel->setText("Target Bitrate (Mbps):");
|
||||
ui->videobitrateSpinbox->setValue(100);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+20
-3
@@ -598,6 +598,18 @@ EffectField::EffectField(EffectRow *parent, int t) : parent_row(parent), type(t)
|
||||
}
|
||||
}
|
||||
|
||||
QVariant EffectField::get_previous_data() {
|
||||
switch (type) {
|
||||
case EFFECT_FIELD_DOUBLE: return static_cast<LabelSlider*>(ui_element)->getPreviousValue(); break;
|
||||
case EFFECT_FIELD_COLOR: return static_cast<ColorButton*>(ui_element)->getPreviousValue(); break;
|
||||
case EFFECT_FIELD_STRING: return static_cast<TextEditEx*>(ui_element)->getPreviousValue(); break;
|
||||
case EFFECT_FIELD_BOOL: return !static_cast<QCheckBox*>(ui_element)->isChecked(); break;
|
||||
case EFFECT_FIELD_COMBO: return static_cast<ComboBoxEx*>(ui_element)->getPreviousIndex(); break;
|
||||
case EFFECT_FIELD_FONT: return static_cast<FontCombobox*>(ui_element)->getPreviousValue(); break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant EffectField::get_current_data() {
|
||||
switch (type) {
|
||||
case EFFECT_FIELD_DOUBLE: return static_cast<LabelSlider*>(ui_element)->value(); break;
|
||||
@@ -720,9 +732,14 @@ void EffectField::validate_keyframe_data(double timecode) {
|
||||
}
|
||||
|
||||
void EffectField::uiElementChange() {
|
||||
bool enableKeyframes = !(type == EFFECT_FIELD_DOUBLE && static_cast<LabelSlider*>(ui_element)->is_dragging());
|
||||
if (parent_row->isKeyframing()) {
|
||||
parent_row->set_keyframe_now(!(type == EFFECT_FIELD_DOUBLE && static_cast<LabelSlider*>(ui_element)->is_dragging()));
|
||||
}
|
||||
parent_row->set_keyframe_now(enableKeyframes);
|
||||
} else if (enableKeyframes) {
|
||||
// set undo
|
||||
qDebug() << "h";
|
||||
undo_stack.push(new EffectFieldUndo(this));
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
|
||||
@@ -797,7 +814,7 @@ const QString EffectField::get_string_value(double timecode) {
|
||||
}
|
||||
|
||||
void EffectField::set_string_value(const QString& s) {
|
||||
static_cast<TextEditEx*>(ui_element)->setText(s);
|
||||
static_cast<TextEditEx*>(ui_element)->setPlainTextEx(s);
|
||||
}
|
||||
|
||||
const QString EffectField::get_font_name(double timecode) {
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
EffectRow* parent_row;
|
||||
int type;
|
||||
|
||||
QVariant get_previous_data();
|
||||
QVariant get_current_data();
|
||||
double frameToTimecode(long frame);
|
||||
long timecodeToFrame(double timecode);
|
||||
|
||||
@@ -1302,3 +1302,19 @@ void KeyframeSet::redo() {
|
||||
project_changed = true;
|
||||
done = true;
|
||||
}
|
||||
|
||||
EffectFieldUndo::EffectFieldUndo(EffectField* f) : field(f), done(true) {
|
||||
old_val = field->get_previous_data();
|
||||
new_val = field->get_current_data();
|
||||
}
|
||||
|
||||
void EffectFieldUndo::undo() {
|
||||
field->set_current_data(old_val);
|
||||
done = false;
|
||||
}
|
||||
|
||||
void EffectFieldUndo::redo() {
|
||||
if (!done) {
|
||||
field->set_current_data(new_val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ class LabelSlider;
|
||||
class Effect;
|
||||
class SourceTable;
|
||||
class EffectRow;
|
||||
class EffectField;
|
||||
class Transition;
|
||||
struct Clip;
|
||||
struct Sequence;
|
||||
@@ -15,6 +16,7 @@ struct Media;
|
||||
#include <QUndoStack>
|
||||
#include <QUndoCommand>
|
||||
#include <QVector>
|
||||
#include <QVariant>
|
||||
|
||||
#define TA_NO_TRANSITION 0
|
||||
#define TA_OPENING_TRANSITION 1
|
||||
@@ -427,4 +429,16 @@ private:
|
||||
bool done;
|
||||
};
|
||||
|
||||
class EffectFieldUndo : public QUndoCommand {
|
||||
public:
|
||||
EffectFieldUndo(EffectField* field);
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
EffectField* field;
|
||||
QVariant old_val;
|
||||
QVariant new_val;
|
||||
bool done;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
+7
-8
@@ -15,10 +15,15 @@ QColor ColorButton::get_color() {
|
||||
}
|
||||
|
||||
void ColorButton::set_color(QColor c) {
|
||||
previousColor = color;
|
||||
color = c;
|
||||
set_button_color();
|
||||
}
|
||||
|
||||
const QColor &ColorButton::getPreviousValue() {
|
||||
return previousColor;
|
||||
}
|
||||
|
||||
void ColorButton::set_button_color() {
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Button, color);
|
||||
@@ -26,16 +31,10 @@ void ColorButton::set_button_color() {
|
||||
}
|
||||
|
||||
void ColorButton::open_dialog() {
|
||||
QColor old_color = color;
|
||||
QColor new_color = QColorDialog::getColor(color, NULL);
|
||||
if (new_color.isValid() && old_color != new_color) {
|
||||
ColorCommand* command = new ColorCommand(this, old_color, new_color);
|
||||
// undo_stack.push(command);
|
||||
command->redo();
|
||||
delete command;
|
||||
|
||||
if (new_color.isValid() && color != new_color) {
|
||||
set_color(new_color);
|
||||
set_button_color();
|
||||
|
||||
emit color_changed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,10 @@ public:
|
||||
ColorButton(QWidget* parent = 0);
|
||||
QColor get_color();
|
||||
void set_color(QColor c);
|
||||
const QColor& getPreviousValue();
|
||||
private:
|
||||
QColor color;
|
||||
QColor previousColor;
|
||||
void set_button_color();
|
||||
signals:
|
||||
void color_changed();
|
||||
|
||||
@@ -43,8 +43,13 @@ void ComboBoxEx::setCurrentTextEx(const QString &text) {
|
||||
index = currentIndex();
|
||||
}
|
||||
|
||||
int ComboBoxEx::getPreviousIndex() {
|
||||
return previousIndex;
|
||||
}
|
||||
|
||||
void ComboBoxEx::index_changed(int i) {
|
||||
if (index != i) {
|
||||
previousIndex = index;
|
||||
// undo_stack.push(new ComboBoxExCommand(this, index, i));
|
||||
index = i;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,12 @@ public:
|
||||
ComboBoxEx(QWidget* parent = 0);
|
||||
void setCurrentIndexEx(int i);
|
||||
void setCurrentTextEx(const QString &text);
|
||||
int getPreviousIndex();
|
||||
private slots:
|
||||
void index_changed(int);
|
||||
private:
|
||||
int index;
|
||||
int previousIndex;
|
||||
void wheelEvent(QWheelEvent* e);
|
||||
};
|
||||
|
||||
|
||||
@@ -4,4 +4,18 @@
|
||||
|
||||
FontCombobox::FontCombobox(QWidget* parent) : ComboBoxEx(parent) {
|
||||
addItems(QFontDatabase().families());
|
||||
|
||||
value = currentText();
|
||||
|
||||
connect(this, SIGNAL(currentTextChanged(QString)), this, SLOT(updateInternals()));
|
||||
}
|
||||
|
||||
const QString& FontCombobox::getPreviousValue() {
|
||||
return previousValue;
|
||||
}
|
||||
|
||||
void FontCombobox::updateInternals() {
|
||||
qDebug() << "h";
|
||||
previousValue = value;
|
||||
value = currentText();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,15 @@
|
||||
#include "comboboxex.h"
|
||||
|
||||
class FontCombobox : public ComboBoxEx {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontCombobox(QWidget* parent = 0);
|
||||
const QString &getPreviousValue();
|
||||
private slots:
|
||||
void updateInternals();
|
||||
private:
|
||||
QString previousValue;
|
||||
QString value;
|
||||
};
|
||||
|
||||
#endif // FONTCOMBOBOX_H
|
||||
|
||||
+10
-1
@@ -47,6 +47,10 @@ QString LabelSlider::valueToString(double v) {
|
||||
return QString::number(v, 'f', 1);
|
||||
}
|
||||
|
||||
double LabelSlider::getPreviousValue() {
|
||||
return previous_value;
|
||||
}
|
||||
|
||||
double LabelSlider::value() {
|
||||
return internal_value;
|
||||
}
|
||||
@@ -76,7 +80,10 @@ double LabelSlider::get_drag_start_value() {
|
||||
void LabelSlider::mousePressEvent(QMouseEvent *ev) {
|
||||
drag_start_value = internal_value;
|
||||
if (ev->modifiers() & Qt::AltModifier) {
|
||||
set_value(default_value, true);
|
||||
if (internal_value != default_value) {
|
||||
previous_value = internal_value;
|
||||
set_value(default_value, true);
|
||||
}
|
||||
} else {
|
||||
qApp->setOverrideCursor(Qt::BlankCursor);
|
||||
drag_start = true;
|
||||
@@ -99,10 +106,12 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) {
|
||||
drag_start = false;
|
||||
if (drag_proc) {
|
||||
drag_proc = false;
|
||||
previous_value = drag_start_value;
|
||||
emit valueChanged();
|
||||
} else {
|
||||
double d = QInputDialog::getDouble(this, "Set Value", "New value:", internal_value);
|
||||
if (d != internal_value) {
|
||||
previous_value = internal_value;
|
||||
set_value(d, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
double get_drag_start_value();
|
||||
bool is_dragging();
|
||||
virtual QString valueToString(double v);
|
||||
double getPreviousValue();
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
void mouseMoveEvent(QMouseEvent *ev);
|
||||
@@ -26,6 +27,7 @@ private:
|
||||
double default_value;
|
||||
double internal_value;
|
||||
double drag_start_value;
|
||||
double previous_value;
|
||||
|
||||
bool min_enabled;
|
||||
double min_value;
|
||||
|
||||
+15
-1
@@ -2,7 +2,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
TextEditEx::TextEditEx(QWidget *parent) : QTextEdit(parent) {}
|
||||
TextEditEx::TextEditEx(QWidget *parent) : QTextEdit(parent) {
|
||||
setUndoRedoEnabled(false);
|
||||
connect(this, SIGNAL(textChanged()), this, SLOT(updateInternals()));
|
||||
}
|
||||
|
||||
void TextEditEx::setPlainTextEx(const QString &text) {
|
||||
blockSignals(true);
|
||||
@@ -15,5 +18,16 @@ void TextEditEx::setPlainTextEx(const QString &text) {
|
||||
newCursor.setPosition(pos);
|
||||
setTextCursor(newCursor);
|
||||
|
||||
updateInternals();
|
||||
|
||||
blockSignals(false);
|
||||
}
|
||||
|
||||
const QString &TextEditEx::getPreviousValue() {
|
||||
return previousText;
|
||||
}
|
||||
|
||||
void TextEditEx::updateInternals() {
|
||||
previousText = text;
|
||||
text = toPlainText();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@ class TextEditEx : public QTextEdit {
|
||||
public:
|
||||
TextEditEx(QWidget* parent = 0);
|
||||
void setPlainTextEx(const QString &text);
|
||||
const QString& getPreviousValue();
|
||||
private slots:
|
||||
void updateInternals();
|
||||
private:
|
||||
QString previousText;
|
||||
QString text;
|
||||
};
|
||||
|
||||
#endif // TEXTEDITEX_H
|
||||
|
||||
Reference in New Issue
Block a user