From fac921383348e997f2e163358484a5f68da7af7f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 13:44:23 +1100 Subject: [PATCH 1/7] added proxy dialog --- dialogs/proxydialog.cpp | 74 +++++++++++++++++++++++++++++++++++++++ dialogs/proxydialog.h | 30 ++++++++++++++++ olive.pro | 6 ++-- project/sourcescommon.cpp | 13 +++++++ project/sourcescommon.h | 37 ++++++++++---------- 5 files changed, 140 insertions(+), 20 deletions(-) create mode 100644 dialogs/proxydialog.cpp create mode 100644 dialogs/proxydialog.h diff --git a/dialogs/proxydialog.cpp b/dialogs/proxydialog.cpp new file mode 100644 index 000000000..bf3233a8b --- /dev/null +++ b/dialogs/proxydialog.cpp @@ -0,0 +1,74 @@ +#include "proxydialog.h" + +#include +#include +#include +#include +#include + +ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) : QDialog(parent) { + // set dialog title + setWindowTitle(tr("Create Proxy")); + + // set proxy folder name to "Proxy", depending on the user's language + proxy_folder_name = tr("Proxy"); + + // set up dialog's layout + QGridLayout* layout = new QGridLayout(this); + + // set the video dimensions of the proxy + layout->addWidget(new QLabel(tr("Dimensions:"), this), 0, 0); + + QComboBox* size_combobox = new QComboBox(this); + size_combobox->addItem(tr("Same Size as Source"), 1.0); + size_combobox->addItem(tr("Half Resolution (1/2)"), 0.5); + size_combobox->addItem(tr("Quarter Resolution (1/4)"), 0.25); + size_combobox->addItem(tr("Eighth Resolution (1/8)"), 0.125); + size_combobox->addItem(tr("Sixteenth Resolution (1/16)"), 0.0625); + layout->addWidget(size_combobox, 0, 1); + + // set the desired format of the proxy to create + layout->addWidget(new QLabel(tr("Format:"), this), 1, 0); + + QComboBox* format_combobox = new QComboBox(this); + format_combobox->addItem(tr("ProRes HQ")); + format_combobox->addItem(tr("ProRes SQ")); + format_combobox->addItem(tr("ProRes LT")); + format_combobox->addItem(tr("DNxHD")); + format_combobox->addItem(tr("H.264")); + layout->addWidget(format_combobox, 1, 1); + + // set the location to place the proxies + layout->addWidget(new QLabel(tr("Location:"), this), 2, 0); + + location_combobox = new QComboBox(this); + location_combobox->addItem(tr("Same as Source (in \"%1\" folder)").arg(proxy_folder_name)); + location_combobox->addItem(""); + connect(location_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(location_changed(int))); + layout->addWidget(location_combobox, 2, 1); + + // location_changed will set the default "location" items + location_changed(0); + + // set up dialog buttons + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); + buttons->setCenterButtons(true); + layout->addWidget(buttons, 3, 0, 1, 2); + connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); +} + +void ProxyDialog::location_changed(int i) { + custom_location.clear(); + if (i == 1) { + QString s = QFileDialog::getExistingDirectory(this); + if (s.isEmpty()) { + location_combobox->setCurrentIndex(0); + } else { + location_combobox->setItemText(1, s); + custom_location = s; + } + } else { + location_combobox->setItemText(1, tr("Custom Location")); + } +} diff --git a/dialogs/proxydialog.h b/dialogs/proxydialog.h new file mode 100644 index 000000000..fa994d1e1 --- /dev/null +++ b/dialogs/proxydialog.h @@ -0,0 +1,30 @@ +#ifndef PROXYDIALOG_H +#define PROXYDIALOG_H + +#include +#include +#include + +struct Footage; + +class ProxyDialog : public QDialog { + Q_OBJECT +public: + ProxyDialog(QWidget* parent, const QVector& footage); +private: + // user's dimensions + QComboBox* size_combobox; + + // allows users to set the location to store proxies + QComboBox* location_combobox; + + // stores the custom location to store proxies if the user sets a custom location + QString custom_location; + + // stores the subdirectory to be made next to the source in the user's language + QString proxy_folder_name; +private slots: + void location_changed(int i); +}; + +#endif // PROXYDIALOG_H diff --git a/olive.pro b/olive.pro index 126c43d5f..423b5dfac 100644 --- a/olive.pro +++ b/olive.pro @@ -133,7 +133,8 @@ SOURCES += \ project/effectloaders.cpp \ io/crossplatformlib.cpp \ effects/internal/vsthost.cpp \ - ui/flowlayout.cpp + ui/flowlayout.cpp \ + dialogs/proxydialog.cpp HEADERS += \ mainwindow.h \ @@ -234,7 +235,8 @@ HEADERS += \ project/effectloaders.h \ io/crossplatformlib.h \ effects/internal/vsthost.h \ - ui/flowlayout.h + ui/flowlayout.h \ + dialogs/proxydialog.h FORMS += diff --git a/project/sourcescommon.cpp b/project/sourcescommon.cpp index bb557381a..18462b889 100644 --- a/project/sourcescommon.cpp +++ b/project/sourcescommon.cpp @@ -9,6 +9,7 @@ #include "panels/viewer.h" #include "project/projectfilter.h" #include "io/config.h" +#include "dialogs/proxydialog.h" #include "mainwindow.h" #include @@ -126,6 +127,11 @@ void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& it if (all_footage) { QAction* delete_footage_from_sequences = menu.addAction(tr("Delete All Clips Using This Media")); QObject::connect(delete_footage_from_sequences, SIGNAL(triggered(bool)), project_parent, SLOT(delete_clips_using_selected_media())); + + QMenu* proxies = menu.addMenu(tr("Proxy")); + proxies->addAction(tr("Create Proxy"), this, SLOT(open_create_proxy_dialog())); +// proxies->addAction(tr("Modify Proxy")); +// proxies->addAction(tr("Restore Original")); } // delete media @@ -293,3 +299,10 @@ void SourcesCommon::item_renamed(Media* item) { editing_item = nullptr; } } + +void SourcesCommon::open_create_proxy_dialog() { + QVector selected_footage; + + ProxyDialog pd(mainWindow, selected_footage); + pd.exec(); +} diff --git a/project/sourcescommon.h b/project/sourcescommon.h index 4522efdfa..aa740f1d9 100644 --- a/project/sourcescommon.h +++ b/project/sourcescommon.h @@ -11,29 +11,30 @@ class QAbstractItemView; class QDropEvent; class SourcesCommon : public QObject { - Q_OBJECT + Q_OBJECT public: - SourcesCommon(Project *parent); - QAbstractItemView* view; - void show_context_menu(QWidget* parent, const QModelIndexList &items); + SourcesCommon(Project *parent); + QAbstractItemView* view; + void show_context_menu(QWidget* parent, const QModelIndexList &items); - void mousePressEvent(QMouseEvent* e); - void mouseDoubleClickEvent(QMouseEvent* e, const QModelIndexList& selected_items); - void dropEvent(QWidget *parent, QDropEvent* e, const QModelIndex& drop_item, const QModelIndexList &items); + void mousePressEvent(QMouseEvent* e); + void mouseDoubleClickEvent(QMouseEvent* e, const QModelIndexList& selected_items); + void dropEvent(QWidget *parent, QDropEvent* e, const QModelIndex& drop_item, const QModelIndexList &items); - void item_click(Media* m, const QModelIndex &index); + void item_click(Media* m, const QModelIndex &index); private slots: - void create_seq_from_selected(); - void reveal_in_browser(); - void rename_interval(); - void item_renamed(Media *item); + void create_seq_from_selected(); + void reveal_in_browser(); + void rename_interval(); + void item_renamed(Media *item); + void open_create_proxy_dialog(); private: - Media* editing_item; - QModelIndex editing_index; - QModelIndexList selected_items; - Project* project_parent; - void stop_rename_timer(); - QTimer rename_timer; + Media* editing_item; + QModelIndex editing_index; + QModelIndexList selected_items; + Project* project_parent; + void stop_rename_timer(); + QTimer rename_timer; }; #endif // SOURCESCOMMON_H From 373875c72b8601a9008e27ef66f0cdd51b298ef2 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 14:03:23 +1100 Subject: [PATCH 2/7] ensuring UI items are parented --- dialogs/aboutdialog.cpp | 24 ++++++++++++------------ dialogs/actionsearch.cpp | 14 +++++++++----- dialogs/actionsearch.h | 8 ++++++-- dialogs/debugdialog.cpp | 4 ++-- dialogs/demonotice.cpp | 32 ++++++++++++++++---------------- dialogs/exportdialog.cpp | 10 +++++----- io/exportthread.cpp | 5 ++++- io/exportthread.h | 2 +- io/previewgenerator.h | 28 +++++++++++++++------------- 9 files changed, 70 insertions(+), 57 deletions(-) diff --git a/dialogs/aboutdialog.cpp b/dialogs/aboutdialog.cpp index 653f0b859..a62caee6a 100644 --- a/dialogs/aboutdialog.cpp +++ b/dialogs/aboutdialog.cpp @@ -10,21 +10,21 @@ AboutDialog::AboutDialog(QWidget *parent) : setWindowTitle("About Olive"); setMaximumWidth(360); - QVBoxLayout* layout = new QVBoxLayout(); + QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(20); setLayout(layout); - QLabel* label = - new QLabel("" - "

" - "

" - "" - "https://www.olivevideoeditor.org/" - "

" - + tr("Olive is a non-linear video editor. This software is free and protected by the GNU GPL.") - + "

" - + tr("Olive Team is obliged to inform users that Olive source code is available for download from its website.") - + "

"); + QLabel* label = + new QLabel("" + "

" + "

" + "" + "https://www.olivevideoeditor.org/" + "

