code cleanup
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include "colorbutton.h"
|
||||
|
||||
#include "project/undo.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
|
||||
ColorButton::ColorButton(QWidget *parent)
|
||||
: QPushButton(parent), color(Qt::white) {
|
||||
set_button_color();
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(open_dialog()));
|
||||
}
|
||||
|
||||
QColor ColorButton::get_color() {
|
||||
return color;
|
||||
}
|
||||
|
||||
void ColorButton::set_color(QColor c) {
|
||||
color = c;
|
||||
}
|
||||
|
||||
void ColorButton::set_button_color() {
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Button, color);
|
||||
setPalette(pal);
|
||||
}
|
||||
|
||||
void ColorButton::open_dialog() {
|
||||
QColor old_color = color;
|
||||
QColor new_color = QColorDialog::getColor(color, NULL);
|
||||
if (old_color != new_color) {
|
||||
ColorCommand* command = new ColorCommand(this, old_color, new_color);
|
||||
undo_stack.push(command);
|
||||
|
||||
set_button_color();
|
||||
emit color_changed();
|
||||
}
|
||||
}
|
||||
|
||||
ColorCommand::ColorCommand(ColorButton* s, QColor o, QColor n)
|
||||
: sender(s), old_color(o), new_color(n) {}
|
||||
|
||||
void ColorCommand::undo() {
|
||||
sender->set_color(old_color);
|
||||
}
|
||||
|
||||
void ColorCommand::redo() {
|
||||
sender->set_color(new_color);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef COLORBUTTON_H
|
||||
#define COLORBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QColor>
|
||||
#include <QUndoCommand>
|
||||
|
||||
class ColorButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorButton(QWidget* parent = 0);
|
||||
QColor get_color();
|
||||
void set_color(QColor c);
|
||||
private:
|
||||
QColor color;
|
||||
void set_button_color();
|
||||
signals:
|
||||
void color_changed();
|
||||
private slots:
|
||||
void open_dialog();
|
||||
};
|
||||
|
||||
class ColorCommand : public QUndoCommand {
|
||||
public:
|
||||
ColorCommand(ColorButton* s, QColor o, QColor n);
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
ColorButton* sender;
|
||||
QColor old_color;
|
||||
QColor new_color;
|
||||
};
|
||||
|
||||
#endif // COLORBUTTON_H
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "comboboxex.h"
|
||||
|
||||
#include "project/undo.h"
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QWheelEvent>
|
||||
|
||||
class ComboBoxExCommand : public QUndoCommand {
|
||||
public:
|
||||
ComboBoxExCommand(ComboBoxEx* obj, int old_index, int new_index) :
|
||||
combobox(obj), old_val(old_index), new_val(new_index), done(true) {}
|
||||
void undo() {
|
||||
combobox->setCurrentIndex(old_val);
|
||||
done = false;
|
||||
}
|
||||
void redo() {
|
||||
if (!done) {
|
||||
combobox->setCurrentIndex(new_val);
|
||||
}
|
||||
}
|
||||
private:
|
||||
ComboBoxEx* combobox;
|
||||
int old_val;
|
||||
int new_val;
|
||||
bool done;
|
||||
};
|
||||
|
||||
ComboBoxEx::ComboBoxEx(QWidget *parent) : QComboBox(parent), index(0) {
|
||||
connect(this, SIGNAL(activated(int)), this, SLOT(index_changed(int)));
|
||||
}
|
||||
|
||||
void ComboBoxEx::index_changed(int i) {
|
||||
if (index != i) {
|
||||
undo_stack.push(new ComboBoxExCommand(this, index, i));
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBoxEx::wheelEvent(QWheelEvent* e) {
|
||||
e->ignore();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef COMBOBOXEX_H
|
||||
#define COMBOBOXEX_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
|
||||
class ComboBoxEx : public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ComboBoxEx(QWidget* parent = 0);
|
||||
private slots:
|
||||
void index_changed(int);
|
||||
private:
|
||||
int index;
|
||||
void wheelEvent(QWheelEvent* e);
|
||||
};
|
||||
|
||||
#endif // COMBOBOXEX_H
|
||||
+3
-4
@@ -19,8 +19,7 @@ extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
}
|
||||
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent)
|
||||
{
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent) {
|
||||
multithreaded = true;
|
||||
enable_paint = true;
|
||||
force_audio = false;
|
||||
@@ -130,7 +129,7 @@ void ViewerWidget::paintGL() {
|
||||
|
||||
// perform all transform effects
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
c->effects.at(j)->process_gl(&anchor_x, &anchor_y);
|
||||
if (c->effects.at(j)->is_enabled()) c->effects.at(j)->process_gl(&anchor_x, &anchor_y);
|
||||
}
|
||||
|
||||
if (c->opening_transition != NULL) {
|
||||
@@ -169,7 +168,7 @@ void ViewerWidget::paintGL() {
|
||||
|
||||
// perform all transform effects
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
c->effects.at(j)->post_gl();
|
||||
if (c->effects.at(j)->is_enabled()) c->effects.at(j)->post_gl();
|
||||
}
|
||||
}
|
||||
} else if (render_audio &&
|
||||
|
||||
Reference in New Issue
Block a user