From 918ab6132dbc1eaaeffedc67194d90503cf255e4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 17 Mar 2019 08:42:02 +1100 Subject: [PATCH 1/5] fixed #637 --- dialogs/newsequencedialog.cpp | 20 +++++++++---------- dialogs/texteditdialog.cpp | 36 ++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index 8f12077c6..47ead1336 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -20,16 +20,6 @@ #include "newsequencedialog.h" -#include "panels/panels.h" -#include "panels/project.h" -#include "timeline/sequence.h" -#include "undo/undostack.h" -#include "undo/undo.h" -#include "timeline/clip.h" -#include "panels/timeline.h" -#include "project/media.h" -#include "rendering/audio.h" - #include #include #include @@ -40,6 +30,16 @@ #include #include +#include "panels/panels.h" +#include "panels/project.h" +#include "timeline/sequence.h" +#include "undo/undostack.h" +#include "undo/undo.h" +#include "timeline/clip.h" +#include "panels/timeline.h" +#include "project/media.h" +#include "rendering/audio.h" + extern "C" { #include } diff --git a/dialogs/texteditdialog.cpp b/dialogs/texteditdialog.cpp index c1fb194b3..31c841906 100644 --- a/dialogs/texteditdialog.cpp +++ b/dialogs/texteditdialog.cpp @@ -213,24 +213,26 @@ void TextEditDialog::SetAlignmentFromProperty() void TextEditDialog::UpdateUIFromTextCursor() { - italic_button->setChecked(textEdit->fontItalic()); - underline_button->setChecked(textEdit->fontUnderline()); - font_list->setCurrentText(textEdit->fontFamily()); - font_size->SetValue(textEdit->fontPointSize()); - font_color->set_color(textEdit->textColor()); + if (rich_text_) { + italic_button->setChecked(textEdit->fontItalic()); + underline_button->setChecked(textEdit->fontUnderline()); + font_list->setCurrentText(textEdit->fontFamily()); + font_size->SetValue(textEdit->fontPointSize()); + font_color->set_color(textEdit->textColor()); - for (int i=0;icount();i++) { - if (font_weight->itemData(i).toInt() == textEdit->fontWeight()) { - font_weight->blockSignals(true); - font_weight->setCurrentIndex(i); - font_weight->blockSignals(false); - break; + for (int i=0;icount();i++) { + if (font_weight->itemData(i).toInt() == textEdit->fontWeight()) { + font_weight->blockSignals(true); + font_weight->setCurrentIndex(i); + font_weight->blockSignals(false); + break; + } } - } - Qt::Alignment align = textEdit->alignment(); - left_align_button->setChecked(align == Qt::AlignLeft); - center_align_button->setChecked(align == Qt::AlignCenter); - right_align_button->setChecked(align == Qt::AlignRight); - justify_align_button->setChecked(align == Qt::AlignJustify); + Qt::Alignment align = textEdit->alignment(); + left_align_button->setChecked(align == Qt::AlignLeft); + center_align_button->setChecked(align == Qt::AlignCenter); + right_align_button->setChecked(align == Qt::AlignRight); + justify_align_button->setChecked(align == Qt::AlignJustify); + } } From 789b75193575bcc30e7761496cfee2a1863f9f46 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 17 Mar 2019 08:48:07 +1100 Subject: [PATCH 2/5] fixed effect context menu linking --- effects/effect.cpp | 14 +++++- global/debug.cpp | 116 ++++++++++++++++++++++----------------------- ui/effectui.cpp | 26 ++++++++-- 3 files changed, 91 insertions(+), 65 deletions(-) diff --git a/effects/effect.cpp b/effects/effect.cpp index 4b1ff407a..64386d2ff 100644 --- a/effects/effect.cpp +++ b/effects/effect.cpp @@ -415,9 +415,14 @@ void Effect::delete_self() { } void Effect::move_up() { + int index_of_effect = parent_clip->IndexOfEffect(this); + if (index_of_effect == 0) { + return; + } + MoveEffectCommand* command = new MoveEffectCommand(); command->clip = parent_clip; - command->from = parent_clip->IndexOfEffect(this); + command->from = index_of_effect; command->to = command->from - 1; olive::UndoStack.push(command); panel_effect_controls->Reload(); @@ -425,9 +430,14 @@ void Effect::move_up() { } void Effect::move_down() { + int index_of_effect = parent_clip->IndexOfEffect(this); + if (index_of_effect == parent_clip->effects.size()-1) { + return; + } + MoveEffectCommand* command = new MoveEffectCommand(); command->clip = parent_clip; - command->from = parent_clip->IndexOfEffect(this); + command->from = index_of_effect; command->to = command->from + 1; olive::UndoStack.push(command); panel_effect_controls->Reload(); diff --git a/global/debug.cpp b/global/debug.cpp index e948b5e51..b64e38ecd 100644 --- a/global/debug.cpp +++ b/global/debug.cpp @@ -34,79 +34,79 @@ QFile debug_file; QTextStream debug_stream; void open_debug_file() { - QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); - debug_dir.mkpath("."); - if (debug_dir.exists()) { - debug_file.setFileName(debug_dir.path() + "/debug_log"); - if (debug_file.open(QFile::WriteOnly)) { - debug_stream.setDevice(&debug_file); - } else { - qWarning() << "Couldn't open debug log file, debug log will not be saved"; - } + QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + debug_dir.mkpath("."); + if (debug_dir.exists()) { + debug_file.setFileName(debug_dir.path() + "/debug_log"); + if (debug_file.open(QFile::WriteOnly)) { + debug_stream.setDevice(&debug_file); + } else { + qWarning() << "Couldn't open debug log file, debug log will not be saved"; } + } } void close_debug_file() { - if (debug_file.isOpen()) { - debug_file.close(); - } + if (debug_file.isOpen()) { + debug_file.close(); + } } void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { - debug_mutex.lock(); - const QByteArray localMsg = msg.toLocal8Bit(); - const QDateTime now = QDateTime::currentDateTime(); - const QByteArray timeRepr(now.toString(Qt::ISODate).toLocal8Bit()); - QString msgTag; - QString fontColor; - switch (type) { - case QtDebugMsg: - msgTag = "DEBUG"; - fontColor = "grey"; - break; - case QtInfoMsg: - msgTag = "INFO"; - fontColor = "blue"; - break; - case QtWarningMsg: - msgTag = "WARNING"; - fontColor = "yellow"; - break; - case QtCriticalMsg: - msgTag = "ERROR"; - fontColor = "red"; - break; - case QtFatalMsg: - msgTag = "FATAL"; - fontColor = "red"; - break; - default: - fprintf(stderr, "Unknown debug msg type"); - fflush(stderr); - break; - }//switch + debug_mutex.lock(); + const QByteArray localMsg = msg.toLocal8Bit(); + const QDateTime now = QDateTime::currentDateTime(); + const QByteArray timeRepr(now.toString(Qt::ISODate).toLocal8Bit()); + QString msgTag; + QString fontColor; + switch (type) { + case QtDebugMsg: + msgTag = "DEBUG"; + fontColor = "grey"; + break; + case QtInfoMsg: + msgTag = "INFO"; + fontColor = "blue"; + break; + case QtWarningMsg: + msgTag = "WARNING"; + fontColor = "yellow"; + break; + case QtCriticalMsg: + msgTag = "ERROR"; + fontColor = "red"; + break; + case QtFatalMsg: + msgTag = "FATAL"; + fontColor = "red"; + break; + default: + fprintf(stderr, "Unknown debug msg type"); + fflush(stderr); + break; + }//switch - /*fprintf(stderr, "%s [%s] %s (%s:%u, %s)\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data(), + /*fprintf(stderr, "%s [%s] %s (%s:%u, %s)\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data(), context.file, context.line, context.function);*/ - fprintf(stderr, "%s [%s] %s\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data()); + fprintf(stderr, "%s [%s] %s\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data()); - if (debug_file.isOpen()) { - debug_stream << QString("[%1] %2 (%3:%4, %5)\n") - .arg(msgTag, localMsg, context.file, QString::number(context.line), context.function); - } - debug_info.prepend(QString("[%2] %3 (%4:%5, %6)
") - .arg(fontColor, msgTag, localMsg, context.file, QString::number(context.line), context.function)); - fflush(stderr); - if (olive::DebugDialog != nullptr && olive::DebugDialog->isVisible()) { - QMetaObject::invokeMethod(olive::DebugDialog, "update_log", Qt::QueuedConnection); - } - debug_mutex.unlock(); + if (debug_file.isOpen()) { + debug_stream << QString("[%1] %2 (%3:%4, %5)\n") + .arg(msgTag, localMsg, context.file, QString::number(context.line), context.function); + } + debug_info.prepend(QString("[%2] %3 (%4:%5, %6)
") + .arg(fontColor, msgTag, localMsg, context.file, QString::number(context.line), context.function)); + fflush(stderr); + if (olive::DebugDialog != nullptr && olive::DebugDialog->isVisible()) { + QMetaObject::invokeMethod(olive::DebugDialog, "update_log", Qt::QueuedConnection); + } + debug_mutex.unlock(); } const QString &get_debug_str() { - return debug_info; + return debug_info; } diff --git a/ui/effectui.cpp b/ui/effectui.cpp index 4cbee4fa7..feeb0334b 100644 --- a/ui/effectui.cpp +++ b/ui/effectui.cpp @@ -289,23 +289,39 @@ void EffectUI::show_context_menu(const QPoint& pos) { menu.addSeparator(); + QAction* move_up_action = nullptr; + QAction* move_down_action = nullptr; + if (index > 0) { - menu.addAction(tr("Move &Up"), this, SLOT(move_up())); + move_up_action = menu.addAction(tr("Move &Up"), GetEffect(), SLOT(move_up())); } if (index < c->effects.size() - 1) { - menu.addAction(tr("Move &Down"), this, SLOT(move_down())); + move_down_action = menu.addAction(tr("Move &Down"), GetEffect(), SLOT(move_down())); } menu.addSeparator(); - menu.addAction(tr("D&elete"), this, SLOT(delete_self())); + QAction* delete_action = menu.addAction(tr("D&elete"), GetEffect(), SLOT(delete_self())); + + // Loop through additional effects and link these too + for (int i=0;imapToGlobal(pos)); } From 13485a2587a5b947de25cdf26cdaac669625395d Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 17 Mar 2019 09:17:57 +1100 Subject: [PATCH 3/5] dont set value when setting default --- effects/fields/doublefield.cpp | 11 ----------- effects/fields/doublefield.h | 3 --- effects/internal/transformeffect.cpp | 6 ++++++ 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/effects/fields/doublefield.cpp b/effects/fields/doublefield.cpp index a62836c52..a4fdadd05 100644 --- a/effects/fields/doublefield.cpp +++ b/effects/fields/doublefield.cpp @@ -9,7 +9,6 @@ DoubleField::DoubleField(EffectRow* parent, const QString& id) : default_(0), display_type_(LabelSlider::Normal), frame_rate_(30), - value_set_(false), kdc_(nullptr) { connect(this, SIGNAL(Changed()), this, SLOT(ValueHasBeenSet()), Qt::DirectConnection); @@ -35,11 +34,6 @@ void DoubleField::SetMaximum(double maximum) void DoubleField::SetDefault(double d) { default_ = d; - - if (!value_set_) { - SetValueAt(0, d); - value_set_ = false; - } } void DoubleField::SetDisplayType(LabelSlider::DisplayType type) @@ -106,11 +100,6 @@ void DoubleField::UpdateWidgetValue(QWidget *widget, double timecode) } } -void DoubleField::ValueHasBeenSet() -{ - value_set_ = true; -} - void DoubleField::UpdateFromWidget(double d) { LabelSlider* ls = static_cast(sender()); diff --git a/effects/fields/doublefield.h b/effects/fields/doublefield.h index 9b2882f4e..2c7ae3d7f 100644 --- a/effects/fields/doublefield.h +++ b/effects/fields/doublefield.h @@ -48,11 +48,8 @@ private: LabelSlider::DisplayType display_type_; double frame_rate_; - bool value_set_; - KeyframeDataChange* kdc_; private slots: - void ValueHasBeenSet(); void UpdateFromWidget(double d); }; diff --git a/effects/internal/transformeffect.cpp b/effects/internal/transformeffect.cpp index 03c219dcd..e5627fbae 100644 --- a/effects/internal/transformeffect.cpp +++ b/effects/internal/transformeffect.cpp @@ -144,11 +144,17 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) blend_mode_box->SetValueAt(0, ""); anchor_x_box->SetDefault(0); anchor_y_box->SetDefault(0); + opacity->SetValueAt(0, 100); opacity->SetDefault(100); + scale_x->SetValueAt(0, 100); scale_x->SetDefault(100); + scale_y->SetValueAt(0, 100); scale_y->SetDefault(100); refresh(); + + position_x->SetValueAt(0, parent_clip->sequence->width/2); + position_y->SetValueAt(0, parent_clip->sequence->height/2); } void TransformEffect::refresh() { From a24e5c3c33481a924b14f99daff02df2e1a29787 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 17 Mar 2019 09:48:42 +1100 Subject: [PATCH 4/5] Revert "dont set value when setting default" This reverts commit 13485a2587a5b947de25cdf26cdaac669625395d. --- effects/fields/doublefield.cpp | 11 +++++++++++ effects/fields/doublefield.h | 3 +++ effects/internal/transformeffect.cpp | 6 ------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/effects/fields/doublefield.cpp b/effects/fields/doublefield.cpp index a4fdadd05..a62836c52 100644 --- a/effects/fields/doublefield.cpp +++ b/effects/fields/doublefield.cpp @@ -9,6 +9,7 @@ DoubleField::DoubleField(EffectRow* parent, const QString& id) : default_(0), display_type_(LabelSlider::Normal), frame_rate_(30), + value_set_(false), kdc_(nullptr) { connect(this, SIGNAL(Changed()), this, SLOT(ValueHasBeenSet()), Qt::DirectConnection); @@ -34,6 +35,11 @@ void DoubleField::SetMaximum(double maximum) void DoubleField::SetDefault(double d) { default_ = d; + + if (!value_set_) { + SetValueAt(0, d); + value_set_ = false; + } } void DoubleField::SetDisplayType(LabelSlider::DisplayType type) @@ -100,6 +106,11 @@ void DoubleField::UpdateWidgetValue(QWidget *widget, double timecode) } } +void DoubleField::ValueHasBeenSet() +{ + value_set_ = true; +} + void DoubleField::UpdateFromWidget(double d) { LabelSlider* ls = static_cast(sender()); diff --git a/effects/fields/doublefield.h b/effects/fields/doublefield.h index 2c7ae3d7f..9b2882f4e 100644 --- a/effects/fields/doublefield.h +++ b/effects/fields/doublefield.h @@ -48,8 +48,11 @@ private: LabelSlider::DisplayType display_type_; double frame_rate_; + bool value_set_; + KeyframeDataChange* kdc_; private slots: + void ValueHasBeenSet(); void UpdateFromWidget(double d); }; diff --git a/effects/internal/transformeffect.cpp b/effects/internal/transformeffect.cpp index e5627fbae..03c219dcd 100644 --- a/effects/internal/transformeffect.cpp +++ b/effects/internal/transformeffect.cpp @@ -144,17 +144,11 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) blend_mode_box->SetValueAt(0, ""); anchor_x_box->SetDefault(0); anchor_y_box->SetDefault(0); - opacity->SetValueAt(0, 100); opacity->SetDefault(100); - scale_x->SetValueAt(0, 100); scale_x->SetDefault(100); - scale_y->SetValueAt(0, 100); scale_y->SetDefault(100); refresh(); - - position_x->SetValueAt(0, parent_clip->sequence->width/2); - position_y->SetValueAt(0, parent_clip->sequence->height/2); } void TransformEffect::refresh() { From f0dd2ff82dc90cd20974bfb2c34fa154081647c6 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 17 Mar 2019 09:51:16 +1100 Subject: [PATCH 5/5] better fix for doublefield steamrolling the value --- effects/fields/doublefield.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/effects/fields/doublefield.cpp b/effects/fields/doublefield.cpp index a62836c52..ecbadc827 100644 --- a/effects/fields/doublefield.cpp +++ b/effects/fields/doublefield.cpp @@ -38,7 +38,6 @@ void DoubleField::SetDefault(double d) if (!value_set_) { SetValueAt(0, d); - value_set_ = false; } }