From 1da4a315f80e715c5756d5f66f956851e93b9b2c Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 21 Mar 2019 14:33:05 +1100 Subject: [PATCH] more documentation and added edit text button to stringfield --- dialogs/exportdialog.cpp | 10 ++++-- dialogs/exportdialog.h | 17 +++++++++- effects/fields/stringfield.cpp | 6 ++-- rendering/renderfunctions.cpp | 4 +-- ui/texteditex.cpp | 62 +++++++++++++++++++++++++++++----- ui/texteditex.h | 14 +++++++- 6 files changed, 96 insertions(+), 17 deletions(-) diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 73dc3ec65..51180a7ea 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -372,10 +372,12 @@ void ExportDialog::render_thread_finished() { void ExportDialog::prep_ui_for_render(bool r) { export_button->setEnabled(!r); cancel_button->setEnabled(!r); + videoGroupbox->setEnabled(!r); + audioGroupbox->setEnabled(!r); renderCancel->setEnabled(r); } -void ExportDialog::export_action() { +void ExportDialog::StartExport() { if (widthSpinbox->value()%2 == 1 || heightSpinbox->value()%2 == 1) { QMessageBox::critical( this, @@ -533,6 +535,7 @@ void ExportDialog::export_action() { } } + // Set up export parameters to send to the ExportThread ExportParams params; params.filename = filename; params.video_enabled = videoGroupbox->isChecked(); @@ -558,12 +561,15 @@ void ExportDialog::export_action() { params.end_frame = qMin(olive::ActiveSequence->workarea_out, params.end_frame); } + // Create export thread et = new ExportThread(params, vcodec_params, this); + // Connect export thread signals/slots connect(et, SIGNAL(finished()), this, SLOT(render_thread_finished())); connect(et, SIGNAL(ProgressChanged(int, qint64)), this, SLOT(update_progress_bar(int, qint64))); connect(renderCancel, SIGNAL(clicked(bool)), et, SLOT(Interrupt())); + // Close all currently open clips close_active_clips(olive::ActiveSequence.get()); olive::Global->set_rendering_state(true); @@ -776,7 +782,7 @@ void ExportDialog::setup_ui() { export_button = new QPushButton(this); export_button->setText("Export"); - connect(export_button, SIGNAL(clicked(bool)), this, SLOT(export_action())); + connect(export_button, SIGNAL(clicked(bool)), this, SLOT(StartExport())); buttonLayout->addWidget(export_button); diff --git a/dialogs/exportdialog.h b/dialogs/exportdialog.h index df3f14c21..b2ee2e14c 100644 --- a/dialogs/exportdialog.h +++ b/dialogs/exportdialog.h @@ -51,8 +51,23 @@ public: explicit ExportDialog(QWidget *parent); private slots: + /** + * @brief Slot for when the user changes the format + * + * Used to populate the available codecs list for this format. + * + * @param index + * + * Current format index (corresponding to enum ExportFormats) + */ void format_changed(int index); - void export_action(); + + /** + * @brief Slot for when the user clicks the Export button + * + * Asks the user for the file to save to. + */ + void StartExport(); void update_progress_bar(int value, qint64 remaining_ms); void render_thread_finished(); void vcodec_changed(int index); diff --git a/effects/fields/stringfield.cpp b/effects/fields/stringfield.cpp index 30fa3c71e..7d59d3391 100644 --- a/effects/fields/stringfield.cpp +++ b/effects/fields/stringfield.cpp @@ -31,9 +31,9 @@ QWidget *StringField::CreateWidget(QWidget *existing) text_edit->setUndoRedoEnabled(true); // the "2" is because the height needs one extra pixel of padding 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)); + text_edit->setTextHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::CurrentConfig.effect_textbox_lines + + text_edit->document()->documentMargin() + + text_edit->document()->documentMargin() + 2)); } else { diff --git a/rendering/renderfunctions.cpp b/rendering/renderfunctions.cpp index 6ab72b70b..c369f8ab9 100644 --- a/rendering/renderfunctions.cpp +++ b/rendering/renderfunctions.cpp @@ -152,7 +152,7 @@ void process_effect(Clip* c, } } -GLuint compose_sequence(ComposeSequenceParams ¶ms) { +GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) { // qint64 time = QDateTime::currentMSecsSinceEpoch(); GLuint final_fbo = params.main_buffer; @@ -666,7 +666,7 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) { return 0; } -void compose_audio(Viewer* viewer, Sequence* seq, int playback_speed, bool wait_for_mutexes) { +void olive::rendering::compose_audio(Viewer* viewer, Sequence* seq, int playback_speed, bool wait_for_mutexes) { ComposeSequenceParams params; params.viewer = viewer; params.ctx = nullptr; diff --git a/ui/texteditex.cpp b/ui/texteditex.cpp index 3400217fc..cc6f2c189 100644 --- a/ui/texteditex.cpp +++ b/ui/texteditex.cpp @@ -20,6 +20,7 @@ #include "texteditex.h" +#include #include #include "dialogs/texteditdialog.h" @@ -27,13 +28,58 @@ #include "mainwindow.h" TextEditEx::TextEditEx(QWidget *parent, bool enable_rich_text) : - QTextEdit(parent), + QWidget(parent), enable_rich_text_(enable_rich_text) { - setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(text_edit_menu())); + QVBoxLayout* layout = new QVBoxLayout(this); - connect(this, SIGNAL(textChanged()), this, SLOT(queue_text_modified())); + text_editor_ = new QTextEdit(); + connect(text_editor_, SIGNAL(textChanged()), this, SLOT(queue_text_modified())); + layout->addWidget(text_editor_); + + QPushButton* edit_button = new QPushButton(tr("Edit Text")); + layout->addWidget(edit_button); + connect(edit_button, SIGNAL(clicked(bool)), this, SLOT(open_text_edit())); + + /* + text_editor_->setContextMenuPolicy(Qt::CustomContextMenu); + connect(text_editor_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(text_edit_menu())); + */ +} + +void TextEditEx::setUndoRedoEnabled(bool e) +{ + text_editor_->setUndoRedoEnabled(e); +} + +QTextDocument *TextEditEx::document() +{ + return text_editor_->document(); +} + +QTextCursor TextEditEx::textCursor() +{ + return text_editor_->textCursor(); +} + +void TextEditEx::setTextCursor(const QTextCursor &cursor) +{ + text_editor_->setTextCursor(cursor); +} + +void TextEditEx::setTextHeight(int h) +{ + text_editor_->setFixedHeight(h); +} + +void TextEditEx::setHtml(const QString &text) +{ + text_editor_->setHtml(text); +} + +void TextEditEx::setPlainText(const QString &text) +{ + text_editor_->setPlainText(text); } void TextEditEx::text_edit_menu() { @@ -45,21 +91,21 @@ void TextEditEx::text_edit_menu() { } void TextEditEx::open_text_edit() { - const QString& current_text = (enable_rich_text_) ? toHtml() : toPlainText(); + const QString& current_text = (enable_rich_text_) ? text_editor_->toHtml() : text_editor_->toPlainText(); TextEditDialog ted(olive::MainWindow, current_text, enable_rich_text_); ted.exec(); QString result = ted.get_string(); if (!result.isEmpty()) { if (enable_rich_text_) { - setHtml(result); + text_editor_->setHtml(result); } else { - setPlainText(result); + text_editor_->setPlainText(result); } } } void TextEditEx::queue_text_modified() { - emit textModified(enable_rich_text_ ? toHtml() : toPlainText()); + emit textModified(enable_rich_text_ ? text_editor_->toHtml() : text_editor_->toPlainText()); } diff --git a/ui/texteditex.h b/ui/texteditex.h index 0b4802a30..f9f8700a2 100644 --- a/ui/texteditex.h +++ b/ui/texteditex.h @@ -22,11 +22,21 @@ #define TEXTEDITEX_H #include +#include -class TextEditEx : public QTextEdit { +class TextEditEx : public QWidget { Q_OBJECT public: TextEditEx(QWidget* parent = nullptr, bool enable_rich_text = true); + + void setUndoRedoEnabled(bool e); + QTextDocument* document(); + QTextCursor textCursor(); + void setTextCursor(const QTextCursor &cursor); + void setTextHeight(int h); +public slots: + void setHtml(const QString &text); + void setPlainText(const QString &text); signals: void textModified(const QString& s); private slots: @@ -34,6 +44,8 @@ private slots: void open_text_edit(); void queue_text_modified(); private: + QTextEdit* text_editor_; + bool enable_rich_text_; };