diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index 78312b4c2..859ae57db 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -24,6 +24,7 @@ #include "io/config.h" #include "io/path.h" #include "rendering/audio.h" +#include "panels/panels.h" #include "mainwindow.h" #include @@ -74,7 +75,7 @@ QString KeySequenceEditor::export_shortcut() { if (ks != action->property("default")) { return action->property("id").toString() + "\t" + keySequence().toString(); } - return 0; + return nullptr; } PreferencesDialog::PreferencesDialog(QWidget *parent) : @@ -173,6 +174,7 @@ void PreferencesDialog::save() { bool restart_after_saving = false; bool reinit_audio = false; bool reload_language = false; + bool reload_effects = false; // Validate whether the specified CSS file exists if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) { @@ -184,9 +186,13 @@ void PreferencesDialog::save() { return; } + // Validate whether the effects panel should refresh itself + if (olive::CurrentConfig.effect_textbox_lines != effect_textbox_lines_field->value()) { + reload_effects = true; + } + // Check if any settings will require a restart of Olive - if (olive::CurrentConfig.effect_textbox_lines != effect_textbox_lines_field->value() - || olive::CurrentConfig.use_software_fallback != use_software_fallbacks_checkbox->isChecked() + if (olive::CurrentConfig.use_software_fallback != use_software_fallbacks_checkbox->isChecked() || olive::CurrentConfig.thumbnail_resolution != thumbnail_res_spinbox->value() || olive::CurrentConfig.waveform_resolution != waveform_res_spinbox->value()) { @@ -290,6 +296,10 @@ void PreferencesDialog::save() { init_audio(); } + if (reload_effects) { + panel_effect_controls->Reload(); + } + // reload language file if it changed if (reload_language) { olive::Global->load_translation_from_config(); diff --git a/project/effectfields/stringfield.cpp b/project/effectfields/stringfield.cpp index 609a62362..322f40f6f 100644 --- a/project/effectfields/stringfield.cpp +++ b/project/effectfields/stringfield.cpp @@ -1,5 +1,10 @@ #include "stringfield.h" +#include + +#include "ui/texteditex.h" +#include "io/config.h" + StringField::StringField(EffectRow* parent, const QString& id) : EffectField(parent, id, EFFECT_FIELD_STRING) { @@ -10,3 +15,24 @@ QString StringField::GetStringAt(double timecode) { return GetValueAt(timecode).toString(); } + +QWidget *StringField::CreateWidget() +{ + TextEditEx* text_edit = new TextEditEx(); + + text_edit->setUndoRedoEnabled(true); + + // the "2" looks like a magic number, but it's just one pixel on the top and the bottom + text_edit->setFixedHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::CurrentConfig.effect_textbox_lines + + text_edit->document()->documentMargin() + + text_edit->document()->documentMargin() + 2)); + + connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&))); + + return text_edit; +} + +void StringField::UpdateFromWidget(const QString &s) +{ + SetValueAt(Now(), s); +} diff --git a/project/effectfields/stringfield.h b/project/effectfields/stringfield.h index a7ca70668..043dbbb67 100644 --- a/project/effectfields/stringfield.h +++ b/project/effectfields/stringfield.h @@ -10,6 +10,10 @@ public: StringField(EffectRow* parent, const QString& id); QString GetStringAt(double timecode); + + virtual QWidget *CreateWidget() override; +private slots: + void UpdateFromWidget(const QString& b); }; #endif // STRINGFIELD_H diff --git a/ui/texteditex.cpp b/ui/texteditex.cpp index f56bcf1cc..e4c525dd4 100644 --- a/ui/texteditex.cpp +++ b/ui/texteditex.cpp @@ -72,6 +72,8 @@ TextEditEx::TextEditEx(QWidget *parent) : QTextEdit(parent) { setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(text_edit_menu())); + + connect(this, SIGNAL(textChanged()), this, SLOT(queue_text_modified())); } void TextEditEx::text_edit_menu() { @@ -90,3 +92,8 @@ void TextEditEx::open_text_edit() { setHtml(result); } } + +void TextEditEx::queue_text_modified() +{ + emit textModified(toHtml()); +} diff --git a/ui/texteditex.h b/ui/texteditex.h index aca586034..20d3d08f9 100644 --- a/ui/texteditex.h +++ b/ui/texteditex.h @@ -23,31 +23,16 @@ #include -/* class TextEditEx : public QTextEdit { Q_OBJECT public: - TextEditEx(QWidget* parent = 0); - void setPlainTextEx(const QString &text); - const QString& getPreviousValue(); - const QString& getPlainTextEx(); + TextEditEx(QWidget* parent = nullptr); signals: - void updateSelf(); -private slots: - void updateInternals(); - void updateText(); -private: - QString previousText; - QString text; -}; -*/ - -class TextEditEx : public QTextEdit { -public: - TextEditEx(QWidget* parent); + void textModified(const QString& s); private slots: void text_edit_menu(); void open_text_edit(); + void queue_text_modified(); }; #endif // TEXTEDITEX_H