From 373875c72b8601a9008e27ef66f0cdd51b298ef2 Mon Sep 17 00:00:00 2001
From: itsmattkc
Date: Wed, 30 Jan 2019 14:03:23 +1100
Subject: [PATCH] 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