" + + tr("Olive is a non-linear video editor. This software is free and 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); label->setAlignment(Qt::AlignCenter); label->setWordWrap(true); layout->addWidget(label); diff --git a/dialogs/actionsearch.cpp b/dialogs/actionsearch.cpp index b33624bc2..355a111e3 100644 --- a/dialogs/actionsearch.cpp +++ b/dialogs/actionsearch.cpp @@ -17,20 +17,20 @@ ActionSearch::ActionSearch(QWidget *parent) : setWindowFlags(Qt::Popup); - QVBoxLayout* layout = new QVBoxLayout(); + QVBoxLayout* layout = new QVBoxLayout(this); - ActionSearchEntry* entry_field = new ActionSearchEntry(); + ActionSearchEntry* entry_field = new ActionSearchEntry(this); QFont entry_field_font = entry_field->font(); entry_field_font.setPointSize(qRound(entry_field_font.pointSize()*1.2)); entry_field->setFont(entry_field_font); - entry_field->setPlaceholderText(tr("Search for action...")); + entry_field->setPlaceholderText(tr("Search for action...")); connect(entry_field, SIGNAL(textChanged(const QString&)), this, SLOT(search_update(const QString &))); connect(entry_field, SIGNAL(returnPressed()), this, SLOT(perform_action())); connect(entry_field, SIGNAL(moveSelectionUp()), this, SLOT(move_selection_up())); connect(entry_field, SIGNAL(moveSelectionDown()), this, SLOT(move_selection_down())); layout->addWidget(entry_field); - list_widget = new ActionSearchList(); + list_widget = new ActionSearchList(this); QFont list_widget_font = list_widget->font(); list_widget_font.setPointSize(qRound(list_widget_font.pointSize()*1.2)); list_widget->setFont(list_widget_font); @@ -65,7 +65,7 @@ void ActionSearch::search_update(const QString &s, const QString &p, QMenu *pare } else { QString comp = a->text().replace("&", ""); if (comp.contains(s, Qt::CaseInsensitive)) { - QListWidgetItem* item = new QListWidgetItem(comp + "\n(" + menu_text + ")"); + QListWidgetItem* item = new QListWidgetItem(QString("%1\n(%2)").arg(comp, menu_text), list_widget); item->setData(Qt::UserRole+1, reinterpret_cast(a)); list_widget->addItem(item); } @@ -107,6 +107,8 @@ void ActionSearch::move_selection_down() { } } +ActionSearchEntry::ActionSearchEntry(QWidget *parent) : QLineEdit(parent) {} + void ActionSearchEntry::keyPressEvent(QKeyEvent * event) { switch (event->key()) { case Qt::Key_Up: @@ -120,6 +122,8 @@ void ActionSearchEntry::keyPressEvent(QKeyEvent * event) { } } +ActionSearchList::ActionSearchList(QWidget *parent) : QListWidget(parent) {} + void ActionSearchList::mouseDoubleClickEvent(QMouseEvent *) { emit dbl_click(); } diff --git a/dialogs/actionsearch.h b/dialogs/actionsearch.h index 4147f8900..3a30f7c60 100644 --- a/dialogs/actionsearch.h +++ b/dialogs/actionsearch.h @@ -10,6 +10,8 @@ class QMenu; class ActionSearchList : public QListWidget { Q_OBJECT +public: + ActionSearchList(QWidget* parent); protected: void mouseDoubleClickEvent(QMouseEvent *event); signals: @@ -20,9 +22,9 @@ class ActionSearch : public QDialog { Q_OBJECT public: - ActionSearch(QWidget* parent = 0); + ActionSearch(QWidget* parent = nullptr); private slots: - void search_update(const QString& s, const QString &p = 0, QMenu *parent = nullptr); + void search_update(const QString& s, const QString &p = nullptr, QMenu *parent = nullptr); void perform_action(); void move_selection_up(); void move_selection_down(); @@ -32,6 +34,8 @@ private: class ActionSearchEntry : public QLineEdit { Q_OBJECT +public: + ActionSearchEntry(QWidget* parent); protected: void keyPressEvent(QKeyEvent * event); signals: diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index cb8559062..daba96b91 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -11,10 +11,10 @@ DebugDialog* debug_dialog = nullptr; DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Debug Log")); - QVBoxLayout* layout = new QVBoxLayout(); + QVBoxLayout* layout = new QVBoxLayout(this); setLayout(layout); - textEdit = new QTextEdit(); + textEdit = new QTextEdit(this); textEdit->setWordWrapMode(QTextOption::NoWrap); layout->addWidget(textEdit); } diff --git a/dialogs/demonotice.cpp b/dialogs/demonotice.cpp index b47bb9fc1..adfda7792 100644 --- a/dialogs/demonotice.cpp +++ b/dialogs/demonotice.cpp @@ -7,31 +7,31 @@ DemoNotice::DemoNotice(QWidget *parent) : QDialog(parent) { - setWindowTitle(tr("Welcome to Olive!")); + setWindowTitle(tr("Welcome to Olive!")); setMaximumWidth(600); - QVBoxLayout* vlayout = new QVBoxLayout(); + QVBoxLayout* vlayout = new QVBoxLayout(this); setLayout(vlayout); - QHBoxLayout* layout = new QHBoxLayout(); + QHBoxLayout* layout = new QHBoxLayout(this); layout->setMargin(10); layout->setSpacing(20); - QLabel* icon = new QLabel("" - "

" - ""); + QLabel* icon = new QLabel("" + "

" + "", this); layout->addWidget(icon); - QLabel* text = new QLabel("

" - "" - + tr("Welcome to Olive!") - + "

" - + 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.") - + "

" - + 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("www.olivevideoeditor.org") - + "

" - + tr("Thank you for trying Olive and we hope you enjoy it!") - + "

"); + QLabel* text = new QLabel("

" + "" + + tr("Welcome to Olive!") + + "

" + + 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.") + + "

" + + 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("www.olivevideoeditor.org") + + "

" + + tr("Thank you for trying Olive and we hope you enjoy it!") + + "

", this); text->setWordWrap(true); layout->addWidget(text); diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 5ed83c0fd..3bad14add 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -498,7 +498,7 @@ void ExportDialog::export_action() { } } - et = new ExportThread(); + et = new ExportThread(this); connect(et, SIGNAL(finished()), et, SLOT(deleteLater())); connect(et, SIGNAL(finished()), this, SLOT(render_thread_finished())); @@ -599,9 +599,9 @@ void ExportDialog::comp_type_changed(int) { void ExportDialog::setup_ui() { QVBoxLayout* verticalLayout = new QVBoxLayout(this); - QHBoxLayout* format_layout = new QHBoxLayout(); + QHBoxLayout* format_layout = new QHBoxLayout(this); - format_layout->addWidget(new QLabel(tr("Format:"))); + format_layout->addWidget(new QLabel(tr("Format:"), this)); formatCombobox = new QComboBox(this); @@ -609,9 +609,9 @@ void ExportDialog::setup_ui() { verticalLayout->addLayout(format_layout); - QHBoxLayout* range_layout = new QHBoxLayout(); + QHBoxLayout* range_layout = new QHBoxLayout(this); - range_layout->addWidget(new QLabel(tr("Range:"))); + range_layout->addWidget(new QLabel(tr("Range:"), this)); rangeCombobox = new QComboBox(this); rangeCombobox->addItem(tr("Entire Sequence")); diff --git a/io/exportthread.cpp b/io/exportthread.cpp index a16a27ec7..f5eff945a 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -27,7 +27,10 @@ extern "C" { #include #include -ExportThread::ExportThread() : continueEncode(true) { +ExportThread::ExportThread(QObject *parent) : + QThread(parent), + continueEncode(true) +{ surface.create(); fmt_ctx = nullptr; diff --git a/io/exportthread.h b/io/exportthread.h index b06ddc2c2..ae37ed292 100644 --- a/io/exportthread.h +++ b/io/exportthread.h @@ -28,7 +28,7 @@ extern "C" { class ExportThread : public QThread { Q_OBJECT public: - ExportThread(); + ExportThread(QObject* parent = nullptr); void run(); // export parameters diff --git a/io/previewgenerator.h b/io/previewgenerator.h index 3065bb072..76327c40d 100644 --- a/io/previewgenerator.h +++ b/io/previewgenerator.h @@ -4,10 +4,12 @@ #include #include -#define ICON_TYPE_VIDEO 0 -#define ICON_TYPE_AUDIO 1 -#define ICON_TYPE_IMAGE 2 -#define ICON_TYPE_ERROR 3 +enum IconType { + ICON_TYPE_VIDEO, + ICON_TYPE_AUDIO, + ICON_TYPE_IMAGE, + ICON_TYPE_ERROR +}; struct Footage; struct FootageStream; @@ -16,28 +18,28 @@ class Media; class PreviewGenerator : public QThread { - Q_OBJECT + Q_OBJECT public: PreviewGenerator(Media*, Footage*, bool); - void run(); + void run(); void cancel(); signals: void set_icon(int, bool); private: - void parse_media(); + void parse_media(); bool retrieve_preview(const QString &hash); - void generate_waveform(); + void generate_waveform(); void finalize_media(); - AVFormatContext* fmt_ctx; - Media* media; - Footage* footage; + AVFormatContext* fmt_ctx; + Media* media; + Footage* footage; bool retrieve_duration; bool contains_still_image; bool replace; bool cancelled; QString data_path; - QString get_thumbnail_path(const QString &hash, const FootageStream &ms); - QString get_waveform_path(const QString& hash, const FootageStream &ms); + QString get_thumbnail_path(const QString &hash, const FootageStream &ms); + QString get_waveform_path(const QString& hash, const FootageStream &ms); }; #endif // PREVIEWGENERATOR_H From 6f3a826da78956118c9fd5626cb136735174a079 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 17:36:54 +1100 Subject: [PATCH 3/7] ensured parenting of qwidgets --- dialogs/aboutdialog.cpp | 1 - dialogs/actionsearch.cpp | 2 - dialogs/debugdialog.cpp | 1 - dialogs/demonotice.cpp | 1 - dialogs/exportdialog.cpp | 20 ++--- dialogs/loaddialog.cpp | 13 ++- dialogs/mediapropertiesdialog.cpp | 29 +++--- dialogs/newsequencedialog.cpp | 19 ++-- dialogs/preferencesdialog.cpp | 48 +++++----- dialogs/replaceclipmediadialog.cpp | 66 +++++++------- dialogs/speeddialog.cpp | 27 +++--- dialogs/stabilizerdialog.cpp | 127 ++++++++++++++------------- dialogs/texteditdialog.cpp | 9 +- effects/internal/cornerpineffect.cpp | 10 +-- effects/internal/voideffect.cpp | 4 +- effects/internal/vsthost.cpp | 3 + mainwindow.cpp | 9 +- panels/effectcontrols.cpp | 27 +++--- panels/grapheditor.cpp | 53 ++++++----- panels/project.cpp | 16 ++-- panels/timeline.cpp | 84 +++++++++--------- panels/viewer.cpp | 3 +- playback/playback.cpp | 10 ++- project/effect.cpp | 7 +- project/effectfield.cpp | 2 + project/effectfield.h | 4 +- project/effectrow.cpp | 13 +-- project/effectrow.h | 1 + project/media.cpp | 2 +- ui/collapsiblewidget.cpp | 67 +++++++------- ui/embeddedfilechooser.cpp | 9 +- ui/keyframenavigator.cpp | 20 ++--- 32 files changed, 350 insertions(+), 357 deletions(-) diff --git a/dialogs/aboutdialog.cpp b/dialogs/aboutdialog.cpp index a62caee6a..3f595143c 100644 --- a/dialogs/aboutdialog.cpp +++ b/dialogs/aboutdialog.cpp @@ -12,7 +12,6 @@ AboutDialog::AboutDialog(QWidget *parent) : QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(20); - setLayout(layout); QLabel* label = new QLabel("" diff --git a/dialogs/actionsearch.cpp b/dialogs/actionsearch.cpp index 355a111e3..13c7f3c3b 100644 --- a/dialogs/actionsearch.cpp +++ b/dialogs/actionsearch.cpp @@ -37,8 +37,6 @@ ActionSearch::ActionSearch(QWidget *parent) : layout->addWidget(list_widget); connect(list_widget, SIGNAL(dbl_click()), this, SLOT(perform_action())); - setLayout(layout); - entry_field->setFocus(); } diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index daba96b91..6d2718bec 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -12,7 +12,6 @@ DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Debug Log")); QVBoxLayout* layout = new QVBoxLayout(this); - setLayout(layout); textEdit = new QTextEdit(this); textEdit->setWordWrapMode(QTextOption::NoWrap); diff --git a/dialogs/demonotice.cpp b/dialogs/demonotice.cpp index adfda7792..9f3055426 100644 --- a/dialogs/demonotice.cpp +++ b/dialogs/demonotice.cpp @@ -11,7 +11,6 @@ DemoNotice::DemoNotice(QWidget *parent) : setMaximumWidth(600); QVBoxLayout* vlayout = new QVBoxLayout(this); - setLayout(vlayout); QHBoxLayout* layout = new QHBoxLayout(this); layout->setMargin(10); diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 3bad14add..98c4089b2 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -628,27 +628,27 @@ void ExportDialog::setup_ui() { QGridLayout* videoGridLayout = new QGridLayout(videoGroupbox); - videoGridLayout->addWidget(new QLabel(tr("Codec:")), 0, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Codec:"), this), 0, 0, 1, 1); vcodecCombobox = new QComboBox(videoGroupbox); videoGridLayout->addWidget(vcodecCombobox, 0, 1, 1, 1); - videoGridLayout->addWidget(new QLabel(tr("Width:")), 1, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Width:"), this), 1, 0, 1, 1); widthSpinbox = new QSpinBox(videoGroupbox); widthSpinbox->setMaximum(16777216); videoGridLayout->addWidget(widthSpinbox, 1, 1, 1, 1); - videoGridLayout->addWidget(new QLabel(tr("Height:")), 2, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Height:"), this), 2, 0, 1, 1); heightSpinbox = new QSpinBox(videoGroupbox); heightSpinbox->setMaximum(16777216); videoGridLayout->addWidget(heightSpinbox, 2, 1, 1, 1); - videoGridLayout->addWidget(new QLabel(tr("Frame Rate:")), 3, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Frame Rate:"), this), 3, 0, 1, 1); framerateSpinbox = new QDoubleSpinBox(videoGroupbox); framerateSpinbox->setMaximum(60); framerateSpinbox->setValue(0); videoGridLayout->addWidget(framerateSpinbox, 3, 1, 1, 1); - videoGridLayout->addWidget(new QLabel(tr("Compression Type:")), 4, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Compression Type:"), this), 4, 0, 1, 1); compressionTypeCombobox = new QComboBox(videoGroupbox); videoGridLayout->addWidget(compressionTypeCombobox, 4, 1, 1, 1); @@ -667,17 +667,17 @@ void ExportDialog::setup_ui() { QGridLayout* audioGridLayout = new QGridLayout(audioGroupbox); - audioGridLayout->addWidget(new QLabel(tr("Codec:")), 0, 0, 1, 1); + audioGridLayout->addWidget(new QLabel(tr("Codec:"), this), 0, 0, 1, 1); acodecCombobox = new QComboBox(audioGroupbox); audioGridLayout->addWidget(acodecCombobox, 0, 1, 1, 1); - audioGridLayout->addWidget(new QLabel(tr("Sampling Rate:")), 1, 0, 1, 1); + audioGridLayout->addWidget(new QLabel(tr("Sampling Rate:"), this), 1, 0, 1, 1); samplingRateSpinbox = new QSpinBox(audioGroupbox); samplingRateSpinbox->setMaximum(96000); samplingRateSpinbox->setValue(0); audioGridLayout->addWidget(samplingRateSpinbox, 1, 1, 1, 1); - audioGridLayout->addWidget(new QLabel(tr("Bitrate (Kbps/CBR):")), 3, 0, 1, 1); + audioGridLayout->addWidget(new QLabel(tr("Bitrate (Kbps/CBR):"), this), 3, 0, 1, 1); audiobitrateSpinbox = new QSpinBox(audioGroupbox); audiobitrateSpinbox->setMaximum(320); audiobitrateSpinbox->setValue(256); @@ -685,7 +685,7 @@ void ExportDialog::setup_ui() { verticalLayout->addWidget(audioGroupbox); - QHBoxLayout* progressLayout = new QHBoxLayout(); + QHBoxLayout* progressLayout = new QHBoxLayout(this); progressBar = new QProgressBar(this); progressBar->setFormat("%p% (ETA: 0:00:00)"); progressBar->setEnabled(false); @@ -701,7 +701,7 @@ void ExportDialog::setup_ui() { verticalLayout->addLayout(progressLayout); - QHBoxLayout* buttonLayout = new QHBoxLayout(); + QHBoxLayout* buttonLayout = new QHBoxLayout(this); buttonLayout->addStretch(); export_button = new QPushButton(this); diff --git a/dialogs/loaddialog.cpp b/dialogs/loaddialog.cpp index a0ac2a434..4c666cd82 100644 --- a/dialogs/loaddialog.cpp +++ b/dialogs/loaddialog.cpp @@ -14,22 +14,21 @@ #include "mainwindow.h" LoadDialog::LoadDialog(QWidget *parent, bool autorecovery) : QDialog(parent) { - setWindowTitle(tr("Loading...")); + setWindowTitle(tr("Loading...")); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QVBoxLayout* layout = new QVBoxLayout(); - setLayout(layout); + QVBoxLayout* layout = new QVBoxLayout(this); - layout->addWidget(new QLabel(tr("Loading '%1'...").arg(project_url.mid(project_url.lastIndexOf('/')+1)))); + layout->addWidget(new QLabel(tr("Loading '%1'...").arg(project_url.mid(project_url.lastIndexOf('/')+1)), this)); - bar = new QProgressBar(); + bar = new QProgressBar(this); bar->setValue(0); layout->addWidget(bar); - cancel_button = new QPushButton(tr("Cancel")); + cancel_button = new QPushButton(tr("Cancel"), this); connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(cancel())); - hboxLayout = new QHBoxLayout(); + hboxLayout = new QHBoxLayout(this); hboxLayout->addStretch(); hboxLayout->addWidget(cancel_button); hboxLayout->addStretch(); diff --git a/dialogs/mediapropertiesdialog.cpp b/dialogs/mediapropertiesdialog.cpp index bacc74cea..a2cf5fc67 100644 --- a/dialogs/mediapropertiesdialog.cpp +++ b/dialogs/mediapropertiesdialog.cpp @@ -23,17 +23,16 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : setWindowTitle(tr("\"%1\" Properties").arg(i->get_name())); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - QGridLayout* grid = new QGridLayout(); - setLayout(grid); + QGridLayout* grid = new QGridLayout(this); int row = 0; Footage* f = item->to_footage(); - grid->addWidget(new QLabel(tr("Tracks:")), row, 0, 1, 2); + grid->addWidget(new QLabel(tr("Tracks:"), this), row, 0, 1, 2); row++; - track_list = new QListWidget(); + track_list = new QListWidget(this); for (int i=0;ivideo_tracks.size();i++) { const FootageStream& fs = f->video_tracks.at(i); @@ -43,7 +42,8 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : QString::number(fs.video_width), QString::number(fs.video_height), QString::number(fs.video_frame_rate) - ) + ), + track_list ); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); @@ -57,7 +57,8 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : QString::number(fs.file_index), QString::number(fs.audio_frequency), QString::number(fs.audio_channels) - ) + ), + track_list ); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); @@ -70,8 +71,8 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : if (f->video_tracks.size() > 0) { // frame conforming if (!f->video_tracks.at(0).infinite_length) { - grid->addWidget(new QLabel(tr("Conform to Frame Rate:")), row, 0); - conform_fr = new QDoubleSpinBox(); + grid->addWidget(new QLabel(tr("Conform to Frame Rate:"), this), row, 0); + conform_fr = new QDoubleSpinBox(this); conform_fr->setMinimum(0.01); conform_fr->setValue(f->video_tracks.at(0).video_frame_rate * f->speed); grid->addWidget(conform_fr, row, 1); @@ -80,14 +81,14 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : row++; // premultiplied alpha mode - premultiply_alpha_setting = new QCheckBox(tr("Alpha is Premultiplied")); + premultiply_alpha_setting = new QCheckBox(tr("Alpha is Premultiplied"), this); premultiply_alpha_setting->setChecked(f->alpha_is_premultiplied); grid->addWidget(premultiply_alpha_setting, row, 0); row++; // deinterlacing mode - interlacing_box = new QComboBox(); + interlacing_box = new QComboBox(this); interlacing_box->addItem( tr("Auto (%1)").arg( get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) @@ -102,18 +103,18 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : ? 0 : f->video_tracks.at(0).video_interlacing + 1); - grid->addWidget(new QLabel(tr("Interlacing:")), row, 0); + grid->addWidget(new QLabel(tr("Interlacing:"), this), row, 0); grid->addWidget(interlacing_box, row, 1); row++; } - name_box = new QLineEdit(item->get_name()); - grid->addWidget(new QLabel(tr("Name:")), row, 0); + name_box = new QLineEdit(item->get_name(), this); + grid->addWidget(new QLabel(tr("Name:"), this), row, 0); grid->addWidget(name_box, row, 1); row++; - QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); buttons->setCenterButtons(true); grid->addWidget(buttons, row, 0, 1, 2); diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index 567f12a24..9eaf35367 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -103,8 +103,7 @@ void NewSequenceDialog::create() { accept(); } -void NewSequenceDialog::preset_changed(int index) -{ +void NewSequenceDialog::preset_changed(int index) { switch (index) { case 0: // FILM 4K width_numeric->setValue(4096); @@ -157,7 +156,7 @@ void NewSequenceDialog::setup_ui() { QHBoxLayout* preset_layout = new QHBoxLayout(widget); preset_layout->setContentsMargins(0, 0, 0, 0); - preset_layout->addWidget(new QLabel(tr("Preset:"))); + preset_layout->addWidget(new QLabel(tr("Preset:"), this)); preset_combobox = new QComboBox(widget); @@ -183,19 +182,19 @@ void NewSequenceDialog::setup_ui() { QGridLayout* videoLayout = new QGridLayout(videoGroupBox); - videoLayout->addWidget(new QLabel(tr("Width:")), 0, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Width:"), this), 0, 0, 1, 1); width_numeric = new QSpinBox(videoGroupBox); width_numeric->setMaximum(9999); width_numeric->setValue(1920); videoLayout->addWidget(width_numeric, 0, 2, 1, 2); - videoLayout->addWidget(new QLabel(tr("Height:")), 1, 0, 1, 2); + videoLayout->addWidget(new QLabel(tr("Height:"), this), 1, 0, 1, 2); height_numeric = new QSpinBox(videoGroupBox); height_numeric->setMaximum(9999); height_numeric->setValue(1080); videoLayout->addWidget(height_numeric, 1, 2, 1, 2); - videoLayout->addWidget(new QLabel(tr("Frame Rate:")), 2, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Frame Rate:"), this), 2, 0, 1, 1); frame_rate_combobox = new QComboBox(videoGroupBox); frame_rate_combobox->addItem("10 FPS", 10.0); frame_rate_combobox->addItem("12.5 FPS", 12.5); @@ -211,12 +210,12 @@ void NewSequenceDialog::setup_ui() { frame_rate_combobox->setCurrentIndex(6); videoLayout->addWidget(frame_rate_combobox, 2, 2, 1, 2); - videoLayout->addWidget(new QLabel(tr("Pixel Aspect Ratio:")), 4, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Pixel Aspect Ratio:"), this), 4, 0, 1, 1); par_combobox = new QComboBox(videoGroupBox); par_combobox->addItem(tr("Square Pixels (1.0)")); videoLayout->addWidget(par_combobox, 4, 2, 1, 2); - videoLayout->addWidget(new QLabel(tr("Interlacing:")), 6, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Interlacing:"), this), 6, 0, 1, 1); interlacing_combobox = new QComboBox(videoGroupBox); interlacing_combobox->addItem(tr("None (Progressive)")); // interlacing_combobox->addItem("Upper Field First"); @@ -230,7 +229,7 @@ void NewSequenceDialog::setup_ui() { QGridLayout* audioLayout = new QGridLayout(audioGroupBox); - audioLayout->addWidget(new QLabel(tr("Sample Rate: ")), 0, 0, 1, 1); + audioLayout->addWidget(new QLabel(tr("Sample Rate: "), this), 0, 0, 1, 1); audio_frequency_combobox = new QComboBox(audioGroupBox); audio_frequency_combobox->addItem("22050 Hz", 22050); @@ -250,7 +249,7 @@ void NewSequenceDialog::setup_ui() { QHBoxLayout* nameLayout = new QHBoxLayout(nameWidget); nameLayout->setContentsMargins(0, 0, 0, 0); - nameLayout->addWidget(new QLabel("Name:")); + nameLayout->addWidget(new QLabel(tr("Name:"), this)); sequence_name_edit = new QLineEdit(nameWidget); diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index 4415db6ab..37b54958a 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -71,7 +71,7 @@ void PreferencesDialog::setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* QAction* a = actions.at(i); if (!a->isSeparator() && a->property("keyignore").isNull()) { - QTreeWidgetItem* item = new QTreeWidgetItem(); + QTreeWidgetItem* item = new QTreeWidgetItem(parent); item->setText(0, a->text().replace("&", "")); parent->addChild(item); @@ -93,7 +93,7 @@ void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) { for (int i=0;imenu(); - QTreeWidgetItem* item = new QTreeWidgetItem(); + QTreeWidgetItem* item = new QTreeWidgetItem(keyboard_tree); item->setText(0, menu->title().replace("&", "")); keyboard_tree->addTopLevelItem(item); @@ -286,11 +286,11 @@ void PreferencesDialog::setup_ui() { QTabWidget* tabWidget = new QTabWidget(this); // General - QTabWidget* general_tab = new QTabWidget(); + QTabWidget* general_tab = new QTabWidget(this); QGridLayout* general_layout = new QGridLayout(general_tab); // General -> Custom CSS - general_layout->addWidget(new QLabel(tr("Custom CSS:")), 0, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Custom CSS:"), this), 0, 0, 1, 1); custom_css_fn = new QLineEdit(general_tab); custom_css_fn->setText(config.css_path); @@ -301,14 +301,14 @@ void PreferencesDialog::setup_ui() { general_layout->addWidget(custom_css_browse, 0, 2, 1, 1); // General -> Image Sequence Formats - general_layout->addWidget(new QLabel(tr("Image sequence formats:")), 1, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Image sequence formats:"), this), 1, 0, 1, 1); imgSeqFormatEdit = new QLineEdit(general_tab); general_layout->addWidget(imgSeqFormatEdit, 1, 1, 1, 2); // General -> Audio Recording - general_layout->addWidget(new QLabel(tr("Audio Recording:")), 2, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Audio Recording:"), this), 2, 0, 1, 1); recordingComboBox = new QComboBox(general_tab); recordingComboBox->addItem(tr("Mono")); @@ -316,7 +316,7 @@ void PreferencesDialog::setup_ui() { general_layout->addWidget(recordingComboBox, 2, 1, 1, 2); // General -> Effect Textbox Lines - general_layout->addWidget(new QLabel(tr("Effect Textbox Lines:")), 3, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Effect Textbox Lines:"), this), 3, 0, 1, 1); effect_textbox_lines_field = new QSpinBox(general_tab); effect_textbox_lines_field->setMinimum(1); @@ -332,15 +332,15 @@ void PreferencesDialog::setup_ui() { tabWidget->addTab(general_tab, tr("General")); // Behavior - QWidget* behavior_tab = new QWidget(); + QWidget* behavior_tab = new QWidget(this); tabWidget->addTab(behavior_tab, tr("Behavior")); // Playback - QWidget* playback_tab = new QWidget(); + QWidget* playback_tab = new QWidget(this); QVBoxLayout* playback_tab_layout = new QVBoxLayout(playback_tab); // Playback -> Disable Multithreading on Images - disable_img_multithread = new QCheckBox(tr("Disable Multithreading on Images")); + disable_img_multithread = new QCheckBox(tr("Disable Multithreading on Images"), playback_tab); disable_img_multithread->setChecked(config.disable_multithreading_for_images); playback_tab_layout->addWidget(disable_img_multithread); @@ -360,20 +360,20 @@ void PreferencesDialog::setup_ui() { QGroupBox* memory_usage_group = new QGroupBox(playback_tab); memory_usage_group->setTitle(tr("Memory Usage")); QGridLayout* memory_usage_layout = new QGridLayout(memory_usage_group); - memory_usage_layout->addWidget(new QLabel(tr("Upcoming Frame Queue:")), 0, 0); - upcoming_queue_spinbox = new QDoubleSpinBox(); + memory_usage_layout->addWidget(new QLabel(tr("Upcoming Frame Queue:"), playback_tab), 0, 0); + upcoming_queue_spinbox = new QDoubleSpinBox(playback_tab); upcoming_queue_spinbox->setValue(config.upcoming_queue_size); memory_usage_layout->addWidget(upcoming_queue_spinbox, 0, 1); - upcoming_queue_type = new QComboBox(); + upcoming_queue_type = new QComboBox(playback_tab); upcoming_queue_type->addItem(tr("frames")); upcoming_queue_type->addItem(tr("seconds")); upcoming_queue_type->setCurrentIndex(config.upcoming_queue_type); memory_usage_layout->addWidget(upcoming_queue_type, 0, 2); - memory_usage_layout->addWidget(new QLabel(tr("Previous Frame Queue:")), 1, 0); - previous_queue_spinbox = new QDoubleSpinBox(); + memory_usage_layout->addWidget(new QLabel(tr("Previous Frame Queue:"), playback_tab), 1, 0); + previous_queue_spinbox = new QDoubleSpinBox(playback_tab); previous_queue_spinbox->setValue(config.previous_queue_size); memory_usage_layout->addWidget(previous_queue_spinbox, 1, 1); - previous_queue_type = new QComboBox(); + previous_queue_type = new QComboBox(playback_tab); previous_queue_type->addItem(tr("frames")); previous_queue_type->addItem(tr("seconds")); previous_queue_type->setCurrentIndex(config.previous_queue_type); @@ -382,39 +382,39 @@ void PreferencesDialog::setup_ui() { tabWidget->addTab(playback_tab, tr("Playback")); - QWidget* shortcut_tab = new QWidget(); + QWidget* shortcut_tab = new QWidget(this); QVBoxLayout* shortcut_layout = new QVBoxLayout(shortcut_tab); - QLineEdit* key_search_line = new QLineEdit(); + QLineEdit* key_search_line = new QLineEdit(shortcut_tab); key_search_line->setPlaceholderText(tr("Search for action or shortcut")); connect(key_search_line, SIGNAL(textChanged(const QString &)), this, SLOT(refine_shortcut_list(const QString &))); shortcut_layout->addWidget(key_search_line); - keyboard_tree = new QTreeWidget(); + keyboard_tree = new QTreeWidget(shortcut_tab); QTreeWidgetItem* tree_header = keyboard_tree->headerItem(); tree_header->setText(0, tr("Action")); tree_header->setText(1, tr("Shortcut")); shortcut_layout->addWidget(keyboard_tree); - QHBoxLayout* reset_shortcut_layout = new QHBoxLayout(); + QHBoxLayout* reset_shortcut_layout = new QHBoxLayout(shortcut_tab); - QPushButton* import_shortcut_button = new QPushButton(tr("Import")); + QPushButton* import_shortcut_button = new QPushButton(tr("Import"), shortcut_tab); reset_shortcut_layout->addWidget(import_shortcut_button); connect(import_shortcut_button, SIGNAL(clicked(bool)), this, SLOT(load_shortcut_file())); - QPushButton* export_shortcut_button = new QPushButton(tr("Export")); + QPushButton* export_shortcut_button = new QPushButton(tr("Export"), shortcut_tab); reset_shortcut_layout->addWidget(export_shortcut_button); connect(export_shortcut_button, SIGNAL(clicked(bool)), this, SLOT(save_shortcut_file())); reset_shortcut_layout->addStretch(); - QPushButton* reset_selected_shortcut_button = new QPushButton(tr("Reset Selected")); + QPushButton* reset_selected_shortcut_button = new QPushButton(tr("Reset Selected"), shortcut_tab); reset_shortcut_layout->addWidget(reset_selected_shortcut_button); connect(reset_selected_shortcut_button, SIGNAL(clicked(bool)), this, SLOT(reset_default_shortcut())); - QPushButton* reset_all_shortcut_button = new QPushButton(tr("Reset All")); + QPushButton* reset_all_shortcut_button = new QPushButton(tr("Reset All"), shortcut_tab); reset_shortcut_layout->addWidget(reset_all_shortcut_button); connect(reset_all_shortcut_button, SIGNAL(clicked(bool)), this, SLOT(reset_all_shortcuts())); diff --git a/dialogs/replaceclipmediadialog.cpp b/dialogs/replaceclipmediadialog.cpp index c677232f4..41a337610 100644 --- a/dialogs/replaceclipmediadialog.cpp +++ b/dialogs/replaceclipmediadialog.cpp @@ -23,31 +23,31 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media QDialog(parent), media(old_media) { - setWindowTitle(tr("Replace clips using \"%1\"").arg(old_media->get_name())); + setWindowTitle(tr("Replace clips using \"%1\"").arg(old_media->get_name())); resize(300, 400); - QVBoxLayout* layout = new QVBoxLayout(); + QVBoxLayout* layout = new QVBoxLayout(this); - layout->addWidget(new QLabel(tr("Select which media you want to replace this media's clips with:"))); + layout->addWidget(new QLabel(tr("Select which media you want to replace this media's clips with:"), this)); - tree = new QTreeView(); + tree = new QTreeView(this); layout->addWidget(tree); - use_same_media_in_points = new QCheckBox(tr("Keep the same media in-points")); + use_same_media_in_points = new QCheckBox(tr("Keep the same media in-points"), this); use_same_media_in_points->setChecked(true); layout->addWidget(use_same_media_in_points); - QHBoxLayout* buttons = new QHBoxLayout(); + QHBoxLayout* buttons = new QHBoxLayout(this); buttons->addStretch(); - QPushButton* replace_button = new QPushButton(tr("Replace")); + QPushButton* replace_button = new QPushButton(tr("Replace"), this); connect(replace_button, SIGNAL(clicked(bool)), this, SLOT(replace())); buttons->addWidget(replace_button); - QPushButton* cancel_button = new QPushButton(tr("Cancel")); + QPushButton* cancel_button = new QPushButton(tr("Cancel"), this); connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(close())); buttons->addWidget(cancel_button); @@ -55,44 +55,42 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media layout->addLayout(buttons); - setLayout(layout); - tree->setModel(&project_model); } void ReplaceClipMediaDialog::replace() { QModelIndexList selected_items = tree->selectionModel()->selectedRows(); if (selected_items.size() != 1) { - QMessageBox::critical( - this, - tr("No media selected"), - tr("Please select a media to replace with or click 'Cancel'."), - QMessageBox::Ok - ); + QMessageBox::critical( + this, + tr("No media selected"), + tr("Please select a media to replace with or click 'Cancel'."), + QMessageBox::Ok + ); } else { Media* new_item = static_cast(selected_items.at(0).internalPointer()); if (media == new_item) { - QMessageBox::critical( - this, - tr("Same media selected"), - tr("You selected the same media that you're replacing. Please select a different one or click 'Cancel'."), - QMessageBox::Ok - ); + QMessageBox::critical( + this, + tr("Same media selected"), + tr("You selected the same media that you're replacing. Please select a different one or click 'Cancel'."), + QMessageBox::Ok + ); } else if (new_item->get_type() == MEDIA_TYPE_FOLDER) { - QMessageBox::critical( - this, - tr("Folder selected"), - tr("You cannot replace footage with a folder."), - QMessageBox::Ok - ); + QMessageBox::critical( + this, + tr("Folder selected"), + tr("You cannot replace footage with a folder."), + QMessageBox::Ok + ); } else { if (new_item->get_type() == MEDIA_TYPE_SEQUENCE && sequence == new_item->to_sequence()) { - QMessageBox::critical( - this, - tr("Active sequence selected"), - tr("You cannot insert a sequence into itself."), - QMessageBox::Ok - ); + QMessageBox::critical( + this, + tr("Active sequence selected"), + tr("You cannot insert a sequence into itself."), + QMessageBox::Ok + ); } else { ReplaceClipMediaCommand* rcmc = new ReplaceClipMediaCommand( media, diff --git a/dialogs/speeddialog.cpp b/dialogs/speeddialog.cpp index b63419347..d03f6c3e9 100644 --- a/dialogs/speeddialog.cpp +++ b/dialogs/speeddialog.cpp @@ -19,43 +19,42 @@ #include "project/media.h" SpeedDialog::SpeedDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle(tr("Speed/Duration")); + setWindowTitle(tr("Speed/Duration")); - QVBoxLayout* main_layout = new QVBoxLayout(); - setLayout(main_layout); + QVBoxLayout* main_layout = new QVBoxLayout(this); - QGridLayout* grid = new QGridLayout(); + QGridLayout* grid = new QGridLayout(this); grid->setSpacing(6); - grid->addWidget(new QLabel(tr("Speed:")), 0, 0); - percent = new LabelSlider(); + grid->addWidget(new QLabel(tr("Speed:"), this), 0, 0); + percent = new LabelSlider(this); percent->decimal_places = 2; percent->set_display_type(LABELSLIDER_PERCENT); percent->set_default_value(1); grid->addWidget(percent, 0, 1); - grid->addWidget(new QLabel(tr("Frame Rate:")), 1, 0); - frame_rate = new LabelSlider(); + grid->addWidget(new QLabel(tr("Frame Rate:"), this), 1, 0); + frame_rate = new LabelSlider(this); frame_rate->decimal_places = 3; grid->addWidget(frame_rate, 1, 1); - grid->addWidget(new QLabel(tr("Duration:")), 2, 0); - duration = new LabelSlider(); + grid->addWidget(new QLabel(tr("Duration:"), this), 2, 0); + duration = new LabelSlider(this); duration->set_display_type(LABELSLIDER_FRAMENUMBER); duration->set_frame_rate(sequence->frame_rate); grid->addWidget(duration, 2, 1); main_layout->addLayout(grid); - reverse = new QCheckBox(tr("Reverse")); - maintain_pitch = new QCheckBox(tr("Maintain Audio Pitch")); - ripple = new QCheckBox(tr("Ripple Changes")); + reverse = new QCheckBox(tr("Reverse"), this); + maintain_pitch = new QCheckBox(tr("Maintain Audio Pitch"), this); + ripple = new QCheckBox(tr("Ripple Changes"), this); main_layout->addWidget(reverse); main_layout->addWidget(maintain_pitch); main_layout->addWidget(ripple); - QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); buttonBox->setCenterButtons(true); main_layout->addWidget(buttonBox); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); diff --git a/dialogs/stabilizerdialog.cpp b/dialogs/stabilizerdialog.cpp index 5e0738d80..0330fd81b 100644 --- a/dialogs/stabilizerdialog.cpp +++ b/dialogs/stabilizerdialog.cpp @@ -8,96 +8,97 @@ #include "ui/labelslider.h" +// NOTE: this is never used in Olive, hasn't been maintained, and needs to be written + StabilizerDialog::StabilizerDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle("Stabilizer"); + setWindowTitle("Stabilizer"); - layout = new QVBoxLayout(this); - setLayout(layout); + layout = new QVBoxLayout(this); - enable_stab = new QCheckBox(this); - enable_stab->setText("Enable Stabilizer"); - layout->addWidget(enable_stab); + enable_stab = new QCheckBox(this); + enable_stab->setText("Enable Stabilizer"); + layout->addWidget(enable_stab); - analysis = new QGroupBox("Analysis", this); - layout->addWidget(analysis); + analysis = new QGroupBox("Analysis", this); + layout->addWidget(analysis); - analysis_layout = new QGridLayout(analysis); - analysis->setLayout(analysis_layout); + analysis_layout = new QGridLayout(analysis); + analysis->setLayout(analysis_layout); - analysis_layout->addWidget(new QLabel("Shakiness:"), 0, 0); + analysis_layout->addWidget(new QLabel("Shakiness:", this), 0, 0); - shakiness_slider = new LabelSlider(); - shakiness_slider->set_minimum_value(1); - shakiness_slider->set_default_value(5); - shakiness_slider->set_maximum_value(10); - analysis_layout->addWidget(shakiness_slider, 0, 1); + shakiness_slider = new LabelSlider(this); + shakiness_slider->set_minimum_value(1); + shakiness_slider->set_default_value(5); + shakiness_slider->set_maximum_value(10); + analysis_layout->addWidget(shakiness_slider, 0, 1); - analysis_layout->addWidget(new QLabel("Accuracy:"), 1, 0); + analysis_layout->addWidget(new QLabel("Accuracy:", this), 1, 0); - accuracy_slider = new LabelSlider(); - accuracy_slider->set_minimum_value(1); - accuracy_slider->set_default_value(15); - accuracy_slider->set_maximum_value(15); - analysis_layout->addWidget(accuracy_slider, 1, 1); + accuracy_slider = new LabelSlider(this); + accuracy_slider->set_minimum_value(1); + accuracy_slider->set_default_value(15); + accuracy_slider->set_maximum_value(15); + analysis_layout->addWidget(accuracy_slider, 1, 1); - analysis_layout->addWidget(new QLabel("Step Size:"), 2, 0); + analysis_layout->addWidget(new QLabel("Step Size:", this), 2, 0); - stepsize_slider = new LabelSlider(); - stepsize_slider->set_minimum_value(1); - stepsize_slider->set_default_value(6); - analysis_layout->addWidget(stepsize_slider, 2, 1); + stepsize_slider = new LabelSlider(this); + stepsize_slider->set_minimum_value(1); + stepsize_slider->set_default_value(6); + analysis_layout->addWidget(stepsize_slider, 2, 1); - analysis_layout->addWidget(new QLabel("Minimum Contrast:"), 3, 0); + analysis_layout->addWidget(new QLabel("Minimum Contrast:", this), 3, 0); - mincontrast_slider = new LabelSlider(); - mincontrast_slider->set_minimum_value(0); - mincontrast_slider->set_default_value(0.3); - mincontrast_slider->set_maximum_value(1); - analysis_layout->addWidget(mincontrast_slider, 3, 1); + mincontrast_slider = new LabelSlider(this); + mincontrast_slider->set_minimum_value(0); + mincontrast_slider->set_default_value(0.3); + mincontrast_slider->set_maximum_value(1); + analysis_layout->addWidget(mincontrast_slider, 3, 1); - /*analysis_layout->addWidget(new QLabel("Tripod Mode:"), 4, 0); + /*analysis_layout->addWidget(new QLabel("Tripod Mode:"), 4, 0); - tripod_mode_box = new QCheckBox(); - analysis_layout->addWidget(tripod_mode_box, 4, 1);*/ + tripod_mode_box = new QCheckBox(); + analysis_layout->addWidget(tripod_mode_box, 4, 1);*/ - stabilization = new QGroupBox("Stabilization", this); - layout->addWidget(stabilization); + stabilization = new QGroupBox("Stabilization", this); + layout->addWidget(stabilization); - stabilization_layout = new QGridLayout(); - stabilization->setLayout(stabilization_layout); + stabilization_layout = new QGridLayout(this); + stabilization->setLayout(stabilization_layout); - stabilization_layout->addWidget(new QLabel("Smoothing:"), 0, 0); + stabilization_layout->addWidget(new QLabel("Smoothing:", this), 0, 0); - smoothing_slider = new LabelSlider(); - smoothing_slider->set_minimum_value(0); - smoothing_slider->set_default_value(10); - stabilization_layout->addWidget(smoothing_slider, 0, 1); + smoothing_slider = new LabelSlider(); + smoothing_slider->set_minimum_value(0); + smoothing_slider->set_default_value(10); + stabilization_layout->addWidget(smoothing_slider, 0, 1); - stabilization_layout->addWidget(new QLabel("Gaussian Motion:"), 1, 0); + stabilization_layout->addWidget(new QLabel("Gaussian Motion:"), 1, 0); - gaussian_motion = new QCheckBox(); - gaussian_motion->setChecked(true); - stabilization_layout->addWidget(gaussian_motion, 1, 1); + gaussian_motion = new QCheckBox(); + gaussian_motion->setChecked(true); + stabilization_layout->addWidget(gaussian_motion, 1, 1); - stabilization_layout->addWidget(new QLabel("Maximum Movement:"), 2, 0); - stabilization_layout->addWidget(new QLabel("Maximum Rotation:"), 3, 0); - stabilization_layout->addWidget(new QLabel("Crop:"), 4, 0); - stabilization_layout->addWidget(new QLabel("Zoom Behavior:"), 5, 0); - stabilization_layout->addWidget(new QLabel("Zoom Speed:"), 6, 0); - stabilization_layout->addWidget(new QLabel("Interpolation Quality:"), 7, 0); + stabilization_layout->addWidget(new QLabel("Maximum Movement:"), 2, 0); + stabilization_layout->addWidget(new QLabel("Maximum Rotation:"), 3, 0); + stabilization_layout->addWidget(new QLabel("Crop:"), 4, 0); + stabilization_layout->addWidget(new QLabel("Zoom Behavior:"), 5, 0); + stabilization_layout->addWidget(new QLabel("Zoom Speed:"), 6, 0); + stabilization_layout->addWidget(new QLabel("Interpolation Quality:"), 7, 0); - buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); - layout->addWidget(buttons); + buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); + layout->addWidget(buttons); - connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); - connect(enable_stab, SIGNAL(toggled(bool)), this, SLOT(set_all_enabled(bool))); + connect(enable_stab, SIGNAL(toggled(bool)), this, SLOT(set_all_enabled(bool))); - set_all_enabled(false); + set_all_enabled(false); } void StabilizerDialog::set_all_enabled(bool e) { - analysis->setEnabled(e); - stabilization->setEnabled(e); + analysis->setEnabled(e); + stabilization->setEnabled(e); } diff --git a/dialogs/texteditdialog.cpp b/dialogs/texteditdialog.cpp index 51337a637..1c71999df 100644 --- a/dialogs/texteditdialog.cpp +++ b/dialogs/texteditdialog.cpp @@ -7,16 +7,15 @@ TextEditDialog::TextEditDialog(QWidget *parent, const QString &s) : QDialog(parent) { - setWindowTitle(tr("Edit Text")); + setWindowTitle(tr("Edit Text")); - QVBoxLayout* layout = new QVBoxLayout(); - setLayout(layout); + QVBoxLayout* layout = new QVBoxLayout(this); - textEdit = new QPlainTextEdit(); + textEdit = new QPlainTextEdit(this); textEdit->setPlainText(s); layout->addWidget(textEdit); - QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); layout->addWidget(buttons); connect(buttons, SIGNAL(accepted()), this, SLOT(save())); connect(buttons, SIGNAL(rejected()), this, SLOT(cancel())); diff --git a/effects/internal/cornerpineffect.cpp b/effects/internal/cornerpineffect.cpp index d23525e2c..883dcbdb8 100644 --- a/effects/internal/cornerpineffect.cpp +++ b/effects/internal/cornerpineffect.cpp @@ -61,11 +61,11 @@ void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords, i coords.vertexBottomRightY += bottom_right_y->get_double_value(timecode); } -void CornerPinEffect::process_shader(double timecode, GLTextureCoords &coords, int iterations) { - glslProgram->setUniformValue("p0", (GLfloat) coords.vertexBottomLeftX, (GLfloat) coords.vertexBottomLeftY); - glslProgram->setUniformValue("p1", (GLfloat) coords.vertexBottomRightX, (GLfloat) coords.vertexBottomRightY); - glslProgram->setUniformValue("p2", (GLfloat) coords.vertexTopLeftX, (GLfloat) coords.vertexTopLeftY); - glslProgram->setUniformValue("p3", (GLfloat) coords.vertexTopRightX, (GLfloat) coords.vertexTopRightY); +void CornerPinEffect::process_shader(double timecode, GLTextureCoords &coords, int) { + glslProgram->setUniformValue("p0", GLfloat(coords.vertexBottomLeftX), GLfloat(coords.vertexBottomLeftY)); + glslProgram->setUniformValue("p1", GLfloat(coords.vertexBottomRightX), GLfloat(coords.vertexBottomRightY)); + glslProgram->setUniformValue("p2", GLfloat(coords.vertexTopLeftX), GLfloat(coords.vertexTopLeftY)); + glslProgram->setUniformValue("p3", GLfloat(coords.vertexTopRightX), GLfloat(coords.vertexTopRightY)); glslProgram->setUniformValue("perspective", perspective->get_bool_value(timecode)); } diff --git a/effects/internal/voideffect.cpp b/effects/internal/voideffect.cpp index e27d08844..70762cff2 100644 --- a/effects/internal/voideffect.cpp +++ b/effects/internal/voideffect.cpp @@ -11,11 +11,11 @@ VoidEffect::VoidEffect(Clip *c, const QString& n) : Effect(c, nullptr) { name = n; QString display_name; if (n.isEmpty()) { - display_name = tr("(unknown)"); + display_name = tr("(unknown)"); } else { display_name = n; } - EffectRow* row = add_row(tr("Missing Effect"), false, false); + EffectRow* row = add_row(tr("Missing Effect"), false, false); row->add_widget(new QLabel(display_name)); container->setText(display_name); } diff --git a/effects/internal/vsthost.cpp b/effects/internal/vsthost.cpp index 481341b15..71a54a92e 100644 --- a/effects/internal/vsthost.cpp +++ b/effects/internal/vsthost.cpp @@ -240,6 +240,9 @@ VSTHost::~VSTHost() { delete [] inputs; freePlugin(); + + delete show_interface_btn; + delete dialog; } void VSTHost::process_audio(double, double, quint8* samples, int nb_bytes, int) { diff --git a/mainwindow.cpp b/mainwindow.cpp index 881ec2cef..042c52f7a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -558,6 +558,7 @@ bool MainWindow::can_close_project() { ); m->setWindowModality(Qt::WindowModal); int r = m->exec(); + delete m; if (r == QMessageBox::Yes) { return save_project(); } else if (r == QMessageBox::Cancel) { @@ -581,7 +582,7 @@ void MainWindow::setup_menus() { file_menu->addAction(tr("&Open Project"), this, SLOT(open_project()), QKeySequence("Ctrl+O"))->setProperty("id", "openproj"); - clear_open_recent_action = new QAction(tr("Clear Recent List")); + clear_open_recent_action = new QAction(tr("Clear Recent List"), menuBar); clear_open_recent_action->setProperty("id", "clearopenrecent"); connect(clear_open_recent_action, SIGNAL(triggered()), panel_project, SLOT(clear_recent_projects())); @@ -1037,12 +1038,8 @@ void MainWindow::paintEvent(QPaintEvent *event) { #ifndef QT_DEBUG DemoNotice* d = new DemoNotice(this); d->open(); + connect(d, SIGNAL(finished()), d, SLOT(deleteLater())); #endif - /*if (windowState() != Qt::WindowFullScreen) { - // workaround for setting to maximized - on some systems, setting - // to maximized doesn't work until after the paintEvent - setWindowState(Qt::WindowMaximized); - }*/ demoNoticeShown = true; } diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 8dd574166..935ecd63f 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -172,8 +172,7 @@ void EffectControls::show_effect_menu(int type, int subtype) { const EffectMeta& em = effects.at(i); if (em.type == type && em.subtype == subtype) { - QAction* action = new QAction(&effects_menu); - action->setText(em.name); + QAction* action = effects_menu.addAction(em.name); action->setData(reinterpret_cast(&em)); if (!em.tooltip.isEmpty()) { action->setToolTip(em.tooltip); @@ -193,9 +192,8 @@ void EffectControls::show_effect_menu(int type, int subtype) { } } if (!found) { - parent = new QMenu(&effects_menu); + parent = effects_menu.addMenu(em.category); parent->setToolTipsVisible(true); - parent->setTitle(em.category); bool found = false; for (int i=0;isetSpacing(0); @@ -293,7 +291,7 @@ void EffectControls::setup_ui() { scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollArea->setWidgetResizable(true); - QWidget* scrollAreaWidgetContents = new QWidget(); + QWidget* scrollAreaWidgetContents = new QWidget(scrollArea); QHBoxLayout* scrollAreaLayout = new QHBoxLayout(scrollAreaWidgetContents); scrollAreaLayout->setSpacing(0); @@ -308,7 +306,7 @@ void EffectControls::setup_ui() { effects_area_layout->setMargin(0); vcontainer = new QWidget(effects_area); - QVBoxLayout* vcontainerLayout = new QVBoxLayout(vcontainer); + QVBoxLayout* vcontainerLayout = new QVBoxLayout(); vcontainerLayout->setSpacing(0); vcontainerLayout->setMargin(0); @@ -320,7 +318,7 @@ void EffectControls::setup_ui() { veHeaderLayout->setSpacing(0); veHeaderLayout->setMargin(0); - QPushButton* btnAddVideoEffect = new QPushButton(veHeader); + QPushButton* btnAddVideoEffect = new QPushButton(); btnAddVideoEffect->setIcon(QIcon(":/icons/add-effect.png")); btnAddVideoEffect->setToolTip(tr("Add Video Effect")); veHeaderLayout->addWidget(btnAddVideoEffect); @@ -328,7 +326,7 @@ void EffectControls::setup_ui() { veHeaderLayout->addStretch(); - QLabel* lblVideoEffects = new QLabel(veHeader); + QLabel* lblVideoEffects = new QLabel(); QFont font; font.setPointSize(9); lblVideoEffects->setFont(font); @@ -338,16 +336,15 @@ void EffectControls::setup_ui() { veHeaderLayout->addStretch(); - QPushButton* btnAddVideoTransition = new QPushButton(veHeader); + QPushButton* btnAddVideoTransition = new QPushButton(); btnAddVideoTransition->setIcon(QIcon(":/icons/add-transition.png")); btnAddVideoTransition->setToolTip(tr("Add Video Transition")); connect(btnAddVideoTransition, SIGNAL(clicked(bool)), this, SLOT(video_transition_click())); - veHeaderLayout->addWidget(btnAddVideoTransition); vcontainerLayout->addWidget(veHeader); - video_effect_area = new QWidget(vcontainer); + video_effect_area = new QWidget(); QVBoxLayout* veAreaLayout = new QVBoxLayout(video_effect_area); veAreaLayout->setSpacing(0); veAreaLayout->setMargin(0); @@ -368,7 +365,7 @@ void EffectControls::setup_ui() { aeHeaderLayout->setSpacing(0); aeHeaderLayout->setMargin(0); - QPushButton* btnAddAudioEffect = new QPushButton(aeHeader); + QPushButton* btnAddAudioEffect = new QPushButton(); btnAddAudioEffect->setIcon(QIcon(":/icons/add-effect.png")); btnAddAudioEffect->setToolTip(tr("Add Audio Effect")); connect(btnAddAudioEffect, SIGNAL(clicked(bool)), this, SLOT(audio_effect_click())); @@ -376,7 +373,7 @@ void EffectControls::setup_ui() { aeHeaderLayout->addStretch(); - QLabel* lblAudioEffects = new QLabel(aeHeader); + QLabel* lblAudioEffects = new QLabel(); lblAudioEffects->setFont(font); lblAudioEffects->setAlignment(Qt::AlignCenter); lblAudioEffects->setText(tr("AUDIO EFFECTS")); @@ -384,7 +381,7 @@ void EffectControls::setup_ui() { aeHeaderLayout->addStretch(); - QPushButton* btnAddAudioTransition = new QPushButton(aeHeader); + QPushButton* btnAddAudioTransition = new QPushButton(); btnAddAudioTransition->setIcon(QIcon(":/icons/add-transition.png")); btnAddAudioTransition->setToolTip(tr("Add Audio Transition")); connect(btnAddAudioTransition, SIGNAL(clicked(bool)), this, SLOT(audio_transition_click())); diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index faaf91235..cb4bda3c2 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -23,48 +23,47 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(nullptr) { setWindowTitle(tr("Graph Editor")); resize(720, 480); - QWidget* main_widget = new QWidget(); + QWidget* main_widget = new QWidget(this); setWidget(main_widget); - QVBoxLayout* layout = new QVBoxLayout(); - main_widget->setLayout(layout); + QVBoxLayout* layout = new QVBoxLayout(main_widget); - QWidget* tool_widget = new QWidget(); + QWidget* tool_widget = new QWidget(this); tool_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - QHBoxLayout* tools = new QHBoxLayout(); + QHBoxLayout* tools = new QHBoxLayout(this); tool_widget->setLayout(tools); - QWidget* left_tool_widget = new QWidget(); - QHBoxLayout* left_tool_layout = new QHBoxLayout(); + QWidget* left_tool_widget = new QWidget(this); + QHBoxLayout* left_tool_layout = new QHBoxLayout(this); left_tool_layout->setSpacing(0); left_tool_layout->setMargin(0); left_tool_widget->setLayout(left_tool_layout); tools->addWidget(left_tool_widget); - QWidget* center_tool_widget = new QWidget(); - QHBoxLayout* center_tool_layout = new QHBoxLayout(); + QWidget* center_tool_widget = new QWidget(this); + QHBoxLayout* center_tool_layout = new QHBoxLayout(this); center_tool_layout->setSpacing(0); center_tool_layout->setMargin(0); center_tool_widget->setLayout(center_tool_layout); tools->addWidget(center_tool_widget); - QWidget* right_tool_widget = new QWidget(); - QHBoxLayout* right_tool_layout = new QHBoxLayout(); + QWidget* right_tool_widget = new QWidget(this); + QHBoxLayout* right_tool_layout = new QHBoxLayout(this); right_tool_layout->setSpacing(0); right_tool_layout->setMargin(0); right_tool_widget->setLayout(right_tool_layout); tools->addWidget(right_tool_widget); - keyframe_nav = new KeyframeNavigator(0, false); + keyframe_nav = new KeyframeNavigator(this, false); keyframe_nav->enable_keyframes(true); keyframe_nav->enable_keyframe_toggle(false); left_tool_layout->addWidget(keyframe_nav); left_tool_layout->addStretch(); - linear_button = new QPushButton(tr("Linear")); + linear_button = new QPushButton(tr("Linear"), this); linear_button->setProperty("type", EFFECT_KEYFRAME_LINEAR); linear_button->setCheckable(true); - bezier_button = new QPushButton(tr("Bezier")); + bezier_button = new QPushButton(tr("Bezier"), this); bezier_button->setProperty("type", EFFECT_KEYFRAME_BEZIER); bezier_button->setCheckable(true); - hold_button = new QPushButton(tr("Hold")); + hold_button = new QPushButton(tr("Hold"), this); hold_button->setProperty("type", EFFECT_KEYFRAME_HOLD); hold_button->setCheckable(true); @@ -75,36 +74,36 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(nullptr) { layout->addWidget(tool_widget); - QWidget* central_widget = new QWidget(); - QVBoxLayout* central_layout = new QVBoxLayout(); + QWidget* central_widget = new QWidget(this); + QVBoxLayout* central_layout = new QVBoxLayout(this); central_widget->setLayout(central_layout); central_layout->setSpacing(0); central_layout->setMargin(0); - header = new TimelineHeader(); + header = new TimelineHeader(this); header->viewer = panel_sequence_viewer; central_layout->addWidget(header); - view = new GraphView(); + view = new GraphView(this); central_layout->addWidget(view); layout->addWidget(central_widget); - QWidget* value_widget = new QWidget(); + QWidget* value_widget = new QWidget(this); value_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - QHBoxLayout* values = new QHBoxLayout(); + QHBoxLayout* values = new QHBoxLayout(this); value_widget->setLayout(values); values->addStretch(); - QWidget* central_value_widget = new QWidget(); - value_layout = new QHBoxLayout(); + QWidget* central_value_widget = new QWidget(this); + value_layout = new QHBoxLayout(this); value_layout->setMargin(0); - value_layout->addWidget(new QLabel("")); // a spacer so the layout doesn't jump + value_layout->addWidget(new QLabel("", this)); // a spacer so the layout doesn't jump central_value_widget->setLayout(value_layout); values->addWidget(central_value_widget); values->addStretch(); layout->addWidget(value_widget); - current_row_desc = new QLabel(); + current_row_desc = new QLabel(this); current_row_desc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); current_row_desc->setAlignment(Qt::AlignCenter); layout->addWidget(current_row_desc); @@ -158,7 +157,7 @@ void GraphEditor::set_row(EffectRow *r) { for (int i=0;ifieldCount();i++) { EffectField* field = r->field(i); if (field->type == EFFECT_FIELD_DOUBLE) { - QPushButton* slider_button = new QPushButton(); + QPushButton* slider_button = new QPushButton(this); slider_button->setCheckable(true); slider_button->setChecked(field->is_enabled()); slider_button->setIcon(QIcon(":/icons/record.png")); @@ -168,7 +167,7 @@ void GraphEditor::set_row(EffectRow *r) { slider_proxy_buttons.append(slider_button); value_layout->addWidget(slider_button); - LabelSlider* slider = new LabelSlider(); + LabelSlider* slider = new LabelSlider(this); slider->set_color(get_curve_color(i, r->fieldCount()).name()); connect(slider, SIGNAL(valueChanged()), this, SLOT(passthrough_slider_value())); slider_proxies.append(slider); diff --git a/panels/project.cpp b/panels/project.cpp index 5ae0a8432..71a57c9e0 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -63,7 +63,7 @@ Project::Project(QWidget *parent) : { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - QWidget* dockWidgetContents = new QWidget(); + QWidget* dockWidgetContents = new QWidget(this); QVBoxLayout* verticalLayout = new QVBoxLayout(dockWidgetContents); verticalLayout->setContentsMargins(0, 0, 0, 0); verticalLayout->setSpacing(0); @@ -76,10 +76,10 @@ Project::Project(QWidget *parent) : sorter->setSourceModel(&project_model); // optional toolbar - toolbar_widget = new QWidget(); + toolbar_widget = new QWidget(this); toolbar_widget->setVisible(config.show_project_toolbar); toolbar_widget->setObjectName("project_toolbar"); - QHBoxLayout* toolbar = new QHBoxLayout(); + QHBoxLayout* toolbar = new QHBoxLayout(toolbar_widget); toolbar->setMargin(0); toolbar->setSpacing(0); toolbar_widget->setLayout(toolbar); @@ -157,14 +157,14 @@ Project::Project(QWidget *parent) : verticalLayout->addWidget(tree_view); // icon view - icon_view_container = new QWidget(); + icon_view_container = new QWidget(dockWidgetContents); - QVBoxLayout* icon_view_container_layout = new QVBoxLayout(); + QVBoxLayout* icon_view_container_layout = new QVBoxLayout(icon_view_container); icon_view_container_layout->setMargin(0); icon_view_container_layout->setSpacing(0); icon_view_container->setLayout(icon_view_container_layout); - QHBoxLayout* icon_view_controls = new QHBoxLayout(); + QHBoxLayout* icon_view_controls = new QHBoxLayout(icon_view_container); icon_view_controls->setMargin(0); icon_view_controls->setSpacing(0); @@ -172,14 +172,14 @@ Project::Project(QWidget *parent) : directory_up_button.addFile(":/icons/dirup.png", QSize(), QIcon::Normal); directory_up_button.addFile(":/icons/dirup-disabled.png", QSize(), QIcon::Disabled); - directory_up = new QPushButton(); + directory_up = new QPushButton(icon_view_container); directory_up->setIcon(directory_up_button); directory_up->setEnabled(false); icon_view_controls->addWidget(directory_up); icon_view_controls->addStretch(); - QSlider* icon_size_slider = new QSlider(Qt::Horizontal); + QSlider* icon_size_slider = new QSlider(Qt::Horizontal, icon_view_container); icon_size_slider->setMinimum(16); icon_size_slider->setMaximum(120); icon_view_controls->addWidget(icon_size_slider); diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 7626318e2..b7cfe2b5f 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -540,7 +540,7 @@ void Timeline::resizeEvent(QResizeEvent *) { } int comp_height = tool_button_widget->height(); int cols = qCeil(double(total_client_height)/double(comp_height)); - tool_button_widget->setFixedWidth((tool_button_children.at(0)->width())*cols + horizontal_spacing*(cols-1) + 1); + tool_button_widget->setFixedWidth((tool_button_children.at(0)->sizeHint().width())*cols + horizontal_spacing*(cols-1) + 1); } void Timeline::delete_in_out(bool ripple) { @@ -1097,7 +1097,7 @@ void Timeline::paste(bool insert) { QPushButton* replace_button = box.addButton(tr("Replace"), QMessageBox::NoRole); QPushButton* skip_button = box.addButton(tr("Skip"), QMessageBox::RejectRole); - QCheckBox* future_box = new QCheckBox(tr("Do this for all conflicts found")); + QCheckBox* future_box = new QCheckBox(tr("Do this for all conflicts found"), &box); box.setCheckBox(future_box); box.exec(); @@ -1645,18 +1645,19 @@ void Timeline::setup_ui() { QHBoxLayout* horizontalLayout = new QHBoxLayout(dockWidgetContents); horizontalLayout->setSpacing(0); - horizontalLayout->setContentsMargins(0, 0, 0, 0); + horizontalLayout->setMargin(0); - tool_button_widget = new QWidget(dockWidgetContents); - tool_button_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setWidget(dockWidgetContents); + + tool_button_widget = new QWidget(); tool_button_widget->setObjectName("timeline_toolbar"); + tool_button_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); FlowLayout* tool_buttons_layout = new FlowLayout(tool_button_widget); -// tool_buttons_layout->setSizeConstraint(QLayout::SetNoConstraint); tool_buttons_layout->setSpacing(4); - tool_buttons_layout->setContentsMargins(0, 0, 0, 0); + tool_buttons_layout->setMargin(0); - toolArrowButton = new QPushButton(tool_button_widget); + toolArrowButton = new QPushButton(); QIcon arrow_icon; arrow_icon.addFile(QStringLiteral(":/icons/arrow.png"), QSize(), QIcon::Normal, QIcon::Off); arrow_icon.addFile(QStringLiteral(":/icons/arrow-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); @@ -1667,7 +1668,7 @@ void Timeline::setup_ui() { connect(toolArrowButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolArrowButton); - toolEditButton = new QPushButton(tool_button_widget); + toolEditButton = new QPushButton(); QIcon icon1; icon1.addFile(QStringLiteral(":/icons/beam.png"), QSize(), QIcon::Normal, QIcon::Off); icon1.addFile(QStringLiteral(":/icons/beam-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); @@ -1678,7 +1679,7 @@ void Timeline::setup_ui() { connect(toolEditButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolEditButton); - toolRippleButton = new QPushButton(tool_button_widget); + toolRippleButton = new QPushButton(); QIcon icon2; icon2.addFile(QStringLiteral(":/icons/ripple.png"), QSize(), QIcon::Normal, QIcon::Off); icon2.addFile(QStringLiteral(":/icons/ripple-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); @@ -1689,7 +1690,7 @@ void Timeline::setup_ui() { connect(toolRippleButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolRippleButton); - toolRazorButton = new QPushButton(tool_button_widget); + toolRazorButton = new QPushButton(); QIcon icon4; icon4.addFile(QStringLiteral(":/icons/razor.png"), QSize(), QIcon::Normal, QIcon::Off); icon4.addFile(QStringLiteral(":/icons/razor-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); @@ -1700,7 +1701,7 @@ void Timeline::setup_ui() { connect(toolRazorButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolRazorButton); - toolSlipButton = new QPushButton(tool_button_widget); + toolSlipButton = new QPushButton(); QIcon icon5; icon5.addFile(QStringLiteral(":/icons/slip.png"), QSize(), QIcon::Normal, QIcon::On); icon5.addFile(QStringLiteral(":/icons/slip-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1711,7 +1712,7 @@ void Timeline::setup_ui() { connect(toolSlipButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolSlipButton); - toolSlideButton = new QPushButton(tool_button_widget); + toolSlideButton = new QPushButton(); QIcon icon6; icon6.addFile(QStringLiteral(":/icons/slide.png"), QSize(), QIcon::Normal, QIcon::On); icon6.addFile(QStringLiteral(":/icons/slide-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1722,7 +1723,7 @@ void Timeline::setup_ui() { connect(toolSlideButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolSlideButton); - toolHandButton = new QPushButton(tool_button_widget); + toolHandButton = new QPushButton(); QIcon icon7; icon7.addFile(QStringLiteral(":/icons/hand.png"), QSize(), QIcon::Normal, QIcon::On); icon7.addFile(QStringLiteral(":/icons/hand-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1733,7 +1734,7 @@ void Timeline::setup_ui() { connect(toolHandButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolHandButton); - toolTransitionButton = new QPushButton(tool_button_widget); + toolTransitionButton = new QPushButton(); QIcon icon8; icon8.addFile(QStringLiteral(":/icons/transition-tool.png"), QSize(), QIcon::Normal, QIcon::On); icon8.addFile(QStringLiteral(":/icons/transition-tool-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1743,7 +1744,7 @@ void Timeline::setup_ui() { connect(toolTransitionButton, SIGNAL(clicked(bool)), this, SLOT(transition_tool_click())); tool_buttons_layout->addWidget(toolTransitionButton); - snappingButton = new QPushButton(tool_button_widget); + snappingButton = new QPushButton(); QIcon icon9; icon9.addFile(QStringLiteral(":/icons/magnet.png"), QSize(), QIcon::Normal, QIcon::On); icon9.addFile(QStringLiteral(":/icons/magnet-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1754,7 +1755,7 @@ void Timeline::setup_ui() { connect(snappingButton, SIGNAL(toggled(bool)), this, SLOT(snapping_clicked(bool))); tool_buttons_layout->addWidget(snappingButton); - zoomInButton = new QPushButton(tool_button_widget); + zoomInButton = new QPushButton(); QIcon icon10; icon10.addFile(QStringLiteral(":/icons/zoomin.png"), QSize(), QIcon::Normal, QIcon::On); icon10.addFile(QStringLiteral(":/icons/zoomin-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1763,7 +1764,7 @@ void Timeline::setup_ui() { connect(zoomInButton, SIGNAL(clicked(bool)), this, SLOT(zoom_in())); tool_buttons_layout->addWidget(zoomInButton); - zoomOutButton = new QPushButton(tool_button_widget); + zoomOutButton = new QPushButton(); QIcon icon11; icon11.addFile(QStringLiteral(":/icons/zoomout.png"), QSize(), QIcon::Normal, QIcon::On); icon11.addFile(QStringLiteral(":/icons/zoomout-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1772,17 +1773,16 @@ void Timeline::setup_ui() { connect(zoomOutButton, SIGNAL(clicked(bool)), this, SLOT(zoom_out())); tool_buttons_layout->addWidget(zoomOutButton); - recordButton = new QPushButton(tool_button_widget); + recordButton = new QPushButton(); QIcon icon12; icon12.addFile(QStringLiteral(":/icons/record.png"), QSize(), QIcon::Normal, QIcon::On); icon12.addFile(QStringLiteral(":/icons/record-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); recordButton->setIcon(icon12); recordButton->setToolTip(tr("Record audio")); connect(recordButton, SIGNAL(clicked(bool)), this, SLOT(record_btn_click())); - tool_buttons_layout->addWidget(recordButton); - addButton = new QPushButton(tool_button_widget); + addButton = new QPushButton(); QIcon icon13; icon13.addFile(QStringLiteral(":/icons/add-button.png"), QSize(), QIcon::Normal, QIcon::On); icon13.addFile(QStringLiteral(":/icons/add-button-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -1793,54 +1793,58 @@ void Timeline::setup_ui() { horizontalLayout->addWidget(tool_button_widget); - timeline_area = new QWidget(dockWidgetContents); - QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Minimum); - sizePolicy2.setHorizontalStretch(1); - sizePolicy2.setVerticalStretch(0); - sizePolicy2.setHeightForWidth(timeline_area->sizePolicy().hasHeightForWidth()); - timeline_area->setSizePolicy(sizePolicy2); + timeline_area = new QWidget(); + QSizePolicy timeline_area_policy(QSizePolicy::Minimum, QSizePolicy::Minimum); + timeline_area_policy.setHorizontalStretch(1); + timeline_area_policy.setVerticalStretch(0); + timeline_area_policy.setHeightForWidth(timeline_area->sizePolicy().hasHeightForWidth()); + timeline_area->setSizePolicy(timeline_area_policy); + QVBoxLayout* timeline_area_layout = new QVBoxLayout(timeline_area); timeline_area_layout->setSpacing(0); timeline_area_layout->setContentsMargins(0, 0, 0, 0); - headers = new TimelineHeader(timeline_area); + headers = new TimelineHeader(); timeline_area_layout->addWidget(headers); - editAreas = new QWidget(timeline_area); + editAreas = new QWidget(); QHBoxLayout* editAreaLayout = new QHBoxLayout(editAreas); editAreaLayout->setSpacing(0); editAreaLayout->setContentsMargins(0, 0, 0, 0); - QSplitter* splitter = new QSplitter(editAreas); + + QSplitter* splitter = new QSplitter(); splitter->setChildrenCollapsible(false); splitter->setOrientation(Qt::Vertical); - QWidget* videoContainer = new QWidget(splitter); + + QWidget* videoContainer = new QWidget(); + QHBoxLayout* videoContainerLayout = new QHBoxLayout(videoContainer); videoContainerLayout->setSpacing(0); videoContainerLayout->setContentsMargins(0, 0, 0, 0); - video_area = new TimelineWidget(videoContainer); - video_area->setFocusPolicy(Qt::ClickFocus); + video_area = new TimelineWidget(); + video_area->setFocusPolicy(Qt::ClickFocus); videoContainerLayout->addWidget(video_area); - videoScrollbar = new QScrollBar(videoContainer); + videoScrollbar = new QScrollBar(); videoScrollbar->setMaximum(0); videoScrollbar->setSingleStep(20); videoScrollbar->setOrientation(Qt::Vertical); - videoContainerLayout->addWidget(videoScrollbar); splitter->addWidget(videoContainer); - QWidget* audioContainer = new QWidget(splitter); + QWidget* audioContainer = new QWidget(); QHBoxLayout* audioContainerLayout = new QHBoxLayout(audioContainer); audioContainerLayout->setSpacing(0); audioContainerLayout->setContentsMargins(0, 0, 0, 0); - audio_area = new TimelineWidget(audioContainer); + + audio_area = new TimelineWidget(); audio_area->setFocusPolicy(Qt::ClickFocus); audioContainerLayout->addWidget(audio_area); - audioScrollbar = new QScrollBar(audioContainer); + audioScrollbar = new QScrollBar(); audioScrollbar->setMaximum(0); audioScrollbar->setOrientation(Qt::Vertical); @@ -1852,7 +1856,7 @@ void Timeline::setup_ui() { timeline_area_layout->addWidget(editAreas); - horizontalScrollBar = new ResizableScrollBar(timeline_area); + horizontalScrollBar = new ResizableScrollBar(); horizontalScrollBar->setMaximum(0); horizontalScrollBar->setSingleStep(20); horizontalScrollBar->setOrientation(Qt::Horizontal); @@ -1861,7 +1865,7 @@ void Timeline::setup_ui() { horizontalLayout->addWidget(timeline_area); - audio_monitor = new AudioMonitor(dockWidgetContents); + audio_monitor = new AudioMonitor(); audio_monitor->setMinimumSize(QSize(50, 0)); horizontalLayout->addWidget(audio_monitor); diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 741ff166c..c2e99c8e8 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -481,6 +481,7 @@ int Viewer::get_playback_speed() { void Viewer::resizeEvent(QResizeEvent *) { if (seq != nullptr) { set_sb_max(); + viewer_widget->update(); } } @@ -586,7 +587,7 @@ long Viewer::get_seq_out() { } void Viewer::setup_ui() { - QWidget* contents = new QWidget(); + QWidget* contents = new QWidget(this); QVBoxLayout* layout = new QVBoxLayout(contents); layout->setSpacing(0); diff --git a/playback/playback.cpp b/playback/playback.cpp index 1d6289ce8..744723c4e 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -79,9 +79,15 @@ void close_clip(Clip* clip, bool wait) { } if (clip->fbo != nullptr) { - delete clip->fbo[0]; - delete clip->fbo[1]; + // delete 3 fbos for nested sequences, 2 for most clips + int fbo_count = (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_SEQUENCE) ? 3 : 2; + + for (int j=0;jfbo[j]; + } + delete [] clip->fbo; + clip->fbo = nullptr; } diff --git a/project/effect.cpp b/project/effect.cpp index 7bb583bb4..81d686053 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -108,10 +108,9 @@ Effect::Effect(Clip* c, const EffectMeta *em) : // set up base UI container = new CollapsibleWidget(); connect(container->enabled_check, SIGNAL(clicked(bool)), this, SLOT(field_changed())); - ui = new QWidget(); - ui_layout = new QGridLayout(); + ui = new QWidget(container); + ui_layout = new QGridLayout(ui); ui_layout->setSpacing(4); - ui->setLayout(ui_layout); container->setContents(ui); connect(container->title_bar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&))); @@ -314,7 +313,7 @@ Effect::~Effect() { close(); } - //delete container; + delete container; for (int i=0;iaddWidget(w, ui_row, column_count); column_count++; } -EffectRow::~EffectRow() { - for (int i=0;iplayhead-parent_effect->parent_clip->timeline_in+parent_effect->parent_clip->clip_in; diff --git a/project/effectrow.h b/project/effectrow.h index 8ad91be23..1d71a07a4 100644 --- a/project/effectrow.h +++ b/project/effectrow.h @@ -45,6 +45,7 @@ private: QString name; int ui_row; QVector fields; + QVector widgets; KeyframeNavigator* keyframe_nav; diff --git a/project/media.cpp b/project/media.cpp index c27f068b8..083da219d 100644 --- a/project/media.cpp +++ b/project/media.cpp @@ -53,7 +53,7 @@ Media::~Media() { case MEDIA_TYPE_SEQUENCE: if (object != nullptr) delete to_sequence(); break; } if (throbber != nullptr) delete throbber; - qDeleteAll(children); +// qDeleteAll(children); } Footage *Media::to_footage() { diff --git a/ui/collapsiblewidget.cpp b/ui/collapsiblewidget.cpp index 324f8627d..2b17ce57b 100644 --- a/ui/collapsiblewidget.cpp +++ b/ui/collapsiblewidget.cpp @@ -15,62 +15,61 @@ #include "debug.h" CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) { - selected = false; + selected = false; layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); - title_bar = new CollapsibleWidgetHeader(); + title_bar = new CollapsibleWidgetHeader(this); title_bar->setFocusPolicy(Qt::ClickFocus); title_bar->setAutoFillBackground(true); - title_bar_layout = new QHBoxLayout(); + title_bar_layout = new QHBoxLayout(title_bar); title_bar_layout->setMargin(5); - title_bar->setLayout(title_bar_layout); - enabled_check = new CheckboxEx(); + enabled_check = new CheckboxEx(title_bar); enabled_check->setChecked(true); - header = new QLabel(); - collapse_button = new QPushButton(); - collapse_button->setIconSize(collapse_button->iconSize()*0.5); - collapse_button->setStyleSheet("QPushButton { border: none; }"); - setText(tr("")); - title_bar_layout->addWidget(collapse_button); - title_bar_layout->addWidget(enabled_check); - title_bar_layout->addWidget(header); - title_bar_layout->addStretch(); - layout->addWidget(title_bar); + header = new QLabel(title_bar); + collapse_button = new QPushButton(title_bar); + collapse_button->setIconSize(collapse_button->iconSize()*0.5); + collapse_button->setStyleSheet("QPushButton { border: none; }"); + setText(tr("")); + title_bar_layout->addWidget(collapse_button); + title_bar_layout->addWidget(enabled_check); + title_bar_layout->addWidget(header); + title_bar_layout->addStretch(); + layout->addWidget(title_bar); connect(title_bar, SIGNAL(select(bool, bool)), this, SLOT(header_click(bool, bool))); - set_button_icon(true); + set_button_icon(true); contents = nullptr; } void CollapsibleWidget::header_click(bool s, bool deselect) { - selected = s; - title_bar->selected = s; - if (s) { + selected = s; + title_bar->selected = s; + if (s) { QPalette p = title_bar->palette(); - p.setColor(QPalette::Background, QColor(255, 255, 255, 64)); + p.setColor(QPalette::Background, QColor(255, 255, 255, 64)); title_bar->setPalette(p); } else { title_bar->setPalette(palette()); } - if (deselect) emit deselect_others(this); + if (deselect) emit deselect_others(this); } bool CollapsibleWidget::is_focused() { - if (hasFocus()) return true; - return title_bar->hasFocus(); + if (hasFocus()) return true; + return title_bar->hasFocus(); } bool CollapsibleWidget::is_expanded() { - return contents->isVisible(); + return contents->isVisible(); } void CollapsibleWidget::set_button_icon(bool open) { - collapse_button->setIcon(open ? QIcon(":/icons/tri-down.png") : QIcon(":/icons/tri-right.png")); + collapse_button->setIcon(open ? QIcon(":/icons/tri-down.png") : QIcon(":/icons/tri-right.png")); } void CollapsibleWidget::setContents(QWidget* c) { @@ -93,7 +92,7 @@ void CollapsibleWidget::on_enabled_change(bool b) { void CollapsibleWidget::on_visible_change() { contents->setVisible(!contents->isVisible()); - set_button_icon(contents->isVisible()); + set_button_icon(contents->isVisible()); emit visibleChanged(); } @@ -102,14 +101,14 @@ CollapsibleWidgetHeader::CollapsibleWidgetHeader(QWidget* parent) : QWidget(pare } void CollapsibleWidgetHeader::mousePressEvent(QMouseEvent* event) { - if (selected) { - if ((event->modifiers() & Qt::ShiftModifier)) { - selected = false; - emit select(selected, false); - } - } else { - selected = true; - emit select(selected, !(event->modifiers() & Qt::ShiftModifier)); + if (selected) { + if ((event->modifiers() & Qt::ShiftModifier)) { + selected = false; + emit select(selected, false); + } + } else { + selected = true; + emit select(selected, !(event->modifiers() & Qt::ShiftModifier)); } } diff --git a/ui/embeddedfilechooser.cpp b/ui/embeddedfilechooser.cpp index 140149a25..2de15500f 100644 --- a/ui/embeddedfilechooser.cpp +++ b/ui/embeddedfilechooser.cpp @@ -7,13 +7,12 @@ #include EmbeddedFileChooser::EmbeddedFileChooser(QWidget* parent) : QWidget(parent) { - QHBoxLayout* layout = new QHBoxLayout(); + QHBoxLayout* layout = new QHBoxLayout(this); layout->setMargin(0); - setLayout(layout); - file_label = new QLabel(); + file_label = new QLabel(this); update_label(); layout->addWidget(file_label); - QPushButton* browse_button = new QPushButton("..."); + QPushButton* browse_button = new QPushButton("...", this); browse_button->setFixedWidth(25); layout->addWidget(browse_button); connect(browse_button, SIGNAL(clicked(bool)), this, SLOT(browse())); @@ -35,7 +34,7 @@ void EmbeddedFileChooser::setFilename(const QString &s) { } void EmbeddedFileChooser::update_label() { - QString l = "" + tr("File:") + " "; + QString l = "" + tr("File:") + " "; if (filename.isEmpty()) { l += "(none)"; } else { diff --git a/ui/keyframenavigator.cpp b/ui/keyframenavigator.cpp index baa87fc12..c6c726cf1 100644 --- a/ui/keyframenavigator.cpp +++ b/ui/keyframenavigator.cpp @@ -6,7 +6,7 @@ #include KeyframeNavigator::KeyframeNavigator(QWidget *parent, bool addLeftPad) : QWidget(parent) { - key_controls = new QHBoxLayout(); + key_controls = new QHBoxLayout(this); key_controls->setSpacing(0); key_controls->setMargin(0); @@ -14,9 +14,7 @@ KeyframeNavigator::KeyframeNavigator(QWidget *parent, bool addLeftPad) : QWidget key_controls->addStretch(); } - setLayout(key_controls); - - left_key_nav = new QPushButton(); + left_key_nav = new QPushButton(this); left_key_nav->setIcon(QIcon(":/icons/tri-left.png")); left_key_nav->setIconSize(left_key_nav->iconSize()*0.5); left_key_nav->setVisible(false); @@ -24,7 +22,7 @@ KeyframeNavigator::KeyframeNavigator(QWidget *parent, bool addLeftPad) : QWidget connect(left_key_nav, SIGNAL(clicked(bool)), this, SIGNAL(goto_previous_key())); connect(left_key_nav, SIGNAL(clicked(bool)), this, SIGNAL(clicked())); - key_addremove = new QPushButton(); + key_addremove = new QPushButton(this); key_addremove->setIcon(QIcon(":/icons/diamond.png")); key_addremove->setIconSize(key_addremove->iconSize()*0.5); key_addremove->setVisible(false); @@ -32,7 +30,7 @@ KeyframeNavigator::KeyframeNavigator(QWidget *parent, bool addLeftPad) : QWidget connect(key_addremove, SIGNAL(clicked(bool)), this, SIGNAL(toggle_key())); connect(key_addremove, SIGNAL(clicked(bool)), this, SIGNAL(clicked())); - right_key_nav = new QPushButton(); + right_key_nav = new QPushButton(this); right_key_nav->setIcon(QIcon(":/icons/tri-right.png")); right_key_nav->setIconSize(right_key_nav->iconSize()*0.5); right_key_nav->setVisible(false); @@ -40,7 +38,7 @@ KeyframeNavigator::KeyframeNavigator(QWidget *parent, bool addLeftPad) : QWidget connect(right_key_nav, SIGNAL(clicked(bool)), this, SIGNAL(goto_next_key())); connect(right_key_nav, SIGNAL(clicked(bool)), this, SIGNAL(clicked())); - keyframe_enable = new QPushButton(QIcon(":/icons/clock.png"), ""); + keyframe_enable = new QPushButton(QIcon(":/icons/clock.png"), "", this); keyframe_enable->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); keyframe_enable->setIconSize(keyframe_enable->iconSize()*0.75); keyframe_enable->setCheckable(true); @@ -51,13 +49,7 @@ KeyframeNavigator::KeyframeNavigator(QWidget *parent, bool addLeftPad) : QWidget key_controls->addWidget(keyframe_enable); } -KeyframeNavigator::~KeyframeNavigator() { - delete keyframe_enable; - delete right_key_nav; - delete key_addremove; - delete left_key_nav; - delete key_controls; -} +KeyframeNavigator::~KeyframeNavigator() {} void KeyframeNavigator::enable_keyframes(bool b) { keyframe_enable->setChecked(b); From c19a2dad7d56872f1b335e1fee88fee6ec32c231 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 21:36:07 +1100 Subject: [PATCH 4/7] code cleanups and fixed gif export #360 --- dialogs/exportdialog.cpp | 11 +++++------ io/exportthread.cpp | 39 ++++++++++++++++++++++++--------------- io/previewgenerator.cpp | 15 ++++++++------- olive.pro | 4 ++++ panels/effectcontrols.cpp | 37 ++++++++++++++++++++----------------- panels/panels.cpp | 1 + project/footage.cpp | 1 + ui/viewercontainer.cpp | 10 ++++------ 8 files changed, 67 insertions(+), 51 deletions(-) diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 98c4089b2..ec7a0ab7f 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -599,17 +599,16 @@ void ExportDialog::comp_type_changed(int) { void ExportDialog::setup_ui() { QVBoxLayout* verticalLayout = new QVBoxLayout(this); - QHBoxLayout* format_layout = new QHBoxLayout(this); + QHBoxLayout* format_layout = new QHBoxLayout(); format_layout->addWidget(new QLabel(tr("Format:"), this)); - formatCombobox = new QComboBox(this); - + formatCombobox = new QComboBox(); format_layout->addWidget(formatCombobox); verticalLayout->addLayout(format_layout); - QHBoxLayout* range_layout = new QHBoxLayout(this); + QHBoxLayout* range_layout = new QHBoxLayout(); range_layout->addWidget(new QLabel(tr("Range:"), this)); @@ -685,7 +684,7 @@ void ExportDialog::setup_ui() { verticalLayout->addWidget(audioGroupbox); - QHBoxLayout* progressLayout = new QHBoxLayout(this); + QHBoxLayout* progressLayout = new QHBoxLayout(); progressBar = new QProgressBar(this); progressBar->setFormat("%p% (ETA: 0:00:00)"); progressBar->setEnabled(false); @@ -701,7 +700,7 @@ void ExportDialog::setup_ui() { verticalLayout->addLayout(progressLayout); - QHBoxLayout* buttonLayout = new QHBoxLayout(this); + QHBoxLayout* buttonLayout = new QHBoxLayout(); buttonLayout->addStretch(); export_button = new QPushButton(this); diff --git a/io/exportthread.cpp b/io/exportthread.cpp index f5eff945a..ad96a4a0b 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -38,7 +38,6 @@ ExportThread::ExportThread(QObject *parent) : vcodec = nullptr; vcodec_ctx = nullptr; video_frame = nullptr; - sws_frame = nullptr; sws_ctx = nullptr; audio_stream = nullptr; acodec = nullptr; @@ -125,18 +124,17 @@ bool ExportThread::setupVideo() { vcodec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } - if (vcodec_ctx->codec_id == AV_CODEC_ID_H264) { - /*char buffer[50]; - itoa(vcodec_ctx, buffer, 10);*/ - - //av_opt_set(vcodec_ctx->priv_data, "preset", "fast", AV_OPT_SEARCH_CHILDREN); - //av_opt_set(vcodec_ctx->priv_data, "x264opts", "opencl", AV_OPT_SEARCH_CHILDREN); - + switch (vcodec_ctx->codec_id) { + case AV_CODEC_ID_H264: switch (video_compression_type) { case COMPRESSION_TYPE_CFR: av_opt_set(vcodec_ctx->priv_data, "crf", QString::number(static_cast(video_bitrate)).toUtf8(), AV_OPT_SEARCH_CHILDREN); break; } + break; + case AV_CODEC_ID_GIF: + av_opt_set(vcodec_ctx->priv_data, "image", "1", AV_OPT_SEARCH_CHILDREN); + break; } AVDictionary* opts = nullptr; @@ -180,12 +178,6 @@ bool ExportThread::setupVideo() { nullptr ); - sws_frame = av_frame_alloc(); - sws_frame->format = vcodec_ctx->pix_fmt; - sws_frame->width = video_width; - sws_frame->height = video_height; - av_frame_get_buffer(sws_frame, 0); - return true; } @@ -369,12 +361,30 @@ void ExportThread::run() { // encode last frame while rendering next frame double timecode_secs = (double) (sequence->playhead-start_frame) / sequence->frame_rate; if (video_enabled) { + // create sws_frame for converting pixel format + + // + // - I'm not sure why, but we have to alloc/free sws_frame every frame, or it breaks GIF exporting. + // - (i.e. GIFs get stuck on the first frame) + // - The same problem/solution can be seen here: https://stackoverflow.com/a/38997739 + // - Perhaps this is the intended way to use swscale, but it seems inefficient. + // - Anyway, here we are. + // + + sws_frame = av_frame_alloc(); + sws_frame->format = vcodec_ctx->pix_fmt; + sws_frame->width = video_width; + sws_frame->height = video_height; + av_frame_get_buffer(sws_frame, 0); + // change pixel format 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 to encoder if (!encode(fmt_ctx, vcodec_ctx, sws_frame, &video_pkt, video_stream, false)) continueEncode = false; + + av_frame_free(&sws_frame); } if (audio_enabled) { // do we need to encode more audio samples? @@ -481,7 +491,6 @@ void ExportThread::run() { if (sws_ctx != nullptr) { sws_freeContext(sws_ctx); - av_frame_free(&sws_frame); } if (swr_ctx != nullptr) { swr_free(&swr_ctx); diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index e815a2873..ca2fd3bbe 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -19,6 +19,7 @@ #include #define WAVEFORM_RESOLUTION 64 +#define THUMBNAIL_RESOLUTION 120 extern "C" { #include @@ -30,7 +31,7 @@ extern "C" { QSemaphore sem(5); // only 5 preview generators can run at one time PreviewGenerator::PreviewGenerator(Media* i, Footage* m, bool r) : - QThread(0), + QThread(nullptr), fmt_ctx(nullptr), media(i), footage(m), @@ -50,7 +51,7 @@ PreviewGenerator::PreviewGenerator(Media* i, Footage* m, bool r) : void PreviewGenerator::parse_media() { // detect video/audio streams in file - for (int i=0;i<(int)fmt_ctx->nb_streams;i++) { + for (int i=0;inb_streams);i++) { // Find the decoder for the video stream if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == nullptr) { qCritical() << "Unsupported codec in stream" << i << "of file" << footage->name; @@ -106,7 +107,7 @@ void PreviewGenerator::parse_media() { append = true; } else if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { ms.audio_channels = fmt_ctx->streams[i]->codecpar->channels; - ms.audio_layout = fmt_ctx->streams[i]->codecpar->channel_layout; + ms.audio_layout = int(fmt_ctx->streams[i]->codecpar->channel_layout); ms.audio_frequency = fmt_ctx->streams[i]->codecpar->sample_rate; append = true; @@ -277,9 +278,9 @@ void PreviewGenerator::generate_waveform() { if (s != nullptr) { if (fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (!s->preview_done) { - int dstH = 120; - int dstW = dstH * ((float)temp_frame->width/(float)temp_frame->height); - uint8_t* data = new uint8_t[dstW*dstH*4]; + int dstH = THUMBNAIL_RESOLUTION; + int dstW = qRound(dstH * (float(temp_frame->width)/float(temp_frame->height))); + uint8_t* data = new uint8_t[size_t(dstW*dstH*4)]; sws_ctx = sws_getContext( temp_frame->width, @@ -414,7 +415,7 @@ void PreviewGenerator::generate_waveform() { maximum_stream = i; } } - footage->length = (double) media_lengths[maximum_stream] / av_q2d(fmt_ctx->streams[maximum_stream]->avg_frame_rate) * AV_TIME_BASE; // TODO redo with PTS + footage->length = double(media_lengths[maximum_stream]) / av_q2d(fmt_ctx->streams[maximum_stream]->avg_frame_rate) * AV_TIME_BASE; // TODO redo with PTS finalize_media(); } delete [] media_lengths; diff --git a/olive.pro b/olive.pro index 423b5dfac..334fafcb9 100644 --- a/olive.pro +++ b/olive.pro @@ -35,6 +35,10 @@ system("which git") { CONFIG += c++11 +CONFIG(debug, debug|release) { + CONFIG += console +} + SOURCES += \ main.cpp \ mainwindow.cpp \ diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 935ecd63f..88b13e5bf 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -279,11 +279,11 @@ void EffectControls::setup_ui() { hlayout->setSpacing(0); hlayout->setMargin(0); - QSplitter* splitter = new QSplitter(contents); + QSplitter* splitter = new QSplitter(); splitter->setOrientation(Qt::Horizontal); splitter->setChildrenCollapsible(false); - scrollArea = new QScrollArea(splitter); + scrollArea = new QScrollArea(); scrollArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); scrollArea->setFrameShape(QFrame::NoFrame); scrollArea->setFrameShadow(QFrame::Plain); @@ -291,13 +291,13 @@ void EffectControls::setup_ui() { scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollArea->setWidgetResizable(true); - QWidget* scrollAreaWidgetContents = new QWidget(scrollArea); + QWidget* scrollAreaWidgetContents = new QWidget(); QHBoxLayout* scrollAreaLayout = new QHBoxLayout(scrollAreaWidgetContents); scrollAreaLayout->setSpacing(0); scrollAreaLayout->setMargin(0); - effects_area = new EffectsArea(scrollAreaWidgetContents); + effects_area = new EffectsArea(); effects_area->setContextMenuPolicy(Qt::CustomContextMenu); connect(effects_area, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(effects_area_context_menu())); @@ -305,12 +305,12 @@ void EffectControls::setup_ui() { effects_area_layout->setSpacing(0); effects_area_layout->setMargin(0); - vcontainer = new QWidget(effects_area); - QVBoxLayout* vcontainerLayout = new QVBoxLayout(); + vcontainer = new QWidget(); + QVBoxLayout* vcontainerLayout = new QVBoxLayout(vcontainer); vcontainerLayout->setSpacing(0); vcontainerLayout->setMargin(0); - QWidget* veHeader = new QWidget(vcontainer); + QWidget* veHeader = new QWidget(); veHeader->setObjectName(QStringLiteral("veHeader")); veHeader->setStyleSheet(QLatin1String("#veHeader { background: rgba(0, 0, 0, 0.25); }")); @@ -353,11 +353,11 @@ void EffectControls::setup_ui() { effects_area_layout->addWidget(vcontainer); - acontainer = new QWidget(effects_area); + acontainer = new QWidget(); QVBoxLayout* acontainerLayout = new QVBoxLayout(acontainer); acontainerLayout->setSpacing(0); acontainerLayout->setMargin(0); - QWidget* aeHeader = new QWidget(acontainer); + QWidget* aeHeader = new QWidget(); aeHeader->setObjectName(QStringLiteral("aeHeader")); aeHeader->setStyleSheet(QLatin1String("#aeHeader { background: rgba(0, 0, 0, 0.25); }")); @@ -389,7 +389,7 @@ void EffectControls::setup_ui() { acontainerLayout->addWidget(aeHeader); - audio_effect_area = new QWidget(acontainer); + audio_effect_area = new QWidget(); QVBoxLayout* aeAreaLayout = new QVBoxLayout(audio_effect_area); aeAreaLayout->setSpacing(0); aeAreaLayout->setMargin(0); @@ -398,7 +398,7 @@ void EffectControls::setup_ui() { effects_area_layout->addWidget(acontainer); - lblMultipleClipsSelected = new QLabel(effects_area); + lblMultipleClipsSelected = new QLabel(); lblMultipleClipsSelected->setAlignment(Qt::AlignCenter); lblMultipleClipsSelected->setText(tr("(Multiple clips selected)")); effects_area_layout->addWidget(lblMultipleClipsSelected); @@ -409,30 +409,33 @@ void EffectControls::setup_ui() { scrollArea->setWidget(scrollAreaWidgetContents); splitter->addWidget(scrollArea); - QWidget* keyframeArea = new QWidget(splitter); + + QWidget* keyframeArea = new QWidget(); + QSizePolicy keyframe_sp; keyframe_sp.setHorizontalPolicy(QSizePolicy::Minimum); keyframe_sp.setVerticalPolicy(QSizePolicy::Preferred); keyframe_sp.setHorizontalStretch(1); keyframeArea->setSizePolicy(keyframe_sp); + QVBoxLayout* keyframeAreaLayout = new QVBoxLayout(keyframeArea); keyframeAreaLayout->setSpacing(0); keyframeAreaLayout->setMargin(0); - headers = new TimelineHeader(keyframeArea); + headers = new TimelineHeader(); keyframeAreaLayout->addWidget(headers); - QWidget* keyframeCenterWidget = new QWidget(keyframeArea); + QWidget* keyframeCenterWidget = new QWidget(); QHBoxLayout* keyframeCenterLayout = new QHBoxLayout(keyframeCenterWidget); keyframeCenterLayout->setSpacing(0); keyframeCenterLayout->setMargin(0); - keyframeView = new KeyframeView(keyframeCenterWidget); + keyframeView = new KeyframeView(); keyframeCenterLayout->addWidget(keyframeView); - verticalScrollBar = new QScrollBar(keyframeCenterWidget); + verticalScrollBar = new QScrollBar(); verticalScrollBar->setOrientation(Qt::Vertical); keyframeCenterLayout->addWidget(verticalScrollBar); @@ -440,7 +443,7 @@ void EffectControls::setup_ui() { keyframeAreaLayout->addWidget(keyframeCenterWidget); - horizontalScrollBar = new ResizableScrollBar(keyframeArea); + horizontalScrollBar = new ResizableScrollBar(); horizontalScrollBar->setOrientation(Qt::Horizontal); keyframeAreaLayout->addWidget(horizontalScrollBar); diff --git a/panels/panels.cpp b/panels/panels.cpp index bb51363b5..98a61dcd2 100644 --- a/panels/panels.cpp +++ b/panels/panels.cpp @@ -100,6 +100,7 @@ void update_effect_controls() { if (panel_effect_controls->multiple != multiple || !same) { panel_effect_controls->multiple = multiple; + panel_effect_controls->set_clips(selected_clips, mode); } } diff --git a/project/footage.cpp b/project/footage.cpp index c9dbd83f6..c5cdc94e9 100644 --- a/project/footage.cpp +++ b/project/footage.cpp @@ -69,5 +69,6 @@ void FootageStream::make_square_thumb() { int sqx = (diff < 0) ? -diff : 0; int sqy = (diff > 0) ? diff : 0; p.drawImage(sqx, sqy, video_preview); + p.end(); video_preview_square = QIcon(pixmap); } diff --git a/ui/viewercontainer.cpp b/ui/viewercontainer.cpp index 8801db35e..dc02bd520 100644 --- a/ui/viewercontainer.cpp +++ b/ui/viewercontainer.cpp @@ -20,6 +20,9 @@ ViewerContainer::ViewerContainer(QWidget *parent) : horizontal_scrollbar = new QScrollBar(Qt::Horizontal, this); vertical_scrollbar = new QScrollBar(Qt::Vertical, this); + horizontal_scrollbar->setVisible(false); + vertical_scrollbar->setVisible(false); + horizontal_scrollbar->setSingleStep(20); vertical_scrollbar->setSingleStep(20); @@ -30,12 +33,7 @@ ViewerContainer::ViewerContainer(QWidget *parent) : connect(vertical_scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scroll_changed())); } -ViewerContainer::~ViewerContainer() { - delete child; - - delete horizontal_scrollbar; - delete vertical_scrollbar; -} +ViewerContainer::~ViewerContainer() {} void ViewerContainer::dragScrollPress(const QPoint &p) { drag_start_x = p.x(); From 861a5e2ce5c9df919b1f33e0241420cfa33f9023 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 22:51:43 +1100 Subject: [PATCH 5/7] added audio device settings to preferences --- dialogs/newsequencedialog.cpp | 9 +--- dialogs/preferencesdialog.cpp | 77 +++++++++++++++++++++++++++++++++-- dialogs/preferencesdialog.h | 3 ++ io/config.cpp | 8 ++++ io/config.h | 2 + io/exportthread.cpp | 13 +++--- playback/audio.cpp | 59 +++++++++++++++++++++------ playback/audio.h | 3 ++ 8 files changed, 143 insertions(+), 31 deletions(-) diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index 9eaf35367..b80fde74f 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -8,6 +8,7 @@ #include "panels/timeline.h" #include "playback/playback.h" #include "project/media.h" +#include "playback/audio.h" #include #include @@ -232,13 +233,7 @@ void NewSequenceDialog::setup_ui() { audioLayout->addWidget(new QLabel(tr("Sample Rate: "), this), 0, 0, 1, 1); audio_frequency_combobox = new QComboBox(audioGroupBox); - audio_frequency_combobox->addItem("22050 Hz", 22050); - audio_frequency_combobox->addItem("24000 Hz", 24000); - audio_frequency_combobox->addItem("32000 Hz", 32000); - audio_frequency_combobox->addItem("44100 Hz", 44100); - audio_frequency_combobox->addItem("48000 Hz", 48000); - audio_frequency_combobox->addItem("88200 Hz", 88200); - audio_frequency_combobox->addItem("96000 Hz", 96000); + combobox_audio_sample_rates(audio_frequency_combobox); audio_frequency_combobox->setCurrentIndex(4); audioLayout->addWidget(audio_frequency_combobox, 0, 1, 1, 1); diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index 37b54958a..85150b666 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -1,6 +1,7 @@ #include "preferencesdialog.h" #include "io/config.h" +#include "playback/audio.h" #include "mainwindow.h" #include @@ -22,6 +23,7 @@ #include #include #include +#include #include "debug.h" @@ -133,6 +135,14 @@ void PreferencesDialog::save() { config.previous_queue_size = previous_queue_spinbox->value(); config.previous_queue_type = previous_queue_type->currentIndex(); + // audio preferences + bool reset_audio_required = (config.preferred_audio_output != audio_output_devices->currentData().toString() + || config.preferred_audio_input != audio_input_devices->currentData().toString()); + config.preferred_audio_output = audio_output_devices->currentData().toString(); + config.preferred_audio_input = audio_input_devices->currentData().toString(); + qDebug() << "selected audio input" << audio_input_devices->currentData().toString(); + config.audio_rate = audio_sample_rate->currentData().toInt(); + // the following settings may require a restart of Olive to take effect: bool needs_restart = false; @@ -152,6 +162,10 @@ void PreferencesDialog::save() { key_shortcut_fields.at(i)->set_action_shortcut(); } + if (reset_audio_required) { + init_audio(); + } + if (needs_restart) { QMessageBox::information(this, tr("Warning"), tr("Some changed settings will require restarting Olive to take effect")); } @@ -286,7 +300,7 @@ void PreferencesDialog::setup_ui() { QTabWidget* tabWidget = new QTabWidget(this); // General - QTabWidget* general_tab = new QTabWidget(this); + QWidget* general_tab = new QWidget(this); QGridLayout* general_layout = new QGridLayout(general_tab); // General -> Custom CSS @@ -382,6 +396,65 @@ void PreferencesDialog::setup_ui() { tabWidget->addTab(playback_tab, tr("Playback")); + // Audio + QWidget* audio_tab = new QWidget(this); + + QGridLayout* audio_tab_layout = new QGridLayout(audio_tab); + + audio_tab_layout->addWidget(new QLabel(tr("Output Device:")), 0, 0); + + audio_output_devices = new QComboBox(); + audio_output_devices->addItem(tr("Default"), ""); + + // list all available audio output devices + QList devs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); + bool found_preferred_device = false; + for (int i=0;iaddItem(devs.at(i).deviceName(), devs.at(i).deviceName()); + if (!found_preferred_device + && devs.at(i).deviceName() == config.preferred_audio_output) { + audio_output_devices->setCurrentIndex(audio_output_devices->count()-1); + found_preferred_device = true; + } + } + + audio_tab_layout->addWidget(audio_output_devices, 0, 1); + + audio_tab_layout->addWidget(new QLabel(tr("Input Device:")), 1, 0); + + audio_input_devices = new QComboBox(); + audio_input_devices->addItem(tr("Default"), ""); + + // list all available audio input devices + devs = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); + found_preferred_device = false; + for (int i=0;iaddItem(devs.at(i).deviceName(), devs.at(i).deviceName()); + if (!found_preferred_device + && devs.at(i).deviceName() == config.preferred_audio_input) { + audio_input_devices->setCurrentIndex(audio_input_devices->count()-1); + found_preferred_device = true; + } + } + + audio_tab_layout->addWidget(audio_input_devices, 1, 1); + + audio_tab_layout->addWidget(new QLabel(tr("Sample Rate:")), 2, 0); + + audio_sample_rate = new QComboBox(); + combobox_audio_sample_rates(audio_sample_rate); + for (int i=0;icount();i++) { + if (audio_sample_rate->itemData(i).toInt() == config.audio_rate) { + audio_sample_rate->setCurrentIndex(i); + break; + } + } + + audio_tab_layout->addWidget(audio_sample_rate, 2, 1); + + tabWidget->addTab(audio_tab, tr("Audio")); + + // Shortcuts QWidget* shortcut_tab = new QWidget(this); QVBoxLayout* shortcut_layout = new QVBoxLayout(shortcut_tab); @@ -432,6 +505,4 @@ void PreferencesDialog::setup_ui() { connect(buttonBox, SIGNAL(accepted()), this, SLOT(save())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - - tabWidget->setCurrentIndex(2); } diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index 9e3ad21fc..2e8243fda 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -62,6 +62,9 @@ private: QComboBox* previous_queue_type; QSpinBox* effect_textbox_lines_field; QCheckBox* use_software_fallbacks_checkbox; + QComboBox* audio_output_devices; + QComboBox* audio_input_devices; + QComboBox* audio_sample_rate; QVector key_shortcut_actions; QVector key_shortcut_items; diff --git a/io/config.cpp b/io/config.cpp index 912fe86e9..2a3122557 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -173,6 +173,12 @@ void Config::load(QString path) { } else if (stream.name() == "CenterTimelineTimecodes") { stream.readNext(); center_timeline_timecodes = (stream.text() == "1"); + } else if (stream.name() == "PreferredAudioOutput") { + stream.readNext(); + preferred_audio_output = stream.text().toString(); + } else if (stream.name() == "PreferredAudioInput") { + stream.readNext(); + preferred_audio_input = stream.text().toString(); } } } @@ -235,6 +241,8 @@ void Config::save(QString path) { stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines)); stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback)); stream.writeTextElement("CenterTimelineTimecodes", QString::number(center_timeline_timecodes)); + stream.writeTextElement("PreferredAudioOutput", preferred_audio_output); + stream.writeTextElement("PreferredAudioInput", preferred_audio_input); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index 84bd848df..5e8c61f27 100644 --- a/io/config.h +++ b/io/config.h @@ -64,6 +64,8 @@ struct Config { int effect_textbox_lines; bool use_software_fallback; bool center_timeline_timecodes; + QString preferred_audio_output; + QString preferred_audio_input; void load(QString path); void save(QString path); diff --git a/io/exportthread.cpp b/io/exportthread.cpp index ad96a4a0b..79136b2f5 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -132,9 +132,6 @@ bool ExportThread::setupVideo() { break; } break; - case AV_CODEC_ID_GIF: - av_opt_set(vcodec_ctx->priv_data, "image", "1", AV_OPT_SEARCH_CHILDREN); - break; } AVDictionary* opts = nullptr; @@ -377,18 +374,20 @@ void ExportThread::run() { sws_frame->height = video_height; av_frame_get_buffer(sws_frame, 0); - // change pixel format + // convert pixel format 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 to encoder + // send converted frame to encoder if (!encode(fmt_ctx, vcodec_ctx, sws_frame, &video_pkt, video_stream, false)) continueEncode = false; av_frame_free(&sws_frame); } if (audio_enabled) { + // do we need to encode more audio samples? while (continueEncode && file_audio_samples <= (timecode_secs*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); @@ -415,15 +414,13 @@ void ExportThread::run() { } } - // encoding stats + // generating encoding statistics (time it took to encode this frame/estimated remaining time) frame_time = (QDateTime::currentMSecsSinceEpoch()-start_time); total_time += frame_time; remaining_frames = (end_frame-sequence->playhead); avg_time = (total_time/frame_count); eta = (remaining_frames*avg_time); -// qInfo() << "Encoded frame" << sequence->playhead << "- took" << frame_time << "ms (avg:" << avg_time << "ms, remaining:" << remaining_frames << ", ETA:" << eta << ")"; - emit progress_changed(qRound((double(sequence->playhead-start_frame) / double(end_frame-start_frame)) * 100.0), eta); sequence->playhead++; frame_count++; diff --git a/playback/audio.cpp b/playback/audio.cpp index b5abc9faf..44402a6f6 100644 --- a/playback/audio.cpp +++ b/playback/audio.cpp @@ -17,6 +17,7 @@ #include #include #include +#include extern "C" { #include @@ -43,6 +44,35 @@ bool is_audio_device_set() { return audio_device_set; } +QAudioDeviceInfo get_audio_device(QAudio::Mode mode) { + QList devs = QAudioDeviceInfo::availableDevices(mode); + + // try to retrieve preferred device from config + QString preferred_device = (mode == QAudio::AudioOutput) ? config.preferred_audio_output : config.preferred_audio_input; + if (!preferred_device.isEmpty()) { + for (int i=0;i 0) { + return devs.at(0); + } + + // couldn't find any audio devices, return null device + return QAudioDeviceInfo(); +} + void init_audio() { stop_audio(); @@ -54,18 +84,9 @@ void init_audio() { audio_format.setByteOrder(QAudioFormat::LittleEndian); audio_format.setSampleType(QAudioFormat::SignedInt); - QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); - QList devs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); - qInfo() << "Found the following audio devices:"; - for (int i=0;i 0) { - qWarning() << "Default audio returned nullptr, attempting to use first device found..."; - info = devs.at(0); - } - qInfo() << "Using audio device" << info.deviceName(); + QAudioDeviceInfo info = get_audio_device(QAudio::AudioOutput); + // see if desired format can be used by the device, use nearest if not if (!info.isFormatSupported(audio_format)) { qWarning() << "Audio format is not supported by backend, using nearest"; audio_format = info.nearestFormat(audio_format); @@ -311,13 +332,15 @@ bool start_recording() { if (config.recording_mode != audio_format.channelCount()) { audio_format.setChannelCount(config.recording_mode); } - QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice(); + + QAudioDeviceInfo info = get_audio_device(QAudio::AudioInput); + if (!info.isFormatSupported(audio_format)) { qWarning() << "Default format not supported, using nearest"; audio_format = info.nearestFormat(audio_format); } write_wave_header(output_recording, audio_format); - audio_input = new QAudioInput(audio_format); + audio_input = new QAudioInput(info, audio_format); audio_input->start(&output_recording); recording = true; @@ -341,3 +364,13 @@ void stop_recording() { QString get_recorded_audio_filename() { return output_recording.fileName(); } + +void combobox_audio_sample_rates(QComboBox *combobox) { + combobox->addItem("22050 Hz", 22050); + combobox->addItem("24000 Hz", 24000); + combobox->addItem("32000 Hz", 32000); + combobox->addItem("44100 Hz", 44100); + combobox->addItem("48000 Hz", 48000); + combobox->addItem("88200 Hz", 88200); + combobox->addItem("96000 Hz", 96000); +} diff --git a/playback/audio.h b/playback/audio.h index 8ca487fa2..fdb7ee3eb 100644 --- a/playback/audio.h +++ b/playback/audio.h @@ -11,6 +11,7 @@ class QIODevice; class QAudioOutput; +class QComboBox; struct Sequence; @@ -59,4 +60,6 @@ bool start_recording(); void stop_recording(); QString get_recorded_audio_filename(); +void combobox_audio_sample_rates(QComboBox* combobox); + #endif // AUDIO_H From 883b2b9c7c108af7813f5cd25d036bc1352163e9 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 23:18:02 +1100 Subject: [PATCH 6/7] fixed some UI issues --- panels/grapheditor.cpp | 59 +++++++++++++++++++----------------------- panels/project.cpp | 34 ++++++++++++------------ ui/viewercontainer.cpp | 4 +-- 3 files changed, 45 insertions(+), 52 deletions(-) diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index cb4bda3c2..370576465 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -24,46 +24,42 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(nullptr) { resize(720, 480); QWidget* main_widget = new QWidget(this); - setWidget(main_widget); QVBoxLayout* layout = new QVBoxLayout(main_widget); + setWidget(main_widget); - QWidget* tool_widget = new QWidget(this); + QWidget* tool_widget = new QWidget(); tool_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - QHBoxLayout* tools = new QHBoxLayout(this); - tool_widget->setLayout(tools); + QHBoxLayout* tools = new QHBoxLayout(tool_widget); - QWidget* left_tool_widget = new QWidget(this); - QHBoxLayout* left_tool_layout = new QHBoxLayout(this); + QWidget* left_tool_widget = new QWidget(); + QHBoxLayout* left_tool_layout = new QHBoxLayout(left_tool_widget); left_tool_layout->setSpacing(0); left_tool_layout->setMargin(0); - left_tool_widget->setLayout(left_tool_layout); tools->addWidget(left_tool_widget); - QWidget* center_tool_widget = new QWidget(this); - QHBoxLayout* center_tool_layout = new QHBoxLayout(this); + QWidget* center_tool_widget = new QWidget(); + QHBoxLayout* center_tool_layout = new QHBoxLayout(center_tool_widget); center_tool_layout->setSpacing(0); center_tool_layout->setMargin(0); - center_tool_widget->setLayout(center_tool_layout); tools->addWidget(center_tool_widget); - QWidget* right_tool_widget = new QWidget(this); - QHBoxLayout* right_tool_layout = new QHBoxLayout(this); + QWidget* right_tool_widget = new QWidget(); + QHBoxLayout* right_tool_layout = new QHBoxLayout(right_tool_widget); right_tool_layout->setSpacing(0); right_tool_layout->setMargin(0); - right_tool_widget->setLayout(right_tool_layout); tools->addWidget(right_tool_widget); - keyframe_nav = new KeyframeNavigator(this, false); + keyframe_nav = new KeyframeNavigator(nullptr, false); keyframe_nav->enable_keyframes(true); keyframe_nav->enable_keyframe_toggle(false); left_tool_layout->addWidget(keyframe_nav); left_tool_layout->addStretch(); - linear_button = new QPushButton(tr("Linear"), this); + linear_button = new QPushButton(tr("Linear")); linear_button->setProperty("type", EFFECT_KEYFRAME_LINEAR); linear_button->setCheckable(true); - bezier_button = new QPushButton(tr("Bezier"), this); + bezier_button = new QPushButton(tr("Bezier")); bezier_button->setProperty("type", EFFECT_KEYFRAME_BEZIER); bezier_button->setCheckable(true); - hold_button = new QPushButton(tr("Hold"), this); + hold_button = new QPushButton(tr("Hold")); hold_button->setProperty("type", EFFECT_KEYFRAME_HOLD); hold_button->setCheckable(true); @@ -74,36 +70,33 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(nullptr) { layout->addWidget(tool_widget); - QWidget* central_widget = new QWidget(this); - QVBoxLayout* central_layout = new QVBoxLayout(this); - central_widget->setLayout(central_layout); + QWidget* central_widget = new QWidget(); + QVBoxLayout* central_layout = new QVBoxLayout(central_widget); central_layout->setSpacing(0); central_layout->setMargin(0); - header = new TimelineHeader(this); + header = new TimelineHeader(); header->viewer = panel_sequence_viewer; central_layout->addWidget(header); - view = new GraphView(this); + view = new GraphView(); central_layout->addWidget(view); layout->addWidget(central_widget); - QWidget* value_widget = new QWidget(this); + QWidget* value_widget = new QWidget(); value_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - QHBoxLayout* values = new QHBoxLayout(this); - value_widget->setLayout(values); + QHBoxLayout* values = new QHBoxLayout(value_widget); values->addStretch(); - QWidget* central_value_widget = new QWidget(this); - value_layout = new QHBoxLayout(this); + QWidget* central_value_widget = new QWidget(); + value_layout = new QHBoxLayout(central_value_widget); value_layout->setMargin(0); - value_layout->addWidget(new QLabel("", this)); // a spacer so the layout doesn't jump - central_value_widget->setLayout(value_layout); + value_layout->addWidget(new QLabel("")); // a spacer so the layout doesn't jump values->addWidget(central_value_widget); values->addStretch(); layout->addWidget(value_widget); - current_row_desc = new QLabel(this); + current_row_desc = new QLabel(); current_row_desc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); current_row_desc->setAlignment(Qt::AlignCenter); layout->addWidget(current_row_desc); @@ -157,7 +150,7 @@ void GraphEditor::set_row(EffectRow *r) { for (int i=0;ifieldCount();i++) { EffectField* field = r->field(i); if (field->type == EFFECT_FIELD_DOUBLE) { - QPushButton* slider_button = new QPushButton(this); + QPushButton* slider_button = new QPushButton(); slider_button->setCheckable(true); slider_button->setChecked(field->is_enabled()); slider_button->setIcon(QIcon(":/icons/record.png")); @@ -167,7 +160,7 @@ void GraphEditor::set_row(EffectRow *r) { slider_proxy_buttons.append(slider_button); value_layout->addWidget(slider_button); - LabelSlider* slider = new LabelSlider(this); + LabelSlider* slider = new LabelSlider(); slider->set_color(get_curve_color(i, r->fieldCount()).name()); connect(slider, SIGNAL(valueChanged()), this, SLOT(passthrough_slider_value())); slider_proxies.append(slider); @@ -190,7 +183,7 @@ void GraphEditor::set_row(EffectRow *r) { connect(keyframe_nav, SIGNAL(goto_next_key()), row, SLOT(goto_next_key())); } else { row = nullptr; - current_row_desc->setText(0); + current_row_desc->setText(nullptr); } view->set_row(row); update_panel(); diff --git a/panels/project.cpp b/panels/project.cpp index 71a57c9e0..4ec6ae81a 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -64,8 +64,9 @@ Project::Project(QWidget *parent) : setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QWidget* dockWidgetContents = new QWidget(this); + QVBoxLayout* verticalLayout = new QVBoxLayout(dockWidgetContents); - verticalLayout->setContentsMargins(0, 0, 0, 0); + verticalLayout->setMargin(0); verticalLayout->setSpacing(0); setWidget(dockWidgetContents); @@ -76,15 +77,15 @@ Project::Project(QWidget *parent) : sorter->setSourceModel(&project_model); // optional toolbar - toolbar_widget = new QWidget(this); + toolbar_widget = new QWidget(); toolbar_widget->setVisible(config.show_project_toolbar); toolbar_widget->setObjectName("project_toolbar"); + QHBoxLayout* toolbar = new QHBoxLayout(toolbar_widget); toolbar->setMargin(0); toolbar->setSpacing(0); - toolbar_widget->setLayout(toolbar); - QPushButton* toolbar_new = new QPushButton(toolbar_widget); + QPushButton* toolbar_new = new QPushButton(); QIcon icon1; icon1.addFile(QStringLiteral(":/icons/add-button.png"), QSize(), QIcon::Normal, QIcon::On); icon1.addFile(QStringLiteral(":/icons/add-button-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -93,7 +94,7 @@ Project::Project(QWidget *parent) : connect(toolbar_new, SIGNAL(clicked(bool)), this, SLOT(make_new_menu())); toolbar->addWidget(toolbar_new); - QPushButton* toolbar_open = new QPushButton(toolbar_widget); + QPushButton* toolbar_open = new QPushButton(); QIcon icon2; icon2.addFile(QStringLiteral(":/icons/open.png"), QSize(), QIcon::Normal, QIcon::On); icon2.addFile(QStringLiteral(":/icons/open-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -102,7 +103,7 @@ Project::Project(QWidget *parent) : connect(toolbar_open, SIGNAL(clicked(bool)), mainWindow, SLOT(open_project())); toolbar->addWidget(toolbar_open); - QPushButton* toolbar_save = new QPushButton(toolbar_widget); + QPushButton* toolbar_save = new QPushButton(); QIcon icon3; icon3.addFile(QStringLiteral(":/icons/save.png"), QSize(), QIcon::Normal, QIcon::On); icon3.addFile(QStringLiteral(":/icons/save-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -111,7 +112,7 @@ Project::Project(QWidget *parent) : connect(toolbar_save, SIGNAL(clicked(bool)), mainWindow, SLOT(save_project())); toolbar->addWidget(toolbar_save); - QPushButton* toolbar_undo = new QPushButton(toolbar_widget); + QPushButton* toolbar_undo = new QPushButton(); QIcon icon4; icon4.addFile(QStringLiteral(":/icons/undo.png"), QSize(), QIcon::Normal, QIcon::On); icon4.addFile(QStringLiteral(":/icons/undo-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -120,7 +121,7 @@ Project::Project(QWidget *parent) : connect(toolbar_undo, SIGNAL(clicked(bool)), mainWindow, SLOT(undo())); toolbar->addWidget(toolbar_undo); - QPushButton* toolbar_redo = new QPushButton(toolbar_widget); + QPushButton* toolbar_redo = new QPushButton(); QIcon icon5; icon5.addFile(QStringLiteral(":/icons/redo.png"), QSize(), QIcon::Normal, QIcon::On); icon5.addFile(QStringLiteral(":/icons/redo-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -130,7 +131,7 @@ Project::Project(QWidget *parent) : toolbar->addWidget(toolbar_redo); toolbar->addStretch(); - QPushButton* toolbar_tree_view = new QPushButton(toolbar_widget); + QPushButton* toolbar_tree_view = new QPushButton(); QIcon icon6; icon6.addFile(QStringLiteral(":/icons/treeview.png"), QSize(), QIcon::Normal, QIcon::On); icon6.addFile(QStringLiteral(":/icons/treeview-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -139,7 +140,7 @@ Project::Project(QWidget *parent) : connect(toolbar_tree_view, SIGNAL(clicked(bool)), this, SLOT(set_tree_view())); toolbar->addWidget(toolbar_tree_view); - QPushButton* toolbar_icon_view = new QPushButton(toolbar_widget); + QPushButton* toolbar_icon_view = new QPushButton(); QIcon icon7; icon7.addFile(QStringLiteral(":/icons/iconview.png"), QSize(), QIcon::Normal, QIcon::On); icon7.addFile(QStringLiteral(":/icons/iconview-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); @@ -151,20 +152,19 @@ Project::Project(QWidget *parent) : verticalLayout->addWidget(toolbar_widget); // tree view - tree_view = new SourceTable(dockWidgetContents); + tree_view = new SourceTable(); tree_view->project_parent = this; tree_view->setModel(sorter); verticalLayout->addWidget(tree_view); // icon view - icon_view_container = new QWidget(dockWidgetContents); + icon_view_container = new QWidget(); QVBoxLayout* icon_view_container_layout = new QVBoxLayout(icon_view_container); icon_view_container_layout->setMargin(0); icon_view_container_layout->setSpacing(0); - icon_view_container->setLayout(icon_view_container_layout); - QHBoxLayout* icon_view_controls = new QHBoxLayout(icon_view_container); + QHBoxLayout* icon_view_controls = new QHBoxLayout(); icon_view_controls->setMargin(0); icon_view_controls->setSpacing(0); @@ -172,14 +172,14 @@ Project::Project(QWidget *parent) : directory_up_button.addFile(":/icons/dirup.png", QSize(), QIcon::Normal); directory_up_button.addFile(":/icons/dirup-disabled.png", QSize(), QIcon::Disabled); - directory_up = new QPushButton(icon_view_container); + directory_up = new QPushButton(); directory_up->setIcon(directory_up_button); directory_up->setEnabled(false); icon_view_controls->addWidget(directory_up); icon_view_controls->addStretch(); - QSlider* icon_size_slider = new QSlider(Qt::Horizontal, icon_view_container); + QSlider* icon_size_slider = new QSlider(Qt::Horizontal); icon_size_slider->setMinimum(16); icon_size_slider->setMaximum(120); icon_view_controls->addWidget(icon_size_slider); @@ -187,7 +187,7 @@ Project::Project(QWidget *parent) : icon_view_container_layout->addLayout(icon_view_controls); - icon_view = new SourceIconView(dockWidgetContents); + icon_view = new SourceIconView(); icon_view->project_parent = this; icon_view->setModel(sorter); icon_view->setIconSize(QSize(100, 100)); diff --git a/ui/viewercontainer.cpp b/ui/viewercontainer.cpp index dc02bd520..d6e3f0dcd 100644 --- a/ui/viewercontainer.cpp +++ b/ui/viewercontainer.cpp @@ -131,11 +131,11 @@ void ViewerContainer::adjust() { void ViewerContainer::resizeEvent(QResizeEvent *event) { horizontal_scrollbar->move(0, height()-horizontal_scrollbar->height()); - horizontal_scrollbar->setFixedWidth(width()-vertical_scrollbar->width()); + horizontal_scrollbar->setFixedWidth(qMax(0, width()-vertical_scrollbar->width())); horizontal_scrollbar->setPageStep(width()); vertical_scrollbar->move(width() - vertical_scrollbar->width(), 0); - vertical_scrollbar->setFixedHeight(height()-horizontal_scrollbar->height()); + vertical_scrollbar->setFixedHeight(qMax(0, height()-horizontal_scrollbar->height())); vertical_scrollbar->setPageStep(height()); event->accept(); From 1212405046f63205f133063f3795f349d6a596c4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 23:18:23 +1100 Subject: [PATCH 7/7] added no blending modes mode --- main.cpp | 5 ++++ ui/renderfunctions.cpp | 66 +++++++++++++++++++++++++----------------- ui/renderfunctions.h | 2 ++ 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/main.cpp b/main.cpp index d11e9886d..1b9f4670f 100644 --- a/main.cpp +++ b/main.cpp @@ -2,7 +2,10 @@ #include #include "debug.h" + +// importing classes for certain command line args #include "project/effect.h" +#include "ui/renderfunctions.h" extern "C" { #include @@ -40,6 +43,8 @@ int main(int argc, char *argv[]) { shaders_are_enabled = false; } else if (!strcmp(argv[i], "--no-debug")) { use_internal_logger = false; + } else if (!strcmp(argv[i], "--disable-blend-modes")) { + disable_blending = true; } else { printf("[ERROR] Unknown argument '%s'\n", argv[1]); return 1; diff --git a/ui/renderfunctions.cpp b/ui/renderfunctions.cpp index cead4ea51..0e0dfa8d4 100644 --- a/ui/renderfunctions.cpp +++ b/ui/renderfunctions.cpp @@ -24,6 +24,8 @@ #include "panels/timeline.h" #include "panels/viewer.h" +bool disable_blending = false; + extern "C" { #include } @@ -486,11 +488,13 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) { - // copy front buffer to back buffer - if (params.nests.size() > 0) { - draw_clip(params.ctx, params.nests.last()->fbo[2]->handle(), params.nests.last()->fbo[0]->texture(), true); - } else { - draw_clip(params.ctx, params.backend_buffer2, params.main_attachment, true); + // copy front buffer to back buffer (only if we're using blending modes - which we usually will be) + if (!disable_blending) { + if (params.nests.size() > 0) { + draw_clip(params.ctx, params.nests.last()->fbo[2]->handle(), params.nests.last()->fbo[0]->texture(), true); + } else { + draw_clip(params.ctx, params.backend_buffer2, params.main_attachment, true); + } } @@ -502,34 +506,44 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) { // bind front buffer as draw buffer params.ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, final_fbo); - // load background texture into texture unit 0 - params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0 - params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_2); + if (disable_blending) { + // some GPUs don't like the blending shader, so we provide a pure GL fallback here - // load foreground texture into texture unit 1 - params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 1); // Texture unit 1 - params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_1); + params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_1); - // bind and configure blending mode shader - params.blend_mode_program->bind(); - params.blend_mode_program->setUniformValue("blendmode", coords.blendmode); - params.blend_mode_program->setUniformValue("opacity", coords.opacity); - params.blend_mode_program->setUniformValue("background", 0); - params.blend_mode_program->setUniformValue("foreground", 1); + full_blit(); - glClear(GL_COLOR_BUFFER_BIT); + params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0); + } else { + // load background texture into texture unit 0 + params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0 + params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_2); - full_blit(); + // load foreground texture into texture unit 1 + params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 1); // Texture unit 1 + params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, backend_tex_1); - // release blend mode shader - params.blend_mode_program->release(); + // bind and configure blending mode shader + params.blend_mode_program->bind(); + params.blend_mode_program->setUniformValue("blendmode", coords.blendmode); + params.blend_mode_program->setUniformValue("opacity", coords.opacity); + params.blend_mode_program->setUniformValue("background", 0); + params.blend_mode_program->setUniformValue("foreground", 1); - // unbind texture from texture unit 1 - params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0); + glClear(GL_COLOR_BUFFER_BIT); - // unbind texture from texture unit 0 - params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0 - params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0); + full_blit(); + + // release blend mode shader + params.blend_mode_program->release(); + + // unbind texture from texture unit 1 + params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0); + + // unbind texture from texture unit 0 + params.ctx->functions()->glActiveTexture(GL_TEXTURE0 + 0); // Texture unit 0 + params.ctx->functions()->glBindTexture(GL_TEXTURE_2D, 0); + } // unbind framebuffer params.ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); diff --git a/ui/renderfunctions.h b/ui/renderfunctions.h index 0830d6cb4..1fe238db8 100644 --- a/ui/renderfunctions.h +++ b/ui/renderfunctions.h @@ -10,6 +10,8 @@ class QOpenGLShaderProgram; struct Sequence; struct Clip; +extern bool disable_blending; + struct ComposeSequenceParams { Viewer* viewer; QOpenGLContext* ctx;