improved effects signalling
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "ui/colorbutton.h"
|
||||
#include "ui/comboboxex.h"
|
||||
#include "ui/fontcombobox.h"
|
||||
#include "ui/checkboxex.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
@@ -22,8 +23,7 @@ Effect::Effect(Clip* c, int t, int i) : parent_clip(c), type(t), id(i) {
|
||||
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();
|
||||
|
||||
@@ -54,11 +54,6 @@ void Effect::field_changed() {
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
void Effect::checkbox_command() {
|
||||
CheckboxCommand* c = new CheckboxCommand(static_cast<QCheckBox*>(sender()));
|
||||
undo_stack.push(c);
|
||||
}
|
||||
|
||||
bool Effect::is_enabled() {
|
||||
return container->enabled_check->isChecked();
|
||||
}
|
||||
@@ -66,12 +61,12 @@ bool Effect::is_enabled() {
|
||||
void Effect::load(QXmlStreamReader* stream) {
|
||||
for (int i=0;i<rows.size();i++) {
|
||||
EffectRow* row = rows.at(i);
|
||||
while (!stream->atEnd()) {
|
||||
while (!stream->atEnd() && !(stream->name() == "effect" && stream->isEndElement())) {
|
||||
stream->readNext();
|
||||
if (stream->name() == "row" && stream->isStartElement()) {
|
||||
for (int j=0;j<row->fieldCount();j++) {
|
||||
EffectField* field = row->field(j);
|
||||
while (!stream->atEnd()) {
|
||||
while (!stream->atEnd() && !(stream->name() == "effect" && stream->isEndElement())) {
|
||||
stream->readNext();
|
||||
if (stream->name() == "field" && stream->isStartElement()) {
|
||||
stream->readNext();
|
||||
@@ -103,6 +98,7 @@ void Effect::load(QXmlStreamReader* stream) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Effect::save(QXmlStreamWriter* stream) {
|
||||
@@ -148,7 +144,7 @@ EffectRow::EffectRow(Effect *parent, QGridLayout *uilayout, const QString &n, in
|
||||
}
|
||||
|
||||
EffectField* EffectRow::add_field(int type) {
|
||||
EffectField* field = new EffectField(parent_effect, type);
|
||||
EffectField* field = new EffectField(type);
|
||||
fields.append(field);
|
||||
QWidget* element = field->get_ui_element();
|
||||
ui->addWidget(element, ui_row, fields.size());
|
||||
@@ -171,18 +167,20 @@ int EffectRow::fieldCount() {
|
||||
|
||||
/* Effect Field Definitions */
|
||||
|
||||
EffectField::EffectField(Effect *parent, int t) : type(t) {
|
||||
EffectField::EffectField(int t) : type(t) {
|
||||
switch (t) {
|
||||
case EFFECT_FIELD_DOUBLE:
|
||||
{
|
||||
LabelSlider* ls = new LabelSlider();
|
||||
ui_element = ls;
|
||||
QObject::connect(ls, SIGNAL(valueChanged()), parent, SLOT(field_changed()));
|
||||
connect(ls, SIGNAL(valueChanged()), this, SIGNAL(changed()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_COLOR:
|
||||
{
|
||||
ui_element = new ColorButton();
|
||||
ColorButton* cb = new ColorButton();
|
||||
ui_element = cb;
|
||||
connect(cb, SIGNAL(color_changed()), this, SIGNAL(changed()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_STRING:
|
||||
@@ -190,24 +188,28 @@ EffectField::EffectField(Effect *parent, int t) : type(t) {
|
||||
QTextEdit* edit = new QTextEdit();
|
||||
edit->setUndoRedoEnabled(true);
|
||||
ui_element = edit;
|
||||
connect(edit, SIGNAL(textChanged()), this, SIGNAL(changed()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_BOOL:
|
||||
{
|
||||
QCheckBox* cb = new QCheckBox();
|
||||
CheckboxEx* cb = new CheckboxEx();
|
||||
ui_element = cb;
|
||||
QObject::connect(cb, SIGNAL(toggled(bool)), parent, SLOT(field_changed()));
|
||||
QObject::connect(cb, SIGNAL(clicked(bool)), parent, SLOT(checkbox_command()));
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_COMBO:
|
||||
{
|
||||
ui_element = new ComboBoxEx();
|
||||
ComboBoxEx* cb = new ComboBoxEx();
|
||||
ui_element = cb;
|
||||
connect(cb, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_FONT:
|
||||
{
|
||||
ui_element = new FontCombobox();
|
||||
FontCombobox* fcb = new FontCombobox();
|
||||
ui_element = fcb;
|
||||
connect(fcb, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -218,14 +220,7 @@ QWidget* EffectField::get_ui_element() {
|
||||
}
|
||||
|
||||
void EffectField::set_enabled(bool e) {
|
||||
switch (type) {
|
||||
case EFFECT_FIELD_DOUBLE: static_cast<LabelSlider*>(ui_element)->setEnabled(e); break;
|
||||
case EFFECT_FIELD_COLOR: static_cast<ColorButton*>(ui_element)->setEnabled(e); break;
|
||||
case EFFECT_FIELD_STRING: static_cast<QTextEdit*>(ui_element)->setEnabled(e); break;
|
||||
case EFFECT_FIELD_BOOL: static_cast<QCheckBox*>(ui_element)->setEnabled(e); break;
|
||||
case EFFECT_FIELD_COMBO: static_cast<ComboBoxEx*>(ui_element)->setEnabled(e); break;
|
||||
case EFFECT_FIELD_FONT: static_cast<FontCombobox*>(ui_element)->setEnabled(e); break;
|
||||
}
|
||||
ui_element->setEnabled(e);
|
||||
}
|
||||
|
||||
double EffectField::get_double_value() {
|
||||
@@ -233,7 +228,7 @@ double EffectField::get_double_value() {
|
||||
}
|
||||
|
||||
void EffectField::set_double_value(double v) {
|
||||
static_cast<LabelSlider*>(ui_element)->set_value(v);
|
||||
static_cast<LabelSlider*>(ui_element)->set_value(v, false);
|
||||
}
|
||||
|
||||
void EffectField::set_double_default_value(double v) {
|
||||
@@ -24,10 +24,19 @@ class Effect;
|
||||
#define EFFECT_FIELD_COMBO 4
|
||||
#define EFFECT_FIELD_FONT 5
|
||||
|
||||
class EffectField : QObject {
|
||||
#define EFFECT_KEYFRAME_LINEAR 0
|
||||
#define EFFECT_KEYFRAME_HOLD 1
|
||||
#define EFFECT_KEYFRAME_BEZIER 2
|
||||
|
||||
class EffectKeyframe {
|
||||
public:
|
||||
long frame;
|
||||
};
|
||||
|
||||
class EffectField : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EffectField(Effect* parent, int t);
|
||||
EffectField(int t);
|
||||
int type;
|
||||
|
||||
double get_double_value();
|
||||
@@ -56,6 +65,8 @@ public:
|
||||
|
||||
QWidget* get_ui_element();
|
||||
void set_enabled(bool e);
|
||||
signals:
|
||||
void changed();
|
||||
private:
|
||||
QWidget* ui_element;
|
||||
};
|
||||
@@ -106,7 +117,6 @@ public:
|
||||
virtual void process_audio(quint8* samples, int nb_bytes);
|
||||
public slots:
|
||||
void field_changed();
|
||||
void checkbox_command();
|
||||
private:
|
||||
QVector<EffectRow*> rows;
|
||||
QGridLayout* ui_layout;
|
||||
+4
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef EFFECTS_H
|
||||
#define EFFECTS_H
|
||||
|
||||
#include "project/effect.h"
|
||||
#include "effect.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QFont>
|
||||
@@ -98,11 +98,14 @@ public:
|
||||
~TextEffect();
|
||||
void post_gl();
|
||||
Effect* copy(Clip* c);
|
||||
void refresh();
|
||||
|
||||
EffectField* text_val;
|
||||
EffectField* size_val;
|
||||
EffectField* set_color_button;
|
||||
EffectField* set_font_combobox;
|
||||
EffectField* halign_field;
|
||||
EffectField* valign_field;
|
||||
private slots:
|
||||
void update_texture();
|
||||
private:
|
||||
|
||||
@@ -16,6 +16,8 @@ PanEffect::PanEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_PAN_EFFECT) {
|
||||
|
||||
// set defaults
|
||||
pan_val->set_double_default_value(0);
|
||||
|
||||
connect(pan_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
void PanEffect::refresh() {}
|
||||
|
||||
@@ -31,6 +31,10 @@ ShakeEffect::ShakeEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SHAKE_EFF
|
||||
frequency_val->set_double_default_value(10);
|
||||
|
||||
refresh();
|
||||
|
||||
connect(intensity_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(rotation_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(frequency_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
void ShakeEffect::refresh() {
|
||||
|
||||
+52
-29
@@ -38,54 +38,77 @@ TextEffect::TextEffect(Clip *c) :
|
||||
EffectRow* color_row = add_row("Color:");
|
||||
set_color_button = color_row->add_field(EFFECT_FIELD_COLOR);
|
||||
|
||||
connect(static_cast<QTextEdit*>(text_val->get_ui_element()), SIGNAL(textChanged()), this, SLOT(update_texture()));
|
||||
connect(static_cast<LabelSlider*>(size_val->get_ui_element()), SIGNAL(valueChanged()), this, SLOT(update_texture()));
|
||||
connect(static_cast<ColorButton*>(set_color_button->get_ui_element()), SIGNAL(color_changed()), this, SLOT(update_texture()));
|
||||
connect(static_cast<FontCombobox*>(set_font_combobox->get_ui_element()), SIGNAL(currentTextChanged(QString)), this, SLOT(update_texture()));
|
||||
EffectRow* alignment_row = add_row("Alignment:");
|
||||
halign_field = alignment_row->add_field(EFFECT_FIELD_COMBO);
|
||||
halign_field->add_combo_item("Left", Qt::AlignLeft);
|
||||
halign_field->add_combo_item("Center", Qt::AlignHCenter);
|
||||
halign_field->add_combo_item("Right", Qt::AlignRight);
|
||||
halign_field->add_combo_item("Justify", Qt::AlignJustify);
|
||||
valign_field = alignment_row->add_field(EFFECT_FIELD_COMBO);
|
||||
valign_field->add_combo_item("Top", Qt::AlignTop);
|
||||
valign_field->add_combo_item("Center", Qt::AlignVCenter);
|
||||
valign_field->add_combo_item("Bottom", Qt::AlignBottom);
|
||||
|
||||
size_val->set_double_default_value(24);
|
||||
size_val->set_double_default_value(48);
|
||||
text_val->set_string_value("Sample Text");
|
||||
halign_field->set_combo_index(1);
|
||||
valign_field->set_combo_index(1);
|
||||
|
||||
connect(text_val, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(size_val, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(set_color_button, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(set_font_combobox, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(halign_field, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
connect(valign_field, SIGNAL(changed()), this, SLOT(update_texture()));
|
||||
|
||||
update_texture();
|
||||
}
|
||||
|
||||
TextEffect::~TextEffect() {
|
||||
destroy_texture();
|
||||
}
|
||||
|
||||
void TextEffect::refresh() {
|
||||
update_texture();
|
||||
}
|
||||
|
||||
void TextEffect::destroy_texture() {
|
||||
texture->destroy();
|
||||
}
|
||||
|
||||
void TextEffect::update_texture() {
|
||||
if (parent_clip->sequence->width != width || parent_clip->sequence->height != height) {
|
||||
width = parent_clip->sequence->width;
|
||||
height = parent_clip->sequence->height;
|
||||
pixmap = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
pixmap.fill(Qt::transparent);
|
||||
if (parent_clip->sequence != NULL) {
|
||||
if (parent_clip->sequence->width != width || parent_clip->sequence->height != height) {
|
||||
width = parent_clip->sequence->width;
|
||||
height = parent_clip->sequence->height;
|
||||
pixmap = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter p(&pixmap);
|
||||
p.setRenderHint(QPainter::TextAntialiasing, true);
|
||||
QPainter p(&pixmap);
|
||||
p.setRenderHint(QPainter::TextAntialiasing, true);
|
||||
|
||||
// set font
|
||||
font.setFamily(set_font_combobox->get_font_name());
|
||||
font.setPointSize(size_val->get_double_value());
|
||||
font.setStyleHint(QFont::Helvetica, QFont::PreferAntialias);
|
||||
p.setFont(font);
|
||||
// set font
|
||||
font.setFamily(set_font_combobox->get_font_name());
|
||||
font.setPointSize(size_val->get_double_value());
|
||||
font.setStyleHint(QFont::Helvetica, QFont::PreferAntialias);
|
||||
p.setFont(font);
|
||||
|
||||
p.setPen(set_color_button->get_color_value());
|
||||
p.drawText(QRect(0, 0, width, height), Qt::AlignCenter | Qt::TextWordWrap, text_val->get_string_value());
|
||||
p.setPen(set_color_button->get_color_value());
|
||||
p.drawText(QRect(0, 0, width, height), halign_field->get_combo_data().toInt() | valign_field->get_combo_data().toInt() | Qt::TextWordWrap, text_val->get_string_value());
|
||||
|
||||
if (texture == NULL) {
|
||||
texture = new QOpenGLTexture(pixmap);
|
||||
} else {
|
||||
destroy_texture();
|
||||
texture->setData(pixmap);
|
||||
}
|
||||
if (texture == NULL) {
|
||||
texture = new QOpenGLTexture(pixmap);
|
||||
} else {
|
||||
destroy_texture();
|
||||
texture->setData(pixmap);
|
||||
}
|
||||
|
||||
texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
|
||||
texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
|
||||
|
||||
// queue a repaint of the canvas
|
||||
field_changed();
|
||||
// queue a repaint of the canvas
|
||||
field_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void TextEffect::post_gl() {
|
||||
|
||||
@@ -64,6 +64,16 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_T
|
||||
blend_mode_box->set_combo_index(0);
|
||||
refresh();
|
||||
|
||||
connect(position_x, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(position_y, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(scale_x, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(scale_y, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(uniform_scale_field, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(rotation, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(anchor_x_box, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(anchor_y_box, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(opacity, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(blend_mode_box, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(uniform_scale_box, SIGNAL(toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ VolumeEffect::VolumeEffect(Clip* c) : Effect(c, EFFECT_TYPE_AUDIO, AUDIO_VOLUME_
|
||||
|
||||
// set defaults
|
||||
volume_val->set_double_default_value(100);
|
||||
|
||||
connect(volume_val, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
}
|
||||
|
||||
void VolumeEffect::refresh() {}
|
||||
|
||||
@@ -48,7 +48,6 @@ SOURCES += \
|
||||
panels/panels.cpp \
|
||||
effects/volumeeffect.cpp \
|
||||
effects/paneffect.cpp \
|
||||
project/effect.cpp \
|
||||
effects/effects.cpp \
|
||||
playback/cacher.cpp \
|
||||
io/exportthread.cpp \
|
||||
@@ -69,7 +68,9 @@ SOURCES += \
|
||||
dialogs/replaceclipmediadialog.cpp \
|
||||
effects/inverteffect.cpp \
|
||||
effects/linearfadetransition.cpp \
|
||||
ui/fontcombobox.cpp
|
||||
ui/fontcombobox.cpp \
|
||||
ui/checkboxex.cpp \
|
||||
effects/effect.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
@@ -92,7 +93,6 @@ HEADERS += \
|
||||
ui/viewercontainer.h \
|
||||
dialogs/exportdialog.h \
|
||||
ui/collapsiblewidget.h \
|
||||
project/effect.h \
|
||||
panels/panels.h \
|
||||
playback/cacher.h \
|
||||
io/exportthread.h \
|
||||
@@ -108,7 +108,9 @@ HEADERS += \
|
||||
ui/comboboxex.h \
|
||||
ui/colorbutton.h \
|
||||
dialogs/replaceclipmediadialog.h \
|
||||
ui/fontcombobox.h
|
||||
ui/fontcombobox.h \
|
||||
ui/checkboxex.h \
|
||||
effects/effect.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
|
||||
@@ -9,12 +9,14 @@
|
||||
#include "effects/effects.h"
|
||||
#include "effects/transition.h"
|
||||
#include "project/clip.h"
|
||||
#include "project/effect.h"
|
||||
#include "effects/effect.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "project/sequence.h"
|
||||
#include "project/undo.h"
|
||||
#include "panels/project.h"
|
||||
#include "panels/timeline.h"
|
||||
#include "panels/viewer.h"
|
||||
#include "ui/viewerwidget.h"
|
||||
|
||||
EffectControls::EffectControls(QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
@@ -173,6 +175,7 @@ void EffectControls::delete_effects() {
|
||||
}
|
||||
if (command->clips.size() > 0) {
|
||||
undo_stack.push(command);
|
||||
panel_viewer->viewer_widget->update();
|
||||
} else {
|
||||
delete command;
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
#include "effects/effects.h"
|
||||
#include "panels/timeline.h"
|
||||
#include "project/sequence.h"
|
||||
#include "project/effect.h"
|
||||
#include "effects/effect.h"
|
||||
#include "effects/transition.h"
|
||||
#include "io/previewgenerator.h"
|
||||
#include "project/undo.h"
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ void AudioSenderThread::run() {
|
||||
|
||||
lock.lock();
|
||||
while (true) {
|
||||
msleep(20);
|
||||
msleep(15);
|
||||
if (close) {
|
||||
break;
|
||||
} else if (panel_timeline->playing) {
|
||||
|
||||
+2
-2
@@ -789,14 +789,14 @@ void MediaRename::redo() {
|
||||
ValueChangeCommand::ValueChangeCommand() : done(true), old_project_changed(project_changed) {}
|
||||
|
||||
void ValueChangeCommand::undo() {
|
||||
source->set_value(old_val);
|
||||
source->set_value(old_val, false);
|
||||
done = false;
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void ValueChangeCommand::redo() {
|
||||
if (!done) {
|
||||
source->set_value(new_val);
|
||||
source->set_value(new_val, false);
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
+10
-11
@@ -37,14 +37,13 @@ void AudioMonitor::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
void AudioMonitor::paintEvent(QPaintEvent *) {
|
||||
if (sequence != NULL) {
|
||||
|
||||
QPainter p(this);
|
||||
int channel_x = AUDIO_MONITOR_GAP;
|
||||
int channel_count = av_get_channel_layout_nb_channels(sequence->audio_layout);
|
||||
if (peaks.size() != channel_count) {
|
||||
/*if (peaks.size() != channel_count) {
|
||||
peaks.resize(channel_count);
|
||||
peaks.fill(false);
|
||||
}
|
||||
}*/
|
||||
int channel_width = (width()/channel_count) - AUDIO_MONITOR_GAP;
|
||||
long playhead_offset = -1;
|
||||
int i;
|
||||
@@ -52,25 +51,25 @@ void AudioMonitor::paintEvent(QPaintEvent *) {
|
||||
QRect r(channel_x, AUDIO_MONITOR_PEAK_HEIGHT + AUDIO_MONITOR_GAP, channel_width, height());
|
||||
p.fillRect(r, gradient);
|
||||
|
||||
if (sample_cache_offset != -1) {
|
||||
if (sample_cache_offset != -1 && sample_cache.size() > 0) {
|
||||
playhead_offset = (panel_timeline->playhead - sample_cache_offset) * channel_count;
|
||||
if (playhead_offset >= 0 && playhead_offset < sample_cache.size()) {
|
||||
double multiplier = 1 - qAbs((double) sample_cache.at(playhead_offset+i) / 32768.0); // 16-bit int divided to float
|
||||
if (multiplier == (double) 0) {
|
||||
if (playhead_offset >= 0 && playhead_offset < sample_cache.size()) {
|
||||
double multiplier = 1 - qAbs((double) sample_cache.at(playhead_offset+i) / 32768.0); // 16-bit int divided to float
|
||||
/*if (multiplier == (double) 0) {
|
||||
peaks[i] = true;
|
||||
}
|
||||
}*/
|
||||
r.setHeight(r.height()*multiplier);
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
QRect peak_rect(channel_x, 0, channel_width, AUDIO_MONITOR_PEAK_HEIGHT);
|
||||
if (peaks.at(i)) {
|
||||
/*QRect peak_rect(channel_x, 0, channel_width, AUDIO_MONITOR_PEAK_HEIGHT);
|
||||
if (peaks.at(i)) {
|
||||
p.fillRect(peak_rect, QColor(255, 0, 0));
|
||||
} else {
|
||||
p.fillRect(peak_rect, QColor(64, 0, 0));
|
||||
}
|
||||
}*/
|
||||
|
||||
p.fillRect(r, QColor(0, 0, 0, 160));
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public slots:
|
||||
|
||||
private:
|
||||
QLinearGradient gradient;
|
||||
QVector<bool> peaks;
|
||||
// QVector<bool> peaks;
|
||||
};
|
||||
|
||||
#endif // AUDIOMONITOR_H
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "checkboxex.h"
|
||||
|
||||
#include "project/undo.h"
|
||||
|
||||
CheckboxEx::CheckboxEx(QWidget* parent) : QCheckBox(parent) {
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(checkbox_command()));
|
||||
}
|
||||
|
||||
void CheckboxEx::checkbox_command() {
|
||||
CheckboxCommand* c = new CheckboxCommand(this);
|
||||
undo_stack.push(c);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef CHECKBOXEX_H
|
||||
#define CHECKBOXEX_H
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
class CheckboxEx : public QCheckBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CheckboxEx(QWidget* parent = 0);
|
||||
private slots:
|
||||
void checkbox_command();
|
||||
};
|
||||
|
||||
#endif // CHECKBOXEX_H
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "collapsiblewidget.h"
|
||||
|
||||
#include "ui/checkboxex.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
@@ -24,7 +25,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) {
|
||||
QHBoxLayout* title_bar_layout = new QHBoxLayout();
|
||||
title_bar_layout->setMargin(5);
|
||||
title_bar->setLayout(title_bar_layout);
|
||||
enabled_check = new QCheckBox();
|
||||
enabled_check = new CheckboxEx();
|
||||
enabled_check->setChecked(true);
|
||||
header = new QLabel();
|
||||
collapse_button = new QPushButton("[-]");
|
||||
|
||||
@@ -8,6 +8,7 @@ class QHBoxLayout;
|
||||
class QVBoxLayout;
|
||||
class QPushButton;
|
||||
class QFrame;
|
||||
class CheckboxEx;
|
||||
|
||||
class CollapsibleWidgetHeader : public QWidget {
|
||||
Q_OBJECT
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
void setText(const QString &);
|
||||
bool is_focused();
|
||||
|
||||
QCheckBox* enabled_check;
|
||||
CheckboxEx* enabled_check;
|
||||
bool selected;
|
||||
private:
|
||||
QLabel* header;
|
||||
|
||||
+2
-1
@@ -23,7 +23,6 @@ void ColorButton::set_button_color() {
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Button, color);
|
||||
setPalette(pal);
|
||||
emit color_changed();
|
||||
}
|
||||
|
||||
void ColorButton::open_dialog() {
|
||||
@@ -34,6 +33,8 @@ void ColorButton::open_dialog() {
|
||||
undo_stack.push(command);
|
||||
|
||||
set_button_color();
|
||||
|
||||
emit color_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -14,11 +14,11 @@ LabelSlider::LabelSlider(QWidget* parent) : QLabel(parent) {
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
internal_value = -1;
|
||||
set_default_value(0);
|
||||
set_value(0);
|
||||
set_value(0, false);
|
||||
set = false;
|
||||
}
|
||||
|
||||
void LabelSlider::set_value(double v) {
|
||||
void LabelSlider::set_value(double v, bool userSet) {
|
||||
set = true;
|
||||
if (v != internal_value) {
|
||||
if (min_enabled && v < min_value) {
|
||||
@@ -30,7 +30,7 @@ void LabelSlider::set_value(double v) {
|
||||
}
|
||||
|
||||
setText(QString::number(internal_value));
|
||||
emit valueChanged();
|
||||
if (userSet) emit valueChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ double LabelSlider::value() {
|
||||
void LabelSlider::set_default_value(double v) {
|
||||
default_value = v;
|
||||
if (!set) {
|
||||
set_value(v);
|
||||
set_value(v, false);
|
||||
set = false;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ void LabelSlider::mousePressEvent(QMouseEvent *ev) {
|
||||
vcc->new_val = default_value;
|
||||
undo_stack.push(vcc);
|
||||
|
||||
set_value(default_value);
|
||||
set_value(default_value, true);
|
||||
} else {
|
||||
qApp->setOverrideCursor(Qt::BlankCursor);
|
||||
drag_start_value = internal_value;
|
||||
@@ -80,7 +80,7 @@ void LabelSlider::mousePressEvent(QMouseEvent *ev) {
|
||||
|
||||
void LabelSlider::mouseMoveEvent(QMouseEvent*) {
|
||||
if (drag_start) {
|
||||
set_value(internal_value + (cursor().pos().x()-drag_start_x) + (drag_start_y-cursor().pos().y()));
|
||||
set_value(internal_value + (cursor().pos().x()-drag_start_x) + (drag_start_y-cursor().pos().y()), true);
|
||||
cursor().setPos(drag_start_x, drag_start_y);
|
||||
drag_proc = true;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) {
|
||||
vcc->source = this;
|
||||
vcc->old_val = internal_value;
|
||||
|
||||
set_value(d);
|
||||
set_value(d, true);
|
||||
|
||||
vcc->new_val = internal_value;
|
||||
undo_stack.push(vcc);
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class LabelSlider : public QLabel
|
||||
Q_OBJECT
|
||||
public:
|
||||
LabelSlider(QWidget* parent = 0);
|
||||
void set_value(double v);
|
||||
void set_value(double v, bool userSet);
|
||||
void set_default_value(double v);
|
||||
void set_minimum_value(double v);
|
||||
void set_maximum_value(double v);
|
||||
|
||||
Reference in New Issue
Block a user