implemented undos for effect fields that aren't keyframed
This commit is contained in:
+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