merged with master

This commit is contained in:
itsmattkc
2019-03-21 17:22:36 +11:00
46 changed files with 943 additions and 320 deletions
+3
View File
@@ -34,6 +34,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setSpacing(20);
// Construct About text
QLabel* label =
new QLabel(QString("<html><head/><body>"
"<p><img src=\":/icons/olive-splash.png\"/></p>"
@@ -49,6 +50,8 @@ AboutDialog::AboutDialog(QWidget *parent) :
"protected by the GNU GPL."),
tr("Olive Team is obliged to inform users that Olive source code is "
"available for download from its website.")), this);
// Set text formatting
label->setAlignment(Qt::AlignCenter);
label->setWordWrap(true);
layout->addWidget(label);
+14 -1
View File
@@ -23,11 +23,24 @@
#include <QDialog>
/**
* @brief The AboutDialog class
*
* The About dialog (accessible through Help > About). Contains license and version information.
*/
class AboutDialog : public QDialog
{
Q_OBJECT
public:
/**
* @brief AboutDialog Constructor
*
* Creates About dialog.
*
* @param parent
*
* QWidget parent object. Usually this will be MainWindow.
*/
explicit AboutDialog(QWidget *parent = nullptr);
};
+100 -3
View File
@@ -30,63 +30,133 @@
ActionSearch::ActionSearch(QWidget *parent) :
QDialog(parent)
{
// ActionSearch requires a parent widget
Q_ASSERT(parent != nullptr);
// Set styling (object name is required for CSS specific to this object)
setObjectName("ASDiag");
setStyleSheet("#ASDiag{border: 2px solid #808080;}");
// Size proportionally to the parent (usually MainWindow).
resize(parent->width()/3, parent->height()/3);
// Show dialog as a "popup", which will make the dialog close if the user clicks out of it.
setWindowFlags(Qt::Popup);
QVBoxLayout* layout = new QVBoxLayout(this);
// Construct the main entry text field.
ActionSearchEntry* entry_field = new ActionSearchEntry(this);
// Set the main entry field font size to 1.2x its standard font size.
QFont entry_field_font = entry_field->font();
entry_field_font.setPointSize(qRound(entry_field_font.pointSize()*1.2));
entry_field->setFont(entry_field_font);
// Set placeholder text for the main entry field
entry_field->setPlaceholderText(tr("Search for action..."));
// Connect signals/slots
connect(entry_field, SIGNAL(textChanged(const QString&)), this, SLOT(search_update(const QString &)));
connect(entry_field, SIGNAL(returnPressed()), this, SLOT(perform_action()));
// moveSelectionUp() and moveSelectionDown() are emitted when the user pressed up or down on the text field.
// We override it here to select the upper or lower item in the list.
connect(entry_field, SIGNAL(moveSelectionUp()), this, SLOT(move_selection_up()));
connect(entry_field, SIGNAL(moveSelectionDown()), this, SLOT(move_selection_down()));
layout->addWidget(entry_field);
// Construct list of actions
list_widget = new ActionSearchList(this);
// Set list's font to 1.2x its standard font size
QFont list_widget_font = list_widget->font();
list_widget_font.setPointSize(qRound(list_widget_font.pointSize()*1.2));
list_widget->setFont(list_widget_font);
layout->addWidget(list_widget);
connect(list_widget, SIGNAL(dbl_click()), this, SLOT(perform_action()));
// Instantly focus on the entry field to allow for fully keyboard operation (if this popup was initiated by keyboard
// shortcut for example).
entry_field->setFocus();
}
void ActionSearch::search_update(const QString &s, const QString &p, QMenu *parent) {
// This function is recursive, using the `parent` parameter to loop through a menu's items. It functions in two
// modes - the parent being NULL, meaning it'll get MainWindow's menubar and loop over its menus, and the parent
// referring to a menu at which point it'll loop over its actions (and call itself recursively if it finds any
// submenus).
if (parent == nullptr) {
// If parent is NULL, we'll pull from the MainWindow's menubar and call this recursively on all of its submenus
// (and their submenus).
// We'll clear all the current items in the list since if we're here, we're just starting.
list_widget->clear();
QList<QAction*> menus = olive::MainWindow->menuBar()->actions();
QList<QAction*> menus = olive::MainWindow->menuBar()->actions();
// Loop through all menus from the menubar and run this function on each one.
for (int i=0;i<menus.size();i++) {
QMenu* menu = menus.at(i)->menu();
search_update(s, p, menu);
}
if (list_widget->count() > 0)
// Once we're here, all the recursion/item retrieval is complete. We auto-select the first item for better
// keyboard-exclusive functionality.
if (list_widget->count() > 0) {
list_widget->item(0)->setSelected(true);
}
} else {
// Parent was not NULL, so we loop over the actions in the menu we were given in `parent`.
// The list shows a '>' delimited hierarchy of the menus in which this action came from. We construct it here by
// adding the current menu's text to the existing hierarchy (passed in `p`).
QString menu_text;
if (!p.isEmpty()) menu_text += p + " > ";
menu_text += parent->title().replace("&", "");
menu_text += parent->title().replace("&", ""); // Strip out any &s used in menu action names
// Loop over the menu's actions
QList<QAction*> actions = parent->actions();
for (int i=0;i<actions.size();i++) {
QAction* a = actions.at(i);
// Ignore separator actions
if (!a->isSeparator()) {
if (a->menu() != nullptr) {
// If the action is a menu, run this function recursively on it
search_update(s, menu_text, a->menu());
} else {
// This is a valid non-separator non-menu action, so check it against the currently entered string.
// Strip out all &s from the action's name
QString comp = a->text().replace("&", "");
// See if the action's name contains any of the currently entered string
if (comp.contains(s, Qt::CaseInsensitive)) {
// If so, we add it to the list widget.
QListWidgetItem* item = new QListWidgetItem(QString("%1\n(%2)").arg(comp, menu_text), list_widget);
// Add a pointer to the original QAction in the item's data
item->setData(Qt::UserRole+1, reinterpret_cast<quintptr>(a));
list_widget->addItem(item);
}
}
}
}
@@ -94,16 +164,31 @@ void ActionSearch::search_update(const QString &s, const QString &p, QMenu *pare
}
void ActionSearch::perform_action() {
// Loop over all the items in the list and if we find one that's selected, we trigger it.
QList<QListWidgetItem*> selected_items = list_widget->selectedItems();
if (list_widget->count() > 0 && selected_items.size() > 0) {
QListWidgetItem* item = selected_items.at(0);
// Get QAction pointer from item's data
QAction* a = reinterpret_cast<QAction*>(item->data(Qt::UserRole+1).value<quintptr>());
a->trigger();
}
// Close this popup
accept();
}
void ActionSearch::move_selection_up() {
// Here we loop over all the items to find the currently selected one, and then select the one above it. We start
// iterating at 1 (instead of 0) to efficiently ignore the first item (since the selection can't go below the very
// bottom item).
int lim = list_widget->count();
for (int i=1;i<lim;i++) {
if (list_widget->item(i)->isSelected()) {
@@ -115,6 +200,11 @@ void ActionSearch::move_selection_up() {
}
void ActionSearch::move_selection_down() {
// Here we loop over all the items to find the currently selected one, and then select the one below it. We limit it
// one entry before count() to efficiently ignore the item at the end (since the selection can't go below the very
// bottom item).
int lim = list_widget->count()-1;
for (int i=0;i<lim;i++) {
if (list_widget->item(i)->isSelected()) {
@@ -128,6 +218,9 @@ void ActionSearch::move_selection_down() {
ActionSearchEntry::ActionSearchEntry(QWidget *parent) : QLineEdit(parent) {}
void ActionSearchEntry::keyPressEvent(QKeyEvent * event) {
// Listen for up/down, otherwise pass the key event to the base class.
switch (event->key()) {
case Qt::Key_Up:
emit moveSelectionUp();
@@ -138,10 +231,14 @@ void ActionSearchEntry::keyPressEvent(QKeyEvent * event) {
default:
QLineEdit::keyPressEvent(event);
}
}
ActionSearchList::ActionSearchList(QWidget *parent) : QListWidget(parent) {}
void ActionSearchList::mouseDoubleClickEvent(QMouseEvent *) {
// Indiscriminately emit a signal on any double click
emit dbl_click();
}
+116 -10
View File
@@ -26,38 +26,144 @@
#include <QListWidget>
#include <QMenu>
class ActionSearchList : public QListWidget {
Q_OBJECT
public:
ActionSearchList(QWidget* parent);
protected:
void mouseDoubleClickEvent(QMouseEvent *event);
signals:
void dbl_click();
};
class ActionSearchList;
/**
* @brief The ActionSearch class
*
* A popup window (accessible through Help > Action Search) that allows users to search for a menu command by typing
* rather than browsing through the menu bar.
*/
class ActionSearch : public QDialog
{
Q_OBJECT
public:
ActionSearch(QWidget* parent = nullptr);
/**
* @brief ActionSearch Constructor
*
* Create ActionSearch popup.
*
* @param parent
*
* QWidget parent. Usually MainWindow.
*/
ActionSearch(QWidget* parent);
private slots:
/**
* @brief Update the list of actions according to a search query
*
* This function adds/removes actions in the action list according to a given search query entered by the user.
*
* To loop over the menubar and all of its menus and submenus, this function will call itself recursively. As such
* some of its parameters do not need to be set externally, as these will be set by the function itself as it calls
* itself.
*
* @param s
*
* The search text. This is the only parameter that should be set externally.
*
* @param p
*
* The current parent hierarchy. In most cases, this should be left as nullptr when called externally.
* search_update() will fill this automatically as it needs while calling itself recursively.
*
* @param parent
*
* The current menu to loop over. In most cases, this should be left as nullptr when called externally.
* search_update() will fill this automatically as it needs while calling itself recursively.
*/
void search_update(const QString& s, const QString &p = nullptr, QMenu *parent = nullptr);
/**
* @brief Perform the currently selected action
*
* Usually triggered by pressing Enter on the ActionSearchEntry field, this will trigger whatever action is currently
* highlighted and then close this popup. If no entries are highlighted (i.e. the list is empty), no action is
* triggered and the popup closes anyway.
*/
void perform_action();
/**
* @brief Move selection up
*
* A slot for pressing up on the ActionSearchEntry field. Moves the selection in the list up once. If the
* selection is already at the top of the list, this is a no-op.
*/
void move_selection_up();
/**
* @brief Move selection down
*
* A slot for pressing down on the ActionSearchEntry field. Moves the selection in the list down once. If the
* selection is already at the bottom of the list, this is a no-op.
*/
void move_selection_down();
private:
/**
* @brief Main widget that shows the list of commands
*/
ActionSearchList* list_widget;
};
/**
* @brief The ActionSearchList class
*
* Simple wrapper around QListWidget that emits a signal when an item is double clicked that ActionSearch connects
* to a slot that triggers the currently selected action.
*/
class ActionSearchList : public QListWidget {
Q_OBJECT
public:
/**
* @brief ActionSearchList Constructor
* @param parent
*
* Usually ActionSearch.
*/
ActionSearchList(QWidget* parent);
protected:
/**
* @brief Override of QListWidget's double click event that emits a signal.
*/
void mouseDoubleClickEvent(QMouseEvent *);
signals:
/**
* @brief Signal emitted when a QListWidget item is double clicked.
*/
void dbl_click();
};
/**
* @brief The ActionSearchEntry class
*
* Simple wrapper around QLineEdit that emits signals when the up or down arrow keys are pressed so that ActionSearch
* can connect them to moving the current selection up or down.
*/
class ActionSearchEntry : public QLineEdit {
Q_OBJECT
public:
/**
* @brief ActionSearchEntry
* @param parent
*
* Usually ActionSearch.
*/
ActionSearchEntry(QWidget* parent);
protected:
/**
* @brief Override of QLineEdit's key press event that listens for up/down key presses.
* @param event
*/
void keyPressEvent(QKeyEvent * event);
signals:
/**
* @brief Emitted when the user presses the up arrow key.
*/
void moveSelectionUp();
/**
* @brief Emitted when the user presses the down arrow key.
*/
void moveSelectionDown();
};
+13 -6
View File
@@ -114,16 +114,23 @@ void ClipPropertiesDialog::accept()
for (int i=0;i<clips_.size();i++) {
Clip* clip = clips_.at(i);
if (!clip_name.isEmpty()) {
// If the user entered a Clip name and the name is different from the Clip's name, create a rename command
if (!clip_name.isEmpty() && clip_name != clip->name()) {
ca->append(new RenameClipCommand(clip, clip_name));
}
// If the user entered a clip duration (and the duration has changed), create a "clip move" command
if (!qIsNaN(clip_duration)) {
clip->move(ca,
clip->timeline_in(),
clip->timeline_in() + qRound(clip_duration),
clip->clip_in(),
clip->track());
long clip_duration_rounded = qRound(clip_duration);
if (clip->length() != clip_duration_rounded) {
clip->move(ca,
clip->timeline_in(),
clip->timeline_in() + clip_duration_rounded,
clip->clip_in(),
clip->track());
}
}
}
+28
View File
@@ -27,16 +27,44 @@
#include "timeline/clip.h"
#include "ui/labelslider.h"
/**
* @brief The ClipPropertiesDialog class
*
* A dialog for setting Clip properties, accessible by right clicking a Clip and clicking "Properties".
*/
class ClipPropertiesDialog : public QDialog {
Q_OBJECT
public:
/**
* @brief ClipPropertiesDialog Constructor
* @param parent
*
* Parent widget.
*
* @param clips
*
* Array of Clip objects to set the properties of.
*/
ClipPropertiesDialog(QWidget* parent, QVector<Clip*> clips);
protected:
/**
* @brief Accept override. Saves the current properties to the array of Clips.
*/
virtual void accept() override;
private:
/**
* @brief Internal clip array (set in the constructor)
*/
QVector<Clip*> clips_;
/**
* @brief Widget for setting the Clip names
*/
QLineEdit* clip_name_field_;
/**
* @brief Widget for setting the Clip durations
*/
LabelSlider* duration_field_;
};
+32 -2
View File
@@ -24,22 +24,52 @@
#include <QDialog>
#include <QTextEdit>
/**
* @brief The DebugDialog class
*
* A dialog to display the current debug output.
*/
class DebugDialog : public QDialog {
Q_OBJECT
public:
DebugDialog(QWidget* parent = 0);
/**
* @brief DebugDialog Constructor
* @param parent
*
* Parent widget. Usually MainWindow.
*/
DebugDialog(QWidget* parent = nullptr);
/**
* @brief Retranslate window title
*
* Sets title based on the current translation.
*/
void Retranslate();
public slots:
/**
* @brief Update the visual log with the debug text from get_debug_str()
*/
void update_log();
protected:
/**
* @brief Overrides change event to trigger Retranslate() on a LanguageChange event.
*/
virtual void changeEvent(QEvent* e) override;
/**
* @brief Overrides show event to trigger an update of the visual log (the visual log does not update while the
* debug dialog is hidden).
*/
virtual void showEvent(QShowEvent* event) override;
private:
/**
* @brief Display widget for the debug dialog.
*/
QTextEdit* textEdit;
};
namespace olive {
extern DebugDialog* DebugDialog;
extern DebugDialog* DebugDialog;
}
#endif // DEBUGDIALOG_H
+12 -12
View File
@@ -27,7 +27,7 @@
DemoNotice::DemoNotice(QWidget *parent) :
QDialog(parent)
{
setWindowTitle(tr("Welcome to Olive!"));
setWindowTitle(tr("Welcome to Olive!"));
QVBoxLayout* vlayout = new QVBoxLayout(this);
@@ -36,20 +36,20 @@ DemoNotice::DemoNotice(QWidget *parent) :
layout->setSpacing(20);
QLabel* icon = new QLabel("<html><head/><body>"
"<p><img src=\":/icons/olive-splash.png\"/></p>"
"</body></html>", this);
"<p><img src=\":/icons/olive-splash.png\"/></p>"
"</body></html>", this);
layout->addWidget(icon);
QLabel* text = new QLabel("<html><head/><body><p>"
"<span style=\" font-size:14pt;\">"
+ tr("Welcome to Olive!")
+ "</span></p><p>"
+ tr("Olive is a free open-source video editor released under the GNU GPL. If you have paid for this software, you have been scammed.")
+ "</p><p>"
+ tr("This software is currently in ALPHA which means it is unstable and very likely to crash, have bugs, and have missing features. We offer no warranty so use at your own risk. Please report any bugs or feature requests at %1").arg("<a href=\"https://olivevideoeditor.org/\"><span style=\" text-decoration: underline; color:#007af4;\">www.olivevideoeditor.org</span></a>")
+ "</p><p>"
+ tr("Thank you for trying Olive and we hope you enjoy it!")
+ "</p></body></html>", this);
"<span style=\" font-size:14pt;\">"
+ tr("Welcome to Olive!")
+ "</span></p><p>"
+ tr("Olive is a free open-source video editor released under the GNU GPL. If you have paid for this software, you have been scammed.")
+ "</p><p>"
+ tr("This software is currently in ALPHA which means it is unstable and very likely to crash, have bugs, and have missing features. We offer no warranty so use at your own risk. Please report any bugs or feature requests at %1").arg("<a href=\"https://olivevideoeditor.org/\"><span style=\" text-decoration: underline; color:#007af4;\">www.olivevideoeditor.org</span></a>")
+ "</p><p>"
+ tr("Thank you for trying Olive and we hope you enjoy it!")
+ "</p></body></html>", this);
text->setWordWrap(true);
layout->addWidget(text);
+12 -1
View File
@@ -23,11 +23,22 @@
#include <QDialog>
/**
* @brief The DemoNotice class
*
* Simple dialog shown on startup to introduce Olive as alpha software (in release builds).
*/
class DemoNotice : public QDialog
{
Q_OBJECT
public:
explicit DemoNotice(QWidget *parent = 0);
/**
* @brief DemoNotice Constructor
* @param parent
*
* QWidget parent. Usually MainWindow.
*/
explicit DemoNotice(QWidget *parent = nullptr);
};
#endif // DEMONOTICE_H
+38 -21
View File
@@ -20,6 +20,10 @@
#include "exportdialog.h"
extern "C" {
#include <libavformat/avformat.h>
}
#include <QOpenGLWidget>
#include <QFileDialog>
#include <QThread>
@@ -39,10 +43,6 @@
#include "rendering/exportthread.h"
#include "ui/mainwindow.h"
extern "C" {
#include <libavformat/avformat.h>
}
enum ExportFormats {
FORMAT_3GPP,
FORMAT_AIFF,
@@ -118,9 +118,6 @@ ExportDialog::ExportDialog(QWidget *parent) :
vcodec_params.threads = 0;
}
ExportDialog::~ExportDialog()
{}
void ExportDialog::add_codec_to_combobox(QComboBox* box, enum AVCodecID codec) {
QString codec_name;
@@ -334,30 +331,53 @@ void ExportDialog::format_changed(int index) {
}
void ExportDialog::render_thread_finished() {
if (progressBar->value() < 100 && !cancelled) {
// Determine if the export succeeded
bool succeeded = (progressBar->value() == 100);
// If it failed and we didn't cancel it, it must have errored out. Show an error message.
if (!succeeded && !et->WasInterrupted()) {
QMessageBox::critical(
this,
tr("Export Failed"),
tr("Export failed - %1").arg(export_error),
tr("Export failed - %1").arg(et->GetError()),
QMessageBox::Ok
);
}
// Clear audio buffer
clear_audio_ibuffer();
// Re-enable/disable UI widgets based on the rendering state
prep_ui_for_render(false);
// Move OpenGL context back to the sequence viewer
panel_sequence_viewer->viewer_widget->makeCurrent();
panel_sequence_viewer->viewer_widget->initializeGL();
// Update the application UI
update_ui(false);
// Disconnect cancel button from export thread
disconnect(renderCancel, SIGNAL(clicked(bool)), et, SLOT(Interrupt()));
// Free the export thread
et->deleteLater();
if (progressBar->value() == 100) accept();
// If the export succeeded, close the dialog
if (succeeded) {
accept();
}
}
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,
@@ -515,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();
@@ -540,11 +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(progress_changed(int, qint64)), this, SLOT(update_progress_bar(int, qint64)));
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);
@@ -553,8 +578,6 @@ void ExportDialog::export_action() {
prep_ui_for_render(true);
cancelled = false;
total_export_time_start = QDateTime::currentMSecsSinceEpoch();
et->start();
@@ -587,11 +610,6 @@ void ExportDialog::update_progress_bar(int value, qint64 remaining_ms) {
progressBar->setValue(value);
}
void ExportDialog::cancel_render() {
et->continueEncode = false;
cancelled = true;
}
void ExportDialog::vcodec_changed(int index) {
compressionTypeCombobox->clear();
@@ -755,7 +773,6 @@ void ExportDialog::setup_ui() {
renderCancel = new QPushButton(this);
renderCancel->setIcon(QIcon(":/icons/error.svg"));
renderCancel->setEnabled(false);
connect(renderCancel, SIGNAL(clicked(bool)), this, SLOT(cancel_render()));
progressLayout->addWidget(renderCancel);
verticalLayout->addLayout(progressLayout);
@@ -765,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);
+32 -10
View File
@@ -30,34 +30,56 @@
#include <QGroupBox>
#include "timeline/sequence.h"
#include "rendering/exportthread.h"
/**
* @brief The ExportDialog class
*
* The dialog to initiate an export.
*/
class ExportDialog : public QDialog
{
Q_OBJECT
public:
explicit ExportDialog(QWidget *parent = nullptr);
~ExportDialog();
QString export_error;
/**
* @brief ExportDialog Constructor
*
* @param parent
*
* QWidget parent. Usually MainWindow.
*/
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 cancel_render();
void render_thread_finished();
void vcodec_changed(int index);
void comp_type_changed(int index);
void open_advanced_video_dialog();
private:
QVector<QString> format_strings;
void setup_ui();
ExportThread* et;
void prep_ui_for_render(bool r);
bool cancelled;
QVector<QString> format_strings;
ExportThread* et;
void add_codec_to_combobox(QComboBox* box, enum AVCodecID codec);
+3 -3
View File
@@ -451,8 +451,8 @@ void PreferencesDialog::save() {
accept();
if (restart_after_saving) {
// since we already ran can_close_project(), bypass checking again by running setWindowModified(false)
olive::MainWindow->setWindowModified(false);
// since we already ran can_close_project(), bypass checking again by running set_modified(false)
olive::Global->set_modified(false);
olive::MainWindow->close();
@@ -712,7 +712,7 @@ void PreferencesDialog::setup_ui() {
QVBoxLayout* behavior_tab_layout = new QVBoxLayout(behavior_tab);
add_default_effects_to_clips = new QCheckBox("Add Default Effects to New Clips");
add_default_effects_to_clips = new QCheckBox(tr("Add Default Effects to New Clips"));
add_default_effects_to_clips->setChecked(olive::CurrentConfig.add_default_effects_to_clips);
behavior_tab_layout->addWidget(add_default_effects_to_clips);
+2 -1
View File
@@ -31,6 +31,7 @@
#include "project/proxygenerator.h"
#include "project/footage.h"
#include "ui/mainwindow.h"
#include "global/global.h"
ProxyDialog::ProxyDialog(QWidget *parent, const QVector<Media*> &media) :
QDialog(parent),
@@ -155,7 +156,7 @@ void ProxyDialog::accept() {
olive::proxy_generator.queue(info_list.at(i));
}
olive::MainWindow->setWindowModified(true);
olive::Global->set_modified(true);
QDialog::accept();
}
-1
View File
@@ -44,7 +44,6 @@
#include "panels/timeline.h"
#include "panels/effectcontrols.h"
#include "panels/grapheditor.h"
#include "ui/checkboxex.h"
#include "global/debug.h"
#include "global/path.h"
#include "ui/mainwindow.h"
-1
View File
@@ -41,7 +41,6 @@
#include <random>
#include "ui/collapsiblewidget.h"
#include "ui/checkboxex.h"
#include "effectrow.h"
#include "effectgizmo.h"
#include "rendering/qopenglshaderprogramptr.h"
-12
View File
@@ -23,26 +23,14 @@
#include <QDateTime>
#include <QtMath>
#include "ui/labelslider.h"
#include "ui/colorbutton.h"
#include "ui/texteditex.h"
#include "ui/checkboxex.h"
#include "ui/comboboxex.h"
#include "ui/embeddedfilechooser.h"
#include "rendering/renderfunctions.h"
#include "global/config.h"
#include "effects/effectrow.h"
#include "effects/effect.h"
#include "undo/undo.h"
#include "timeline/clip.h"
#include "timeline/sequence.h"
#include "global/math.h"
#include "global/debug.h"
EffectField::EffectField(EffectRow* parent, const QString &i, EffectFieldType t) :
+5
View File
@@ -23,6 +23,11 @@
#include "../effectfield.h"
/**
* @brief The BoolField class
*
* An EffectField derivative the uses boolean values (true or false) and uses a checkbox as its visual representation.
*/
class BoolField : public EffectField
{
Q_OBJECT
+5 -4
View File
@@ -30,7 +30,8 @@ StringField::StringField(EffectRow* parent, const QString& id, bool rich_text) :
EffectField(parent, id, EFFECT_FIELD_STRING),
rich_text_(rich_text)
{
// Set default value to an empty string
SetValueAt(0, "");
}
QString StringField::GetStringAt(double timecode)
@@ -50,9 +51,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 {
-2
View File
@@ -298,8 +298,6 @@ void TextEffect::redraw(double timecode) {
}
void TextEffect::shadow_enable(bool e) {
close();
shadow_color->SetEnabled(e);
shadow_angle->SetEnabled(e);
shadow_distance->SetEnabled(e);
+1 -1
View File
@@ -82,7 +82,7 @@ TimecodeEffect::TimecodeEffect(Clip* c, const EffectMeta* em) :
offset_y_val = new DoubleField(offset_row, "offsety");
EffectRow* prepent_text_row = new EffectRow(this, tr("Prepend"));
prepend_text = new StringField(prepent_text_row, "prepend");
prepend_text = new StringField(prepent_text_row, "prepend", false);
prepend_text->SetColumnSpan(2);
}
+2 -1
View File
@@ -31,6 +31,7 @@
#include "rendering/audio.h"
#include "ui/mainwindow.h"
#include "global/global.h"
#include "global/debug.h"
#ifdef __linux__
@@ -83,7 +84,7 @@ intptr_t hostCallback(AEffect* effect, int32_t opcode, int32_t index, intptr_t v
// but we are aware of it
break;
case audioMasterEndEdit: // change made
olive::MainWindow->setWindowModified(true);
olive::Global->set_modified(true);
break;
default:
qInfo() << "Plugin requested unhandled opcode" << opcode;
+19 -3
View File
@@ -48,7 +48,9 @@ std::unique_ptr<OliveGlobal> olive::Global;
QString olive::ActiveProjectFilename;
QString olive::AppName;
OliveGlobal::OliveGlobal() {
OliveGlobal::OliveGlobal() :
changed_since_last_autorecovery(false)
{
// sets current app name
QString version_id;
@@ -107,6 +109,17 @@ void OliveGlobal::set_rendering_state(bool rendering) {
}
}
void OliveGlobal::set_modified(bool modified)
{
olive::MainWindow->setWindowModified(modified);
changed_since_last_autorecovery = modified;
}
bool OliveGlobal::is_modified()
{
return olive::MainWindow->isWindowModified();
}
void OliveGlobal::load_project_on_launch(const QString& s) {
olive::ActiveProjectFilename = s;
enable_load_project_on_init = true;
@@ -219,7 +232,7 @@ bool OliveGlobal::save_project() {
}
bool OliveGlobal::can_close_project() {
if (olive::MainWindow->isWindowModified()) {
if (is_modified()) {
QMessageBox* m = new QMessageBox(
QMessageBox::Question,
tr("Unsaved Project"),
@@ -281,8 +294,11 @@ void OliveGlobal::finished_initialize() {
}
void OliveGlobal::save_autorecovery_file() {
if (olive::MainWindow->isWindowModified()) {
if (changed_since_last_autorecovery) {
panel_project->save_project(true);
changed_since_last_autorecovery = false;
qInfo() << "Auto-recovery project saved";
}
}
+35
View File
@@ -92,6 +92,31 @@ public:
*/
void set_rendering_state(bool rendering);
/**
* @brief Set the application's "modified" state
*
* Primarily controls whether the application prompts the user to save the project upon closing or not. Also
* technically controls whether to create autorecovery files as they'll only be generated if there are unsaved
* changes.
*
* @param modified
*
* TRUE if the project has been modified, FALSE if it has not.
*/
void set_modified(bool modified);
/**
* @brief Get application's current "modified" state
*
* Currently just a wrapper around MainWindow::isWindowModified(), but use this instead in case it changes.
* This value is used to determine whether the currently open project has unsaved changes.
*
* @return
*
* TRUE if the project has been modified since the last save.
*/
bool is_modified();
/**
* @brief Set a project to load just after launching
*
@@ -324,6 +349,16 @@ private:
*/
std::unique_ptr<QTranslator> translator;
/**
* @brief Internal variable for whether the project has changed since the last autorecovery
*
* Set by set_modified(), which should be called alongside any change made to the project file and is "unset" when
* an autorecovery file is made. Provides an extra layer of abstraction from the application "modified" state to
* prevents an autorecovery file saving multiple times if the project hasn't actually changed since the last
* autorecovery, but still hasn't been saved into the original file yet.
*/
bool changed_since_last_autorecovery;
private slots:
};
+1 -1
View File
@@ -136,7 +136,7 @@ int main(int argc, char *argv[]) {
olive::rendering::InitializeBitDepths();
// connect main window's first paint to global's init finished function
QObject::connect(&w, SIGNAL(finished_first_paint()), olive::Global.get(), SLOT(finished_initialize()));
QObject::connect(&w, SIGNAL(finished_first_paint()), olive::Global.get(), SLOT(finished_initialize()), Qt::QueuedConnection);
if (!load_proj.isEmpty()) {
olive::Global->load_project_on_launch(load_proj);
-2
View File
@@ -84,7 +84,6 @@ SOURCES += \
ui/comboboxex.cpp \
ui/colorbutton.cpp \
dialogs/replaceclipmediadialog.cpp \
ui/checkboxex.cpp \
ui/keyframeview.cpp \
ui/texteditex.cpp \
dialogs/demonotice.cpp \
@@ -209,7 +208,6 @@ HEADERS += \
ui/comboboxex.h \
ui/colorbutton.h \
dialogs/replaceclipmediadialog.h \
ui/checkboxex.h \
ui/keyframeview.h \
ui/texteditex.h \
dialogs/demonotice.h \
+2 -2
View File
@@ -1051,7 +1051,7 @@ void Project::new_project() {
olive::Global->set_sequence(nullptr);
panel_footage_viewer->set_media(nullptr);
clear();
olive::MainWindow->setWindowModified(false);
olive::Global->set_modified(false);
}
void Project::load_project(const QString& filename, bool autorecovery, bool clear) {
@@ -1319,7 +1319,7 @@ void Project::save_project(bool autorecovery) {
if (!autorecovery) {
add_recent_project(olive::ActiveProjectFilename);
olive::MainWindow->setWindowModified(false);
olive::Global->set_modified(false);
}
}
+1 -1
View File
@@ -771,7 +771,7 @@ void LoadThread::success_func() {
panel_project->add_recent_project(filename_);
}
olive::MainWindow->setWindowModified(autorecovery_ || !clear_);
olive::Global->set_modified(autorecovery_ || !clear_);
if (open_seq != nullptr) {
olive::Global->set_sequence(open_seq);
}
+2 -1
View File
@@ -39,6 +39,7 @@
#include "project/projectfilter.h"
#include "timeline/sequence.h"
#include "global/config.h"
#include "global/global.h"
#include "dialogs/proxydialog.h"
#include "ui/viewerwidget.h"
#include "project/proxygenerator.h"
@@ -446,5 +447,5 @@ void SourcesCommon::clear_proxies_from_selected() {
panel_sequence_viewer->viewer_widget->frame_update();
}
olive::MainWindow->setWindowModified(true);
olive::Global->set_modified(true);
}
+37 -7
View File
@@ -30,6 +30,7 @@
#include <QtMath>
#include <QAudioOutput>
#include <QStatusBar>
#include <math.h>
#include "project/projectelements.h"
@@ -38,6 +39,7 @@
#include "panels/panels.h"
#include "global/config.h"
#include "global/debug.h"
#include "ui/mainwindow.h"
// Enable verbose audio messages - good for debugging reversed audio
//#define AUDIOWARNINGS
@@ -846,7 +848,12 @@ void Cacher::WakeMainThread()
Cacher::Cacher(Clip* c) :
clip(c),
frame_(nullptr),
pkt(nullptr)
pkt(nullptr),
formatCtx(nullptr),
opts(nullptr),
filter_graph(nullptr),
codecCtx(nullptr),
is_valid_state_(false)
{}
void Cacher::OpenWorker() {
@@ -910,6 +917,7 @@ void Cacher::OpenWorker() {
char err[1024];
av_strerror(errCode, err, 1024);
qCritical() << "Could not open" << filename << "-" << err;
olive::MainWindow->statusBar()->showMessage(tr("Could not open %1 - %2").arg(filename, err));
return;
}
@@ -918,6 +926,7 @@ void Cacher::OpenWorker() {
char err[1024];
av_strerror(errCode, err, 1024);
qCritical() << "Could not open" << filename << "-" << err;
olive::MainWindow->statusBar()->showMessage(tr("Could not open %1 - %2").arg(filename, err));
return;
}
@@ -1082,6 +1091,8 @@ void Cacher::OpenWorker() {
}
qInfo() << "Clip opened on track" << clip->track() << "(took" << (QDateTime::currentMSecsSinceEpoch() - time_start) << "ms)";
is_valid_state_ = true;
}
void Cacher::CacheWorker() {
@@ -1111,17 +1122,27 @@ void Cacher::CloseWorker() {
}
if (clip->media() != nullptr && clip->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
avfilter_graph_free(&filter_graph);
if (filter_graph != nullptr) {
avfilter_graph_free(&filter_graph);
filter_graph = nullptr;
}
avcodec_close(codecCtx);
avcodec_free_context(&codecCtx);
if (codecCtx != nullptr) {
avcodec_close(codecCtx);
avcodec_free_context(&codecCtx);
codecCtx = nullptr;
}
av_dict_free(&opts);
if (opts != nullptr) {
av_dict_free(&opts);
}
// protection for get_timebase()
stream = nullptr;
avformat_close_input(&formatCtx);
if (formatCtx != nullptr) {
avformat_close_input(&formatCtx);
}
}
qInfo() << "Clip closed on track" << clip->track();
@@ -1141,11 +1162,16 @@ void Cacher::run() {
queued_ = false;
if (!caching_) {
break;
} else {
} else if (is_valid_state_) {
CacheWorker();
} else {
// main thread waits until cacher starts fully, but the cacher can't run, so we just wake it up here
WakeMainThread();
}
}
is_valid_state_ = false;
CloseWorker();
clip->state_change_lock.unlock();
@@ -1166,6 +1192,10 @@ void Cacher::Open()
void Cacher::Cache(long playhead, bool scrubbing, QVector<Clip*>& nests, int playback_speed)
{
if (!is_valid_state_) {
return;
}
if (clip->media_stream() != nullptr
&& queue_.size() > 0
&& clip->media_stream()->infinite_length) {
+7
View File
@@ -465,6 +465,13 @@ private:
*/
bool caching_;
/**
* @brief Internal variable for whether the current Cacher state is valid or not
*
* If there was an error opening the Cacher for any reason, this will be false.
*/
bool is_valid_state_;
/**
* @brief Internal function for opening the file handles and decoder
*
+276 -151
View File
@@ -43,35 +43,34 @@ extern "C" {
#include <QOpenGLPaintDevice>
#include <QPainter>
ExportThread::ExportThread(const ExportParams &iparams,
const VideoCodecParams& ivparams,
ExportThread::ExportThread(const ExportParams &params,
const VideoCodecParams& vparams,
QObject *parent) :
QThread(parent)
QThread(parent),
params_(params),
vcodec_params_(vparams),
interrupt_(false),
fmt_ctx(nullptr),
video_stream(nullptr),
vcodec(nullptr),
vcodec_ctx(nullptr),
video_frame(nullptr),
sws_ctx(nullptr),
audio_stream(nullptr),
acodec(nullptr),
audio_frame(nullptr),
swr_frame(nullptr),
acodec_ctx(nullptr),
swr_ctx(nullptr),
vpkt_alloc(false),
apkt_alloc(false),
c_filename(nullptr)
{
params = iparams;
vcodec_params = ivparams;
continueEncode = true;
// Create offscreen surface for rendering while exporting
surface.create();
fmt_ctx = nullptr;
video_stream = nullptr;
vcodec = nullptr;
vcodec_ctx = nullptr;
video_frame = nullptr;
sws_ctx = nullptr;
audio_stream = nullptr;
acodec = nullptr;
audio_frame = nullptr;
swr_frame = nullptr;
acodec_ctx = nullptr;
swr_ctx = nullptr;
vpkt_alloc = false;
apkt_alloc = false;
}
bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream, bool rescale) {
bool ExportThread::Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream, bool rescale) {
ret = avcodec_send_frame(codec_ctx, frame);
if (ret < 0) {
qCritical() << "Failed to send frame to encoder." << ret;
@@ -99,15 +98,15 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx,
return true;
}
bool ExportThread::setupVideo() {
bool ExportThread::SetupVideo() {
// if video is disabled, no setup necessary
if (!params.video_enabled) return true;
if (!params_.video_enabled) return true;
// find video encoder
vcodec = avcodec_find_encoder(static_cast<enum AVCodecID>(params.video_codec));
vcodec = avcodec_find_encoder(static_cast<enum AVCodecID>(params_.video_codec));
if (!vcodec) {
qCritical() << "Could not find video encoder";
export_error = tr("could not video encoder for %1").arg(QString::number(params.video_codec));
export_error = tr("could not video encoder for %1").arg(QString::number(params_.video_codec));
return false;
}
@@ -130,15 +129,15 @@ bool ExportThread::setupVideo() {
}
// setup context
vcodec_ctx->codec_id = static_cast<enum AVCodecID>(params.video_codec);
vcodec_ctx->codec_id = static_cast<enum AVCodecID>(params_.video_codec);
vcodec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
vcodec_ctx->width = params.video_width;
vcodec_ctx->height = params.video_height;
vcodec_ctx->width = params_.video_width;
vcodec_ctx->height = params_.video_height;
vcodec_ctx->sample_aspect_ratio = {1, 1};
vcodec_ctx->pix_fmt = static_cast<AVPixelFormat>(vcodec_params.pix_fmt);
vcodec_ctx->framerate = av_d2q(params.video_frame_rate, INT_MAX);
if (params.video_compression_type == COMPRESSION_TYPE_CBR) {
vcodec_ctx->bit_rate = qRound(params.video_bitrate * 1000000);
vcodec_ctx->pix_fmt = static_cast<AVPixelFormat>(vcodec_params_.pix_fmt);
vcodec_ctx->framerate = av_d2q(params_.video_frame_rate, INT_MAX);
if (params_.video_compression_type == COMPRESSION_TYPE_CBR) {
vcodec_ctx->bit_rate = qRound(params_.video_bitrate * 1000000);
}
vcodec_ctx->time_base = av_inv_q(vcodec_ctx->framerate);
video_stream->time_base = vcodec_ctx->time_base;
@@ -147,27 +146,30 @@ bool ExportThread::setupVideo() {
vcodec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
// Some codecs require special settings so we set that up here
switch (vcodec_ctx->codec_id) {
/// H.264 specific settings
case AV_CODEC_ID_H264:
case AV_CODEC_ID_H265:
switch (params.video_compression_type) {
switch (params_.video_compression_type) {
case COMPRESSION_TYPE_CFR:
av_opt_set(vcodec_ctx->priv_data, "crf", QString::number(static_cast<int>(params.video_bitrate)).toUtf8(), AV_OPT_SEARCH_CHILDREN);
av_opt_set(vcodec_ctx->priv_data, "crf", QString::number(static_cast<int>(params_.video_bitrate)).toUtf8(), AV_OPT_SEARCH_CHILDREN);
break;
}
break;
}
// Set export to be multithreaded
AVDictionary* opts = nullptr;
if (vcodec_params.threads == 0) {
if (vcodec_params_.threads == 0) {
av_dict_set(&opts, "threads", "auto", 0);
} else {
av_dict_set(&opts, "threads", QString::number(vcodec_params.threads).toUtf8(), 0);
av_dict_set(&opts, "threads", QString::number(vcodec_params_.threads).toUtf8(), 0);
}
// Open video encoder
ret = avcodec_open2(vcodec_ctx, vcodec, &opts);
if (ret < 0) {
qCritical() << "Could not open output video encoder." << ret;
@@ -175,7 +177,7 @@ bool ExportThread::setupVideo() {
return false;
}
// copy video encoder parameters to output stream
// Copy video encoder parameters to output stream
ret = avcodec_parameters_from_context(video_stream->codecpar, vcodec_ctx);
if (ret < 0) {
qCritical() << "Could not copy video encoder parameters to output stream." << ret;
@@ -183,7 +185,7 @@ bool ExportThread::setupVideo() {
return false;
}
// create AVFrame
// Create raw AVFrame that will contain the RGBA buffer straight from compositing
video_frame = av_frame_alloc();
av_frame_make_writable(video_frame);
video_frame->format = AV_PIX_FMT_RGBA;
@@ -193,14 +195,15 @@ bool ExportThread::setupVideo() {
av_init_packet(&video_pkt);
// Set up conversion context
sws_ctx = sws_getContext(
olive::ActiveSequence->width,
olive::ActiveSequence->height,
AV_PIX_FMT_RGBA,
params.video_width,
params.video_height,
params_.video_width,
params_.video_height,
vcodec_ctx->pix_fmt,
SWS_FAST_BILINEAR,
SWS_BILINEAR,
nullptr,
nullptr,
nullptr
@@ -209,29 +212,31 @@ bool ExportThread::setupVideo() {
return true;
}
bool ExportThread::setupAudio() {
// if audio is disabled, no setup necessary
if (!params.audio_enabled) return true;
bool ExportThread::SetupAudio() {
// find encoder
acodec = avcodec_find_encoder(static_cast<AVCodecID>(params.audio_codec));
// Find encoder for this codec
acodec = avcodec_find_encoder(static_cast<AVCodecID>(params_.audio_codec));
if (!acodec) {
qCritical() << "Could not find audio encoder";
export_error = tr("could not audio encoder for %1").arg(QString::number(params.audio_codec));
export_error = tr("could not audio encoder for %1").arg(QString::number(params_.audio_codec));
return false;
}
// allocate audio stream
// Allocate audio stream
audio_stream = avformat_new_stream(fmt_ctx, acodec);
audio_stream->id = 1;
if (!audio_stream) {
if (audio_stream == nullptr) {
qCritical() << "Could not allocate audio stream";
export_error = tr("could not allocate audio stream");
return false;
}
// allocate context
// acodec_ctx = audio_stream->codec;
// Set audio stream's ID to 1
audio_stream->id = 1;
// set sample rate to use for project
audio_rendering_rate = params_.audio_sampling_rate;
// Allocate encoding context
acodec_ctx = avcodec_alloc_context3(acodec);
if (!acodec_ctx) {
qCritical() << "Could not find allocate audio encoding context";
@@ -239,27 +244,24 @@ bool ExportThread::setupAudio() {
return false;
}
// set sample rate to use for project
audio_rendering_rate = params.audio_sampling_rate;
// setup context
acodec_ctx->codec_id = static_cast<AVCodecID>(params.audio_codec);
// Set up encoding context
acodec_ctx->codec_id = static_cast<AVCodecID>(params_.audio_codec);
acodec_ctx->codec_type = AVMEDIA_TYPE_AUDIO;
acodec_ctx->sample_rate = params.audio_sampling_rate;
acodec_ctx->sample_rate = params_.audio_sampling_rate;
acodec_ctx->channel_layout = AV_CH_LAYOUT_STEREO; // change this to support surround/mono sound in the future (this is what the user sets the output audio to)
acodec_ctx->channels = av_get_channel_layout_nb_channels(acodec_ctx->channel_layout);
acodec_ctx->sample_fmt = acodec->sample_fmts[0];
acodec_ctx->bit_rate = params.audio_bitrate * 1000;
acodec_ctx->bit_rate = params_.audio_bitrate * 1000;
acodec_ctx->time_base.num = 1;
acodec_ctx->time_base.den = params.audio_sampling_rate;
acodec_ctx->time_base.den = params_.audio_sampling_rate;
audio_stream->time_base = acodec_ctx->time_base;
if (fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) {
acodec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
// open encoder
// Open encoder
ret = avcodec_open2(acodec_ctx, acodec, nullptr);
if (ret < 0) {
qCritical() << "Could not open output audio encoder." << ret;
@@ -267,7 +269,7 @@ bool ExportThread::setupAudio() {
return false;
}
// copy params to output stream
// Copy paramters from the codec context (set up above) to the output stream
ret = avcodec_parameters_from_context(audio_stream->codecpar, acodec_ctx);
if (ret < 0) {
qCritical() << "Could not copy audio encoder parameters to output stream." << ret;
@@ -299,8 +301,10 @@ bool ExportThread::setupAudio() {
audio_frame->nb_samples = 256;
}
// TODO change this to support surround/mono sound in the future (this is whatever format they're held in the internal buffer)
audio_frame->channel_layout = AV_CH_LAYOUT_STEREO;
audio_frame->format = AV_SAMPLE_FMT_S16;
audio_frame->channel_layout = AV_CH_LAYOUT_STEREO; // change this to support surround/mono sound in the future (this is whatever format they're held in the internal buffer)
audio_frame->channels = av_get_channel_layout_nb_channels(audio_frame->channel_layout);
av_frame_make_writable(audio_frame);
ret = av_frame_get_buffer(audio_frame, 0);
@@ -327,18 +331,25 @@ bool ExportThread::setupAudio() {
return true;
}
bool ExportThread::setupContainer() {
bool ExportThread::SetupContainer() {
// Set up output context (using the filename as the format specification)
avformat_alloc_output_context2(&fmt_ctx, nullptr, nullptr, c_filename);
if (!fmt_ctx) {
if (fmt_ctx == nullptr) {
// Failed to create the output format context. Exit the export and throw an error.
qCritical() << "Could not create output context";
export_error = tr("could not create output format context");
return false;
}
//av_dump_format(fmt_ctx, 0, c_filename, 1);
ret = avio_open(&fmt_ctx->pb, c_filename, AVIO_FLAG_WRITE);
if (ret < 0) {
// Failed to get a valid write handle for the exported file. Exit the export and throw an error.
qCritical() << "Could not open output file." << ret;
export_error = tr("could not open output file (%1)").arg(QString::number(ret));
return false;
@@ -347,60 +358,98 @@ bool ExportThread::setupContainer() {
return true;
}
void ExportThread::run() {
panel_sequence_viewer->pause();
panel_sequence_viewer->seek(params.start_frame);
// copy filename
QByteArray ba = params.filename.toUtf8();
void ExportThread::Export()
{
// Copy filename from QString to const char
QByteArray ba = params_.filename.toUtf8();
c_filename = new char[ba.size()+1];
strcpy(c_filename, ba.data());
continueEncode = setupContainer();
if (params.video_enabled && continueEncode) continueEncode = setupVideo();
if (params.audio_enabled && continueEncode) continueEncode = setupAudio();
if (continueEncode) {
ret = avformat_write_header(fmt_ctx, nullptr);
if (ret < 0) {
qCritical() << "Could not write output file header." << ret;
export_error = tr("could not write output file header (%1)").arg(QString::number(ret));
continueEncode = false;
}
// Set up file container
if (!SetupContainer()) {
return;
}
// If video is enabled, set it up in the container now
if (params_.video_enabled && !SetupVideo()) {
return;
}
// If audio is enabled, set it up in the container now
if (params_.audio_enabled && !SetupAudio()) {
return;
}
// Write the container header based on what's been set up above
ret = avformat_write_header(fmt_ctx, nullptr);
if (ret < 0) {
// FFmpeg failed to write the header, so cancel the export and throw an error
qCritical() << "Could not write output file header." << ret;
export_error = tr("could not write output file header (%1)").arg(QString::number(ret));
return;
}
// Count audio samples in file (used for calculating PTS)
long file_audio_samples = 0;
qint64 start_time, frame_time, avg_time, eta, total_time = 0;
// Set up timing variables, used for determining rendering ETA
qint64 frame_start_time, frame_time, avg_time, eta, total_time = 0;
// Frame counters - used for generating encoding statistics (e.g. average frame time, ETA, etc.)
long remaining_frames, frame_count = 1;
// Use Sequence Viewer's render thread - TODO separate this into a new render thread for background rendering
RenderThread* renderer = panel_sequence_viewer->viewer_widget->get_renderer();
// Override connection from RenderThread
disconnect(renderer, SIGNAL(ready()), panel_sequence_viewer->viewer_widget, SLOT(queue_repaint()));
connect(renderer, SIGNAL(ready()), this, SLOT(wake()));
// Lock mutex (used for synchronization with RenderThread)
mutex.lock();
while (olive::ActiveSequence->playhead <= params.end_frame && continueEncode) {
start_time = QDateTime::currentMSecsSinceEpoch();
// Loop from now (set to the beginning frame earlier) to the end of the frame
while (olive::ActiveSequence->playhead <= params_.end_frame && !interrupt_) {
if (params.audio_enabled) {
compose_audio(nullptr, olive::ActiveSequence.get(), 1, true);
// Start timing how long this frame will take
frame_start_time = QDateTime::currentMSecsSinceEpoch();
// If we're exporting audio, run compose_audio() which will write mixed audio to the internal audio buffer
if (params_.audio_enabled) {
olive::rendering::compose_audio(nullptr, olive::ActiveSequence.get(), 1, true);
}
if (params.video_enabled) {
// If we're exporting video, trigger a render on the RenderThread
if (params_.video_enabled) {
do {
// TODO optimize by rendering the next frame while encoding the last
renderer->start_render(nullptr, olive::ActiveSequence.get(), 1, nullptr, video_frame->data[0], video_frame->linesize[0]/4);
// Wait for RenderThread to return
waitCond.wait(&mutex);
if (!continueEncode) break;
if (interrupt_) {
return;
}
// If the RenderThread failed, do another render
} while (renderer->did_texture_fail());
if (!continueEncode) break;
if (interrupt_) {
return;
}
}
// encode last frame while rendering next frame
double timecode_secs = double(olive::ActiveSequence->playhead - params.start_frame) / olive::ActiveSequence->frame_rate;
if (params.video_enabled) {
// create sws_frame for converting pixel format
// Get the current sequence playhead in seconds (used for timestamp calculations later on)
double timecode_secs = double(olive::ActiveSequence->playhead - params_.start_frame) / olive::ActiveSequence->frame_rate;
// If we're exporting video, construct an AVFrame in the destination codec's pixel format to convert the raw RGBA
// OpenGL buffer to
if (params_.video_enabled) {
//
// - I'm not sure why, but we have to alloc/free sws_frame every frame, or it breaks GIF exporting.
@@ -410,146 +459,222 @@ void ExportThread::run() {
// - Anyway, here we are.
//
// Construct destination pixel format frame
sws_frame = av_frame_alloc();
sws_frame->format = vcodec_ctx->pix_fmt;
sws_frame->width = params.video_width;
sws_frame->height = params.video_height;
sws_frame->width = params_.video_width;
sws_frame->height = params_.video_height;
av_frame_get_buffer(sws_frame, 0);
// convert pixel format to format expected by the encoder
// Convert raw RGBA buffer to format expected by the encoder
sws_scale(sws_ctx, video_frame->data, video_frame->linesize, 0, video_frame->height, sws_frame->data, sws_frame->linesize);
sws_frame->pts = qRound(timecode_secs/av_q2d(video_stream->time_base));
// send converted frame to encoder
if (!encode(fmt_ctx, vcodec_ctx, sws_frame, &video_pkt, video_stream, false)) continueEncode = false;
// Send frame to encoder
if (!Encode(fmt_ctx, vcodec_ctx, sws_frame, &video_pkt, video_stream, false)) {
return;
}
av_frame_free(&sws_frame);
sws_frame = nullptr;
}
if (params.audio_enabled) {
// do we need to encode more audio samples?
while (continueEncode && file_audio_samples <= (timecode_secs*params.audio_sampling_rate)) {
// If we're exporting audio, copy audio from the buffer into an AVFrame for encoding
if (params_.audio_enabled) {
// copy samples from audio buffer to AVFrame
// Check if the count of encoded samples exceeds the current Sequence playhead, in which case we don't need to
// encode any audio at this moment
while (!interrupt_ && file_audio_samples <= (timecode_secs*params_.audio_sampling_rate)) {
// Copy samples from audio buffer to AVFrame
int adjusted_read = audio_ibuffer_read%audio_ibuffer_size;
int copylen = qMin(aframe_bytes, audio_ibuffer_size-adjusted_read);
memcpy(audio_frame->data[0], audio_ibuffer+adjusted_read, copylen);
memset(audio_ibuffer+adjusted_read, 0, copylen);
audio_ibuffer_read += copylen;
// If we reached the end of the buffer without reaching the end of the frame, do another copy from the start
// of the buffer
if (copylen < aframe_bytes) {
// copy remainder
int remainder_len = aframe_bytes-copylen;
memcpy(audio_frame->data[0]+copylen, audio_ibuffer, remainder_len);
memset(audio_ibuffer, 0, remainder_len);
audio_ibuffer_read += remainder_len;
}
// convert to export sample format
// Convert raw audio samples to the destination codec's sample format
swr_convert_frame(swr_ctx, swr_frame, audio_frame);
// The timestamp is set to the current count of audio samples (since the audio stream's timebase is
swr_frame->pts = file_audio_samples;
// send to encoder
if (!encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) continueEncode = false;
// Send frame to encoder
if (!Encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) {
return;
}
// Increment by the frame's number of samples
file_audio_samples += swr_frame->nb_samples;
}
}
// generating encoding statistics (time it took to encode this frame/estimated remaining time)
frame_time = (QDateTime::currentMSecsSinceEpoch()-start_time);
// Generating encoding statistics (e.g. the time it took to encode this frame/estimated remaining time)
frame_time = (QDateTime::currentMSecsSinceEpoch()-frame_start_time);
total_time += frame_time;
remaining_frames = (params.end_frame - olive::ActiveSequence->playhead);
remaining_frames = (params_.end_frame - olive::ActiveSequence->playhead);
avg_time = (total_time/frame_count);
eta = (remaining_frames*avg_time);
emit progress_changed(qRound((double(olive::ActiveSequence->playhead - params.start_frame) / double(params.end_frame - params.start_frame)) * 100.0), eta);
// Emit a signal for the percent of the sequence that's been encoded so far
emit ProgressChanged(qRound((double(olive::ActiveSequence->playhead - params_.start_frame) / double(params_.end_frame - params_.start_frame)) * 100.0), eta);
// Increment sequence playhead
olive::ActiveSequence->playhead++;
// Increment frame count (used for generating encoding statistics above)
frame_count++;
}
// Restore original connection from RenderThread
disconnect(renderer, SIGNAL(ready()), this, SLOT(wake()));
connect(renderer, SIGNAL(ready()), panel_sequence_viewer->viewer_widget, SLOT(queue_repaint()));
mutex.unlock();
if (continueEncode) {
if (params.video_enabled) vpkt_alloc = true;
if (params.audio_enabled) apkt_alloc = true;
if (interrupt_) {
return;
}
if (params_.video_enabled) vpkt_alloc = true;
if (params_.audio_enabled) apkt_alloc = true;
olive::Global->set_rendering_state(false);
if (params.audio_enabled && continueEncode) {
// If audio is enabled, flush the rest of the audio out of swresample
if (params_.audio_enabled) {
// flush swresample
do {
swr_convert_frame(swr_ctx, swr_frame, nullptr);
if (swr_frame->nb_samples == 0) break;
swr_frame->pts = file_audio_samples;
if (!encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) continueEncode = false;
if (!Encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) {
return;
}
file_audio_samples += swr_frame->nb_samples;
} while (swr_frame->nb_samples > 0);
}
bool continueVideo = true;
bool continueAudio = true;
if (continueEncode) {
// flush remaining packets
while (continueVideo && continueAudio) {
if (continueVideo && params.video_enabled) continueVideo = encode(fmt_ctx, vcodec_ctx, nullptr, &video_pkt, video_stream, false);
if (continueAudio && params.audio_enabled) continueAudio = encode(fmt_ctx, acodec_ctx, nullptr, &audio_pkt, audio_stream, true);
}
if (interrupt_) {
return;
}
ret = av_write_trailer(fmt_ctx);
if (ret < 0) {
qCritical() << "Could not write output file trailer." << ret;
export_error = tr("could not write output file trailer (%1)").arg(QString::number(ret));
continueEncode = false;
}
bool continueVideo = params_.video_enabled;
bool continueAudio = params_.audio_enabled;
if (continueEncode) {
emit progress_changed(100, 0);
// Flush remaining packets out of video and audio encoders
while (continueVideo && continueAudio) {
if (continueVideo) {
continueVideo = Encode(fmt_ctx, vcodec_ctx, nullptr, &video_pkt, video_stream, false);
}
if (continueAudio) {
continueAudio = Encode(fmt_ctx, acodec_ctx, nullptr, &audio_pkt, audio_stream, true);
}
}
avio_closep(&fmt_ctx->pb);
// Write container trailer
ret = av_write_trailer(fmt_ctx);
if (ret < 0) {
qCritical() << "Could not write output file trailer." << ret;
export_error = tr("could not write output file trailer (%1)").arg(QString::number(ret));
return;
}
if (vpkt_alloc) av_packet_unref(&video_pkt);
if (video_frame != nullptr) av_frame_free(&video_frame);
if (vcodec_ctx != nullptr) {
avcodec_close(vcodec_ctx);
avcodec_free_context(&vcodec_ctx);
emit ProgressChanged(100, 0);
}
void ExportThread::Cleanup()
{
if (fmt_ctx != nullptr) {
avio_closep(&fmt_ctx->pb);
avformat_free_context(fmt_ctx);
}
if (apkt_alloc) av_packet_unref(&audio_pkt);
if (audio_frame != nullptr) av_frame_free(&audio_frame);
if (acodec_ctx != nullptr) {
avcodec_close(acodec_ctx);
avcodec_free_context(&acodec_ctx);
}
avformat_free_context(fmt_ctx);
if (audio_frame != nullptr) {
av_frame_free(&audio_frame);
}
if (apkt_alloc) {
av_packet_unref(&audio_pkt);
}
if (vcodec_ctx != nullptr) {
avcodec_close(vcodec_ctx);
avcodec_free_context(&vcodec_ctx);
}
if (video_frame != nullptr) {
av_frame_free(&video_frame);
}
if (vpkt_alloc) {
av_packet_unref(&video_pkt);
}
if (sws_ctx != nullptr) {
sws_freeContext(sws_ctx);
}
if (swr_ctx != nullptr) {
av_frame_free(&swr_frame);
swr_free(&swr_ctx);
}
if (swr_frame != nullptr) {
av_frame_free(&swr_frame);
}
if (sws_frame != nullptr) {
av_frame_free(&sws_frame);
}
delete [] c_filename;
}
const QString &ExportThread::getError() {
void ExportThread::run() {
// Ensure sequence isn't currently playing
panel_sequence_viewer->pause();
// Seek to the first frame we're exporting
panel_sequence_viewer->seek(params_.start_frame);
// Run export function (which will return if there's a failure)
Export();
// Clean up anything that was allocated in Export() (whether it succeeded or not)
Cleanup();
}
const QString &ExportThread::GetError() {
return export_error;
}
bool ExportThread::WasInterrupted()
{
return interrupt_;
}
void ExportThread::Interrupt()
{
interrupt_ = true;
}
void ExportThread::wake() {
mutex.lock();
waitCond.wakeAll();
+21 -16
View File
@@ -72,27 +72,30 @@ struct VideoCodecParams {
class ExportThread : public QThread {
Q_OBJECT
public:
ExportThread(const ExportParams& iparams, const VideoCodecParams& ivparams, QObject* parent = nullptr);
void run();
ExportThread(const ExportParams& params, const VideoCodecParams& vparams, QObject* parent = nullptr);
virtual void run() override;
const QString& getError();
const QString& GetError();
bool WasInterrupted();
signals:
void ProgressChanged(int value, qint64 remaining_ms);
public slots:
void Interrupt();
private:
bool Encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream, bool rescale);
bool SetupVideo();
bool SetupAudio();
bool SetupContainer();
void Export();
void Cleanup();
QOffscreenSurface surface;
bool continueEncode;
signals:
void progress_changed(int value, qint64 remaining_ms);
public slots:
void wake();
private:
bool encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream, bool rescale);
bool setupVideo();
bool setupAudio();
bool setupContainer();
bool interrupt_;
// params imported from dialogs
ExportParams params;
VideoCodecParams vcodec_params;
ExportParams params_;
VideoCodecParams vcodec_params_;
AVFormatContext* fmt_ctx;
AVStream* video_stream;
@@ -121,6 +124,8 @@ private:
QWaitCondition waitCond;
QString export_error;
private slots:
void wake();
};
#endif // EXPORTTHREAD_H
+2 -2
View File
@@ -309,7 +309,7 @@ void process_effect(QOpenGLContext* ctx,
}
}
GLuint compose_sequence(ComposeSequenceParams &params) {
GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
GLuint final_fbo = params.video ? params.main_buffer->buffer() : 0;
Sequence* s = params.seq;
@@ -888,7 +888,7 @@ GLuint compose_sequence(ComposeSequenceParams &params) {
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;
+4
View File
@@ -191,6 +191,8 @@ struct ComposeSequenceParams {
const FramebufferObject* backend_buffer2;
};
namespace olive {
namespace rendering {
/**
* @brief Compose a frame of a given sequence
*
@@ -239,6 +241,8 @@ GLuint compose_sequence(ComposeSequenceParams &params);
* Whether to wait for media to open or simply fail if the media is not yet open. This should usually be **FALSE**.
*/
void compose_audio(Viewer* viewer, Sequence *seq, int playback_speed, bool wait_for_mutexes);
}
}
/**
* @brief Rescale a frame number between two frame rates
+1 -1
View File
@@ -243,7 +243,7 @@ void RenderThread::paint() {
f->glClear(GL_COLOR_BUFFER_BIT);
// Compose the current frame
compose_sequence(params);
olive::rendering::compose_sequence(params);
// Copy composite buffer to front buffer
// First lock the appropriate mutex for exclusivity
+21 -17
View File
@@ -40,24 +40,22 @@ const int kRGBAComponentCount = 4;
Clip::Clip(Sequence* s) :
sequence(s),
cacher(this)
cacher(this),
enabled_(true),
clip_in_(0),
timeline_in_(0),
timeline_out_(0),
track_(0),
media_(nullptr),
reverse_(false),
autoscale_(olive::CurrentConfig.autoscale_by_default),
opening_transition(nullptr),
closing_transition(nullptr),
undeletable(false),
replaced(false),
open_(false),
texture(0)
{
enabled_ = true;
clip_in_ = 0;
timeline_in_ = 0;
timeline_out_ = 0;
track_ = 0;
media_ = nullptr;
speed_.value = 1.0;
speed_.maintain_audio_pitch = false;
reverse_ = false;
autoscale_ = olive::CurrentConfig.autoscale_by_default;
opening_transition = nullptr;
closing_transition = nullptr;
undeletable = false;
replaced = false;
open_ = false;
texture = 0;
}
ClipPtr Clip::copy(Sequence* s) {
@@ -617,3 +615,9 @@ bool Clip::UsesCacher()
{
return track() >= 0 || (media() != nullptr && media()->get_type() == MEDIA_TYPE_FOOTAGE);
}
ClipSpeed::ClipSpeed() :
value(1.0),
maintain_audio_pitch(false)
{
}
+1
View File
@@ -45,6 +45,7 @@ extern "C" {
}
struct ClipSpeed {
ClipSpeed();
double value;
bool maintain_audio_pitch;
};
+1 -3
View File
@@ -30,9 +30,7 @@
#include <QWidget>
#include <QPainter>
#include "ui/checkboxex.h"
#include "ui/icons.h"
#include "global/debug.h"
CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) {
@@ -47,7 +45,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) {
title_bar->setAutoFillBackground(true);
title_bar_layout = new QHBoxLayout(title_bar);
title_bar_layout->setMargin(5);
enabled_check = new CheckboxEx(title_bar);
enabled_check = new QCheckBox(title_bar);
enabled_check->setChecked(true);
header = new QLabel(title_bar);
collapse_button = new QPushButton(title_bar);
+1 -3
View File
@@ -30,8 +30,6 @@
#include <QFrame>
#include <QIcon>
#include "ui/checkboxex.h"
class CollapsibleWidgetHeader : public QWidget {
Q_OBJECT
public:
@@ -56,7 +54,7 @@ public:
bool IsExpanded();
bool IsSelected();
protected:
CheckboxEx* enabled_check;
QCheckBox* enabled_check;
CollapsibleWidgetHeader* title_bar;
QWidget* contents;
private:
+54 -8
View File
@@ -20,6 +20,7 @@
#include "texteditex.h"
#include <QVBoxLayout>
#include <QDebug>
#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());
}
+13 -1
View File
@@ -22,11 +22,21 @@
#define TEXTEDITEX_H
#include <QTextEdit>
#include <QPushButton>
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_;
};
+18 -3
View File
@@ -328,11 +328,26 @@ double TimelineHeader::get_zoom() {
void TimelineHeader::delete_markers() {
if (selected_markers.size() > 0) {
// Send command to delete selected markers
DeleteMarkerAction* dma = new DeleteMarkerAction(viewer->marker_ref);
for (int i=0;i<selected_markers.size();i++) {
dma->markers.append(selected_markers.at(i));
}
dma->markers.append(selected_markers);
olive::UndoStack.push(dma);
// remove any indices for the selected markers that no longer exist
for (int i=0;i<selected_markers.size();i++) {
if (selected_markers.at(i) >= viewer->marker_ref->size()) {
selected_markers.removeAt(i);
i--;
}
}
// if we removed all the indices, re-select the last marker in the array so something is always selected
// (allows users to hold delete when deleting markers)
if (selected_markers.isEmpty() && !viewer->marker_ref->isEmpty()) {
selected_markers.append(viewer->marker_ref->size() - 1);
}
update_parents();
}
}
+1 -2
View File
@@ -57,7 +57,6 @@
#include "global/debug.h"
#include "effects/effect.h"
#include "effects/internal/solideffect.h"
#include "effects/internal/texteffect.h"
#define MAX_TEXT_WIDTH 20
#define TRANSITION_BETWEEN_RANGE 40
@@ -1022,7 +1021,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
switch (panel_timeline->creating_object) {
case ADD_OBJ_TITLE:
c->set_name(tr("Title"));
c->effects.append(Effect::Create(c.get(), Effect::GetInternalMeta(EFFECT_INTERNAL_TEXT, EFFECT_TYPE_EFFECT)));
c->effects.append(Effect::Create(c.get(), Effect::GetInternalMeta(EFFECT_INTERNAL_RICHTEXT, EFFECT_TYPE_EFFECT)));
break;
case ADD_OBJ_SOLID:
c->set_name(tr("Solid Color"));
+1 -1
View File
@@ -244,7 +244,7 @@ void ViewerWidget::frame_update() {
}
// render the audio
compose_audio(viewer, viewer->seq.get(), viewer->get_playback_speed(), viewer->WaitingForPlayWake());
olive::rendering::compose_audio(viewer, viewer->seq.get(), viewer->get_playback_speed(), viewer->WaitingForPlayWake());
}
}
+3 -3
View File
@@ -1136,7 +1136,7 @@ void OliveAction::undo() {
doUndo();
if (set_window_modified) {
olive::MainWindow->setWindowModified(old_window_modified);
olive::Global->set_modified(old_window_modified);
}
}
@@ -1146,10 +1146,10 @@ void OliveAction::redo() {
if (set_window_modified) {
// store current modified state
old_window_modified = olive::MainWindow->isWindowModified();
old_window_modified = olive::Global->is_modified();
// set modified to true
olive::MainWindow->setWindowModified(true);
olive::Global->set_modified(true);
}
}
+3
View File
@@ -24,6 +24,9 @@
#include <QUndoStack>
namespace olive {
/**
* @brief Global undo stack object
*/
extern QUndoStack UndoStack;
}