code cleanup
This commit is contained in:
+16
-7
@@ -5,27 +5,36 @@
|
||||
#include "ui/viewerwidget.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "effects/effects.h"
|
||||
#include "panels/project.h"
|
||||
#include "project/undo.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
|
||||
Effect::Effect(Clip* c) : parent_clip(c) {
|
||||
type = EFFECT_TYPE_INVALID;
|
||||
}
|
||||
|
||||
void Effect::setup_effect(int t, int i) {
|
||||
type = t;
|
||||
id = i;
|
||||
Effect::Effect(Clip* c, int t, int i) : parent_clip(c), type(t), id(i) {
|
||||
container = new CollapsibleWidget();
|
||||
if (type == EFFECT_TYPE_VIDEO) {
|
||||
container->setText(video_effect_names[i]);
|
||||
} else if (type == EFFECT_TYPE_AUDIO) {
|
||||
container->setText(audio_effect_names[i]);
|
||||
}
|
||||
connect(container->enabled_check, SIGNAL(clicked(bool)), this, SLOT(checkbox_command()));
|
||||
connect(container->enabled_check, SIGNAL(clicked(bool)), this, SLOT(field_changed()));
|
||||
ui = new QWidget();
|
||||
|
||||
ui_layout = new QGridLayout();
|
||||
ui->setLayout(ui_layout);
|
||||
container->setContents(ui);
|
||||
}
|
||||
|
||||
void Effect::field_changed() {
|
||||
panel_viewer->viewer_widget->update();
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
void Effect::checkbox_command() {
|
||||
CheckboxCommand* c = new CheckboxCommand(static_cast<QCheckBox*>(sender()));
|
||||
undo_stack.push(c);
|
||||
}
|
||||
|
||||
bool Effect::is_enabled() {
|
||||
|
||||
+5
-6
@@ -5,6 +5,7 @@
|
||||
#include <QString>
|
||||
class QWidget;
|
||||
class CollapsibleWidget;
|
||||
class QGridLayout;
|
||||
|
||||
struct Clip;
|
||||
class QXmlStreamReader;
|
||||
@@ -16,13 +17,14 @@ class Effect : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Effect(Clip* c); // default constructor
|
||||
Effect(Clip* c, int t, int i); // default constructor
|
||||
Clip* parent_clip;
|
||||
int type;
|
||||
int id;
|
||||
QString name;
|
||||
CollapsibleWidget* container;
|
||||
QGridLayout* ui_layout;
|
||||
QWidget* ui;
|
||||
Clip* parent_clip;
|
||||
|
||||
bool is_enabled();
|
||||
|
||||
@@ -34,12 +36,9 @@ public:
|
||||
virtual void process_gl(int* anchor_x, int* anchor_y);
|
||||
virtual void post_gl();
|
||||
virtual void process_audio(quint8* samples, int nb_bytes);
|
||||
|
||||
public slots:
|
||||
void field_changed();
|
||||
|
||||
protected:
|
||||
void setup_effect(int t, int i);
|
||||
void checkbox_command();
|
||||
};
|
||||
|
||||
#endif // EFFECT_H
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <QDebug>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QMessageBox>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "project/clip.h"
|
||||
#include "project/sequence.h"
|
||||
@@ -383,3 +384,18 @@ void LinkCommand::redo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CheckboxCommand::CheckboxCommand(QCheckBox* b) : box(b), done(true), checked(box->isChecked()) {}
|
||||
|
||||
CheckboxCommand::~CheckboxCommand() {}
|
||||
|
||||
void CheckboxCommand::undo() {
|
||||
box->setChecked(!checked);
|
||||
done = false;
|
||||
}
|
||||
|
||||
void CheckboxCommand::redo() {
|
||||
if (!done) {
|
||||
box->setChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define UNDO_H
|
||||
|
||||
class QTreeWidgetItem;
|
||||
class QCheckBox;
|
||||
struct Clip;
|
||||
struct Sequence;
|
||||
|
||||
@@ -79,4 +80,16 @@ private:
|
||||
QVector< QVector<int> > old_links;
|
||||
};
|
||||
|
||||
class CheckboxCommand : public QUndoCommand {
|
||||
public:
|
||||
CheckboxCommand(QCheckBox* b);
|
||||
~CheckboxCommand();
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
QCheckBox* box;
|
||||
bool checked;
|
||||
bool done;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
Reference in New Issue
Block a user