From 0b0aaa32183210e4e1fc86f8cb6c52fdb5f79af9 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 00:24:09 +1100 Subject: [PATCH 01/25] added reset in or out point --- mainwindow.cpp | 19 +++++++++++++++++++ mainwindow.h | 2 ++ panels/viewer.cpp | 14 ++++++++++++++ panels/viewer.h | 2 ++ 4 files changed, 37 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index d5186842d..473c7f447 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -245,6 +245,9 @@ void MainWindow::make_new_menu(QMenu *parent) { void MainWindow::make_inout_menu(QMenu *parent) { parent->addAction("Set In Point", this, SLOT(set_in_point()), QKeySequence("I")); parent->addAction("Set Out Point", this, SLOT(set_out_point()), QKeySequence("O")); + parent->addSeparator(); + parent->addAction("Reset In Point", this, SLOT(clear_in())); + parent->addAction("Reset Out Point", this, SLOT(clear_out())); parent->addAction("Clear In/Out Point", this, SLOT(clear_inout()), QKeySequence("G")); } @@ -1212,6 +1215,22 @@ void MainWindow::set_out_point() { } } +void MainWindow::clear_in() { + if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { + panel_sequence_viewer->clear_in(); + } else if (panel_footage_viewer->is_focused()) { + panel_footage_viewer->clear_in(); + } +} + +void MainWindow::clear_out() { + if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { + panel_sequence_viewer->clear_out(); + } else if (panel_footage_viewer->is_focused()) { + panel_footage_viewer->clear_out(); + } +} + void MainWindow::clear_inout() { if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { panel_sequence_viewer->clear_inout_point(); diff --git a/mainwindow.h b/mainwindow.h index 124b862c5..ed2748080 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -98,6 +98,8 @@ private slots: void set_in_point(); void set_out_point(); + void clear_in(); + void clear_out(); void clear_inout(); void delete_inout(); void ripple_delete_inout(); diff --git a/panels/viewer.cpp b/panels/viewer.cpp index b8fee4edc..a77a2d423 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -431,6 +431,20 @@ void Viewer::update_viewer() { update_end_timecode(); } +void Viewer::clear_in() { + if (seq->using_workarea) { + undo_stack.push(new SetTimelineInOutCommand(seq, true, 0, seq->workarea_out)); + update_parents(); + } +} + +void Viewer::clear_out() { + if (seq->using_workarea) { + undo_stack.push(new SetTimelineInOutCommand(seq, true, seq->workarea_in, seq->getEndFrame())); + update_parents(); + } +} + void Viewer::clear_inout_point() { if (seq->using_workarea) { undo_stack.push(new SetTimelineInOutCommand(seq, false, 0, 0)); diff --git a/panels/viewer.h b/panels/viewer.h index f08b19e30..03376a3f9 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -37,6 +37,8 @@ public: void update_end_timecode(); void update_header_zoom(); void update_viewer(); + void clear_in(); + void clear_out(); void clear_inout_point(); void set_in_point(); void set_out_point(); From 1a0464179df7dffcc5c37403132cbe2a2f81efe7 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 01:33:02 +1100 Subject: [PATCH 02/25] made timeline in/out toggleable --- dialogs/exportdialog.cpp | 4 ++-- io/loadthread.cpp | 2 ++ mainwindow.cpp | 11 ++++++++++- mainwindow.h | 1 + panels/project.cpp | 3 ++- panels/timeline.cpp | 2 +- panels/viewer.cpp | 17 ++++++++++++----- panels/viewer.h | 1 + project/sequence.cpp | 1 + project/sequence.h | 1 + project/undo.cpp | 3 +++ project/undo.h | 2 ++ ui/timelineheader.cpp | 5 ++--- 13 files changed, 40 insertions(+), 13 deletions(-) diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 7f4c433e0..c7cce721a 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -62,8 +62,8 @@ ExportDialog::ExportDialog(QWidget *parent) : rangeCombobox->setCurrentIndex(0); if (sequence->using_workarea) { - rangeCombobox->setEnabled(sequence->using_workarea); - rangeCombobox->setCurrentIndex(1); + rangeCombobox->setEnabled(true); + if (sequence->enable_workarea) rangeCombobox->setCurrentIndex(1); } format_strings.resize(FORMAT_SIZE); diff --git a/io/loadthread.cpp b/io/loadthread.cpp index 3ae94d103..9e6778136 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -273,6 +273,8 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { open_seq = s; } else if (attr.name() == "workarea") { s->using_workarea = (attr.value() == "1"); + } else if (attr.name() == "workareaEnabled") { + s->enable_workarea = (attr.value() == "1"); } else if (attr.name() == "workareaIn") { s->workarea_in = attr.value().toLong(); } else if (attr.name() == "workareaOut") { diff --git a/mainwindow.cpp b/mainwindow.cpp index 473c7f447..e62e7bf80 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -245,6 +245,7 @@ void MainWindow::make_new_menu(QMenu *parent) { void MainWindow::make_inout_menu(QMenu *parent) { parent->addAction("Set In Point", this, SLOT(set_in_point()), QKeySequence("I")); parent->addAction("Set Out Point", this, SLOT(set_out_point()), QKeySequence("O")); + parent->addAction("Enable/Disable In/Out Point", this, SLOT(enable_inout())); parent->addSeparator(); parent->addAction("Reset In Point", this, SLOT(clear_in())); parent->addAction("Reset Out Point", this, SLOT(clear_out())); @@ -1258,7 +1259,15 @@ void MainWindow::ripple_delete_inout() { if (panel_timeline->focused()) { panel_timeline->delete_in_out(true); - } + } +} + +void MainWindow::enable_inout() { + if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { + panel_sequence_viewer->toggle_enable_inout(); + } else if (panel_footage_viewer->is_focused()) { + panel_footage_viewer->toggle_enable_inout(); + } } void MainWindow::set_tsa_default() { diff --git a/mainwindow.h b/mainwindow.h index ed2748080..ef8d2930a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -103,6 +103,7 @@ private slots: void clear_inout(); void delete_inout(); void ripple_delete_inout(); + void enable_inout(); // title safe area functions void set_tsa_disable(); diff --git a/panels/project.cpp b/panels/project.cpp index faf05daf6..4ecffe3e8 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -944,7 +944,8 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, if (s == sequence) { stream.writeAttribute("open", "1"); } - stream.writeAttribute("workarea", QString::number(s->using_workarea)); + stream.writeAttribute("workarea", QString::number(s->using_workarea)); + stream.writeAttribute("workareaEnabled", QString::number(s->enable_workarea)); stream.writeAttribute("workareaIn", QString::number(s->workarea_in)); stream.writeAttribute("workareaOut", QString::number(s->workarea_out)); diff --git a/panels/timeline.cpp b/panels/timeline.cpp index b450f7e61..2b8a0f4da 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -240,7 +240,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector case MEDIA_TYPE_SEQUENCE: g.out = entry_point + sequence_length - default_clip_in; - if (s->using_workarea) { + if (s->using_workarea && s->enable_workarea) { g.out -= (sequence_length - default_clip_out); } diff --git a/panels/viewer.cpp b/panels/viewer.cpp index a77a2d423..faa33f924 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -257,7 +257,7 @@ void Viewer::go_to_end() { void Viewer::go_to_in() { if (seq != NULL) { - if (seq->using_workarea) { + if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_in); } else { go_to_start(); @@ -275,7 +275,7 @@ void Viewer::next_frame() { void Viewer::go_to_out() { if (seq != NULL) { - if (seq->using_workarea) { + if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_out); } else { go_to_end(); @@ -449,7 +449,14 @@ void Viewer::clear_inout_point() { if (seq->using_workarea) { undo_stack.push(new SetTimelineInOutCommand(seq, false, 0, 0)); update_parents(); - } + } +} + +void Viewer::toggle_enable_inout() { + if (seq != NULL && seq->using_workarea) { + undo_stack.push(new SetBool(&seq->enable_workarea, !seq->enable_workarea)); + update_parents(); + } } void Viewer::set_in_point() { @@ -484,13 +491,13 @@ void Viewer::set_sb_max() { } long Viewer::get_seq_in() { - return (seq->using_workarea) + return (seq->using_workarea && seq->enable_workarea) ? seq->workarea_in : 0; } long Viewer::get_seq_out() { - return (seq->using_workarea && previous_playhead < seq->workarea_out) + return (seq->using_workarea && seq->enable_workarea && previous_playhead < seq->workarea_out) ? seq->workarea_out : seq->getEndFrame(); } diff --git a/panels/viewer.h b/panels/viewer.h index 03376a3f9..af81f1bf3 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -40,6 +40,7 @@ public: void clear_in(); void clear_out(); void clear_inout_point(); + void toggle_enable_inout(); void set_in_point(); void set_out_point(); void set_zoom(bool in); diff --git a/project/sequence.cpp b/project/sequence.cpp index 4450df41f..1a902966d 100644 --- a/project/sequence.cpp +++ b/project/sequence.cpp @@ -8,6 +8,7 @@ Sequence::Sequence() : playhead(0), using_workarea(false), + enable_workarea(true), workarea_in(0), workarea_out(0), wrapper_sequence(false) diff --git a/project/sequence.h b/project/sequence.h index 9ab5c03d9..d3e02504f 100644 --- a/project/sequence.h +++ b/project/sequence.h @@ -28,6 +28,7 @@ struct Sequence { long playhead; bool using_workarea; + bool enable_workarea; long workarea_in; long workarea_out; diff --git a/project/undo.cpp b/project/undo.cpp index be8932c47..d8660a7b5 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -209,6 +209,7 @@ SetTimelineInOutCommand::SetTimelineInOutCommand(Sequence *s, bool enabled, long void SetTimelineInOutCommand::undo() { seq->using_workarea = old_enabled; + seq->enable_workarea = old_workarea_enabled; seq->workarea_in = old_in; seq->workarea_out = old_out; @@ -225,9 +226,11 @@ void SetTimelineInOutCommand::undo() { void SetTimelineInOutCommand::redo() { old_enabled = seq->using_workarea; + old_workarea_enabled = seq->enable_workarea; old_in = seq->workarea_in; old_out = seq->workarea_out; + if (!seq->using_workarea) seq->enable_workarea = true; seq->using_workarea = new_enabled; seq->workarea_in = new_in; seq->workarea_out = new_out; diff --git a/project/undo.h b/project/undo.h index ebc7348de..aaae9a016 100644 --- a/project/undo.h +++ b/project/undo.h @@ -174,6 +174,8 @@ public: private: Sequence* seq; + bool old_workarea_enabled; + bool old_enabled; long old_in; long old_out; diff --git a/ui/timelineheader.cpp b/ui/timelineheader.cpp index 7ea79ac2c..5e7cf4b6a 100644 --- a/ui/timelineheader.cpp +++ b/ui/timelineheader.cpp @@ -321,8 +321,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) { while (true) { long frame = qRound(interval*i); - int lineX = qRound(frame*zoom) - scroll; - int next_lineX = qRound(qRound(interval*(i+1))*zoom) - scroll; + int lineX = qRound(frame*zoom) - scroll; if (lineX > width()) break; @@ -367,7 +366,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) { if (viewer->seq->using_workarea) { in_x = getHeaderScreenPointFromFrame((resizing_workarea ? temp_workarea_in : viewer->seq->workarea_in)); int out_x = getHeaderScreenPointFromFrame((resizing_workarea ? temp_workarea_out : viewer->seq->workarea_out)); - p.fillRect(QRect(in_x, 0, out_x-in_x, height()), QColor(0, 192, 255, 128)); + p.fillRect(QRect(in_x, 0, out_x-in_x, height()), viewer->seq->enable_workarea ? QColor(0, 192, 255, 128) : QColor(255, 255, 255, 64)); p.setPen(Qt::white); p.drawLine(in_x, 0, in_x, height()); p.drawLine(out_x, 0, out_x, height()); From 007d4017f353fde99c36b83af14b37d7cdfb6e56 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 12:26:21 +1100 Subject: [PATCH 03/25] minor playback enhancement --- ui/viewerwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index f46b8c1c3..ef22f953f 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -870,7 +870,7 @@ void ViewerWidget::paintGL() { if (rendering) { dout << "[INFO] Texture failed - looping"; loop = true; - } else { + } else if (!viewer->playing) { retry_timer.start(); } } From 0a48a84e223d3fa651c5c1565f6c9f9cf078384a Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 13:41:20 +1100 Subject: [PATCH 04/25] fixed status message --- main.cpp | 9 ++++----- mainwindow.cpp | 45 +++++++++++++++++++++++---------------------- mainwindow.h | 12 ++++++------ 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/main.cpp b/main.cpp index 88f0a1488..3c8aaf3d9 100644 --- a/main.cpp +++ b/main.cpp @@ -14,10 +14,10 @@ int main(int argc, char *argv[]) { appName += GITHASH; #endif appName += ")"; - + bool launch_fullscreen = false; QString load_proj; - + if (argc > 1) { for (int i=1;iupdate(); } -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent) +MainWindow::MainWindow(QWidget *parent, const QString &an) : + QMainWindow(parent), + appName(an) { enable_launch_with_project = false; @@ -245,10 +246,10 @@ void MainWindow::make_new_menu(QMenu *parent) { void MainWindow::make_inout_menu(QMenu *parent) { parent->addAction("Set In Point", this, SLOT(set_in_point()), QKeySequence("I")); parent->addAction("Set Out Point", this, SLOT(set_out_point()), QKeySequence("O")); - parent->addAction("Enable/Disable In/Out Point", this, SLOT(enable_inout())); - parent->addSeparator(); - parent->addAction("Reset In Point", this, SLOT(clear_in())); - parent->addAction("Reset Out Point", this, SLOT(clear_out())); + parent->addAction("Enable/Disable In/Out Point", this, SLOT(enable_inout())); + parent->addSeparator(); + parent->addAction("Reset In Point", this, SLOT(clear_in())); + parent->addAction("Reset Out Point", this, SLOT(clear_out())); parent->addAction("Clear In/Out Point", this, SLOT(clear_inout()), QKeySequence("G")); } @@ -1217,19 +1218,19 @@ void MainWindow::set_out_point() { } void MainWindow::clear_in() { - if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { - panel_sequence_viewer->clear_in(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->clear_in(); - } + if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { + panel_sequence_viewer->clear_in(); + } else if (panel_footage_viewer->is_focused()) { + panel_footage_viewer->clear_in(); + } } void MainWindow::clear_out() { - if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { - panel_sequence_viewer->clear_out(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->clear_out(); - } + if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { + panel_sequence_viewer->clear_out(); + } else if (panel_footage_viewer->is_focused()) { + panel_footage_viewer->clear_out(); + } } void MainWindow::clear_inout() { @@ -1259,15 +1260,15 @@ void MainWindow::ripple_delete_inout() { if (panel_timeline->focused()) { panel_timeline->delete_in_out(true); - } + } } void MainWindow::enable_inout() { - if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { - panel_sequence_viewer->toggle_enable_inout(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->toggle_enable_inout(); - } + if (panel_timeline->focused() || panel_sequence_viewer->is_focused()) { + panel_sequence_viewer->toggle_enable_inout(); + } else if (panel_footage_viewer->is_focused()) { + panel_footage_viewer->toggle_enable_inout(); + } } void MainWindow::set_tsa_default() { diff --git a/mainwindow.h b/mainwindow.h index ef8d2930a..7b1cd31b3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -11,7 +11,7 @@ class Timeline; class MainWindow : public QMainWindow { Q_OBJECT public: - explicit MainWindow(QWidget *parent = 0); + explicit MainWindow(QWidget *parent, const QString& an); void updateTitle(const QString &url); ~MainWindow(); @@ -23,8 +23,6 @@ public: void load_shortcuts(const QString &fn, bool first = false); void save_shortcuts(const QString &fn); - QString appName; - public slots: void undo(); void redo(); @@ -98,12 +96,12 @@ private slots: void set_in_point(); void set_out_point(); - void clear_in(); - void clear_out(); + void clear_in(); + void clear_out(); void clear_inout(); void delete_inout(); void ripple_delete_inout(); - void enable_inout(); + void enable_inout(); // title safe area functions void set_tsa_disable(); @@ -193,6 +191,8 @@ private: void set_button_action_checked(QAction* a); bool enable_launch_with_project; + + QString appName; }; extern MainWindow* mainWindow; From 404e028ea75c1e67cae1bb6a247b9c185b64d728 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 17:14:37 +1100 Subject: [PATCH 05/25] fixed some import bugs --- panels/project.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/panels/project.cpp b/panels/project.cpp index 4ecffe3e8..aa9a5f9d0 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -394,8 +394,9 @@ bool Project::is_focused() { } Media* Project::new_folder(QString name) { - Media* item = new Media(0); + Media* item = new Media(0); item->set_folder(); + item->set_name(name); return item; } @@ -722,10 +723,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla m->url = file; m->name = get_file_name_from_path(files.at(i)); - item->set_footage(m); - - // generate waveform/thumbnail in another thread - start_preview_generator(item, replace != NULL); + item->set_footage(m); last_imported_media.append(item); @@ -733,7 +731,8 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla if (create_undo_action) { ca->append(new AddMediaCommand(item, parent)); } else { - project_model.appendChild(parent, item); + parent->appendChild(item); +// project_model.appendChild(parent, item); } } @@ -742,7 +741,12 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla } } if (create_undo_action) { - if (imported) { + if (imported) { + for (int i=0;i Date: Fri, 11 Jan 2019 17:30:51 +1100 Subject: [PATCH 06/25] preview generator only starts after media is added --- panels/project.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panels/project.cpp b/panels/project.cpp index aa9a5f9d0..748ad0ced 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -742,12 +742,12 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla } if (create_undo_action) { if (imported) { + undo_stack.push(ca); + for (int i=0;i Date: Fri, 11 Jan 2019 19:04:34 +1100 Subject: [PATCH 07/25] added seek also selects #297 --- io/config.cpp | 7 ++++++- io/config.h | 1 + mainwindow.cpp | 5 +++++ mainwindow.h | 1 + panels/timeline.cpp | 18 +++++++++++++++++- panels/timeline.h | 1 + panels/viewer.cpp | 11 ++++++++--- panels/viewer.h | 2 +- 8 files changed, 40 insertions(+), 6 deletions(-) diff --git a/io/config.cpp b/io/config.cpp index fe5d30a8a..98dd8841e 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -45,7 +45,8 @@ Config::Config() upcoming_queue_size(0.5), upcoming_queue_type(FRAME_QUEUE_TYPE_SECONDS), loop(true), - pause_at_out_point(true) + pause_at_out_point(true), + seek_also_selects(false) {} void Config::load(QString path) { @@ -158,6 +159,9 @@ void Config::load(QString path) { } else if (stream.name() == "PauseAtOutPoint") { stream.readNext(); pause_at_out_point = (stream.text() == "1"); + } else if (stream.name() == "SeekAlsoSelects") { + stream.readNext(); + seek_also_selects = (stream.text() == "1"); } } } @@ -216,6 +220,7 @@ void Config::save(QString path) { stream.writeTextElement("UpcomingFrameQueueType", QString::number(upcoming_queue_type)); stream.writeTextElement("Loop", QString::number(loop)); stream.writeTextElement("PauseAtOutPoint", QString::number(pause_at_out_point)); + stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index ce5a323dc..542443b4b 100644 --- a/io/config.h +++ b/io/config.h @@ -60,6 +60,7 @@ struct Config { int upcoming_queue_type; bool loop; bool pause_at_out_point; + bool seek_also_selects; void load(QString path); void save(QString path); diff --git a/mainwindow.cpp b/mainwindow.cpp index cf8d5795e..e23eed766 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -783,6 +783,10 @@ void MainWindow::setup_menus() { edit_tool_selects_links->setCheckable(true); edit_tool_selects_links->setData(reinterpret_cast(&config.edit_tool_selects_links)); + seek_also_selects = tools_menu->addAction("Seek Also Selects", this, SLOT(toggle_bool_action())); + seek_also_selects->setCheckable(true); + seek_also_selects->setData(reinterpret_cast(&config.seek_also_selects)); + seek_to_end_of_pastes = tools_menu->addAction("Seek to the End of Pastes", this, SLOT(toggle_bool_action())); seek_to_end_of_pastes->setCheckable(true); seek_to_end_of_pastes->setData(reinterpret_cast(&config.paste_seeks)); @@ -1127,6 +1131,7 @@ void MainWindow::toolMenu_About_To_Be_Shown() { set_bool_action_checked(set_name_and_marker); set_bool_action_checked(loop_action); set_bool_action_checked(pause_at_out_point_action); + set_bool_action_checked(seek_also_selects); set_int_action_checked(no_autoscroll, config.autoscroll); set_int_action_checked(page_autoscroll, config.autoscroll); diff --git a/mainwindow.h b/mainwindow.h index 7b1cd31b3..6a71918fa 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -181,6 +181,7 @@ private: QAction* set_name_and_marker; QAction* loop_action; QAction* pause_at_out_point_action; + QAction* seek_also_selects; // edit menu actions QAction* undo_action; diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 2b8a0f4da..c03d61f12 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -476,7 +476,23 @@ void Timeline::select_all() { } void Timeline::scroll_to_frame(long frame) { - scroll_to_frame_internal(horizontalScrollBar, frame, zoom, timeline_area->width()); + scroll_to_frame_internal(horizontalScrollBar, frame, zoom, timeline_area->width()); +} + +void Timeline::select_from_playhead() { + sequence->selections.clear(); + for (int i=0;iclips.size();i++) { + Clip* c = sequence->clips.at(i); + if (c != NULL + && c->timeline_in <= sequence->playhead + && c->timeline_out > sequence->playhead) { + Selection s; + s.in = c->timeline_in; + s.out = c->timeline_out; + s.track = c->track; + sequence->selections.append(s); + } + } } void Timeline::resizeEvent(QResizeEvent *event) { diff --git a/panels/timeline.h b/panels/timeline.h index 7714df242..02ef8240c 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -204,6 +204,7 @@ public: QPushButton* snappingButton; void scroll_to_frame(long frame); + void select_from_playhead(); void resizeEvent(QResizeEvent *event); public slots: diff --git a/panels/viewer.cpp b/panels/viewer.cpp index faa33f924..61781f730 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -238,11 +238,16 @@ bool frame_rate_is_droppable(float rate) { void Viewer::seek(long p) { pause(); seq->playhead = p; + bool update_fx = false; if (main_sequence) { panel_timeline->scroll_to_frame(p); panel_effect_controls->scroll_to_frame(p); + if (config.seek_also_selects) { + panel_timeline->select_from_playhead(); + update_fx = true; + } } - update_parents(); + update_parents(update_fx); reset_all_audio(); audio_scrub = true; } @@ -410,9 +415,9 @@ void Viewer::update_header_zoom() { } } -void Viewer::update_parents() { +void Viewer::update_parents(bool reload_fx) { if (main_sequence) { - update_ui(false); + update_ui(reload_fx); } else { update_viewer(); } diff --git a/panels/viewer.h b/panels/viewer.h index af81f1bf3..6264e88d0 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -63,7 +63,7 @@ public: int recording_track; void reset_all_audio(); - void update_parents(); + void update_parents(bool reload_fx = false); ViewerWidget* viewer_widget; From ee019517b1696ece9852eb80e85ee0ad3ef65653 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 19:38:58 +1100 Subject: [PATCH 08/25] removed minimum width from effect controls --- panels/effectcontrols.cpp | 18 +++++++++++------- panels/effectcontrols.h | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 5e58f3cdf..5e187abfc 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -45,7 +45,7 @@ EffectControls::EffectControls(QWidget *parent) : headers->viewer = panel_sequence_viewer; headers->snapping = false; - effects_area->parent_widget = scrollArea; + effects_area->parent_widget = scrollArea; effects_area->keyframe_area = keyframeView; effects_area->header = headers; keyframeView->header = headers; @@ -260,9 +260,9 @@ void EffectControls::open_effect(QVBoxLayout* layout, Effect* e) { void EffectControls::setup_ui() { QWidget* contents = new QWidget(); - QHBoxLayout* layout = new QHBoxLayout(contents); - layout->setSpacing(0); - layout->setMargin(0); + QHBoxLayout* hlayout = new QHBoxLayout(contents); + hlayout->setSpacing(0); + hlayout->setMargin(0); QSplitter* splitter = new QSplitter(contents); splitter->setOrientation(Qt::Horizontal); @@ -431,7 +431,7 @@ void EffectControls::setup_ui() { splitter->addWidget(keyframeArea); - layout->addWidget(splitter); + hlayout->addWidget(splitter); setWidget(contents); } @@ -546,8 +546,12 @@ bool EffectControls::is_focused() { return false; } -EffectsArea::EffectsArea(QWidget* parent) : QWidget(parent) {} +EffectsArea::EffectsArea(QWidget* parent) : + QWidget(parent) +{} void EffectsArea::resizeEvent(QResizeEvent*) { - parent_widget->setMinimumWidth(sizeHint().width()); +// parent_widget->setMinimumWidth(sizeHint().width()); +// parent_widget->resize(sizeHint().width(), parent_widget->height()); +// parent_widget->updateGeometry(); } diff --git a/panels/effectcontrols.h b/panels/effectcontrols.h index 1201e8a13..5e207e846 100644 --- a/panels/effectcontrols.h +++ b/panels/effectcontrols.h @@ -16,6 +16,7 @@ class ResizableScrollBar; class QLabel; class KeyframeView; class QScrollBar; +class QHBoxLayout; class EffectsArea : public QWidget { public: @@ -53,6 +54,8 @@ public: QScrollBar* verticalScrollBar; QMutex effects_loaded; + + public slots: void update_keyframes(); private slots: @@ -70,7 +73,7 @@ private: void show_effect_menu(int type, int subtype); void load_effects(); void load_keyframes(); - void open_effect(QVBoxLayout* layout, Effect* e); + void open_effect(QVBoxLayout* hlayout, Effect* e); void setup_ui(); From 731300539a820ddca391163835c299442675fd32 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 21:44:21 +1100 Subject: [PATCH 09/25] added seek also selects to play function --- panels/viewer.cpp | 53 +++++++++++++++++++++++++---------------------- panels/viewer.h | 8 +++---- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 61781f730..26f74e9ff 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -238,16 +238,16 @@ bool frame_rate_is_droppable(float rate) { void Viewer::seek(long p) { pause(); seq->playhead = p; - bool update_fx = false; + bool update_fx = false; if (main_sequence) { panel_timeline->scroll_to_frame(p); panel_effect_controls->scroll_to_frame(p); - if (config.seek_also_selects) { - panel_timeline->select_from_playhead(); - update_fx = true; - } + if (config.seek_also_selects) { + panel_timeline->select_from_playhead(); + update_fx = true; + } } - update_parents(update_fx); + update_parents(update_fx); reset_all_audio(); audio_scrub = true; } @@ -262,7 +262,7 @@ void Viewer::go_to_end() { void Viewer::go_to_in() { if (seq != NULL) { - if (seq->using_workarea && seq->enable_workarea) { + if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_in); } else { go_to_start(); @@ -280,7 +280,7 @@ void Viewer::next_frame() { void Viewer::go_to_out() { if (seq != NULL) { - if (seq->using_workarea && seq->enable_workarea) { + if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_out); } else { go_to_end(); @@ -417,7 +417,7 @@ void Viewer::update_header_zoom() { void Viewer::update_parents(bool reload_fx) { if (main_sequence) { - update_ui(reload_fx); + update_ui(reload_fx); } else { update_viewer(); } @@ -437,31 +437,31 @@ void Viewer::update_viewer() { } void Viewer::clear_in() { - if (seq->using_workarea) { - undo_stack.push(new SetTimelineInOutCommand(seq, true, 0, seq->workarea_out)); - update_parents(); - } + if (seq->using_workarea) { + undo_stack.push(new SetTimelineInOutCommand(seq, true, 0, seq->workarea_out)); + update_parents(); + } } void Viewer::clear_out() { - if (seq->using_workarea) { - undo_stack.push(new SetTimelineInOutCommand(seq, true, seq->workarea_in, seq->getEndFrame())); - update_parents(); - } + if (seq->using_workarea) { + undo_stack.push(new SetTimelineInOutCommand(seq, true, seq->workarea_in, seq->getEndFrame())); + update_parents(); + } } void Viewer::clear_inout_point() { if (seq->using_workarea) { undo_stack.push(new SetTimelineInOutCommand(seq, false, 0, 0)); update_parents(); - } + } } void Viewer::toggle_enable_inout() { - if (seq != NULL && seq->using_workarea) { - undo_stack.push(new SetBool(&seq->enable_workarea, !seq->enable_workarea)); - update_parents(); - } + if (seq != NULL && seq->using_workarea) { + undo_stack.push(new SetBool(&seq->enable_workarea, !seq->enable_workarea)); + update_parents(); + } } void Viewer::set_in_point() { @@ -496,13 +496,13 @@ void Viewer::set_sb_max() { } long Viewer::get_seq_in() { - return (seq->using_workarea && seq->enable_workarea) + return (seq->using_workarea && seq->enable_workarea) ? seq->workarea_in : 0; } long Viewer::get_seq_out() { - return (seq->using_workarea && seq->enable_workarea && previous_playhead < seq->workarea_out) + return (seq->using_workarea && seq->enable_workarea && previous_playhead < seq->workarea_out) ? seq->workarea_out : seq->getEndFrame(); } @@ -692,7 +692,10 @@ void Viewer::timer_update() { previous_playhead = seq->playhead; seq->playhead = qRound(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * seq->frame_rate)); - update_parents(); + + if (config.seek_also_selects) panel_timeline->select_from_playhead(); + + update_parents(config.seek_also_selects); long end_frame = get_seq_out(); if (!recording diff --git a/panels/viewer.h b/panels/viewer.h index 6264e88d0..e102c1f57 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -37,10 +37,10 @@ public: void update_end_timecode(); void update_header_zoom(); void update_viewer(); - void clear_in(); - void clear_out(); + void clear_in(); + void clear_out(); void clear_inout_point(); - void toggle_enable_inout(); + void toggle_enable_inout(); void set_in_point(); void set_out_point(); void set_zoom(bool in); @@ -63,7 +63,7 @@ public: int recording_track; void reset_all_audio(); - void update_parents(bool reload_fx = false); + void update_parents(bool reload_fx = false); ViewerWidget* viewer_widget; From 652ac72c1cb4ff577df4658be77e621f7de6bd35 Mon Sep 17 00:00:00 2001 From: Carmot <563580@gmail.com> Date: Fri, 11 Jan 2019 11:51:24 +0100 Subject: [PATCH 10/25] clipboard: vector size only calculated once. transition: check of t pointer inside the check sourcescommon: logical expression simplified. --- io/clipboard.cpp | 6 ++++-- project/sourcescommon.cpp | 2 +- project/transition.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/io/clipboard.cpp b/io/clipboard.cpp index 8a699e379..1c3a8075b 100644 --- a/io/clipboard.cpp +++ b/io/clipboard.cpp @@ -8,14 +8,16 @@ QVector clipboard; QVector clipboard_transitions; void clear_clipboard() { - for (int i=0;i(clipboard.at(i)); } else if (clipboard_type == CLIPBOARD_TYPE_EFFECT) { delete static_cast(clipboard.at(i)); } } - for (int i=0;clipboard_transitions.size();i++) { + clipboard_size = clipboard_transitions.size(); + for (int i=0;iget_type() == MEDIA_TYPE_FOLDER)) { + if (!drop_item.isValid() || m->get_type() == MEDIA_TYPE_FOLDER) { QVector move_items; for (int i=0;i= 0) t->set_length(length); if (t != NULL) { + if (length >= 0) t->set_length(length); QVector& transition_list = (c->sequence == NULL) ? clipboard_transitions : c->sequence->transitions; transition_list.append(t); return transition_list.size() - 1; From e8f632940c20026ea294d1340fad5d666aab0e9f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 11 Jan 2019 23:30:15 +1100 Subject: [PATCH 11/25] added text edit dialog to text effect --- dialogs/texteditdialog.cpp | 36 +++++++++++++++++++++++++++++++++ dialogs/texteditdialog.h | 21 +++++++++++++++++++ effects/internal/texteffect.cpp | 24 ++++++++++++++++++++++ effects/internal/texteffect.h | 4 +++- olive.pro | 6 ++++-- panels/viewer.cpp | 2 -- project/effectfield.h | 4 ++-- 7 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 dialogs/texteditdialog.cpp create mode 100644 dialogs/texteditdialog.h diff --git a/dialogs/texteditdialog.cpp b/dialogs/texteditdialog.cpp new file mode 100644 index 000000000..508a67c4c --- /dev/null +++ b/dialogs/texteditdialog.cpp @@ -0,0 +1,36 @@ +#include "texteditdialog.h" + +#include +#include +#include + +TextEditDialog::TextEditDialog(QWidget *parent, const QString &s) : + QDialog(parent) +{ + setWindowTitle("Edit Text"); + + QVBoxLayout* layout = new QVBoxLayout(); + setLayout(layout); + + textEdit = new QPlainTextEdit(); + textEdit->setPlainText(s); + layout->addWidget(textEdit); + + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + layout->addWidget(buttons); + connect(buttons, SIGNAL(accepted()), this, SLOT(save())); + connect(buttons, SIGNAL(rejected()), this, SLOT(cancel())); +} + +const QString& TextEditDialog::get_string() { + return result_str; +} + +void TextEditDialog::save() { + result_str = textEdit->toPlainText(); + accept(); +} + +void TextEditDialog::cancel() { + reject(); +} diff --git a/dialogs/texteditdialog.h b/dialogs/texteditdialog.h new file mode 100644 index 000000000..b58b99e79 --- /dev/null +++ b/dialogs/texteditdialog.h @@ -0,0 +1,21 @@ +#ifndef TEXTEDITDIALOG_H +#define TEXTEDITDIALOG_H + +#include + +class QPlainTextEdit; + +class TextEditDialog : public QDialog { + Q_OBJECT +public: + TextEditDialog(QWidget* parent = 0, const QString& s = 0); + const QString& get_string(); +private slots: + void save(); + void cancel(); +private: + QString result_str; + QPlainTextEdit* textEdit; +}; + +#endif // TEXTEDITDIALOG_H diff --git a/effects/internal/texteffect.cpp b/effects/internal/texteffect.cpp index 862dca8a9..56b609f80 100644 --- a/effects/internal/texteffect.cpp +++ b/effects/internal/texteffect.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "ui/labelslider.h" #include "ui/collapsiblewidget.h" @@ -19,6 +20,8 @@ #include "ui/comboboxex.h" #include "ui/colorbutton.h" #include "ui/fontcombobox.h" +#include "dialogs/texteditdialog.h" +#include "mainwindow.h" TextEffect::TextEffect(Clip *c, const EffectMeta* em) : Effect(c, em) @@ -27,6 +30,9 @@ TextEffect::TextEffect(Clip *c, const EffectMeta* em) : //enable_shader = true; text_val = add_row("Text")->add_field(EFFECT_FIELD_STRING, "text", 2); + QTextEdit* text_widget = static_cast(text_val->ui_element); + text_widget->setContextMenuPolicy(Qt::CustomContextMenu); + connect(text_widget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(text_edit_menu())); set_font_combobox = add_row("Font")->add_field(EFFECT_FIELD_FONT, "font", 2); @@ -198,6 +204,24 @@ void TextEffect::shadow_enable(bool e) { shadow_opacity->set_enabled(e); } +void TextEffect::text_edit_menu() { + QMenu menu; + + menu.addAction("&Edit Text", this, SLOT(open_text_edit())); + + menu.exec(QCursor::pos()); +} + +void TextEffect::open_text_edit() { + TextEditDialog ted(mainWindow, text_val->get_current_data().toString()); + ted.exec(); + QString result = ted.get_string(); + if (!result.isEmpty()) { + text_val->set_current_data(result); + text_val->ui_element_change(); + } +} + void TextEffect::outline_enable(bool e) { outline_color->set_enabled(e); outline_width->set_enabled(e); diff --git a/effects/internal/texteffect.h b/effects/internal/texteffect.h index 0571ac141..c7c32dd86 100644 --- a/effects/internal/texteffect.h +++ b/effects/internal/texteffect.h @@ -33,8 +33,10 @@ public: private slots: void outline_enable(bool); void shadow_enable(bool); + void text_edit_menu(); + void open_text_edit(); private: - QFont font; + QFont font; }; #endif // TEXTEFFECT_H diff --git a/olive.pro b/olive.pro index 1f8bc78d0..06d662653 100644 --- a/olive.pro +++ b/olive.pro @@ -120,7 +120,8 @@ SOURCES += \ dialogs/actionsearch.cpp \ ui/embeddedfilechooser.cpp \ effects/internal/fillleftrighteffect.cpp \ - effects/internal/voideffect.cpp + effects/internal/voideffect.cpp \ + dialogs/texteditdialog.cpp HEADERS += \ mainwindow.h \ @@ -210,7 +211,8 @@ HEADERS += \ dialogs/actionsearch.h \ ui/embeddedfilechooser.h \ effects/internal/fillleftrighteffect.h \ - effects/internal/voideffect.h + effects/internal/voideffect.h \ + dialogs/texteditdialog.h FORMS += diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 26f74e9ff..3caeedebc 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -692,9 +692,7 @@ void Viewer::timer_update() { previous_playhead = seq->playhead; seq->playhead = qRound(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * seq->frame_rate)); - if (config.seek_also_selects) panel_timeline->select_from_playhead(); - update_parents(config.seek_also_selects); long end_frame = get_seq_out(); diff --git a/project/effectfield.h b/project/effectfield.h index 0e836feaf..1564e9a27 100644 --- a/project/effectfield.h +++ b/project/effectfield.h @@ -68,10 +68,10 @@ public: QWidget* ui_element; void make_key_from_change(ComboAction* ca); +public slots: + void ui_element_change(); private: bool hasKeyframes(); -private slots: - void ui_element_change(); signals: void changed(); void toggled(bool); From 99243155086762078baa6b939e7be03bfc6f9658 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 00:54:39 +1100 Subject: [PATCH 12/25] rewrote debug message handler --- debug.cpp | 58 +++++++++------ debug.h | 11 +-- dialogs/debugdialog.cpp | 26 +++++++ dialogs/debugdialog.h | 21 ++++++ dialogs/exportdialog.cpp | 10 +-- effects/internal/toneeffect.cpp | 2 +- effects/internal/transformeffect.cpp | 2 +- effects/internal/vsthostwin.cpp | 6 +- io/config.cpp | 38 +++++----- io/exportthread.cpp | 102 +++++++++++++-------------- io/loadthread.cpp | 20 +++--- io/previewgenerator.cpp | 6 +- main.cpp | 7 +- mainwindow.cpp | 35 +++++---- mainwindow.h | 3 +- olive.pro | 6 +- panels/effectcontrols.cpp | 14 ++-- panels/project.cpp | 31 ++++---- panels/viewer.cpp | 2 +- playback/audio.cpp | 20 +++--- playback/cacher.cpp | 36 +++++----- playback/playback.cpp | 10 +-- project/effect.cpp | 42 +++++------ project/transition.cpp | 2 +- ui/timelinewidget.cpp | 12 ++-- ui/viewerwidget.cpp | 10 +-- 26 files changed, 301 insertions(+), 231 deletions(-) create mode 100644 dialogs/debugdialog.cpp create mode 100644 dialogs/debugdialog.h diff --git a/debug.cpp b/debug.cpp index 1e64959d8..666a6b203 100644 --- a/debug.cpp +++ b/debug.cpp @@ -3,30 +3,46 @@ #include #include #include +#include -#ifndef QT_DEBUG -QFile debug_file; -QDebug debug_out(&debug_file); -#endif +#include "dialogs/debugdialog.h" -void setup_debug() { -#ifndef QT_DEBUG - debug_file.setFileName(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/debug_log"); - if (debug_file.open(QFile::WriteOnly)) { - QString debug_intro = "Olive Session " + QString::number(QDateTime::currentMSecsSinceEpoch()); - debug_file.write(debug_intro.toUtf8()); - } else { - debug_out = QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).debug(); +QString debug_info; + +void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + QByteArray localMsg = msg.toLocal8Bit(); + switch (type) { + case QtDebugMsg: + fprintf(stderr, "[DEBUG] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + debug_info.prepend(QString("[DEBUG] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); + fflush(stderr); + break; + case QtInfoMsg: + fprintf(stderr, "[INFO] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + debug_info.prepend(QString("[INFO] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); + fflush(stderr); + break; + case QtWarningMsg: + fprintf(stderr, "[WARNING] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + debug_info.prepend(QString("[WARNING] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); + fflush(stderr); + break; + case QtCriticalMsg: + fprintf(stderr, "[ERROR] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + debug_info.prepend(QString("[ERROR] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); + fflush(stderr); + break; + case QtFatalMsg: + fprintf(stderr, "[FATAL] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + debug_info.prepend(QString("[FATAL] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); + fflush(stderr); + abort(); + } + if (debug_dialog->isVisible()) { + QMetaObject::invokeMethod(debug_dialog, "update_log", Qt::QueuedConnection); } -#endif } -void close_debug() { -#ifndef QT_DEBUG - if (debug_file.isOpen()) { - debug_file.putChar(10); - debug_file.putChar(10); - debug_file.close(); - } -#endif +const QString &get_debug_str() { + return debug_info; } diff --git a/debug.h b/debug.h index d7161d57a..bf741056d 100644 --- a/debug.h +++ b/debug.h @@ -3,14 +3,9 @@ #include -#ifndef QT_DEBUG -#define dout debug_out << "\n" -extern QDebug debug_out; -#else -#define dout qDebug() -#endif +void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg); +const QString& get_debug_str(); -void setup_debug(); -void close_debug(); +#define dout qDebug() #endif // DEBUG_H diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp new file mode 100644 index 000000000..b70b24bab --- /dev/null +++ b/dialogs/debugdialog.cpp @@ -0,0 +1,26 @@ +#include "debugdialog.h" + +#include +#include + +#include "debug.h" + +DebugDialog* debug_dialog = NULL; + +DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { + setWindowTitle("Debug Log"); + + QVBoxLayout* layout = new QVBoxLayout(); + setLayout(layout); + + textEdit = new QTextEdit(); + layout->addWidget(textEdit); +} + +void DebugDialog::update_log() { + textEdit->setHtml(get_debug_str()); +} + +void DebugDialog::showEvent(QShowEvent *) { + update_log(); +} diff --git a/dialogs/debugdialog.h b/dialogs/debugdialog.h new file mode 100644 index 000000000..a22deef8e --- /dev/null +++ b/dialogs/debugdialog.h @@ -0,0 +1,21 @@ +#ifndef DEBUGDIALOG_H +#define DEBUGDIALOG_H + +#include +class QTextEdit; + +class DebugDialog : public QDialog { + Q_OBJECT +public: + DebugDialog(QWidget* parent = 0); +public slots: + void update_log(); +protected: + void showEvent(QShowEvent* event); +private: + QTextEdit* textEdit; +}; + +extern DebugDialog* debug_dialog; + +#endif // DEBUGDIALOG_H diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index c7cce721a..edcafc1f9 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -62,8 +62,8 @@ ExportDialog::ExportDialog(QWidget *parent) : rangeCombobox->setCurrentIndex(0); if (sequence->using_workarea) { - rangeCombobox->setEnabled(true); - if (sequence->enable_workarea) rangeCombobox->setCurrentIndex(1); + rangeCombobox->setEnabled(true); + if (sequence->enable_workarea) rangeCombobox->setCurrentIndex(1); } format_strings.resize(FORMAT_SIZE); @@ -286,7 +286,7 @@ void ExportDialog::format_changed(int index) default_acodec = 1; break; default: - dout << "[ERROR] Invalid format selection - this is a bug, please inform the developers"; + qCritical() << "Invalid format selection - this is a bug, please inform the developers"; } AVCodec* codec_info; @@ -388,7 +388,7 @@ void ExportDialog::export_action() { ext = "tif"; break; default: - dout << "[ERROR] Invalid codec selection for an image sequence"; + qCritical() << "Invalid codec selection for an image sequence"; QMessageBox::critical(this, "Invalid codec", "Couldn't determine output parameters for the selected codec. This is a bug, please contact the developers.", QMessageBox::Ok); return; } @@ -453,7 +453,7 @@ void ExportDialog::export_action() { } break; default: - dout << "[ERROR] Invalid format - this is a bug, please inform the developers"; + qCritical() << "Invalid format - this is a bug, please inform the developers"; QMessageBox::critical(this, "Invalid format", "Couldn't determine output format. This is a bug, please contact the developers.", QMessageBox::Ok); return; } diff --git a/effects/internal/toneeffect.cpp b/effects/internal/toneeffect.cpp index b17478e40..1df21ff5c 100644 --- a/effects/internal/toneeffect.cpp +++ b/effects/internal/toneeffect.cpp @@ -50,7 +50,7 @@ void ToneEffect::process_audio(double timecode_start, double timecode_end, quint int presin = sinX; sinX++; if (sinX < presin) { - dout << "[WARNING] Tone effect overflowed"; + qWarning() << "Tone effect overflowed"; } } } diff --git a/effects/internal/transformeffect.cpp b/effects/internal/transformeffect.cpp index ca65a4b9a..e1cf1dde7 100644 --- a/effects/internal/transformeffect.cpp +++ b/effects/internal/transformeffect.cpp @@ -225,7 +225,7 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); break; default: - dout << "[ERROR] Invalid blend mode. This is a bug - please contact developers"; + qCritical() << "Invalid blend mode. This is a bug - please contact developers"; } // opacity diff --git a/effects/internal/vsthostwin.cpp b/effects/internal/vsthostwin.cpp index 093298907..302cb5d34 100644 --- a/effects/internal/vsthostwin.cpp +++ b/effects/internal/vsthostwin.cpp @@ -36,7 +36,7 @@ extern "C" { mainWindow->setWindowModified(true); break; default: - dout << "[INFO] Plugin requested unhandled opcode" << opcode; + qInfo() << "Plugin requested unhandled opcode" << opcode; break; } } @@ -60,7 +60,7 @@ void VSTHostWin::loadPlugin() { modulePtr = LoadLibrary(dll_fn_w); if(modulePtr == NULL) { DWORD dll_err = GetLastError(); - dout << "[ERROR] Failed to load VST" << dll_fn_w << "-" << dll_err; + qCritical() << "Failed to load VST" << dll_fn_w << "-" << dll_err; QString msg_err = "Failed to load VST plugin \"" + dll_fn + "\": " + QString::number(dll_err); if (dll_err == 193) { #ifdef _WIN64 @@ -92,7 +92,7 @@ bool VSTHostWin::configurePluginCallbacks() { // If incorrect, then the file either was not loaded properly, is not a // real VST plugin, or is otherwise corrupt. if(plugin->magic != kEffectMagic) { - dout << "[ERROR] Plugin's magic number is bad"; + qCritical() << "Plugin's magic number is bad"; QMessageBox::critical(mainWindow, "VST Error", "Plugin's magic number is invalid"); return false; } diff --git a/io/config.cpp b/io/config.cpp index 98dd8841e..1da1a8c46 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -43,10 +43,10 @@ Config::Config() previous_queue_size(3), previous_queue_type(FRAME_QUEUE_TYPE_FRAMES), upcoming_queue_size(0.5), - upcoming_queue_type(FRAME_QUEUE_TYPE_SECONDS), - loop(true), - pause_at_out_point(true), - seek_also_selects(false) + upcoming_queue_type(FRAME_QUEUE_TYPE_SECONDS), + loop(true), + pause_at_out_point(true), + seek_also_selects(false) {} void Config::load(QString path) { @@ -153,20 +153,20 @@ void Config::load(QString path) { } else if (stream.name() == "UpcomingFrameQueueType") { stream.readNext(); upcoming_queue_type = stream.text().toInt(); - } else if (stream.name() == "Loop") { - stream.readNext(); - loop = (stream.text() == "1"); - } else if (stream.name() == "PauseAtOutPoint") { - stream.readNext(); - pause_at_out_point = (stream.text() == "1"); - } else if (stream.name() == "SeekAlsoSelects") { - stream.readNext(); - seek_also_selects = (stream.text() == "1"); - } + } else if (stream.name() == "Loop") { + stream.readNext(); + loop = (stream.text() == "1"); + } else if (stream.name() == "PauseAtOutPoint") { + stream.readNext(); + pause_at_out_point = (stream.text() == "1"); + } else if (stream.name() == "SeekAlsoSelects") { + stream.readNext(); + seek_also_selects = (stream.text() == "1"); + } } } if (stream.hasError()) { - dout << "[ERROR] Error parsing config XML." << stream.errorString(); + qCritical() << "Error parsing config XML." << stream.errorString(); } f.close(); @@ -176,7 +176,7 @@ void Config::load(QString path) { void Config::save(QString path) { QFile f(path); if (!f.open(QIODevice::WriteOnly)) { - dout << "[ERROR] Could not save configuration"; + qCritical() << "Could not save configuration"; return; } @@ -218,9 +218,9 @@ void Config::save(QString path) { stream.writeTextElement("PreviousFrameQueueType", QString::number(previous_queue_type)); stream.writeTextElement("UpcomingFrameQueueSize", QString::number(upcoming_queue_size)); stream.writeTextElement("UpcomingFrameQueueType", QString::number(upcoming_queue_type)); - stream.writeTextElement("Loop", QString::number(loop)); - stream.writeTextElement("PauseAtOutPoint", QString::number(pause_at_out_point)); - stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); + stream.writeTextElement("Loop", QString::number(loop)); + stream.writeTextElement("PauseAtOutPoint", QString::number(pause_at_out_point)); + stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/exportthread.cpp b/io/exportthread.cpp index a3e7cf965..5993f0316 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -27,28 +27,28 @@ extern "C" { ExportThread::ExportThread() : continueEncode(true) { surface.create(); - fmt_ctx = NULL; - video_stream = NULL; - vcodec = NULL; - vcodec_ctx = NULL; - video_frame = NULL; - sws_frame = NULL; - sws_ctx = NULL; - audio_stream = NULL; - acodec = NULL; - audio_frame = NULL; - swr_frame = NULL; - acodec_ctx = NULL; - swr_ctx = NULL; + fmt_ctx = NULL; + video_stream = NULL; + vcodec = NULL; + vcodec_ctx = NULL; + video_frame = NULL; + sws_frame = NULL; + sws_ctx = NULL; + audio_stream = NULL; + acodec = NULL; + audio_frame = NULL; + swr_frame = NULL; + acodec_ctx = NULL; + swr_ctx = NULL; - vpkt_alloc = false; - apkt_alloc = false; + vpkt_alloc = false; + apkt_alloc = false; } bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, AVFrame* frame, AVPacket* packet, AVStream* stream, bool rescale) { ret = avcodec_send_frame(codec_ctx, frame); if (ret < 0) { - dout << "[ERROR] Failed to send frame to encoder." << ret; + qCritical() << "Failed to send frame to encoder." << ret; ed->export_error = "failed to send frame to encoder (" + QString::number(ret) + ")"; return false; } @@ -59,7 +59,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, return true; } else if (ret < 0) { if (ret != AVERROR_EOF) { - dout << "[ERROR] Failed to receive packet from encoder." << ret; + qCritical() << "Failed to receive packet from encoder." << ret; ed->export_error = "failed to receive packet from encoder (" + QString::number(ret) + ")"; } return false; @@ -80,7 +80,7 @@ bool ExportThread::setupVideo() { // find video encoder vcodec = avcodec_find_encoder((enum AVCodecID) video_codec); if (!vcodec) { - dout << "[ERROR] Could not find video encoder"; + qCritical() << "Could not find video encoder"; ed->export_error = "could not video encoder for " + QString::number(video_codec); return false; } @@ -89,7 +89,7 @@ bool ExportThread::setupVideo() { video_stream = avformat_new_stream(fmt_ctx, vcodec); video_stream->id = 0; if (!video_stream) { - dout << "[ERROR] Could not allocate video stream"; + qCritical() << "Could not allocate video stream"; ed->export_error = "could not allocate video stream"; return false; } @@ -98,7 +98,7 @@ bool ExportThread::setupVideo() { // vcodec_ctx = video_stream->codec; vcodec_ctx = avcodec_alloc_context3(vcodec); if (!vcodec_ctx) { - dout << "[ERROR] Could not allocate video encoding context"; + qCritical() << "Could not allocate video encoding context"; ed->export_error = "could not allocate video encoding context"; return false; } @@ -135,7 +135,7 @@ bool ExportThread::setupVideo() { ret = avcodec_open2(vcodec_ctx, vcodec, NULL); if (ret < 0) { - dout << "[ERROR] Could not open output video encoder." << ret; + qCritical() << "Could not open output video encoder." << ret; ed->export_error = "could not open output video encoder (" + QString::number(ret) + ")"; return false; } @@ -143,7 +143,7 @@ bool ExportThread::setupVideo() { // copy video encoder parameters to output stream ret = avcodec_parameters_from_context(video_stream->codecpar, vcodec_ctx); if (ret < 0) { - dout << "[ERROR] Could not copy video encoder parameters to output stream." << ret; + qCritical() << "Could not copy video encoder parameters to output stream." << ret; ed->export_error = "could not copy video encoder parameters to output stream (" + QString::number(ret) + ")"; return false; } @@ -187,7 +187,7 @@ bool ExportThread::setupAudio() { // find encoder acodec = avcodec_find_encoder(static_cast(audio_codec)); if (!acodec) { - dout << "[ERROR] Could not find audio encoder"; + qCritical() << "Could not find audio encoder"; ed->export_error = "could not audio encoder for " + QString::number(audio_codec); return false; } @@ -196,7 +196,7 @@ bool ExportThread::setupAudio() { audio_stream = avformat_new_stream(fmt_ctx, acodec); audio_stream->id = 1; if (!audio_stream) { - dout << "[ERROR] Could not allocate audio stream"; + qCritical() << "Could not allocate audio stream"; ed->export_error = "could not allocate audio stream"; return false; } @@ -205,7 +205,7 @@ bool ExportThread::setupAudio() { // acodec_ctx = audio_stream->codec; acodec_ctx = avcodec_alloc_context3(acodec); if (!acodec_ctx) { - dout << "[ERROR] Could not find allocate audio encoding context"; + qCritical() << "Could not find allocate audio encoding context"; ed->export_error = "could not allocate audio encoding context"; return false; } @@ -230,7 +230,7 @@ bool ExportThread::setupAudio() { // open encoder ret = avcodec_open2(acodec_ctx, acodec, NULL); if (ret < 0) { - dout << "[ERROR] Could not open output audio encoder." << ret; + qCritical() << "Could not open output audio encoder." << ret; ed->export_error = "could not open output audio encoder (" + QString::number(ret) + ")"; return false; } @@ -238,7 +238,7 @@ bool ExportThread::setupAudio() { // copy params to output stream ret = avcodec_parameters_from_context(audio_stream->codecpar, acodec_ctx); if (ret < 0) { - dout << "[ERROR] Could not copy audio encoder parameters to output stream." << ret; + qCritical() << "Could not copy audio encoder parameters to output stream." << ret; ed->export_error = "could not copy audio encoder parameters to output stream (" + QString::number(ret) + ")"; return false; } @@ -268,7 +268,7 @@ bool ExportThread::setupAudio() { av_frame_make_writable(audio_frame); ret = av_frame_get_buffer(audio_frame, 0); if (ret < 0) { - dout << "[ERROR] Could not allocate audio buffer." << ret; + qCritical() << "Could not allocate audio buffer." << ret; ed->export_error = "could not allocate audio buffer (" + QString::number(ret) + ")"; return false; } @@ -290,7 +290,7 @@ bool ExportThread::setupAudio() { bool ExportThread::setupContainer() { avformat_alloc_output_context2(&fmt_ctx, NULL, NULL, c_filename); if (!fmt_ctx) { - dout << "[ERROR] Could not create output context"; + qCritical() << "Could not create output context"; ed->export_error = "could not create output format context"; return false; } @@ -299,7 +299,7 @@ bool ExportThread::setupContainer() { ret = avio_open(&fmt_ctx->pb, c_filename, AVIO_FLAG_WRITE); if (ret < 0) { - dout << "[ERROR] Could not open output file." << ret; + qCritical() << "Could not open output file." << ret; ed->export_error = "could not open output file (" + QString::number(ret) + ")"; return false; } @@ -311,7 +311,7 @@ void ExportThread::run() { panel_sequence_viewer->pause(); if (!panel_sequence_viewer->viewer_widget->context()->makeCurrent(&surface)) { - dout << "[ERROR] Make current failed"; + qCritical() << "Make current failed"; ed->export_error = "could not make OpenGL context current"; return; } @@ -330,7 +330,7 @@ void ExportThread::run() { if (continueEncode) { ret = avformat_write_header(fmt_ctx, NULL); if (ret < 0) { - dout << "[ERROR] Could not write output file header." << ret; + qCritical() << "Could not write output file header." << ret; ed->export_error = "could not write output file header (" + QString::number(ret) + ")"; continueEncode = false; } @@ -400,24 +400,24 @@ void ExportThread::run() { avg_time = (total_time/frame_count); eta = (remaining_frames*avg_time); -// dout << "[INFO] Encoded frame" << sequence->playhead << "- took" << frame_time << "ms (avg:" << avg_time << "ms, remaining:" << remaining_frames << ", ETA:" << eta << ")"; +// 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), eta); sequence->playhead++; frame_count++; } - if (continueEncode) { - if (video_enabled) vpkt_alloc = true; - if (audio_enabled) apkt_alloc = true; - } + if (continueEncode) { + if (video_enabled) vpkt_alloc = true; + if (audio_enabled) apkt_alloc = true; + } panel_sequence_viewer->viewer_widget->default_fbo = NULL; rendering = false; fbo.release(); - if (audio_enabled && continueEncode) { + if (audio_enabled && continueEncode) { // flush swresample do { swr_convert_frame(swr_ctx, swr_frame, NULL); @@ -439,7 +439,7 @@ void ExportThread::run() { ret = av_write_trailer(fmt_ctx); if (ret < 0) { - dout << "[ERROR] Could not write output file trailer." << ret; + qCritical() << "Could not write output file trailer." << ret; ed->export_error = "could not write output file trailer (" + QString::number(ret) + ")"; continueEncode = false; } @@ -449,19 +449,19 @@ void ExportThread::run() { avio_closep(&fmt_ctx->pb); - if (vpkt_alloc) av_packet_unref(&video_pkt); - if (video_frame != NULL) av_frame_free(&video_frame); - if (vcodec_ctx != NULL) { - avcodec_close(vcodec_ctx); - avcodec_free_context(&vcodec_ctx); - } + if (vpkt_alloc) av_packet_unref(&video_pkt); + if (video_frame != NULL) av_frame_free(&video_frame); + if (vcodec_ctx != NULL) { + avcodec_close(vcodec_ctx); + avcodec_free_context(&vcodec_ctx); + } - if (apkt_alloc) av_packet_unref(&audio_pkt); - if (audio_frame != NULL) av_frame_free(&audio_frame); - if (acodec_ctx != NULL) { - avcodec_close(acodec_ctx); - avcodec_free_context(&acodec_ctx); - } + if (apkt_alloc) av_packet_unref(&audio_pkt); + if (audio_frame != NULL) av_frame_free(&audio_frame); + if (acodec_ctx != NULL) { + avcodec_close(acodec_ctx); + avcodec_free_context(&acodec_ctx); + } avformat_free_context(fmt_ctx); diff --git a/io/loadthread.cpp b/io/loadthread.cpp index 9e6778136..06d0fc3c7 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -209,19 +209,19 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { if (QFileInfo::exists(proj_dir_test)) { // if path is relative to the project's current dir m->url = proj_dir_test; - dout << "[INFO] Matched" << attr.value().toString() << "relative to project's current directory"; + qInfo() << "Matched" << attr.value().toString() << "relative to project's current directory"; } else if (QFileInfo::exists(internal_proj_dir_test)) { // if path is relative to the last directory the project was saved in m->url = internal_proj_dir_test; - dout << "[INFO] Matched" << attr.value().toString() << "relative to project's internal directory"; + qInfo() << "Matched" << attr.value().toString() << "relative to project's internal directory"; } else if (m->url.contains('%')) { // hack for image sequences (qt won't be able to find the URL with %, but ffmpeg may) m->url = internal_proj_dir_test; - dout << "[INFO] Guess image sequence" << attr.value().toString() << "path to project's internal directory"; + qInfo() << "Guess image sequence" << attr.value().toString() << "path to project's internal directory"; } else { - dout << "[INFO] Failed to match" << attr.value().toString() << "to file"; + qInfo() << "Failed to match" << attr.value().toString() << "to file"; } } else { - dout << "[INFO] Matched" << attr.value().toString() << "with absolute path"; + qInfo() << "Matched" << attr.value().toString() << "with absolute path"; } } else if (attr.name() == "duration") { m->length = attr.value().toLongLong(); @@ -273,8 +273,8 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { open_seq = s; } else if (attr.name() == "workarea") { s->using_workarea = (attr.value() == "1"); - } else if (attr.name() == "workareaEnabled") { - s->enable_workarea = (attr.value() == "1"); + } else if (attr.name() == "workareaEnabled") { + s->enable_workarea = (attr.value() == "1"); } else if (attr.name() == "workareaIn") { s->workarea_in = attr.value().toLong(); } else if (attr.name() == "workareaOut") { @@ -471,7 +471,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { } const EffectMeta* meta = get_meta_from_name(td.name); if (meta == NULL) { - dout << "[WARNING] Failed to link transition with name:" << td.name; + qWarning() << "Failed to link transition with name:" << td.name; if (td.otc != NULL) td.otc->opening_transition = -1; if (td.ctc != NULL) td.ctc->closing_transition = -1; } else { @@ -514,7 +514,7 @@ void LoadThread::run() { QFile file(project_url); if (!file.open(QIODevice::ReadOnly)) { - dout << "[ERROR] Could not open file"; + qCritical() << "Could not open file"; return; } @@ -623,7 +623,7 @@ void LoadThread::cancel() { void LoadThread::error_func() { if (xml_error) { - dout << "[ERROR] Error parsing XML." << error_str; + qCritical() << "Error parsing XML." << error_str; QMessageBox::critical(mainWindow, "XML Parsing Error", "Couldn't load '" + project_url + "'. " + error_str, QMessageBox::Ok); } else { QMessageBox::critical(mainWindow, "Project Load Error", "Error loading project: " + error_str, QMessageBox::Ok); diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index 6c27e3932..cbc386743 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -53,7 +53,7 @@ void PreviewGenerator::parse_media() { for (int i=0;i<(int)fmt_ctx->nb_streams;i++) { // Find the decoder for the video stream if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == NULL) { - dout << "[ERROR] Unsupported codec in stream" << i << "of file" << footage->name; + qCritical() << "Unsupported codec in stream" << i << "of file" << footage->name; } else { FootageStream ms; ms.preview_done = false; @@ -253,13 +253,13 @@ void PreviewGenerator::generate_waveform() { if (read_ret < 0) { end_of_file = true; - if (read_ret != AVERROR_EOF) dout << "[ERROR] Failed to read packet for preview generation" << read_ret; + if (read_ret != AVERROR_EOF) qCritical() << "Failed to read packet for preview generation" << read_ret; break; } if (codec_ctx[packet->stream_index] != NULL) { int send_ret = avcodec_send_packet(codec_ctx[packet->stream_index], packet); if (send_ret < 0 && send_ret != AVERROR(EAGAIN)) { - dout << "[ERROR] Failed to send packet for preview generation - aborting" << send_ret; + qCritical() << "Failed to send packet for preview generation - aborting" << send_ret; end_of_file = true; break; } diff --git a/main.cpp b/main.cpp index 3c8aaf3d9..995e29357 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include -#include + +#include "debug.h" extern "C" { #include @@ -18,12 +19,14 @@ int main(int argc, char *argv[]) { bool launch_fullscreen = false; QString load_proj; + qInstallMessageHandler(debug_message_handler); + if (argc > 1) { for (int i=1;i 0) dout << "[INFO] Deleted" << deleted_ars << "autorecovery" << ((deleted_ars == 1) ? "file that was" : "files that were") << "older than 7 days"; + if (deleted_ars > 0) qInfo() << "Deleted" << deleted_ars << "autorecovery" << ((deleted_ars == 1) ? "file that was" : "files that were") << "older than 7 days"; // delete previews older than 30 days QDir preview_dir = QDir(data_dir + "/previews"); @@ -168,7 +168,7 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) : if (QFile(file_name).remove()) deleted_ars++; } } - if (deleted_ars > 0) dout << "[INFO] Deleted" << deleted_ars << "preview" << ((deleted_ars == 1) ? "file that was" : "files that were") << "last read over 30 days ago"; + if (deleted_ars > 0) qInfo() << "Deleted" << deleted_ars << "preview" << ((deleted_ars == 1) ? "file that was" : "files that were") << "last read over 30 days ago"; } // search for open recents list @@ -227,7 +227,6 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) : MainWindow::~MainWindow() { free_panels(); - close_debug(); } void MainWindow::launch_with_project(const QString& s) { @@ -327,7 +326,7 @@ void MainWindow::save_shortcuts(const QString& fn) { shortcut_file_io.write(shortcut_file); shortcut_file_io.close(); } else { - dout << "[ERROR] Failed to save shortcut file"; + qCritical() << "Failed to save shortcut file"; } } @@ -336,6 +335,10 @@ void MainWindow::show_about() { a.exec(); } +void MainWindow::show_debug_log() { + debug_dialog->show(); +} + void MainWindow::delete_slot() { if (panel_timeline->headers->hasFocus()) { panel_timeline->headers->delete_markers(); @@ -479,7 +482,7 @@ void MainWindow::new_project() { void MainWindow::autorecover_interval() { if (!rendering && isWindowModified()) { panel_project->save_project(true); - dout << "[INFO] Auto-recovery project saved"; + qInfo() << "Auto-recovery project saved"; } } @@ -783,9 +786,9 @@ void MainWindow::setup_menus() { edit_tool_selects_links->setCheckable(true); edit_tool_selects_links->setData(reinterpret_cast(&config.edit_tool_selects_links)); - seek_also_selects = tools_menu->addAction("Seek Also Selects", this, SLOT(toggle_bool_action())); - seek_also_selects->setCheckable(true); - seek_also_selects->setData(reinterpret_cast(&config.seek_also_selects)); + seek_also_selects = tools_menu->addAction("Seek Also Selects", this, SLOT(toggle_bool_action())); + seek_also_selects->setCheckable(true); + seek_also_selects->setData(reinterpret_cast(&config.seek_also_selects)); seek_to_end_of_pastes = tools_menu->addAction("Seek to the End of Pastes", this, SLOT(toggle_bool_action())); seek_to_end_of_pastes->setCheckable(true); @@ -861,6 +864,10 @@ void MainWindow::setup_menus() { help_menu->addSeparator(); + help_menu->addAction("Debug Log", this, SLOT(show_debug_log())); + + help_menu->addSeparator(); + help_menu->addAction("&About...", this, SLOT(show_about())); load_shortcuts(get_config_path() + "/shortcuts", true); @@ -913,7 +920,7 @@ void MainWindow::closeEvent(QCloseEvent *e) { panel_config.write(saveState(0)); panel_config.close(); } else { - dout << "[ERROR] Failed to save layout"; + qCritical() << "Failed to save layout"; } save_shortcuts(config_dir + "/shortcuts"); @@ -1131,7 +1138,7 @@ void MainWindow::toolMenu_About_To_Be_Shown() { set_bool_action_checked(set_name_and_marker); set_bool_action_checked(loop_action); set_bool_action_checked(pause_at_out_point_action); - set_bool_action_checked(seek_also_selects); + set_bool_action_checked(seek_also_selects); set_int_action_checked(no_autoscroll, config.autoscroll); set_int_action_checked(page_autoscroll, config.autoscroll); diff --git a/mainwindow.h b/mainwindow.h index 6a71918fa..d4a3a6025 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -43,6 +43,7 @@ private slots: void clear_undo_stack(); void show_about(); + void show_debug_log(); void delete_slot(); void select_all(); @@ -181,7 +182,7 @@ private: QAction* set_name_and_marker; QAction* loop_action; QAction* pause_at_out_point_action; - QAction* seek_also_selects; + QAction* seek_also_selects; // edit menu actions QAction* undo_action; diff --git a/olive.pro b/olive.pro index 06d662653..112eb4e83 100644 --- a/olive.pro +++ b/olive.pro @@ -121,7 +121,8 @@ SOURCES += \ ui/embeddedfilechooser.cpp \ effects/internal/fillleftrighteffect.cpp \ effects/internal/voideffect.cpp \ - dialogs/texteditdialog.cpp + dialogs/texteditdialog.cpp \ + dialogs/debugdialog.cpp HEADERS += \ mainwindow.h \ @@ -212,7 +213,8 @@ HEADERS += \ ui/embeddedfilechooser.h \ effects/internal/fillleftrighteffect.h \ effects/internal/voideffect.h \ - dialogs/texteditdialog.h + dialogs/texteditdialog.h \ + dialogs/debugdialog.h FORMS += diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 5e187abfc..aab9635a2 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -45,7 +45,7 @@ EffectControls::EffectControls(QWidget *parent) : headers->viewer = panel_sequence_viewer; headers->snapping = false; - effects_area->parent_widget = scrollArea; + effects_area->parent_widget = scrollArea; effects_area->keyframe_area = keyframeView; effects_area->header = headers; keyframeView->header = headers; @@ -260,9 +260,9 @@ void EffectControls::open_effect(QVBoxLayout* layout, Effect* e) { void EffectControls::setup_ui() { QWidget* contents = new QWidget(); - QHBoxLayout* hlayout = new QHBoxLayout(contents); - hlayout->setSpacing(0); - hlayout->setMargin(0); + QHBoxLayout* hlayout = new QHBoxLayout(contents); + hlayout->setSpacing(0); + hlayout->setMargin(0); QSplitter* splitter = new QSplitter(contents); splitter->setOrientation(Qt::Horizontal); @@ -431,7 +431,7 @@ void EffectControls::setup_ui() { splitter->addWidget(keyframeArea); - hlayout->addWidget(splitter); + hlayout->addWidget(splitter); setWidget(contents); } @@ -540,14 +540,14 @@ bool EffectControls::is_focused() { } } } else { - dout << "[WARNING] Tried to check focus of a NULL clip"; + qWarning() << "Tried to check focus of a NULL clip"; } } return false; } EffectsArea::EffectsArea(QWidget* parent) : - QWidget(parent) + QWidget(parent) {} void EffectsArea::resizeEvent(QResizeEvent*) { diff --git a/panels/project.cpp b/panels/project.cpp index 748ad0ced..eafb8da23 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -283,7 +283,6 @@ void Project::duplicate_selected() { bool duped = false; ComboAction* ca = new ComboAction(); for (int j=0;jget_type() == MEDIA_TYPE_SEQUENCE) { new_sequence(ca, i->to_sequence()->copy(), false, item_to_media(items.at(j).parent())); @@ -394,9 +393,9 @@ bool Project::is_focused() { } Media* Project::new_folder(QString name) { - Media* item = new Media(0); + Media* item = new Media(0); item->set_folder(); - item->set_name(name); + item->set_name(name); return item; } @@ -528,7 +527,7 @@ void Project::delete_selected_media() { // remove if (remove) { panel_effect_controls->clear_effects(true); - if (sequence != NULL) sequence->selections.clear(); + if (sequence != NULL) sequence->selections.clear(); // remove media and parents for (int m=0;murl = file; m->name = get_file_name_from_path(files.at(i)); - item->set_footage(m); + item->set_footage(m); last_imported_media.append(item); @@ -731,7 +730,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla if (create_undo_action) { ca->append(new AddMediaCommand(item, parent)); } else { - parent->appendChild(item); + parent->appendChild(item); // project_model.appendChild(parent, item); } } @@ -741,13 +740,13 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla } } if (create_undo_action) { - if (imported) { - undo_stack.push(ca); + if (imported) { + undo_stack.push(ca); - for (int i=0;iusing_workarea)); - stream.writeAttribute("workareaEnabled", QString::number(s->enable_workarea)); + stream.writeAttribute("workarea", QString::number(s->using_workarea)); + stream.writeAttribute("workareaEnabled", QString::number(s->enable_workarea)); stream.writeAttribute("workareaIn", QString::number(s->workarea_in)); stream.writeAttribute("workareaOut", QString::number(s->workarea_out)); @@ -1042,7 +1041,7 @@ void Project::save_project(bool autorecovery) { QFile file(autorecovery ? autorecovery_filename : project_url); if (!file.open(QIODevice::WriteOnly/* | QIODevice::Text*/)) { - dout << "[ERROR] Could not open file"; + qCritical() << "Could not open file"; return; } @@ -1122,7 +1121,7 @@ void Project::save_recent_projects() { } f.close(); } else { - dout << "[WARNING] Could not save recent projects"; + qWarning() << "Could not save recent projects"; } } diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 3caeedebc..eb713724d 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -328,7 +328,7 @@ void Viewer::play() { reset_all_audio(); if (is_recording_cued() && !start_recording()) { - dout << "[ERROR] Failed to record audio"; + qCritical() << "Failed to record audio"; return; } playhead_start = seq->playhead; diff --git a/playback/audio.cpp b/playback/audio.cpp index 302ad6af6..71c71b81b 100644 --- a/playback/audio.cpp +++ b/playback/audio.cpp @@ -55,18 +55,18 @@ void init_audio() { QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); QList devs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); - dout << "[INFO] Found the following audio devices:"; + qInfo() << "Found the following audio devices:"; for (int i=0;i 0) { - dout << "[WARNING] Default audio returned NULL, attempting to use first device found..."; + qWarning() << "Default audio returned NULL, attempting to use first device found..."; info = devs.at(0); } - dout << "[INFO] Using audio device" << info.deviceName(); + qInfo() << "Using audio device" << info.deviceName(); if (!info.isFormatSupported(audio_format)) { - qWarning() << "[WARNING] Audio format is not supported by backend, using nearest"; + qWarning() << "Audio format is not supported by backend, using nearest"; audio_format = info.nearestFormat(audio_format); } @@ -77,7 +77,7 @@ void init_audio() { // connect audio_io_device = audio_output->start(); if (audio_io_device == NULL) { - dout << "[WARNING] Received NULL audio device. No compatible audio output was found."; + qWarning() << "Received NULL audio device. No compatible audio output was found."; } else { audio_device_set = true; @@ -115,7 +115,7 @@ int get_buffer_offset_from_frame(double framerate, long frame) { if (frame >= audio_ibuffer_frame) { return qFloor(((double) (frame - audio_ibuffer_frame)/framerate)*current_audio_freq())*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16)*av_get_channel_layout_nb_channels(AV_CH_LAYOUT_STEREO); } else { - dout << "[WARNING] Invalid values passed to get_buffer_offset_from_frame"; + qWarning() << "Invalid values passed to get_buffer_offset_from_frame"; return 0; } } @@ -288,14 +288,14 @@ void write_wave_trailer(QFile& f) { bool start_recording() { if (sequence == NULL) { - dout << "[ERROR] No active sequence to record into"; + qCritical() << "No active sequence to record into"; return false; } QString audio_path = project_url + " Audio"; QDir audio_dir(audio_path); if (!audio_dir.exists() && !audio_dir.mkpath(".")) { - dout << "[ERROR] Failed to create audio directory"; + qCritical() << "Failed to create audio directory"; return false; } @@ -308,7 +308,7 @@ bool start_recording() { output_recording.setFileName(audio_filename); if (!output_recording.open(QFile::WriteOnly)) { - dout << "[ERROR] Failed to open output file. Does Olive have permission to write to this directory?"; + qCritical() << "Failed to open output file. Does Olive have permission to write to this directory?"; return false; } @@ -318,7 +318,7 @@ bool start_recording() { } QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice(); if (!info.isFormatSupported(audio_format)) { - dout << "[WARNING] Default format not supported, using nearest"; + qWarning() << "Default format not supported, using nearest"; audio_format = info.nearestFormat(audio_format); } write_wave_header(output_recording, audio_format); diff --git a/playback/cacher.cpp b/playback/cacher.cpp index e172d534f..cc6cddd56 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -168,7 +168,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { ret = retrieve_next_frame(c, c->frame); if (ret >= 0) { if ((ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, c->frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) { - dout << "[ERROR] Could not feed filtergraph -" << ret; + qCritical() << "Could not feed filtergraph -" << ret; break; } } else { @@ -182,7 +182,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { } else { } } else { - dout << "[WARNING] Raw audio frame data could not be retrieved." << ret; + qWarning() << "Raw audio frame data could not be retrieved." << ret; c->reached_end = true; } break; @@ -191,7 +191,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { if (ret < 0) { if (ret != AVERROR_EOF) { - dout << "[ERROR] Could not pull from filtergraph"; + qCritical() << "Could not pull from filtergraph"; c->reached_end = true; break; } else { @@ -356,7 +356,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { } } else { // shouldn't ever get here - dout << "[ERROR] Tried to cache a non-footage/tone clip"; + qCritical() << "Tried to cache a non-footage/tone clip"; return; } @@ -478,7 +478,7 @@ void cache_video_worker(Clip* c, long playhead) { if (send_it) { if ((send_ret = av_buffersrc_add_frame_flags(c->buffersrc_ctx, send_frame, AV_BUFFERSRC_FLAG_KEEP_REF)) < 0) { - dout << "[ERROR] Failed to add frame to buffer source." << send_ret; + qCritical() << "Failed to add frame to buffer source." << send_ret; break; } } @@ -488,7 +488,7 @@ void cache_video_worker(Clip* c, long playhead) { if (read_ret == AVERROR_EOF) { c->reached_end = true; } else { - dout << "[ERROR] Failed to read frame." << read_ret; + qCritical() << "Failed to read frame." << read_ret; } break; } @@ -498,7 +498,7 @@ void cache_video_worker(Clip* c, long playhead) { if (retr_ret == AVERROR_EOF) { c->reached_end = true; } else { - dout << "[ERROR] Failed to retrieve frame from buffersink." << retr_ret; + qCritical() << "Failed to retrieve frame from buffersink." << retr_ret; } av_frame_free(&frame); break; @@ -577,7 +577,7 @@ void reset_cache(Clip* c, long target_frame) { av_frame_unref(c->frame); int ret = retrieve_next_frame(c, c->frame); if (ret < 0) { - dout << "[WARNING] Seeking terminated prematurely"; + qWarning() << "Seeking terminated prematurely"; break; } if (c->frame->pts <= target_ts) { @@ -635,7 +635,7 @@ void open_clip_worker(Clip* clip) { clip->frame->nb_samples = 2048; av_frame_make_writable(clip->frame); if (av_frame_get_buffer(clip->frame, 0)) { - dout << "[ERROR] Could not allocate buffer for tone clip"; + qCritical() << "Could not allocate buffer for tone clip"; } clip->audio_reset = true; } @@ -655,7 +655,7 @@ void open_clip_worker(Clip* clip) { if (errCode != 0) { char err[1024]; av_strerror(errCode, err, 1024); - dout << "[ERROR] Could not open" << filename << "-" << err; + qCritical() << "Could not open" << filename << "-" << err; return; } @@ -663,7 +663,7 @@ void open_clip_worker(Clip* clip) { if (errCode < 0) { char err[1024]; av_strerror(errCode, err, 1024); - dout << "[ERROR] Could not open" << filename << "-" << err; + qCritical() << "Could not open" << filename << "-" << err; return; } @@ -709,13 +709,13 @@ void open_clip_worker(Clip* clip) { // Open codec if (avcodec_open2(clip->codecCtx, clip->codec, &clip->opts) < 0) { - dout << "[ERROR] Could not open codec"; + qCritical() << "Could not open codec"; } // allocate filtergraph clip->filter_graph = avfilter_graph_alloc(); if (clip->filter_graph == NULL) { - dout << "[ERROR] Could not create filtergraph"; + qCritical() << "Could not create filtergraph"; } char filter_args[512]; @@ -807,12 +807,12 @@ void open_clip_worker(Clip* clip) { enum AVSampleFormat sample_fmts[] = { sample_format, static_cast(-1) }; if (av_opt_set_int_list(clip->buffersink_ctx, "sample_fmts", sample_fmts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { - dout << "[ERROR] Could not set output sample format"; + qCritical() << "Could not set output sample format"; } int64_t channel_layouts[] = { AV_CH_LAYOUT_STEREO, static_cast(-1) }; if (av_opt_set_int_list(clip->buffersink_ctx, "channel_layouts", channel_layouts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { - dout << "[ERROR] Could not set output sample format"; + qCritical() << "Could not set output sample format"; } int target_sample_rate = current_audio_freq(); @@ -858,7 +858,7 @@ void open_clip_worker(Clip* clip) { int sample_rates[] = { target_sample_rate, 0 }; if (av_opt_set_int_list(clip->buffersink_ctx, "sample_rates", sample_rates, 0, AV_OPT_SEARCH_CHILDREN) < 0) { - dout << "[ERROR] Could not set output sample rates"; + qCritical() << "Could not set output sample rates"; } avfilter_graph_config(clip->filter_graph, NULL); @@ -875,7 +875,7 @@ void open_clip_worker(Clip* clip) { clip->finished_opening = true; - dout << "[INFO] Clip opened on track" << clip->track; + qInfo() << "Clip opened on track" << clip->track; } void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QVector nests) { @@ -918,7 +918,7 @@ void close_clip_worker(Clip* clip) { clip->reset(); - dout << "[INFO] Clip closed on track" << clip->track; + qInfo() << "Clip closed on track" << clip->track; } void Cacher::run() { diff --git a/playback/playback.cpp b/playback/playback.cpp index e8a64a0c7..d6faaa28f 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -243,7 +243,7 @@ void get_clip_frame(Clip* c, long playhead) { if (target_frame == NULL || reset) { // reset cache texture_failed = true; - dout << "[INFO] Frame queue couldn't keep up - either the user seeked or the system is overloaded (queue size:" << c->queue.size() << ")"; + qInfo() << "Frame queue couldn't keep up - either the user seeked or the system is overloaded (queue size:" << c->queue.size() << ")"; } if (target_frame != NULL) { @@ -325,24 +325,24 @@ int retrieve_next_frame(Clip* c, AVFrame* f) { if (read_ret >= 0) { int send_ret = avcodec_send_packet(c->codecCtx, c->pkt); if (send_ret < 0) { - dout << "[ERROR] Failed to send packet to decoder." << send_ret; + qCritical() << "Failed to send packet to decoder." << send_ret; return send_ret; } } else { if (read_ret == AVERROR_EOF) { int send_ret = avcodec_send_packet(c->codecCtx, NULL); if (send_ret < 0) { - dout << "[ERROR] Failed to send packet to decoder." << send_ret; + qCritical() << "Failed to send packet to decoder." << send_ret; return send_ret; } } else { - dout << "[ERROR] Could not read frame." << read_ret; + qCritical() << "Could not read frame." << read_ret; return read_ret; // skips trying to find a frame at all } } } if (receive_ret < 0) { - if (receive_ret != AVERROR_EOF) dout << "[ERROR] Failed to receive packet from decoder." << receive_ret; + if (receive_ret != AVERROR_EOF) qCritical() << "Failed to receive packet from decoder." << receive_ret; result = receive_ret; } diff --git a/project/effect.cpp b/project/effect.cpp index 7468a757d..de62ec7c9 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -69,7 +69,7 @@ Effect* create_effect(Clip* c, const EffectMeta* em) { #endif } } else { - dout << "[ERROR] Invalid effect data"; + qCritical() << "Invalid effect data"; QMessageBox::critical(mainWindow, "Invalid effect", "No candidate for effect '" + em->name + "'. This effect may be corrupt. Try reinstalling it or Olive."); } return NULL; @@ -192,7 +192,7 @@ void load_shader_effects() { for (int i=0;ieffects_loaded.unlock(); - dout << "[INFO] Finished initializing effects"; + qInfo() << "Finished initializing effects"; } Effect::Effect(Clip* c, const EffectMeta *em) : @@ -334,7 +334,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) : } if (id.isEmpty()) { - dout << "[ERROR] Couldn't load field from" << em->filename << "- ID cannot be empty."; + qCritical() << "Couldn't load field from" << em->filename << "- ID cannot be empty."; } else if (type > -1) { EffectField* field = row->add_field(type, id); connect(field, SIGNAL(changed()), this, SLOT(field_changed())); @@ -453,7 +453,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) : if (script_file.open(QFile::ReadOnly)) { script = script_file.readAll(); } else { - dout << "[ERROR] Failed to open superimpose script file for" << em->filename; + qCritical() << "Failed to open superimpose script file for" << em->filename; enable_superimpose = false; } break; @@ -465,7 +465,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) : effect_file.close(); } else { - dout << "[ERROR] Failed to open effect file" << em->filename; + qCritical() << "Failed to open effect file" << em->filename; } } } @@ -661,7 +661,7 @@ void Effect::load(QXmlStreamReader& stream) { if (row->field(l)->id == attr.value()) { field_number = l; found_field_by_id = true; - dout << "[INFO] Found field by ID"; + qInfo() << "Found field by ID"; break; } } @@ -710,14 +710,14 @@ void Effect::load(QXmlStreamReader& stream) { } } } else { - dout << "[ERROR] Too many fields for effect" << id << "row" << row_count << ". Project might be corrupt. (Got" << field_count << ", expected <" << row->fieldCount()-1 << ")"; + qCritical() << "Too many fields for effect" << id << "row" << row_count << ". Project might be corrupt. (Got" << field_count << ", expected <" << row->fieldCount()-1 << ")"; } field_count++; } } } else { - dout << "[ERROR] Too many rows for effect" << id << ". Project might be corrupt. (Got" << row_count << ", expected <" << rows.size()-1 << ")"; + qCritical() << "Too many rows for effect" << id << ". Project might be corrupt. (Got" << row_count << ", expected <" << rows.size()-1 << ")"; } row_count++; } else if (stream.isStartElement()) { @@ -783,37 +783,37 @@ void Effect::validate_meta_path() { void Effect::open() { if (isOpen) { - dout << "[WARNING] Tried to open an effect that was already open"; + qWarning() << "Tried to open an effect that was already open"; close(); } if (enable_shader) { if (QOpenGLContext::currentContext() == NULL) { - dout << "[WARNING] No current context to create a shader program for - will retry next repaint"; + qWarning() << "No current context to create a shader program for - will retry next repaint"; } else { glslProgram = new QOpenGLShaderProgram(); validate_meta_path(); bool glsl_compiled = true; if (!vertPath.isEmpty()) { if (glslProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, meta->path + "/" + vertPath)) { - dout << "[INFO] Vertex shader added successfully"; + qInfo() << "Vertex shader added successfully"; } else { glsl_compiled = false; - dout << "[WARNING] Vertex shader could not be added"; + qWarning() << "Vertex shader could not be added"; } } if (!fragPath.isEmpty()) { if (glslProgram->addShaderFromSourceFile(QOpenGLShader::Fragment, meta->path + "/" + fragPath)) { - dout << "[INFO] Fragment shader added successfully"; + qInfo() << "Fragment shader added successfully"; } else { glsl_compiled = false; - dout << "[WARNING] Fragment shader could not be added"; + qWarning() << "Fragment shader could not be added"; } } if (glsl_compiled) { if (glslProgram->link()) { - dout << "[INFO] Shader program linked successfully"; + qInfo() << "Shader program linked successfully"; } else { - dout << "[WARNING] Shader program failed to link"; + qWarning() << "Shader program failed to link"; } } isOpen = true; @@ -829,7 +829,7 @@ void Effect::open() { void Effect::close() { if (!isOpen) { - dout << "[WARNING] Tried to close an effect that was already closed"; + qWarning() << "Tried to close an effect that was already closed"; } delete_texture(); if (glslProgram != NULL) { @@ -846,7 +846,7 @@ bool Effect::is_glsl_linked() { void Effect::startEffect() { if (!isOpen) { open(); - dout << "[WARNING] Tried to start a closed effect - opening"; + qWarning() << "Tried to start a closed effect - opening"; } if (enable_shader && glslProgram->isLinked()) bound = glslProgram->bind(); } diff --git a/project/transition.cpp b/project/transition.cpp index 8ee186001..3badb5ca3 100644 --- a/project/transition.cpp +++ b/project/transition.cpp @@ -73,7 +73,7 @@ Transition* get_transition_from_meta(Clip* c, Clip* s, const EffectMeta* em) { case TRANSITION_INTERNAL_CUBE: return new CubeTransition(c, s, em); } } else { - dout << "[ERROR] Invalid transition data"; + qCritical() << "Invalid transition data"; QMessageBox::critical(mainWindow, "Invalid transition", "No candidate for transition '" + em->name + "'. This transition may be corrupt. Try reinstalling it or Olive."); } return NULL; diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 34896859a..44b69ffdc 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -554,10 +554,10 @@ bool isLiveEditing() { void TimelineWidget::mousePressEvent(QMouseEvent *event) { if (sequence != NULL) { int tool = panel_timeline->tool; - if (event->button() == Qt::MiddleButton) { - tool = TIMELINE_TOOL_HAND; - panel_timeline->creating = false; - } else if (event->button() == Qt::RightButton) { + if (event->button() == Qt::MiddleButton) { + tool = TIMELINE_TOOL_HAND; + panel_timeline->creating = false; + } else if (event->button() == Qt::RightButton) { tool = TIMELINE_TOOL_MENU; panel_timeline->creating = false; } @@ -1163,7 +1163,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { update_ui(true); } - panel_timeline->hand_moving = false; + panel_timeline->hand_moving = false; } } @@ -2178,7 +2178,7 @@ void draw_waveform(Clip* clip, const FootageStream* ms, long media_length, QPain p->drawLine(clip_rect.left()+i, mid+min, clip_rect.left()+i, mid+max); } }/* else { - dout << "[WARNING] Tried to reach" << offset + 1 << ", limit:" << ms->audio_preview.size(); + qWarning() << "Tried to reach" << offset + 1 << ", limit:" << ms->audio_preview.size(); }*/ } } diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index ef22f953f..51467aacc 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -437,7 +437,7 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture if (e->enable_superimpose) { GLuint superimpose_texture = e->process_superimpose(timecode); if (superimpose_texture == 0) { - dout << "[WARNING] Superimpose texture was NULL, retrying..."; + qWarning() << "Superimpose texture was NULL, retrying..."; texture_failed = true; } else { composite_texture = draw_clip(c->fbo[!fbo_switcher], superimpose_texture, false); @@ -498,7 +498,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) close_clip(c, false); } } else { - //dout << "[WARNING] Media '" + m->name + "' was not ready, retrying..."; + //qWarning() << "Media '" + m->name + "' was not ready, retrying..."; texture_failed = true; } } @@ -542,7 +542,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) Clip* c = current_clips.at(i); if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE && !c->finished_opening) { - dout << "[WARNING] Tried to display clip" << i << "but it's closed"; + qWarning() << "Tried to display clip" << i << "but it's closed"; texture_failed = true; } else { if (c->track < 0) { @@ -572,7 +572,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } if (textureID == 0 && c->media != NULL) { - dout << "[WARNING] Texture hasn't been created yet"; + qWarning() << "Texture hasn't been created yet"; texture_failed = true; } else if (playhead >= c->get_timeline_in_with_transition()) { glPushMatrix(); @@ -868,7 +868,7 @@ void ViewerWidget::paintGL() { if (force_quit) break; if (texture_failed) { if (rendering) { - dout << "[INFO] Texture failed - looping"; + qInfo() << "Texture failed - looping"; loop = true; } else if (!viewer->playing) { retry_timer.start(); From 317d278fc5222c27096ce31f12cd494c309da348 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 01:10:36 +1100 Subject: [PATCH 13/25] write debug log to file --- debug.cpp | 28 ++++++++++++++++++++++++++++ debug.h | 2 ++ mainwindow.cpp | 7 +++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/debug.cpp b/debug.cpp index 666a6b203..ed43cea42 100644 --- a/debug.cpp +++ b/debug.cpp @@ -4,36 +4,63 @@ #include #include #include +#include #include "dialogs/debugdialog.h" QString debug_info; +QMutex debug_mutex; +QFile debug_file; +QTextStream debug_stream; + +void open_debug_file() { + QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + debug_dir.mkpath("."); + if (debug_dir.exists()) { + debug_file.setFileName(debug_dir.path() + "/debug_log"); + if (debug_file.open(QFile::WriteOnly)) { + debug_stream.setDevice(&debug_file); + } else { + qWarning() << "Couldn't open debug log file, debug log will not be saved"; + } + } +} + +void close_debug_file() { + if (debug_file.isOpen()) debug_file.close(); +} void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { + debug_mutex.lock(); QByteArray localMsg = msg.toLocal8Bit(); switch (type) { case QtDebugMsg: fprintf(stderr, "[DEBUG] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + if (debug_file.isOpen()) debug_stream << QString("[DEBUG] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function); debug_info.prepend(QString("[DEBUG] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); fflush(stderr); break; case QtInfoMsg: fprintf(stderr, "[INFO] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + if (debug_file.isOpen()) debug_stream << QString("[INFO] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function); debug_info.prepend(QString("[INFO] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); fflush(stderr); break; case QtWarningMsg: fprintf(stderr, "[WARNING] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + if (debug_file.isOpen()) debug_stream << QString("[WARNING] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function); debug_info.prepend(QString("[WARNING] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); fflush(stderr); break; case QtCriticalMsg: fprintf(stderr, "[ERROR] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + if (debug_file.isOpen()) debug_stream << QString("[ERROR] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function); debug_info.prepend(QString("[ERROR] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); fflush(stderr); break; case QtFatalMsg: fprintf(stderr, "[FATAL] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + if (debug_file.isOpen()) debug_stream << QString("[FATAL] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function); debug_info.prepend(QString("[FATAL] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function)); fflush(stderr); abort(); @@ -41,6 +68,7 @@ void debug_message_handler(QtMsgType type, const QMessageLogContext &context, co if (debug_dialog->isVisible()) { QMetaObject::invokeMethod(debug_dialog, "update_log", Qt::QueuedConnection); } + debug_mutex.unlock(); } const QString &get_debug_str() { diff --git a/debug.h b/debug.h index bf741056d..0e75d54c4 100644 --- a/debug.h +++ b/debug.h @@ -5,6 +5,8 @@ void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg); const QString& get_debug_str(); +void open_debug_file(); +void close_debug_file(); #define dout qDebug() diff --git a/mainwindow.cpp b/mainwindow.cpp index 5260036a7..b43471c79 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -94,9 +94,11 @@ void MainWindow::setup_layout(bool reset) { MainWindow::MainWindow(QWidget *parent, const QString &an) : QMainWindow(parent), - appName(an), - enable_launch_with_project(false) + enable_launch_with_project(false), + appName(an) { + open_debug_file(); + debug_dialog = new DebugDialog(this); mainWindow = this; @@ -227,6 +229,7 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) : MainWindow::~MainWindow() { free_panels(); + close_debug_file(); } void MainWindow::launch_with_project(const QString& s) { From 587b3040d4872d86d1d44b4371c5e1a9a1e95e36 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 01:13:56 +1100 Subject: [PATCH 14/25] fixed bug preventing footage viewer closing deleted media --- panels/project.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/panels/project.cpp b/panels/project.cpp index eafb8da23..8742eecca 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -558,10 +558,8 @@ void Project::delete_selected_media() { if (panel_footage_viewer->seq != NULL) { for (int j=0;jseq->clips.size();j++) { Clip* c = panel_footage_viewer->seq->clips.at(j); - if (c != NULL) { - if (c->media == items.at(i)->to_object()) { - panel_footage_viewer->set_media(NULL); - } + if (c != NULL && c->media == items.at(i)) { + panel_footage_viewer->set_media(NULL); break; } } From 462e7ba586ee9a42be347e72390a621b6ae4accb Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 01:17:12 +1100 Subject: [PATCH 15/25] added close media for #304 --- panels/viewer.cpp | 8 ++++++++ panels/viewer.h | 2 ++ ui/viewerwidget.cpp | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/panels/viewer.cpp b/panels/viewer.cpp index eb713724d..be165cfd7 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -90,6 +90,10 @@ bool Viewer::is_focused() { || btnSkipToEnd->hasFocus(); } +bool Viewer::is_main_sequence() { + return main_sequence; +} + void Viewer::set_main_sequence() { clean_created_seq(); set_sequence(true, sequence); @@ -260,6 +264,10 @@ void Viewer::go_to_end() { if (seq != NULL) seek(seq->getEndFrame()); } +void Viewer::close_media() { + set_media(NULL); +} + void Viewer::go_to_in() { if (seq != NULL) { if (seq->using_workarea && seq->enable_workarea) { diff --git a/panels/viewer.h b/panels/viewer.h index e102c1f57..acb187559 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -29,6 +29,7 @@ public: ~Viewer(); bool is_focused(); + bool is_main_sequence(); void set_main_sequence(); void set_media(Media *m); void compose(); @@ -81,6 +82,7 @@ public slots: void next_frame(); void go_to_out(); void go_to_end(); + void close_media(); private slots: void update_playhead(); diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 51467aacc..3783b563f 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -109,6 +109,10 @@ void ViewerWidget::show_context_menu() { connect(&zoom_menu, SIGNAL(triggered(QAction*)), this, SLOT(set_menu_zoom(QAction*))); menu.addMenu(&zoom_menu); + if (!viewer->is_main_sequence()) { + menu.addAction("Close Media", viewer, SLOT(close_media())); + } + menu.exec(QCursor::pos()); } From b1bb4b78087e4e706e80a171cc9570e36608fc43 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 01:46:42 +1100 Subject: [PATCH 16/25] added --disable-shaders arg --- main.cpp | 10 +++++++--- project/effect.cpp | 13 ++++++++++--- project/effect.h | 1 + ui/viewerwidget.cpp | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 995e29357..11668c0ae 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ #include #include "debug.h" +#include "project/effect.h" extern "C" { #include @@ -24,17 +25,20 @@ int main(int argc, char *argv[]) { if (argc > 1) { for (int i=1;i #include +bool shaders_are_enabled = true; QVector effects; Effect* create_effect(Clip* c, const EffectMeta* em) { @@ -85,6 +86,8 @@ const EffectMeta* get_internal_meta(int internal_id, int type) { } void load_internal_effects() { + qWarning() << "Shaders are disabled, some effects may be nonfunctional"; + EffectMeta em; // internal effects @@ -785,8 +788,8 @@ void Effect::open() { if (isOpen) { qWarning() << "Tried to open an effect that was already open"; close(); - } - if (enable_shader) { + } + if (shaders_are_enabled && enable_shader) { if (QOpenGLContext::currentContext() == NULL) { qWarning() << "No current context to create a shader program for - will retry next repaint"; } else { @@ -848,7 +851,11 @@ void Effect::startEffect() { open(); qWarning() << "Tried to start a closed effect - opening"; } - if (enable_shader && glslProgram->isLinked()) bound = glslProgram->bind(); + if (shaders_are_enabled + && enable_shader + && glslProgram->isLinked()) { + bound = glslProgram->bind(); + } } void Effect::endEffect() { diff --git a/project/effect.h b/project/effect.h index 21e0f381b..413df6d9f 100644 --- a/project/effect.h +++ b/project/effect.h @@ -34,6 +34,7 @@ struct EffectMeta { int subtype; }; +extern bool shaders_are_enabled; extern QVector effects; double log_volume(double linear); diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 3783b563f..f8adf8313 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -431,9 +431,9 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture if (e->enable_coords) { e->process_coords(timecode, coords, data); } - if (e->enable_shader || e->enable_superimpose) { + if ((e->enable_shader && shaders_are_enabled) || e->enable_superimpose) { e->startEffect(); - if (e->enable_shader && e->is_glsl_linked()) { + if ((e->enable_shader && shaders_are_enabled) && e->is_glsl_linked()) { e->process_shader(timecode, coords); composite_texture = draw_clip(c->fbo[fbo_switcher], composite_texture, true); fbo_switcher = !fbo_switcher; From 215606772ccdd1c068a3afb838ec4c36109363c7 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 02:03:53 +1100 Subject: [PATCH 17/25] css files can be loaded from file --- dialogs/preferencesdialog.cpp | 35 ++++++++++++++++++++++++++++++----- dialogs/preferencesdialog.h | 2 ++ io/config.cpp | 10 +++++++--- io/config.h | 1 + mainwindow.cpp | 22 +++++++++++++++++++--- mainwindow.h | 2 ++ 6 files changed, 61 insertions(+), 11 deletions(-) diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index b7df9ddaa..a730d6bb5 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -1,6 +1,7 @@ #include "preferencesdialog.h" #include "io/config.h" +#include "mainwindow.h" #include #include @@ -108,6 +109,13 @@ void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) { } void PreferencesDialog::save() { + if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) { + QMessageBox::critical(this, "Invalid CSS File", "CSS file '" + custom_css_fn->text() + "' does not exist."); + return; + } + + config.css_path = custom_css_fn->text(); + mainWindow->load_css_from_file(config.css_path); config.recording_mode = recordingComboBox->currentIndex() + 1; config.img_seq_formats = imgSeqFormatEdit->text(); config.fast_seeking = fastSeekButton->isChecked(); @@ -230,7 +238,14 @@ void PreferencesDialog::save_shortcut_file() { } else { QMessageBox::critical(this, "Error saving shortcuts", "Failed to open file for writing"); } - } + } +} + +void PreferencesDialog::browse_css_file() { + QString fn = QFileDialog::getOpenFileName(this, "Browse for CSS file"); + if (!fn.isEmpty()) { + custom_css_fn->setText(fn); + } } void PreferencesDialog::setup_ui() { @@ -240,19 +255,29 @@ void PreferencesDialog::setup_ui() { QTabWidget* general_tab = new QTabWidget(); QGridLayout* general_layout = new QGridLayout(general_tab); - general_layout->addWidget(new QLabel("Image sequence formats:"), 0, 0, 1, 1); + general_layout->addWidget(new QLabel("Custom CSS:"), 0, 0, 1, 1); + + custom_css_fn = new QLineEdit(general_tab); + custom_css_fn->setText(config.css_path); + general_layout->addWidget(custom_css_fn, 0, 1, 1, 1); + + QPushButton* custom_css_browse = new QPushButton("Browse", general_tab); + connect(custom_css_browse, SIGNAL(clicked(bool)), this, SLOT(browse_css_file())); + general_layout->addWidget(custom_css_browse, 0, 2, 1, 1); + + general_layout->addWidget(new QLabel("Image sequence formats:"), 1, 0, 1, 1); imgSeqFormatEdit = new QLineEdit(general_tab); - general_layout->addWidget(imgSeqFormatEdit, 0, 1, 1, 1); + general_layout->addWidget(imgSeqFormatEdit, 1, 1, 1, 2); - general_layout->addWidget(new QLabel("Audio Recording:"), 1, 0, 1, 1); + general_layout->addWidget(new QLabel("Audio Recording:"), 2, 0, 1, 1); recordingComboBox = new QComboBox(general_tab); recordingComboBox->addItem("Mono"); recordingComboBox->addItem("Stereo"); - general_layout->addWidget(recordingComboBox, 1, 1, 1, 1); + general_layout->addWidget(recordingComboBox, 2, 1, 1, 2); tabWidget->addTab(general_tab, "General"); QWidget* behavior_tab = new QWidget(); diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index 5647997f5..0b1344c71 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -42,11 +42,13 @@ private slots: bool refine_shortcut_list(const QString &, QTreeWidgetItem* parent = NULL); void load_shortcut_file(); void save_shortcut_file(); + void browse_css_file(); private: void setup_ui(); void setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent); + QLineEdit* custom_css_fn; QLineEdit* imgSeqFormatEdit; QComboBox* recordingComboBox; QRadioButton* accurateSeekButton; diff --git a/io/config.cpp b/io/config.cpp index 1da1a8c46..18d0bc540 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -46,7 +46,7 @@ Config::Config() upcoming_queue_type(FRAME_QUEUE_TYPE_SECONDS), loop(true), pause_at_out_point(true), - seek_also_selects(false) + seek_also_selects(false) {} void Config::load(QString path) { @@ -162,7 +162,10 @@ void Config::load(QString path) { } else if (stream.name() == "SeekAlsoSelects") { stream.readNext(); seek_also_selects = (stream.text() == "1"); - } + } else if (stream.name() == "CSSPath") { + stream.readNext(); + css_path = stream.text().toString(); + } } } if (stream.hasError()) { @@ -220,7 +223,8 @@ void Config::save(QString path) { stream.writeTextElement("UpcomingFrameQueueType", QString::number(upcoming_queue_type)); stream.writeTextElement("Loop", QString::number(loop)); stream.writeTextElement("PauseAtOutPoint", QString::number(pause_at_out_point)); - stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); + stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); + stream.writeTextElement("CSSPath", css_path); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index 542443b4b..9983839d9 100644 --- a/io/config.h +++ b/io/config.h @@ -61,6 +61,7 @@ struct Config { bool loop; bool pause_at_out_point; bool seek_also_selects; + QString css_path; void load(QString path); void save(QString path); diff --git a/mainwindow.cpp b/mainwindow.cpp index b43471c79..b16de94a3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -53,6 +53,7 @@ MainWindow* mainWindow; +#define DEFAULT_CSS "QPushButton::checked { background: rgb(25, 25, 25); }" #define OLIVE_FILE_FILTER "Olive Project (*.ove)" QTimer autorecovery_timer; @@ -106,7 +107,7 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) : // set up style? qApp->setStyle(QStyleFactory::create("Fusion")); - setStyleSheet("QPushButton::checked { background: rgb(25, 25, 25); }"); + setStyleSheet(DEFAULT_CSS); QPalette darkPalette; darkPalette.setColor(QPalette::Window, QColor(53,53,53)); @@ -197,7 +198,11 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) : config_fn = config_path + "/config.xml"; if (QFileInfo::exists(config_fn)) { config.load(config_fn); - } + + if (!config.css_path.isEmpty()) { + load_css_from_file(config.css_path); + } + } } alloc_panels(this); @@ -330,7 +335,18 @@ void MainWindow::save_shortcuts(const QString& fn) { shortcut_file_io.close(); } else { qCritical() << "Failed to save shortcut file"; - } + } +} + +void MainWindow::load_css_from_file(const QString &fn) { + QFile css_file(fn); + if (css_file.exists() && css_file.open(QFile::ReadOnly)) { + setStyleSheet(css_file.readAll()); + css_file.close(); + } else { + // set default stylesheet + setStyleSheet(DEFAULT_CSS); + } } void MainWindow::show_about() { diff --git a/mainwindow.h b/mainwindow.h index d4a3a6025..490c75097 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -23,6 +23,8 @@ public: void load_shortcuts(const QString &fn, bool first = false); void save_shortcuts(const QString &fn); + void load_css_from_file(const QString& fn); + public slots: void undo(); void redo(); From 345328432da8b10bb1d2afc14c5e37d32ffdb006 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 10:10:24 +1100 Subject: [PATCH 18/25] translation --- dialogs/aboutdialog.cpp | 12 +++- dialogs/actionsearch.cpp | 2 +- dialogs/debugdialog.cpp | 2 +- dialogs/demonotice.cpp | 17 ++++- dialogs/exportdialog.cpp | 91 +++++++++++++++--------- dialogs/loaddialog.cpp | 6 +- dialogs/mediapropertiesdialog.cpp | 41 ++++++++--- dialogs/newsequencedialog.cpp | 48 ++++++------- dialogs/preferencesdialog.cpp | 89 +++++++++++++---------- dialogs/replaceclipmediadialog.cpp | 38 +++++++--- dialogs/speeddialog.cpp | 14 ++-- dialogs/texteditdialog.cpp | 2 +- effects/internal/audionoiseeffect.cpp | 4 +- effects/internal/cornerpineffect.cpp | 10 +-- effects/internal/fillleftrighteffect.cpp | 6 +- effects/internal/paneffect.cpp | 2 +- effects/internal/shakeeffect.cpp | 6 +- effects/internal/solideffect.cpp | 14 ++-- effects/internal/texteffect.cpp | 46 ++++++------ effects/internal/timecodeeffect.cpp | 18 ++--- effects/internal/toneeffect.cpp | 8 +-- effects/internal/transformeffect.cpp | 22 +++--- effects/internal/voideffect.cpp | 4 +- effects/internal/volumeeffect.cpp | 2 +- effects/internal/vsthostwin.cpp | 20 +++--- io/exportthread.cpp | 36 +++++----- io/loadthread.cpp | 25 +++++-- io/previewgenerator.cpp | 4 +- olive.pro | 2 + panels/effectcontrols.cpp | 16 ++--- panels/grapheditor.cpp | 8 +-- panels/project.cpp | 45 ++++++++---- panels/timeline.cpp | 66 +++++++++-------- panels/viewer.cpp | 4 +- playback/audio.cpp | 4 +- playback/cacher.cpp | 2 +- project/effect.cpp | 13 ++-- project/effectrow.cpp | 5 +- project/media.cpp | 59 ++++++++------- project/sequence.cpp | 4 +- project/sourcescommon.cpp | 36 +++++----- project/transition.cpp | 8 ++- ui/collapsiblewidget.cpp | 2 +- ui/colorbutton.cpp | 2 +- ui/embeddedfilechooser.cpp | 2 +- ui/graphview.cpp | 6 +- ui/keyframenavigator.cpp | 2 +- ui/keyframeview.cpp | 6 +- ui/labelslider.cpp | 8 +-- ui/timelinewidget.cpp | 28 ++++---- ui/viewerwidget.cpp | 19 ++--- 51 files changed, 555 insertions(+), 381 deletions(-) diff --git a/dialogs/aboutdialog.cpp b/dialogs/aboutdialog.cpp index 7d1bdb7e9..653f0b859 100644 --- a/dialogs/aboutdialog.cpp +++ b/dialogs/aboutdialog.cpp @@ -14,7 +14,17 @@ AboutDialog::AboutDialog(QWidget *parent) : layout->setSpacing(20); setLayout(layout); - QLabel* label = new QLabel("

https://www.olivevideoeditor.org/

Olive is a non-linear video editor. This software is free and protected by the GNU GPL.

Olive Team is obliged to inform users that Olive source code is available for download from its website.

Olive uses (at least) the following libraries in accordance with the GNU GPL/LGPL:

Qt, FFmpeg, libass, libfreetype, libmp3lame, libopenjpeg, libopus, libtheora, libtwolame, libvpx, libwavpack, libwebp, libx264, libx265, lzma, bzlib, zlib, libvidstab, libvorbis.

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

"); label->setAlignment(Qt::AlignCenter); label->setWordWrap(true); layout->addWidget(label); diff --git a/dialogs/actionsearch.cpp b/dialogs/actionsearch.cpp index 3f5593dbe..8641cf584 100644 --- a/dialogs/actionsearch.cpp +++ b/dialogs/actionsearch.cpp @@ -23,7 +23,7 @@ ActionSearch::ActionSearch(QWidget *parent) : QFont entry_field_font = entry_field->font(); entry_field_font.setPointSize(entry_field_font.pointSize()*1.2); entry_field->setFont(entry_field_font); - entry_field->setPlaceholderText("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())); diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index b70b24bab..614f68e1c 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -8,7 +8,7 @@ DebugDialog* debug_dialog = NULL; DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle("Debug Log"); + setWindowTitle(tr("Debug Log")); QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); diff --git a/dialogs/demonotice.cpp b/dialogs/demonotice.cpp index d16f9bd47..b47bb9fc1 100644 --- a/dialogs/demonotice.cpp +++ b/dialogs/demonotice.cpp @@ -7,7 +7,7 @@ DemoNotice::DemoNotice(QWidget *parent) : QDialog(parent) { - setWindowTitle("Welcome to Olive!"); + setWindowTitle(tr("Welcome to Olive!")); setMaximumWidth(600); QVBoxLayout* vlayout = new QVBoxLayout(); @@ -17,10 +17,21 @@ DemoNotice::DemoNotice(QWidget *parent) : layout->setMargin(10); layout->setSpacing(20); - QLabel* icon = new QLabel("

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

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

Welcome to Olive!

Olive is a free open-source video editor released under the GNU GPL. If you have paid for this software, you have been scammed.

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 www.olivevideoeditor.org

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

"); text->setWordWrap(true); layout->addWidget(text); diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index edcafc1f9..97349fd19 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -57,7 +57,7 @@ enum ExportFormats { ExportDialog::ExportDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle("Export \"" + sequence->name + "\""); + setWindowTitle(tr("Export \"%1\"").arg(sequence->name)); setup_ui(); rangeCombobox->setCurrentIndex(0); @@ -320,7 +320,12 @@ void ExportDialog::format_changed(int index) void ExportDialog::render_thread_finished() { if (progressBar->value() < 100 && !cancelled) { - QMessageBox::critical(this, "Export Failed", "Export failed - " + export_error, QMessageBox::Ok); + QMessageBox::critical( + this, + tr("Export Failed"), + tr("Export failed - %1").arg(export_error), + QMessageBox::Ok + ); } prep_ui_for_render(false); panel_sequence_viewer->viewer_widget->makeCurrent(); @@ -337,7 +342,12 @@ void ExportDialog::prep_ui_for_render(bool r) { void ExportDialog::export_action() { if (widthSpinbox->value()%2 == 1 || heightSpinbox->value()%2 == 1) { - QMessageBox::critical(this, "Invalid dimensions", "Export width and height must both be even numbers/divisible by 2.", QMessageBox::Ok); + QMessageBox::critical( + this, + tr("Invalid dimensions"), + tr("Export width and height must both be even numbers/divisible by 2."), + QMessageBox::Ok + ); return; } @@ -389,7 +399,12 @@ void ExportDialog::export_action() { break; default: qCritical() << "Invalid codec selection for an image sequence"; - QMessageBox::critical(this, "Invalid codec", "Couldn't determine output parameters for the selected codec. This is a bug, please contact the developers.", QMessageBox::Ok); + QMessageBox::critical( + this, + tr("Invalid codec"), + tr("Couldn't determine output parameters for the selected codec. This is a bug, please contact the developers."), + QMessageBox::Ok + ); return; } break; @@ -454,10 +469,20 @@ void ExportDialog::export_action() { break; default: qCritical() << "Invalid format - this is a bug, please inform the developers"; - QMessageBox::critical(this, "Invalid format", "Couldn't determine output format. This is a bug, please contact the developers.", QMessageBox::Ok); + QMessageBox::critical( + this, + tr("Invalid format"), + tr("Couldn't determine output format. This is a bug, please contact the developers."), + QMessageBox::Ok + ); return; } - QString filename = QFileDialog::getSaveFileName(this, "Export Media", "", format_strings[formatCombobox->currentIndex()] + " (*." + ext + ")"); + QString filename = QFileDialog::getSaveFileName( + this, + tr("Export Media"), + "", + format_strings[formatCombobox->currentIndex()] + " (*." + ext + ")" + ); if (!filename.isEmpty()) { if (!filename.endsWith("." + ext, Qt::CaseInsensitive)) { filename += "." + ext; @@ -540,11 +565,11 @@ void ExportDialog::vcodec_changed(int index) { compressionTypeCombobox->clear(); if ((format_vcodecs.size() > 0 && format_vcodecs.at(index) == AV_CODEC_ID_H264)) { compressionTypeCombobox->setEnabled(true); - compressionTypeCombobox->addItem("Quality-based (Constant Rate Factor)", COMPRESSION_TYPE_CFR); + compressionTypeCombobox->addItem(tr("Quality-based (Constant Rate Factor)"), COMPRESSION_TYPE_CFR); // compressionTypeCombobox->addItem("File size-based (Two-Pass)", COMPRESSION_TYPE_TARGETSIZE); // compressionTypeCombobox->addItem("Average bitrate (Two-Pass)", COMPRESSION_TYPE_TARGETBR); } else { - compressionTypeCombobox->addItem("Constant Bitrate", COMPRESSION_TYPE_CBR); + compressionTypeCombobox->addItem(tr("Constant Bitrate"), COMPRESSION_TYPE_CBR); compressionTypeCombobox->setCurrentIndex(0); compressionTypeCombobox->setEnabled(false); } @@ -557,17 +582,17 @@ void ExportDialog::comp_type_changed(int) { switch (compressionTypeCombobox->currentData().toInt()) { case COMPRESSION_TYPE_CBR: case COMPRESSION_TYPE_TARGETBR: - videoBitrateLabel->setText("Bitrate (Mbps):"); + videoBitrateLabel->setText(tr("Bitrate (Mbps):")); videobitrateSpinbox->setValue(qMax(0.5, (double) qRound((0.01528 * sequence->height) - 4.5))); break; case COMPRESSION_TYPE_CFR: - videoBitrateLabel->setText("Quality (CRF):"); + videoBitrateLabel->setText(tr("Quality (CRF):")); videobitrateSpinbox->setValue(36); videobitrateSpinbox->setMaximum(51); - videobitrateSpinbox->setToolTip("Quality Factor:\n\n0 = lossless\n17-18 = visually lossless (compressed, but unnoticeable)\n23 = high quality\n51 = lowest quality possible"); + videobitrateSpinbox->setToolTip(tr("Quality Factor:\n\n0 = lossless\n17-18 = visually lossless (compressed, but unnoticeable)\n23 = high quality\n51 = lowest quality possible")); break; case COMPRESSION_TYPE_TARGETSIZE: - videoBitrateLabel->setText("Target File Size (MB):"); + videoBitrateLabel->setText(tr("Target File Size (MB):")); videobitrateSpinbox->setValue(100); break; } @@ -576,59 +601,57 @@ void ExportDialog::comp_type_changed(int) { void ExportDialog::setup_ui() { QVBoxLayout* verticalLayout = new QVBoxLayout(this); - QHBoxLayout* horizontalLayout = new QHBoxLayout(); + QHBoxLayout* format_layout = new QHBoxLayout(); - horizontalLayout->addWidget(new QLabel("Format:")); + format_layout->addWidget(new QLabel(tr("Format:"))); formatCombobox = new QComboBox(this); - horizontalLayout->addWidget(formatCombobox); + format_layout->addWidget(formatCombobox); - verticalLayout->addLayout(horizontalLayout); + verticalLayout->addLayout(format_layout); - QHBoxLayout* horizontalLayout_4 = new QHBoxLayout(); + QHBoxLayout* range_layout = new QHBoxLayout(); - horizontalLayout_4->addWidget(new QLabel("Range:")); + range_layout->addWidget(new QLabel(tr("Range:"))); rangeCombobox = new QComboBox(this); - rangeCombobox->addItem("Entire Sequence"); - rangeCombobox->addItem("In to Out"); + rangeCombobox->addItem(tr("Entire Sequence")); + rangeCombobox->addItem(tr("In to Out")); - horizontalLayout_4->addWidget(rangeCombobox); + range_layout->addWidget(rangeCombobox); - verticalLayout->addLayout(horizontalLayout_4); + verticalLayout->addLayout(range_layout); videoGroupbox = new QGroupBox(this); - videoGroupbox->setTitle("Video"); + videoGroupbox->setTitle(tr("Video")); videoGroupbox->setFlat(false); videoGroupbox->setCheckable(true); QGridLayout* videoGridLayout = new QGridLayout(videoGroupbox); - videoGridLayout->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Codec:")), 0, 0, 1, 1); vcodecCombobox = new QComboBox(videoGroupbox); videoGridLayout->addWidget(vcodecCombobox, 0, 1, 1, 1); - videoGridLayout->addWidget(new QLabel("Width:"), 1, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Width:")), 1, 0, 1, 1); widthSpinbox = new QSpinBox(videoGroupbox); widthSpinbox->setMaximum(16777216); videoGridLayout->addWidget(widthSpinbox, 1, 1, 1, 1); - videoGridLayout->addWidget(new QLabel("Height:"), 2, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Height:")), 2, 0, 1, 1); heightSpinbox = new QSpinBox(videoGroupbox); heightSpinbox->setMaximum(16777216); videoGridLayout->addWidget(heightSpinbox, 2, 1, 1, 1); - videoGridLayout->addWidget(new QLabel("Frame Rate:"), 3, 0, 1, 1); + videoGridLayout->addWidget(new QLabel(tr("Frame Rate:")), 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("Compression Type:"), 4, 0, 1, 1); - compressionTypeCombobox = new QComboBox(videoGroupbox); - compressionTypeCombobox->addItem("Quality-based (Constant Rate Factor)"); - compressionTypeCombobox->addItem("File size-based (Two-Pass)"); + videoGridLayout->addWidget(new QLabel(tr("Compression Type:")), 4, 0, 1, 1); + compressionTypeCombobox = new QComboBox(videoGroupbox); videoGridLayout->addWidget(compressionTypeCombobox, 4, 1, 1, 1); videoBitrateLabel = new QLabel(videoGroupbox); @@ -646,17 +669,17 @@ void ExportDialog::setup_ui() { QGridLayout* audioGridLayout = new QGridLayout(audioGroupbox); - audioGridLayout->addWidget(new QLabel("Codec:"), 0, 0, 1, 1); + audioGridLayout->addWidget(new QLabel(tr("Codec:")), 0, 0, 1, 1); acodecCombobox = new QComboBox(audioGroupbox); audioGridLayout->addWidget(acodecCombobox, 0, 1, 1, 1); - audioGridLayout->addWidget(new QLabel("Sampling Rate:"), 1, 0, 1, 1); + audioGridLayout->addWidget(new QLabel(tr("Sampling Rate:")), 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("Bitrate (Kbps/CBR):"), 3, 0, 1, 1); + audioGridLayout->addWidget(new QLabel(tr("Bitrate (Kbps/CBR):")), 3, 0, 1, 1); audiobitrateSpinbox = new QSpinBox(audioGroupbox); audiobitrateSpinbox->setMaximum(320); audiobitrateSpinbox->setValue(256); diff --git a/dialogs/loaddialog.cpp b/dialogs/loaddialog.cpp index 3751ebea9..a0ac2a434 100644 --- a/dialogs/loaddialog.cpp +++ b/dialogs/loaddialog.cpp @@ -14,19 +14,19 @@ #include "mainwindow.h" LoadDialog::LoadDialog(QWidget *parent, bool autorecovery) : QDialog(parent) { - setWindowTitle("Loading..."); + setWindowTitle(tr("Loading...")); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); - layout->addWidget(new QLabel("Loading '" + project_url.mid(project_url.lastIndexOf('/')+1) + "'...")); + layout->addWidget(new QLabel(tr("Loading '%1'...").arg(project_url.mid(project_url.lastIndexOf('/')+1)))); bar = new QProgressBar(); bar->setValue(0); layout->addWidget(bar); - cancel_button = new QPushButton("Cancel"); + cancel_button = new QPushButton(tr("Cancel")); connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(cancel())); hboxLayout = new QHBoxLayout(); diff --git a/dialogs/mediapropertiesdialog.cpp b/dialogs/mediapropertiesdialog.cpp index f8f128b95..188187f3f 100644 --- a/dialogs/mediapropertiesdialog.cpp +++ b/dialogs/mediapropertiesdialog.cpp @@ -19,7 +19,7 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : QDialog(parent), item(i) { - setWindowTitle("\"" + i->get_name() + "\" Properties"); + setWindowTitle(tr("\"%1\" Properties").arg(i->get_name())); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QGridLayout* grid = new QGridLayout(); @@ -29,13 +29,21 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : Footage* f = item->to_footage(); - grid->addWidget(new QLabel("Tracks:"), row, 0, 1, 2); + grid->addWidget(new QLabel(tr("Tracks:")), row, 0, 1, 2); row++; track_list = new QListWidget(); for (int i=0;ivideo_tracks.size();i++) { const FootageStream& fs = f->video_tracks.at(i); - QListWidgetItem* item = new QListWidgetItem("Video " + QString::number(fs.file_index) + ": " + QString::number(fs.video_width) + "x" + QString::number(fs.video_height) + " " + QString::number(fs.video_frame_rate) + "FPS"); + + QListWidgetItem* item = new QListWidgetItem( + tr("Video %1: %2x%3 %4FPS").arg( + QString::number(fs.file_index), + QString::number(fs.video_width), + QString::number(fs.video_height), + QString::number(fs.video_frame_rate) + ) + ); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); item->setData(Qt::UserRole+1, fs.file_index); @@ -43,7 +51,13 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : } for (int i=0;iaudio_tracks.size();i++) { const FootageStream& fs = f->audio_tracks.at(i); - QListWidgetItem* item = new QListWidgetItem("Audio " + QString::number(fs.file_index) + ": " + QString::number(fs.audio_frequency) + "Hz " + QString::number(fs.audio_channels) + " channels"); + QListWidgetItem* item = new QListWidgetItem( + tr("Audio %1: %2Hz %3 channels").arg( + QString::number(fs.file_index), + QString::number(fs.audio_frequency), + QString::number(fs.audio_channels) + ) + ); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(fs.enabled ? Qt::Checked : Qt::Unchecked); item->setData(Qt::UserRole+1, fs.file_index); @@ -55,7 +69,7 @@ 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("Conform to Frame Rate:"), row, 0); + grid->addWidget(new QLabel(tr("Conform to Frame Rate:")), row, 0); conform_fr = new QDoubleSpinBox(); conform_fr->setMinimum(0.01); conform_fr->setValue(f->video_tracks.at(0).video_frame_rate * f->speed); @@ -65,22 +79,29 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : row++; // deinterlacing mode - interlacing_box = new QComboBox(); - interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) + ")"); + interlacing_box = new QComboBox(); + interlacing_box->addItem( + tr("Auto (%1)").arg( + get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) + ) + ); interlacing_box->addItem(get_interlacing_name(VIDEO_PROGRESSIVE)); interlacing_box->addItem(get_interlacing_name(VIDEO_TOP_FIELD_FIRST)); interlacing_box->addItem(get_interlacing_name(VIDEO_BOTTOM_FIELD_FIRST)); - interlacing_box->setCurrentIndex((f->video_tracks.at(0).video_auto_interlacing == f->video_tracks.at(0).video_interlacing) ? 0 : f->video_tracks.at(0).video_interlacing + 1); + interlacing_box->setCurrentIndex( + (f->video_tracks.at(0).video_auto_interlacing == f->video_tracks.at(0).video_interlacing) + ? 0 + : f->video_tracks.at(0).video_interlacing + 1); - grid->addWidget(new QLabel("Interlacing:"), row, 0); + grid->addWidget(new QLabel(tr("Interlacing:")), row, 0); grid->addWidget(interlacing_box, row, 1); row++; } name_box = new QLineEdit(item->get_name()); - grid->addWidget(new QLabel("Name:"), row, 0); + grid->addWidget(new QLabel(tr("Name:")), row, 0); grid->addWidget(name_box, row, 1); row++; diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index 0451aa886..66e3b45dc 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -31,7 +31,7 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : if (existing != NULL) { existing_sequence = existing->to_sequence(); - setWindowTitle("Editing \"" + existing_sequence->name + "\""); + setWindowTitle(tr("Editing \"%1\"").arg(existing_sequence->name)); width_numeric->setValue(existing_sequence->width); height_numeric->setValue(existing_sequence->height); @@ -51,7 +51,7 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : } } else { existing_sequence = NULL; - setWindowTitle("New Sequence"); + setWindowTitle(tr("New Sequence")); } } @@ -157,21 +157,21 @@ void NewSequenceDialog::setup_ui() { QHBoxLayout* preset_layout = new QHBoxLayout(widget); preset_layout->setContentsMargins(0, 0, 0, 0); - preset_layout->addWidget(new QLabel("Preset:")); + preset_layout->addWidget(new QLabel(tr("Preset:"))); preset_combobox = new QComboBox(widget); - preset_combobox->addItem("Film 4K"); - preset_combobox->addItem("TV 4K (Ultra HD/2160p)"); - preset_combobox->addItem("1080p"); - preset_combobox->addItem("720p"); - preset_combobox->addItem("480p"); - preset_combobox->addItem("360p"); - preset_combobox->addItem("240p"); - preset_combobox->addItem("144p"); - preset_combobox->addItem("NTSC (480i)"); - preset_combobox->addItem("PAL (576i)"); - preset_combobox->addItem("Custom"); + preset_combobox->addItem(tr("Film 4K")); + preset_combobox->addItem(tr("TV 4K (Ultra HD/2160p)")); + preset_combobox->addItem(tr("1080p")); + preset_combobox->addItem(tr("720p")); + preset_combobox->addItem(tr("480p")); + preset_combobox->addItem(tr("360p")); + preset_combobox->addItem(tr("240p")); + preset_combobox->addItem(tr("144p")); + preset_combobox->addItem(tr("NTSC (480i)")); + preset_combobox->addItem(tr("PAL (576i)")); + preset_combobox->addItem(tr("Custom")); preset_combobox->setCurrentIndex(2); preset_layout->addWidget(preset_combobox); @@ -179,23 +179,23 @@ void NewSequenceDialog::setup_ui() { verticalLayout->addWidget(widget); QGroupBox* videoGroupBox = new QGroupBox(this); - videoGroupBox->setTitle("Video"); + videoGroupBox->setTitle(tr("Video")); QGridLayout* videoLayout = new QGridLayout(videoGroupBox); - videoLayout->addWidget(new QLabel("Width:"), 0, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Width:")), 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("Height:"), 1, 0, 1, 2); + videoLayout->addWidget(new QLabel(tr("Height:")), 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("Frame Rate:"), 2, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Frame Rate:")), 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,14 +211,14 @@ void NewSequenceDialog::setup_ui() { frame_rate_combobox->setCurrentIndex(6); videoLayout->addWidget(frame_rate_combobox, 2, 2, 1, 2); - videoLayout->addWidget(new QLabel("Pixel Aspect Ratio:"), 4, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Pixel Aspect Ratio:")), 4, 0, 1, 1); par_combobox = new QComboBox(videoGroupBox); - par_combobox->addItem("Square Pixels (1.0)"); + par_combobox->addItem(tr("Square Pixels (1.0)")); videoLayout->addWidget(par_combobox, 4, 2, 1, 2); - videoLayout->addWidget(new QLabel("Interlacing:"), 6, 0, 1, 1); + videoLayout->addWidget(new QLabel(tr("Interlacing:")), 6, 0, 1, 1); interlacing_combobox = new QComboBox(videoGroupBox); - interlacing_combobox->addItem("None (Progressive)"); + interlacing_combobox->addItem(tr("None (Progressive)")); // interlacing_combobox->addItem("Upper Field First"); // interlacing_combobox->addItem("Lower Field First"); videoLayout->addWidget(interlacing_combobox, 6, 2, 1, 2); @@ -226,11 +226,11 @@ void NewSequenceDialog::setup_ui() { verticalLayout->addWidget(videoGroupBox); QGroupBox* audioGroupBox = new QGroupBox(this); - audioGroupBox->setTitle("Audio"); + audioGroupBox->setTitle(tr("Audio")); QGridLayout* audioLayout = new QGridLayout(audioGroupBox); - audioLayout->addWidget(new QLabel("Sample Rate: "), 0, 0, 1, 1); + audioLayout->addWidget(new QLabel(tr("Sample Rate: ")), 0, 0, 1, 1); audio_frequency_combobox = new QComboBox(audioGroupBox); audio_frequency_combobox->addItem("22050 Hz", 22050); diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index a730d6bb5..f6e8e8359 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -54,7 +54,7 @@ QString KeySequenceEditor::export_shortcut() { PreferencesDialog::PreferencesDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle("Preferences"); + setWindowTitle(tr("Preferences")); setup_ui(); accurateSeekButton->setChecked(!config.fast_seeking); @@ -110,7 +110,11 @@ void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) { void PreferencesDialog::save() { if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) { - QMessageBox::critical(this, "Invalid CSS File", "CSS file '" + custom_css_fn->text() + "' does not exist."); + QMessageBox::critical( + this, + tr("Invalid CSS File"), + tr("CSS file '%1' does not exist.").arg(custom_css_fn->text()) + ); return; } @@ -142,7 +146,11 @@ void PreferencesDialog::reset_default_shortcut() { } void PreferencesDialog::reset_all_shortcuts() { - if (QMessageBox::question(this, "Confirm Reset All Shortcuts", "Are you sure you wish to reset all keyboard shortcuts to their defaults?", QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + if (QMessageBox::question( + this, + tr("Confirm Reset All Shortcuts"), + tr("Are you sure you wish to reset all keyboard shortcuts to their defaults?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { for (int i=0;ireset_to_default(); } @@ -191,7 +199,7 @@ bool PreferencesDialog::refine_shortcut_list(const QString &s, QTreeWidgetItem* } void PreferencesDialog::load_shortcut_file() { - QString fn = QFileDialog::getOpenFileName(this, "Import Keyboard Shortcuts"); + QString fn = QFileDialog::getOpenFileName(this, tr("Import Keyboard Shortcuts")); if (!fn.isEmpty()) { QFile f(fn); if (f.exists() && f.open(QFile::ReadOnly)) { @@ -206,21 +214,24 @@ void PreferencesDialog::load_shortcut_file() { while (index < ba.size() && ba.at(index) != '\n') { ks.append(ba.at(index)); index++; - } - dout << "set" << key_shortcut_fields.at(i)->action_name() << "to" << ks; + } key_shortcut_fields.at(i)->setKeySequence(ks); } else { key_shortcut_fields.at(i)->reset_to_default(); } } } else { - QMessageBox::critical(this, "Error saving shortcuts", "Failed to open file for reading"); + QMessageBox::critical( + this, + tr("Error saving shortcuts"), + tr("Failed to open file for reading") + ); } } } void PreferencesDialog::save_shortcut_file() { - QString fn = QFileDialog::getSaveFileName(this, "Export Keyboard Shortcuts"); + QString fn = QFileDialog::getSaveFileName(this, tr("Export Keyboard Shortcuts")); if (!fn.isEmpty()) { QFile f(fn); if (f.open(QFile::WriteOnly)) { @@ -233,16 +244,16 @@ void PreferencesDialog::save_shortcut_file() { start = false; } } - QMessageBox::information(this, "Export Shortcuts", "Shortcuts exported successfully"); + QMessageBox::information(this, tr("Export Shortcuts"), tr("Shortcuts exported successfully")); f.close(); } else { - QMessageBox::critical(this, "Error saving shortcuts", "Failed to open file for writing"); + QMessageBox::critical(this, tr("Error saving shortcuts"), tr("Failed to open file for writing")); } } } void PreferencesDialog::browse_css_file() { - QString fn = QFileDialog::getOpenFileName(this, "Browse for CSS file"); + QString fn = QFileDialog::getOpenFileName(this, tr("Browse for CSS file")); if (!fn.isEmpty()) { custom_css_fn->setText(fn); } @@ -255,120 +266,120 @@ void PreferencesDialog::setup_ui() { QTabWidget* general_tab = new QTabWidget(); QGridLayout* general_layout = new QGridLayout(general_tab); - general_layout->addWidget(new QLabel("Custom CSS:"), 0, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Custom CSS:")), 0, 0, 1, 1); custom_css_fn = new QLineEdit(general_tab); custom_css_fn->setText(config.css_path); general_layout->addWidget(custom_css_fn, 0, 1, 1, 1); - QPushButton* custom_css_browse = new QPushButton("Browse", general_tab); + QPushButton* custom_css_browse = new QPushButton(tr("Browse"), general_tab); connect(custom_css_browse, SIGNAL(clicked(bool)), this, SLOT(browse_css_file())); general_layout->addWidget(custom_css_browse, 0, 2, 1, 1); - general_layout->addWidget(new QLabel("Image sequence formats:"), 1, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Image sequence formats:")), 1, 0, 1, 1); imgSeqFormatEdit = new QLineEdit(general_tab); general_layout->addWidget(imgSeqFormatEdit, 1, 1, 1, 2); - general_layout->addWidget(new QLabel("Audio Recording:"), 2, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Audio Recording:")), 2, 0, 1, 1); recordingComboBox = new QComboBox(general_tab); - recordingComboBox->addItem("Mono"); - recordingComboBox->addItem("Stereo"); + recordingComboBox->addItem(tr("Mono")); + recordingComboBox->addItem(tr("Stereo")); general_layout->addWidget(recordingComboBox, 2, 1, 1, 2); - tabWidget->addTab(general_tab, "General"); + tabWidget->addTab(general_tab, tr("General")); QWidget* behavior_tab = new QWidget(); - tabWidget->addTab(behavior_tab, "Behavior"); + tabWidget->addTab(behavior_tab, tr("Behavior")); // Playback QWidget* playback_tab = new QWidget(); QVBoxLayout* playback_tab_layout = new QVBoxLayout(playback_tab); // Playback -> Disable Multithreading on Images - disable_img_multithread = new QCheckBox("Disable Multithreading on Images"); + disable_img_multithread = new QCheckBox(tr("Disable Multithreading on Images")); disable_img_multithread->setChecked(config.disable_multithreading_for_images); playback_tab_layout->addWidget(disable_img_multithread); // Playback -> Seeking QGroupBox* seeking_group = new QGroupBox(playback_tab); - seeking_group->setTitle("Seeking"); + seeking_group->setTitle(tr("Seeking")); QVBoxLayout* seeking_group_layout = new QVBoxLayout(seeking_group); accurateSeekButton = new QRadioButton(seeking_group); - accurateSeekButton->setText("Accurate Seeking\nAlways show the correct frame (visual may pause briefly as correct frame is retrieved)"); + accurateSeekButton->setText(tr("Accurate Seeking\nAlways show the correct frame (visual may pause briefly as correct frame is retrieved)")); seeking_group_layout->addWidget(accurateSeekButton); fastSeekButton = new QRadioButton(seeking_group); - fastSeekButton->setText("Fast Seeking\nSeek quickly (may briefly show inaccurate frames when seeking - doesn't affect playback/export)"); + fastSeekButton->setText(tr("Fast Seeking\nSeek quickly (may briefly show inaccurate frames when seeking - doesn't affect playback/export)")); seeking_group_layout->addWidget(fastSeekButton); playback_tab_layout->addWidget(seeking_group); // Playback -> Memory Usage QGroupBox* memory_usage_group = new QGroupBox(playback_tab); - memory_usage_group->setTitle("Memory Usage"); + memory_usage_group->setTitle(tr("Memory Usage")); QGridLayout* memory_usage_layout = new QGridLayout(memory_usage_group); - memory_usage_layout->addWidget(new QLabel("Upcoming Frame Queue:"), 0, 0); + memory_usage_layout->addWidget(new QLabel(tr("Upcoming Frame Queue:")), 0, 0); upcoming_queue_spinbox = new QDoubleSpinBox(); 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->addItem("frames"); - upcoming_queue_type->addItem("seconds"); + 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("Previous Frame Queue:"), 1, 0); + memory_usage_layout->addWidget(new QLabel(tr("Previous Frame Queue:")), 1, 0); previous_queue_spinbox = new QDoubleSpinBox(); 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->addItem("frames"); - previous_queue_type->addItem("seconds"); + previous_queue_type->addItem(tr("frames")); + previous_queue_type->addItem(tr("seconds")); previous_queue_type->setCurrentIndex(config.previous_queue_type); memory_usage_layout->addWidget(previous_queue_type, 1, 2); playback_tab_layout->addWidget(memory_usage_group); - tabWidget->addTab(playback_tab, "Playback"); + tabWidget->addTab(playback_tab, tr("Playback")); QWidget* shortcut_tab = new QWidget(); QVBoxLayout* shortcut_layout = new QVBoxLayout(shortcut_tab); QLineEdit* key_search_line = new QLineEdit(); - key_search_line->setPlaceholderText("Search for action or shortcut"); + 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(); QTreeWidgetItem* tree_header = keyboard_tree->headerItem(); - tree_header->setText(0, "Action"); - tree_header->setText(1, "Shortcut"); + tree_header->setText(0, tr("Action")); + tree_header->setText(1, tr("Shortcut")); shortcut_layout->addWidget(keyboard_tree); QHBoxLayout* reset_shortcut_layout = new QHBoxLayout(); - QPushButton* import_shortcut_button = new QPushButton("Import"); + QPushButton* import_shortcut_button = new QPushButton(tr("Import")); 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("Export"); + QPushButton* export_shortcut_button = new QPushButton(tr("Export")); 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("Reset Selected"); + QPushButton* reset_selected_shortcut_button = new QPushButton(tr("Reset Selected")); 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("Reset All"); + QPushButton* reset_all_shortcut_button = new QPushButton(tr("Reset All")); reset_shortcut_layout->addWidget(reset_all_shortcut_button); connect(reset_all_shortcut_button, SIGNAL(clicked(bool)), this, SLOT(reset_all_shortcuts())); shortcut_layout->addLayout(reset_shortcut_layout); - tabWidget->addTab(shortcut_tab, "Keyboard"); + tabWidget->addTab(shortcut_tab, tr("Keyboard")); verticalLayout->addWidget(tabWidget); diff --git a/dialogs/replaceclipmediadialog.cpp b/dialogs/replaceclipmediadialog.cpp index 5243cc71c..ee07947ee 100644 --- a/dialogs/replaceclipmediadialog.cpp +++ b/dialogs/replaceclipmediadialog.cpp @@ -23,19 +23,19 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media QDialog(parent), media(old_media) { - setWindowTitle("Replace clips using \"" + old_media->get_name() + "\""); + setWindowTitle(tr("Replace clips using \"%1\"").arg(old_media->get_name())); resize(300, 400); QVBoxLayout* layout = new QVBoxLayout(); - layout->addWidget(new QLabel("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:"))); tree = new QTreeView(); layout->addWidget(tree); - use_same_media_in_points = new QCheckBox("Keep the same media in-points"); + use_same_media_in_points = new QCheckBox(tr("Keep the same media in-points")); use_same_media_in_points->setChecked(true); layout->addWidget(use_same_media_in_points); @@ -43,11 +43,11 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media buttons->addStretch(); - QPushButton* replace_button = new QPushButton("Replace"); + QPushButton* replace_button = new QPushButton(tr("Replace")); connect(replace_button, SIGNAL(clicked(bool)), this, SLOT(replace())); buttons->addWidget(replace_button); - QPushButton* cancel_button = new QPushButton("Cancel"); + QPushButton* cancel_button = new QPushButton(tr("Cancel")); connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(close())); buttons->addWidget(cancel_button); @@ -63,16 +63,36 @@ ReplaceClipMediaDialog::ReplaceClipMediaDialog(QWidget *parent, Media *old_media void ReplaceClipMediaDialog::replace() { QModelIndexList selected_items = tree->selectionModel()->selectedRows(); if (selected_items.size() != 1) { - QMessageBox::critical(this, "No media selected", "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, "Same media selected", "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, "Folder selected", "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, "Active sequence selected", "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 ff4c52a14..a8cede70a 100644 --- a/dialogs/speeddialog.cpp +++ b/dialogs/speeddialog.cpp @@ -19,25 +19,27 @@ #include "project/media.h" SpeedDialog::SpeedDialog(QWidget *parent) : QDialog(parent) { + setWindowTitle(tr("Speed/Duration")); + QVBoxLayout* main_layout = new QVBoxLayout(); setLayout(main_layout); QGridLayout* grid = new QGridLayout(); grid->setSpacing(6); - grid->addWidget(new QLabel("Speed:"), 0, 0); + grid->addWidget(new QLabel(tr("Speed:")), 0, 0); percent = new LabelSlider(); percent->decimal_places = 2; percent->set_display_type(LABELSLIDER_PERCENT); percent->set_default_value(1); grid->addWidget(percent, 0, 1); - grid->addWidget(new QLabel("Frame Rate:"), 1, 0); + grid->addWidget(new QLabel(tr("Frame Rate:")), 1, 0); frame_rate = new LabelSlider(); frame_rate->decimal_places = 3; grid->addWidget(frame_rate, 1, 1); - grid->addWidget(new QLabel("Duration:"), 2, 0); + grid->addWidget(new QLabel(tr("Duration:")), 2, 0); duration = new LabelSlider(); duration->set_display_type(LABELSLIDER_FRAMENUMBER); duration->set_frame_rate(sequence->frame_rate); @@ -45,9 +47,9 @@ SpeedDialog::SpeedDialog(QWidget *parent) : QDialog(parent) { main_layout->addLayout(grid); - reverse = new QCheckBox("Reverse"); - maintain_pitch = new QCheckBox("Maintain Audio Pitch"); - ripple = new QCheckBox("Ripple Changes"); + reverse = new QCheckBox(tr("Reverse")); + maintain_pitch = new QCheckBox(tr("Maintain Audio Pitch")); + ripple = new QCheckBox(tr("Ripple Changes")); main_layout->addWidget(reverse); main_layout->addWidget(maintain_pitch); diff --git a/dialogs/texteditdialog.cpp b/dialogs/texteditdialog.cpp index 508a67c4c..51337a637 100644 --- a/dialogs/texteditdialog.cpp +++ b/dialogs/texteditdialog.cpp @@ -7,7 +7,7 @@ TextEditDialog::TextEditDialog(QWidget *parent, const QString &s) : QDialog(parent) { - setWindowTitle("Edit Text"); + setWindowTitle(tr("Edit Text")); QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); diff --git a/effects/internal/audionoiseeffect.cpp b/effects/internal/audionoiseeffect.cpp index effd65f6e..0ec1f8a45 100644 --- a/effects/internal/audionoiseeffect.cpp +++ b/effects/internal/audionoiseeffect.cpp @@ -4,12 +4,12 @@ #include AudioNoiseEffect::AudioNoiseEffect(Clip* c, const EffectMeta *em) : Effect(c, em) { - amount_val = add_row("Amount")->add_field(EFFECT_FIELD_DOUBLE, "amount"); + amount_val = add_row(tr("Amount"))->add_field(EFFECT_FIELD_DOUBLE, "amount"); amount_val->set_double_minimum_value(0); amount_val->set_double_maximum_value(100); amount_val->set_double_default_value(20); - mix_val = add_row("Mix")->add_field(EFFECT_FIELD_BOOL, "mix"); + mix_val = add_row(tr("Mix"))->add_field(EFFECT_FIELD_BOOL, "mix"); mix_val->set_bool_value(true); srand(QDateTime::currentMSecsSinceEpoch()); diff --git a/effects/internal/cornerpineffect.cpp b/effects/internal/cornerpineffect.cpp index 5be93b671..1fa328c67 100644 --- a/effects/internal/cornerpineffect.cpp +++ b/effects/internal/cornerpineffect.cpp @@ -8,23 +8,23 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em) enable_coords = true; enable_shader = true; - EffectRow* top_left = add_row("Top Left"); + EffectRow* top_left = add_row(tr("Top Left")); top_left_x = top_left->add_field(EFFECT_FIELD_DOUBLE, "topleftx"); top_left_y = top_left->add_field(EFFECT_FIELD_DOUBLE, "toplefty"); - EffectRow* top_right = add_row("Top Right"); + EffectRow* top_right = add_row(tr("Top Right")); top_right_x = top_right->add_field(EFFECT_FIELD_DOUBLE, "toprightx"); top_right_y = top_right->add_field(EFFECT_FIELD_DOUBLE, "toprighty"); - EffectRow* bottom_left = add_row("Bottom Left"); + EffectRow* bottom_left = add_row(tr("Bottom Left")); bottom_left_x = bottom_left->add_field(EFFECT_FIELD_DOUBLE, "bottomleftx"); bottom_left_y = bottom_left->add_field(EFFECT_FIELD_DOUBLE, "bottomlefty"); - EffectRow* bottom_right = add_row("Bottom Right"); + EffectRow* bottom_right = add_row(tr("Bottom Right")); bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE, "bottomrightx"); bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE, "bottomrighty"); - perspective = add_row("Perspective")->add_field(EFFECT_FIELD_BOOL, "perspective"); + perspective = add_row(tr("Perspective"))->add_field(EFFECT_FIELD_BOOL, "perspective"); perspective->set_bool_value(true); top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT); diff --git a/effects/internal/fillleftrighteffect.cpp b/effects/internal/fillleftrighteffect.cpp index d21765e60..15ed2a4bd 100644 --- a/effects/internal/fillleftrighteffect.cpp +++ b/effects/internal/fillleftrighteffect.cpp @@ -4,10 +4,10 @@ #define FILL_TYPE_RIGHT 1 FillLeftRightEffect::FillLeftRightEffect(Clip* c, const EffectMeta *em) : Effect(c, em) { - EffectRow* type_row = add_row("Type"); + EffectRow* type_row = add_row(tr("Type")); fill_type = type_row->add_field(EFFECT_FIELD_COMBO, "type"); - fill_type->add_combo_item("Fill Left with Right", FILL_TYPE_LEFT); - fill_type->add_combo_item("Fill Right with Left", FILL_TYPE_RIGHT); + fill_type->add_combo_item(tr("Fill Left with Right"), FILL_TYPE_LEFT); + fill_type->add_combo_item(tr("Fill Right with Left"), FILL_TYPE_RIGHT); } void FillLeftRightEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) { diff --git a/effects/internal/paneffect.cpp b/effects/internal/paneffect.cpp index fcb862192..e50d29612 100644 --- a/effects/internal/paneffect.cpp +++ b/effects/internal/paneffect.cpp @@ -9,7 +9,7 @@ #include "ui/collapsiblewidget.h" PanEffect::PanEffect(Clip* c, const EffectMeta *em) : Effect(c, em) { - EffectRow* pan_row = add_row("Pan"); + EffectRow* pan_row = add_row(tr("Pan")); pan_val = pan_row->add_field(EFFECT_FIELD_DOUBLE, "pan"); pan_val->set_double_minimum_value(-100); pan_val->set_double_maximum_value(100); diff --git a/effects/internal/shakeeffect.cpp b/effects/internal/shakeeffect.cpp index 92975fe8a..91e7dfe7c 100644 --- a/effects/internal/shakeeffect.cpp +++ b/effects/internal/shakeeffect.cpp @@ -16,15 +16,15 @@ ShakeEffect::ShakeEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { enable_coords = true; - EffectRow* intensity_row = add_row("Intensity"); + EffectRow* intensity_row = add_row(tr("Intensity")); intensity_val = intensity_row->add_field(EFFECT_FIELD_DOUBLE, "intensity"); intensity_val->set_double_minimum_value(0); - EffectRow* rotation_row = add_row("Rotation"); + EffectRow* rotation_row = add_row(tr("Rotation")); rotation_val = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation"); rotation_val->set_double_minimum_value(0); - EffectRow* frequency_row = add_row("Frequency"); + EffectRow* frequency_row = add_row(tr("Frequency")); frequency_val = frequency_row->add_field(EFFECT_FIELD_DOUBLE, "frequency"); frequency_val->set_double_minimum_value(0); diff --git a/effects/internal/solideffect.cpp b/effects/internal/solideffect.cpp index 512dccda6..41522adaf 100644 --- a/effects/internal/solideffect.cpp +++ b/effects/internal/solideffect.cpp @@ -21,20 +21,20 @@ SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) : Effect(c, em) { enable_superimpose = true; - solid_type = add_row("Type")->add_field(EFFECT_FIELD_COMBO, "type"); - solid_type->add_combo_item("Solid Color", SOLID_TYPE_COLOR); - solid_type->add_combo_item("SMPTE Bars", SOLID_TYPE_BARS); - solid_type->add_combo_item("Checkerboard", SOLID_TYPE_CHECKERBOARD); + solid_type = add_row(tr("Type"))->add_field(EFFECT_FIELD_COMBO, "type"); + solid_type->add_combo_item(tr("Solid Color"), SOLID_TYPE_COLOR); + solid_type->add_combo_item(tr("SMPTE Bars"), SOLID_TYPE_BARS); + solid_type->add_combo_item(tr("Checkerboard"), SOLID_TYPE_CHECKERBOARD); - opacity_field = add_row("Opacity")->add_field(EFFECT_FIELD_DOUBLE, "opacity"); + opacity_field = add_row(tr("Opacity"))->add_field(EFFECT_FIELD_DOUBLE, "opacity"); opacity_field->set_double_minimum_value(0); opacity_field->set_double_maximum_value(100); opacity_field->set_double_default_value(100); - solid_color_field = add_row("Color")->add_field(EFFECT_FIELD_COLOR, "color"); + solid_color_field = add_row(tr("Color"))->add_field(EFFECT_FIELD_COLOR, "color"); solid_color_field->set_color_value(Qt::red); - checkerboard_size_field = add_row("Checkerboard Size")->add_field(EFFECT_FIELD_DOUBLE, "checker_size"); + checkerboard_size_field = add_row(tr("Checkerboard Size"))->add_field(EFFECT_FIELD_DOUBLE, "checker_size"); checkerboard_size_field->set_double_minimum_value(1); checkerboard_size_field->set_double_default_value(10); diff --git a/effects/internal/texteffect.cpp b/effects/internal/texteffect.cpp index 56b609f80..e30c1648c 100644 --- a/effects/internal/texteffect.cpp +++ b/effects/internal/texteffect.cpp @@ -29,49 +29,49 @@ TextEffect::TextEffect(Clip *c, const EffectMeta* em) : enable_superimpose = true; //enable_shader = true; - text_val = add_row("Text")->add_field(EFFECT_FIELD_STRING, "text", 2); + text_val = add_row(tr("Text"))->add_field(EFFECT_FIELD_STRING, "text", 2); QTextEdit* text_widget = static_cast(text_val->ui_element); text_widget->setContextMenuPolicy(Qt::CustomContextMenu); connect(text_widget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(text_edit_menu())); - set_font_combobox = add_row("Font")->add_field(EFFECT_FIELD_FONT, "font", 2); + set_font_combobox = add_row(tr("Font"))->add_field(EFFECT_FIELD_FONT, "font", 2); - size_val = add_row("Size")->add_field(EFFECT_FIELD_DOUBLE, "size", 2); + size_val = add_row(tr("Size"))->add_field(EFFECT_FIELD_DOUBLE, "size", 2); size_val->set_double_minimum_value(0); - set_color_button = add_row("Color")->add_field(EFFECT_FIELD_COLOR, "color", 2); + set_color_button = add_row(tr("Color"))->add_field(EFFECT_FIELD_COLOR, "color", 2); - EffectRow* alignment_row = add_row("Alignment"); + EffectRow* alignment_row = add_row(tr("Alignment")); halign_field = alignment_row->add_field(EFFECT_FIELD_COMBO, "halign"); - halign_field->add_combo_item("Left", Qt::AlignLeft); - halign_field->add_combo_item("Center", Qt::AlignHCenter); - halign_field->add_combo_item("Right", Qt::AlignRight); - halign_field->add_combo_item("Justify", Qt::AlignJustify); + halign_field->add_combo_item(tr("Left"), Qt::AlignLeft); + halign_field->add_combo_item(tr("Center"), Qt::AlignHCenter); + halign_field->add_combo_item(tr("Right"), Qt::AlignRight); + halign_field->add_combo_item(tr("Justify"), Qt::AlignJustify); valign_field = alignment_row->add_field(EFFECT_FIELD_COMBO, "valign"); - valign_field->add_combo_item("Top", Qt::AlignTop); - valign_field->add_combo_item("Center", Qt::AlignVCenter); - valign_field->add_combo_item("Bottom", Qt::AlignBottom); + valign_field->add_combo_item(tr("Top"), Qt::AlignTop); + valign_field->add_combo_item(tr("Center"), Qt::AlignVCenter); + valign_field->add_combo_item(tr("Bottom"), Qt::AlignBottom); - word_wrap_field = add_row("Word Wrap")->add_field(EFFECT_FIELD_BOOL, "wordwrap", 2); + word_wrap_field = add_row(tr("Word Wrap"))->add_field(EFFECT_FIELD_BOOL, "wordwrap", 2); - outline_bool = add_row("Outline")->add_field(EFFECT_FIELD_BOOL, "outline", 2); - outline_color = add_row("Outline Color")->add_field(EFFECT_FIELD_COLOR, "outlinecolor", 2); - outline_width = add_row("Outline Width")->add_field(EFFECT_FIELD_DOUBLE, "outlinewidth", 2); + outline_bool = add_row(tr("Outline"))->add_field(EFFECT_FIELD_BOOL, "outline", 2); + outline_color = add_row(tr("Outline Color"))->add_field(EFFECT_FIELD_COLOR, "outlinecolor", 2); + outline_width = add_row(tr("Outline Width"))->add_field(EFFECT_FIELD_DOUBLE, "outlinewidth", 2); outline_width->set_double_minimum_value(0); - shadow_bool = add_row("Shadow")->add_field(EFFECT_FIELD_BOOL, "shadow", 2); - shadow_color = add_row("Shadow Color")->add_field(EFFECT_FIELD_COLOR, "shadowcolor", 2); - shadow_distance = add_row("Shadow Distance")->add_field(EFFECT_FIELD_DOUBLE, "shadowdistance", 2); + shadow_bool = add_row(tr("Shadow"))->add_field(EFFECT_FIELD_BOOL, "shadow", 2); + shadow_color = add_row(tr("Shadow Color"))->add_field(EFFECT_FIELD_COLOR, "shadowcolor", 2); + shadow_distance = add_row(tr("Shadow Distance"))->add_field(EFFECT_FIELD_DOUBLE, "shadowdistance", 2); shadow_distance->set_double_minimum_value(0); - shadow_softness = add_row("Shadow Softness")->add_field(EFFECT_FIELD_DOUBLE, "shadowsoftness", 2); + shadow_softness = add_row(tr("Shadow Softness"))->add_field(EFFECT_FIELD_DOUBLE, "shadowsoftness", 2); shadow_softness->set_double_minimum_value(0); - shadow_opacity = add_row("Shadow Opacity")->add_field(EFFECT_FIELD_DOUBLE, "shadowopacity", 2); + shadow_opacity = add_row(tr("Shadow Opacity"))->add_field(EFFECT_FIELD_DOUBLE, "shadowopacity", 2); shadow_opacity->set_double_minimum_value(0); shadow_opacity->set_double_maximum_value(100); size_val->set_double_default_value(48); - text_val->set_string_value("Sample Text"); + text_val->set_string_value(tr("Sample Text")); halign_field->set_combo_index(1); valign_field->set_combo_index(1); word_wrap_field->set_bool_value(true); @@ -207,7 +207,7 @@ void TextEffect::shadow_enable(bool e) { void TextEffect::text_edit_menu() { QMenu menu; - menu.addAction("&Edit Text", this, SLOT(open_text_edit())); + menu.addAction(tr("&Edit Text"), this, SLOT(open_text_edit())); menu.exec(QCursor::pos()); } diff --git a/effects/internal/timecodeeffect.cpp b/effects/internal/timecodeeffect.cpp index baba8c50d..7e8299b76 100644 --- a/effects/internal/timecodeeffect.cpp +++ b/effects/internal/timecodeeffect.cpp @@ -29,33 +29,33 @@ TimecodeEffect::TimecodeEffect(Clip *c, const EffectMeta* em) : enable_always_update = true; enable_superimpose = true; - EffectRow* tc_row = add_row("Timecode"); + EffectRow* tc_row = add_row(tr("Timecode")); tc_select = tc_row->add_field(EFFECT_FIELD_COMBO, "tc_selector"); - tc_select->add_combo_item("Sequence", true); - tc_select->add_combo_item("Media", false); + tc_select->add_combo_item(tr("Sequence"), true); + tc_select->add_combo_item(tr("Media"), false); tc_select->set_combo_index(0); - scale_val = add_row("Scale")->add_field(EFFECT_FIELD_DOUBLE, "scale", 2); + scale_val = add_row(tr("Scale"))->add_field(EFFECT_FIELD_DOUBLE, "scale", 2); scale_val->set_double_minimum_value(1); scale_val->set_double_default_value(100); scale_val->set_double_maximum_value(1000); - color_val = add_row("Color")->add_field(EFFECT_FIELD_COLOR, "color", 2); + color_val = add_row(tr("Color"))->add_field(EFFECT_FIELD_COLOR, "color", 2); color_val->set_color_value(Qt::white); - color_bg_val = add_row("Background Color")->add_field(EFFECT_FIELD_COLOR, "bgcolor", 2); + color_bg_val = add_row(tr("Background Color"))->add_field(EFFECT_FIELD_COLOR, "bgcolor", 2); color_bg_val->set_color_value(Qt::black); - bg_alpha = add_row("Background Opacity")->add_field(EFFECT_FIELD_DOUBLE, "bgalpha", 2); + bg_alpha = add_row(tr("Background Opacity"))->add_field(EFFECT_FIELD_DOUBLE, "bgalpha", 2); bg_alpha->set_double_minimum_value(0); bg_alpha->set_double_maximum_value(100); bg_alpha->set_double_default_value(50); - EffectRow* offset = add_row("Offset"); + EffectRow* offset = add_row(tr("Offset")); offset_x_val = offset->add_field(EFFECT_FIELD_DOUBLE, "offsetx"); offset_y_val = offset->add_field(EFFECT_FIELD_DOUBLE, "offsety"); - prepend_text = add_row("Prepend")->add_field(EFFECT_FIELD_STRING, "prepend", 2); + prepend_text = add_row(tr("Prepend"))->add_field(EFFECT_FIELD_STRING, "prepend", 2); } diff --git a/effects/internal/toneeffect.cpp b/effects/internal/toneeffect.cpp index 1df21ff5c..1ccb03d8a 100644 --- a/effects/internal/toneeffect.cpp +++ b/effects/internal/toneeffect.cpp @@ -9,20 +9,20 @@ #include "debug.h" ToneEffect::ToneEffect(Clip* c, const EffectMeta *em) : Effect(c, em), sinX(INT_MIN) { - type_val = add_row("Type")->add_field(EFFECT_FIELD_COMBO, "type"); + type_val = add_row(tr("Type"))->add_field(EFFECT_FIELD_COMBO, "type"); type_val->add_combo_item("Sine", TONE_TYPE_SINE); - freq_val = add_row("Frequency")->add_field(EFFECT_FIELD_DOUBLE, "frequency"); + freq_val = add_row(tr("Frequency"))->add_field(EFFECT_FIELD_DOUBLE, "frequency"); freq_val->set_double_minimum_value(20); freq_val->set_double_maximum_value(20000); freq_val->set_double_default_value(1000); - amount_val = add_row("Amount")->add_field(EFFECT_FIELD_DOUBLE, "amount"); + amount_val = add_row(tr("Amount"))->add_field(EFFECT_FIELD_DOUBLE, "amount"); amount_val->set_double_minimum_value(0); amount_val->set_double_maximum_value(100); amount_val->set_double_default_value(25); - mix_val = add_row("Mix")->add_field(EFFECT_FIELD_BOOL, "mix"); + mix_val = add_row(tr("Mix"))->add_field(EFFECT_FIELD_BOOL, "mix"); mix_val->set_bool_value(true); } diff --git a/effects/internal/transformeffect.cpp b/effects/internal/transformeffect.cpp index e1cf1dde7..f1c6d2bce 100644 --- a/effects/internal/transformeffect.cpp +++ b/effects/internal/transformeffect.cpp @@ -31,11 +31,11 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) { enable_coords = true; - EffectRow* position_row = add_row("Position"); + EffectRow* position_row = add_row(tr("Position")); position_x = position_row->add_field(EFFECT_FIELD_DOUBLE, "posx"); // position X position_y = position_row->add_field(EFFECT_FIELD_DOUBLE, "posy"); // position Y - EffectRow* scale_row = add_row("Scale"); + EffectRow* scale_row = add_row(tr("Scale")); scale_x = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scalex"); // scale X (and Y is uniform scale is selected) scale_x->set_double_minimum_value(0); scale_x->set_double_maximum_value(3000); @@ -43,27 +43,27 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) scale_y->set_double_minimum_value(0); scale_y->set_double_maximum_value(3000); - EffectRow* uniform_scale_row = add_row("Uniform Scale"); + EffectRow* uniform_scale_row = add_row(tr("Uniform Scale")); uniform_scale_field = uniform_scale_row->add_field(EFFECT_FIELD_BOOL, "uniformscale"); // uniform scale option - EffectRow* rotation_row = add_row("Rotation"); + EffectRow* rotation_row = add_row(tr("Rotation")); rotation = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation"); - EffectRow* anchor_point_row = add_row("Anchor Point"); + EffectRow* anchor_point_row = add_row(tr("Anchor Point")); anchor_x_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchorx"); // anchor point X anchor_y_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchory"); // anchor point Y - EffectRow* opacity_row = add_row("Opacity"); + EffectRow* opacity_row = add_row(tr("Opacity")); opacity = opacity_row->add_field(EFFECT_FIELD_DOUBLE, "opacity"); // opacity opacity->set_double_minimum_value(0); opacity->set_double_maximum_value(100); - EffectRow* blend_mode_row = add_row("Blend Mode"); + EffectRow* blend_mode_row = add_row(tr("Blend Mode")); blend_mode_box = blend_mode_row->add_field(EFFECT_FIELD_COMBO, "blendmode"); // blend mode - blend_mode_box->add_combo_item("Normal", BLEND_MODE_NORMAL); - blend_mode_box->add_combo_item("Overlay", BLEND_MODE_OVERLAY); - blend_mode_box->add_combo_item("Screen", BLEND_MODE_SCREEN); - blend_mode_box->add_combo_item("Multiply", BLEND_MODE_MULTIPLY); + blend_mode_box->add_combo_item(tr("Normal"), BLEND_MODE_NORMAL); + blend_mode_box->add_combo_item(tr("Overlay"), BLEND_MODE_OVERLAY); + blend_mode_box->add_combo_item(tr("Screen"), BLEND_MODE_SCREEN); + blend_mode_box->add_combo_item(tr("Multiply"), BLEND_MODE_MULTIPLY); // set up gizmos top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT); diff --git a/effects/internal/voideffect.cpp b/effects/internal/voideffect.cpp index 11a8c25ff..8a4c11f30 100644 --- a/effects/internal/voideffect.cpp +++ b/effects/internal/voideffect.cpp @@ -11,11 +11,11 @@ VoidEffect::VoidEffect(Clip *c, const QString& n) : Effect(c, NULL) { name = n; QString display_name; if (n.isEmpty()) { - display_name = "(unknown)"; + display_name = tr("(unknown)"); } else { display_name = n; } - EffectRow* row = add_row("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/volumeeffect.cpp b/effects/internal/volumeeffect.cpp index 48a329c16..997d9a2e6 100644 --- a/effects/internal/volumeeffect.cpp +++ b/effects/internal/volumeeffect.cpp @@ -9,7 +9,7 @@ #include "ui/collapsiblewidget.h" VolumeEffect::VolumeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) { - EffectRow* volume_row = add_row("Volume"); + EffectRow* volume_row = add_row(tr("Volume")); volume_val = volume_row->add_field(EFFECT_FIELD_DOUBLE, "volume"); volume_val->set_double_minimum_value(0); diff --git a/effects/internal/vsthostwin.cpp b/effects/internal/vsthostwin.cpp index 302cb5d34..c1030d878 100644 --- a/effects/internal/vsthostwin.cpp +++ b/effects/internal/vsthostwin.cpp @@ -60,16 +60,16 @@ void VSTHostWin::loadPlugin() { modulePtr = LoadLibrary(dll_fn_w); if(modulePtr == NULL) { DWORD dll_err = GetLastError(); - qCritical() << "Failed to load VST" << dll_fn_w << "-" << dll_err; - QString msg_err = "Failed to load VST plugin \"" + dll_fn + "\": " + QString::number(dll_err); + qCritical() << "Failed to load VST" << dll_fn_w << "-" << dll_err; + QString msg_err = tr("Failed to load VST plugin \"%1\": %2").arg(dll_fn, QString::number(dll_err)); if (dll_err == 193) { #ifdef _WIN64 - msg_err += "\n\nNOTE: You can't load 32-bit VST plugins into a 64-bit build of Olive. Please find a 64-bit version of this plugin or switch to a 32-bit build of Olive."; + msg_err += "\n\n" + tr("NOTE: You can't load 32-bit VST plugins into a 64-bit build of Olive. Please find a 64-bit version of this plugin or switch to a 32-bit build of Olive."); #elif _WIN32 - msg_err += "\n\nNOTE: You can't load 64-bit VST plugins into a 32-bit build of Olive. Please find a 32-bit version of this plugin or switch to a 64-bit build of Olive."; + msg_err += "\n\n" + tr("NOTE: You can't load 64-bit VST plugins into a 32-bit build of Olive. Please find a 32-bit version of this plugin or switch to a 64-bit build of Olive."); #endif } - QMessageBox::critical(mainWindow, "Error loading VST plugin", msg_err); + QMessageBox::critical(mainWindow, tr("Error loading VST plugin"), msg_err); return; } @@ -93,7 +93,7 @@ bool VSTHostWin::configurePluginCallbacks() { // real VST plugin, or is otherwise corrupt. if(plugin->magic != kEffectMagic) { qCritical() << "Plugin's magic number is bad"; - QMessageBox::critical(mainWindow, "VST Error", "Plugin's magic number is invalid"); + QMessageBox::critical(mainWindow, tr("VST Error"), tr("Plugin's magic number is invalid")); return false; } @@ -162,18 +162,18 @@ VSTHostWin::VSTHostWin(Clip* c, const EffectMeta *em) : Effect(c, em) { initializeIO(); - file_field = add_row("Plugin", true, false)->add_field(EFFECT_FIELD_FILE, "filename"); + file_field = add_row(tr("Plugin"), true, false)->add_field(EFFECT_FIELD_FILE, "filename"); connect(file_field, SIGNAL(changed()), this, SLOT(change_plugin())); - EffectRow* interface_row = add_row("Interface", false, false); - show_interface_btn = new QPushButton("Show"); + EffectRow* interface_row = add_row(tr("Interface"), false, false); + show_interface_btn = new QPushButton(tr("Show")); show_interface_btn->setCheckable(true); show_interface_btn->setEnabled(false); connect(show_interface_btn, SIGNAL(toggled(bool)), this, SLOT(show_interface(bool))); interface_row->add_widget(show_interface_btn); dialog = new QDialog(mainWindow); - dialog->setWindowTitle("VST Plugin"); + dialog->setWindowTitle(tr("VST Plugin")); dialog->setAttribute(Qt::WA_NativeWindow, true); dialog->setWindowFlags(dialog->windowFlags() | Qt::MSWindowsFixedSizeDialogHint); connect(dialog, SIGNAL(finished(int)), this, SLOT(uncheck_show_button())); diff --git a/io/exportthread.cpp b/io/exportthread.cpp index 5993f0316..99deaf5ce 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -49,7 +49,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, ret = avcodec_send_frame(codec_ctx, frame); if (ret < 0) { qCritical() << "Failed to send frame to encoder." << ret; - ed->export_error = "failed to send frame to encoder (" + QString::number(ret) + ")"; + ed->export_error = tr("failed to send frame to encoder (%1)").arg(QString::number(ret)); return false; } @@ -60,7 +60,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, } else if (ret < 0) { if (ret != AVERROR_EOF) { qCritical() << "Failed to receive packet from encoder." << ret; - ed->export_error = "failed to receive packet from encoder (" + QString::number(ret) + ")"; + ed->export_error = tr("failed to receive packet from encoder (%1)").arg(QString::number(ret)); } return false; } @@ -81,7 +81,7 @@ bool ExportThread::setupVideo() { vcodec = avcodec_find_encoder((enum AVCodecID) video_codec); if (!vcodec) { qCritical() << "Could not find video encoder"; - ed->export_error = "could not video encoder for " + QString::number(video_codec); + ed->export_error = tr("could not video encoder for %1").arg(QString::number(video_codec)); return false; } @@ -90,7 +90,7 @@ bool ExportThread::setupVideo() { video_stream->id = 0; if (!video_stream) { qCritical() << "Could not allocate video stream"; - ed->export_error = "could not allocate video stream"; + ed->export_error = tr("could not allocate video stream"); return false; } @@ -99,7 +99,7 @@ bool ExportThread::setupVideo() { vcodec_ctx = avcodec_alloc_context3(vcodec); if (!vcodec_ctx) { qCritical() << "Could not allocate video encoding context"; - ed->export_error = "could not allocate video encoding context"; + ed->export_error = tr("could not allocate video encoding context"); return false; } @@ -136,7 +136,7 @@ bool ExportThread::setupVideo() { ret = avcodec_open2(vcodec_ctx, vcodec, NULL); if (ret < 0) { qCritical() << "Could not open output video encoder." << ret; - ed->export_error = "could not open output video encoder (" + QString::number(ret) + ")"; + ed->export_error = tr("could not open output video encoder (%1)").arg(QString::number(ret)); return false; } @@ -144,7 +144,7 @@ bool ExportThread::setupVideo() { ret = avcodec_parameters_from_context(video_stream->codecpar, vcodec_ctx); if (ret < 0) { qCritical() << "Could not copy video encoder parameters to output stream." << ret; - ed->export_error = "could not copy video encoder parameters to output stream (" + QString::number(ret) + ")"; + ed->export_error = tr("could not copy video encoder parameters to output stream (%1)").arg(QString::number(ret)); return false; } @@ -188,7 +188,7 @@ bool ExportThread::setupAudio() { acodec = avcodec_find_encoder(static_cast(audio_codec)); if (!acodec) { qCritical() << "Could not find audio encoder"; - ed->export_error = "could not audio encoder for " + QString::number(audio_codec); + ed->export_error = tr("could not audio encoder for %1").arg(QString::number(audio_codec)); return false; } @@ -197,7 +197,7 @@ bool ExportThread::setupAudio() { audio_stream->id = 1; if (!audio_stream) { qCritical() << "Could not allocate audio stream"; - ed->export_error = "could not allocate audio stream"; + ed->export_error = tr("could not allocate audio stream"); return false; } @@ -206,7 +206,7 @@ bool ExportThread::setupAudio() { acodec_ctx = avcodec_alloc_context3(acodec); if (!acodec_ctx) { qCritical() << "Could not find allocate audio encoding context"; - ed->export_error = "could not allocate audio encoding context"; + ed->export_error = tr("could not allocate audio encoding context"); return false; } @@ -231,7 +231,7 @@ bool ExportThread::setupAudio() { ret = avcodec_open2(acodec_ctx, acodec, NULL); if (ret < 0) { qCritical() << "Could not open output audio encoder." << ret; - ed->export_error = "could not open output audio encoder (" + QString::number(ret) + ")"; + ed->export_error = tr("could not open output audio encoder (%1)").arg(QString::number(ret)); return false; } @@ -239,7 +239,7 @@ bool ExportThread::setupAudio() { ret = avcodec_parameters_from_context(audio_stream->codecpar, acodec_ctx); if (ret < 0) { qCritical() << "Could not copy audio encoder parameters to output stream." << ret; - ed->export_error = "could not copy audio encoder parameters to output stream (" + QString::number(ret) + ")"; + ed->export_error = tr("could not copy audio encoder parameters to output stream (%1)").arg(QString::number(ret)); return false; } @@ -269,7 +269,7 @@ bool ExportThread::setupAudio() { ret = av_frame_get_buffer(audio_frame, 0); if (ret < 0) { qCritical() << "Could not allocate audio buffer." << ret; - ed->export_error = "could not allocate audio buffer (" + QString::number(ret) + ")"; + ed->export_error = tr("could not allocate audio buffer (%1)").arg(QString::number(ret)); return false; } aframe_bytes = av_samples_get_buffer_size(NULL, audio_frame->channels, audio_frame->nb_samples, static_cast(audio_frame->format), 0); @@ -291,7 +291,7 @@ bool ExportThread::setupContainer() { avformat_alloc_output_context2(&fmt_ctx, NULL, NULL, c_filename); if (!fmt_ctx) { qCritical() << "Could not create output context"; - ed->export_error = "could not create output format context"; + ed->export_error = tr("could not create output format context"); return false; } @@ -300,7 +300,7 @@ bool ExportThread::setupContainer() { ret = avio_open(&fmt_ctx->pb, c_filename, AVIO_FLAG_WRITE); if (ret < 0) { qCritical() << "Could not open output file." << ret; - ed->export_error = "could not open output file (" + QString::number(ret) + ")"; + ed->export_error = tr("could not open output file (%1)").arg(QString::number(ret)); return false; } @@ -312,7 +312,7 @@ void ExportThread::run() { if (!panel_sequence_viewer->viewer_widget->context()->makeCurrent(&surface)) { qCritical() << "Make current failed"; - ed->export_error = "could not make OpenGL context current"; + ed->export_error = tr("could not make OpenGL context current"); return; } @@ -331,7 +331,7 @@ void ExportThread::run() { ret = avformat_write_header(fmt_ctx, NULL); if (ret < 0) { qCritical() << "Could not write output file header." << ret; - ed->export_error = "could not write output file header (" + QString::number(ret) + ")"; + ed->export_error = tr("could not write output file header (%1)").arg(QString::number(ret)); continueEncode = false; } } @@ -440,7 +440,7 @@ void ExportThread::run() { ret = av_write_trailer(fmt_ctx); if (ret < 0) { qCritical() << "Could not write output file trailer." << ret; - ed->export_error = "could not write output file trailer (" + QString::number(ret) + ")"; + ed->export_error = tr("could not write output file trailer (%1)").arg(QString::number(ret)); continueEncode = false; } diff --git a/io/loadthread.cpp b/io/loadthread.cpp index 06d0fc3c7..0f8b44865 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -153,7 +153,12 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { if (type == LOAD_TYPE_VERSION) { int proj_version = stream.readElementText().toInt(); if (proj_version < MIN_SAVE_VERSION && proj_version > SAVE_VERSION) { - if (QMessageBox::warning(mainWindow, "Version Mismatch", "This project was saved in a different version of Olive and may not be fully compatible with this version. Would you like to attempt loading it anyway?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { + if (QMessageBox::warning( + mainWindow, + tr("Version Mismatch"), + tr("This project was saved in a different version of Olive and may not be fully compatible with this version. Would you like to attempt loading it anyway?"), + QMessageBox::Yes, + QMessageBox::No) == QMessageBox::No) { show_err = false; return false; } @@ -435,7 +440,11 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { if (!found) { correct_clip->linked.removeAt(j); j--; - if (QMessageBox::warning(mainWindow, "Invalid Clip Link", "This project contains an invalid clip link. It may be corrupt. Would you like to continue loading it?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { + if (QMessageBox::warning(mainWindow, + tr("Invalid Clip Link"), + tr("This project contains an invalid clip link. It may be corrupt. Would you like to continue loading it?"), + QMessageBox::Yes, + QMessageBox::No) == QMessageBox::No) { delete s; return false; } @@ -584,7 +593,7 @@ void LoadThread::run() { xml_error = false; if (show_err) emit error(); } else if (stream.hasError()) { - error_str = stream.errorString() + " - Line: " + QString::number(stream.lineNumber()) + " Col:" + QString::number(stream.columnNumber()); + error_str = tr("%1 - Line: %2 Col: %3").arg(stream.errorString(), QString::number(stream.lineNumber()), QString::number(stream.columnNumber())); xml_error = true; emit error(); cont = false; @@ -624,9 +633,15 @@ void LoadThread::cancel() { void LoadThread::error_func() { if (xml_error) { qCritical() << "Error parsing XML." << error_str; - QMessageBox::critical(mainWindow, "XML Parsing Error", "Couldn't load '" + project_url + "'. " + error_str, QMessageBox::Ok); + QMessageBox::critical(mainWindow, + tr("XML Parsing Error"), + tr("Couldn't load '%1'. %2").arg(project_url, error_str), + QMessageBox::Ok); } else { - QMessageBox::critical(mainWindow, "Project Load Error", "Error loading project: " + error_str, QMessageBox::Ok); + QMessageBox::critical(mainWindow, + tr("Project Load Error"), + tr("Error loading project: %1").arg(error_str), + QMessageBox::Ok); } } diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index cbc386743..247305320 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -435,14 +435,14 @@ void PreviewGenerator::run() { if(errCode != 0) { char err[1024]; av_strerror(errCode, err, 1024); - errorStr = "Could not open file - " + QString(err); + errorStr = tr("Could not open file - %1").arg(err); error = true; } else { errCode = avformat_find_stream_info(fmt_ctx, NULL); if (errCode < 0) { char err[1024]; av_strerror(errCode, err, 1024); - errorStr = "Could not find stream information - " + QString(err); + errorStr = tr("Could not find stream information - %1").arg(err); error = true; } else { av_dump_format(fmt_ctx, 0, filename, 0); diff --git a/olive.pro b/olive.pro index 112eb4e83..9451c287d 100644 --- a/olive.pro +++ b/olive.pro @@ -27,6 +27,8 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +QMAKE_CXXFLAGS += -std=c++11 -Wextra -Wshadow -Wnon-virtual-dtor -pedantic + # Tries to get the current Git short hash system("which git") { GITHASHVAR = $$system(git --git-dir $$PWD/.git --work-tree $$PWD log -1 --format=%h) diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index aab9635a2..a596ce09e 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -34,7 +34,7 @@ EffectControls::EffectControls(QWidget *parent) : QDockWidget(parent), multiple(false), zoom(1), - panel_name("Effects: "), + panel_name(tr("Effects: ")), mode(TA_NO_TRANSITION) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -303,7 +303,7 @@ void EffectControls::setup_ui() { QPushButton* btnAddVideoEffect = new QPushButton(veHeader); btnAddVideoEffect->setIcon(QIcon(":/icons/add-effect.png")); - btnAddVideoEffect->setToolTip("Add Video Effect"); + btnAddVideoEffect->setToolTip(tr("Add Video Effect")); veHeaderLayout->addWidget(btnAddVideoEffect); connect(btnAddVideoEffect, SIGNAL(clicked(bool)), this, SLOT(video_effect_click())); @@ -314,14 +314,14 @@ void EffectControls::setup_ui() { font.setPointSize(9); lblVideoEffects->setFont(font); lblVideoEffects->setAlignment(Qt::AlignCenter); - lblVideoEffects->setText("VIDEO EFFECTS"); + lblVideoEffects->setText(tr("VIDEO EFFECTS")); veHeaderLayout->addWidget(lblVideoEffects); veHeaderLayout->addStretch(); QPushButton* btnAddVideoTransition = new QPushButton(veHeader); btnAddVideoTransition->setIcon(QIcon(":/icons/add-transition.png")); - btnAddVideoTransition->setToolTip("Add Video Transition"); + btnAddVideoTransition->setToolTip(tr("Add Video Transition")); connect(btnAddVideoTransition, SIGNAL(clicked(bool)), this, SLOT(video_transition_click())); veHeaderLayout->addWidget(btnAddVideoTransition); @@ -351,7 +351,7 @@ void EffectControls::setup_ui() { QPushButton* btnAddAudioEffect = new QPushButton(aeHeader); btnAddAudioEffect->setIcon(QIcon(":/icons/add-effect.png")); - btnAddAudioEffect->setToolTip("Add Audio Effect"); + btnAddAudioEffect->setToolTip(tr("Add Audio Effect")); connect(btnAddAudioEffect, SIGNAL(clicked(bool)), this, SLOT(audio_effect_click())); aeHeaderLayout->addWidget(btnAddAudioEffect); @@ -360,14 +360,14 @@ void EffectControls::setup_ui() { QLabel* lblAudioEffects = new QLabel(aeHeader); lblAudioEffects->setFont(font); lblAudioEffects->setAlignment(Qt::AlignCenter); - lblAudioEffects->setText("AUDIO EFFECTS"); + lblAudioEffects->setText(tr("AUDIO EFFECTS")); aeHeaderLayout->addWidget(lblAudioEffects); aeHeaderLayout->addStretch(); QPushButton* btnAddAudioTransition = new QPushButton(aeHeader); btnAddAudioTransition->setIcon(QIcon(":/icons/add-transition.png")); - btnAddAudioTransition->setToolTip("Add Audio Transition"); + btnAddAudioTransition->setToolTip(tr("Add Audio Transition")); connect(btnAddAudioTransition, SIGNAL(clicked(bool)), this, SLOT(audio_transition_click())); aeHeaderLayout->addWidget(btnAddAudioTransition); @@ -384,7 +384,7 @@ void EffectControls::setup_ui() { lblMultipleClipsSelected = new QLabel(effects_area); lblMultipleClipsSelected->setAlignment(Qt::AlignCenter); - lblMultipleClipsSelected->setText("(Multiple clips selected)"); + lblMultipleClipsSelected->setText(tr("(Multiple clips selected)")); effects_area_layout->addWidget(lblMultipleClipsSelected); effects_area_layout->addStretch(); diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index 2cb44f673..c2c56525f 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -20,7 +20,7 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(NULL) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setWindowTitle("Graph Editor"); + setWindowTitle(tr("Graph Editor")); resize(720, 480); QWidget* main_widget = new QWidget(); @@ -58,13 +58,13 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(NULL) { left_tool_layout->addWidget(keyframe_nav); left_tool_layout->addStretch(); - linear_button = new QPushButton("Linear"); + linear_button = new QPushButton(tr("Linear")); linear_button->setProperty("type", KEYFRAME_TYPE_LINEAR); linear_button->setCheckable(true); - bezier_button = new QPushButton("Bezier"); + bezier_button = new QPushButton(tr("Bezier")); bezier_button->setProperty("type", KEYFRAME_TYPE_BEZIER); bezier_button->setCheckable(true); - hold_button = new QPushButton("Hold"); + hold_button = new QPushButton(tr("Hold")); hold_button->setProperty("type", KEYFRAME_TYPE_HOLD); hold_button->setCheckable(true); diff --git a/panels/project.cpp b/panels/project.cpp index 8742eecca..562617cef 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -177,7 +177,7 @@ Project::Project(QWidget *parent) : connect(icon_view, SIGNAL(changed_root()), this, SLOT(set_up_dir_enabled())); //retranslateUi(Project); - setWindowTitle(QApplication::translate("Project", "Project", nullptr)); + setWindowTitle(tr("Project")); update_view_type(); } @@ -187,7 +187,7 @@ Project::~Project() { } QString Project::get_next_sequence_name(QString start) { - if (start.isEmpty()) start = "Sequence"; + if (start.isEmpty()) start = tr("Sequence"); int n = 1; bool found = true; @@ -308,7 +308,11 @@ void Project::replace_selected_file() { void Project::replace_media(Media* item, QString filename) { if (filename.isEmpty()) { - filename = QFileDialog::getOpenFileName(this, "Replace '" + item->get_name() + "'", "", "All Files (*)"); + filename = QFileDialog::getOpenFileName( + this, + tr("Replace '%1'").arg(item->get_name()), + "", + tr("All Files") + " (*)"); } if (!filename.isEmpty()) { ReplaceMediaCommand* rmc = new ReplaceMediaCommand(item, filename); @@ -318,13 +322,19 @@ void Project::replace_media(Media* item, QString filename) { void Project::replace_clip_media() { if (sequence == NULL) { - QMessageBox::critical(this, "No active sequence", "No sequence is active, please open the sequence you want to replace clips from.", QMessageBox::Ok); + QMessageBox::critical(this, + tr("No active sequence"), + tr("No sequence is active, please open the sequence you want to replace clips from."), + QMessageBox::Ok); } else { QModelIndexList selected_items = get_current_selected(); if (selected_items.size() == 1) { Media* item = item_to_media(selected_items.at(0)); if (item->get_type() == MEDIA_TYPE_SEQUENCE && sequence == item->to_sequence()) { - QMessageBox::critical(this, "Active sequence selected", "You cannot insert a sequence into itself, so no clips of this media would be in this sequence.", QMessageBox::Ok); + QMessageBox::critical(this, + tr("Active sequence selected"), + tr("You cannot insert a sequence into itself, so no clips of this media would be in this sequence."), + QMessageBox::Ok); } else { ReplaceClipMediaDialog dialog(this, item); dialog.exec(); @@ -353,7 +363,11 @@ void Project::open_properties() { default: { // fall back to renaming - QString new_name = QInputDialog::getText(this, "Rename '" + item->get_name() + "'", "Enter new name:", QLineEdit::Normal, item->get_name()); + QString new_name = QInputDialog::getText(this, + tr("Rename '%1'").arg(item->get_name()), + tr("Enter new name:"), + QLineEdit::Normal, + item->get_name()); if (!new_name.isEmpty()) { MediaRename* mr = new MediaRename(item, new_name); undo_stack.push(mr); @@ -466,11 +480,11 @@ void Project::delete_selected_media() { if (!confirm_delete) { // we found a reference, so we know we'll need to ask if the user wants to delete it QMessageBox confirm(this); - confirm.setWindowTitle("Delete media in use?"); - confirm.setText("The media '" + media->name + "' is currently used in '" + s->name + "'. Deleting it will remove all instances in the sequence. Are you sure you want to do this?"); + confirm.setWindowTitle(tr("Delete media in use?")); + confirm.setText(tr("The media '%1' is currently used in '%2'. Deleting it will remove all instances in the sequence. Are you sure you want to do this?").arg(media->name, s->name)); QAbstractButton* yes_button = confirm.addButton(QMessageBox::Yes); QAbstractButton* skip_button = NULL; - if (items.size() > 1) skip_button = confirm.addButton("Skip", QMessageBox::NoRole); + if (items.size() > 1) skip_button = confirm.addButton(tr("Skip"), QMessageBox::NoRole); QAbstractButton* abort_button = confirm.addButton(QMessageBox::Cancel); confirm.exec(); if (confirm.clickedButton() == yes_button) { @@ -693,7 +707,11 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla } if (!found) { image_sequence_urls.append(new_filename); - if (QMessageBox::question(this, "Image sequence detected", "The file '" + file + "' appears to be part of an image sequence. Would you like to import it as such?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) { + if (QMessageBox::question(this, + tr("Image sequence detected"), + tr("The file '%1' appears to be part of an image sequence. Would you like to import it as such?").arg(file), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::Yes) == QMessageBox::Yes) { file = new_filename; image_sequence_importassequence.append(true); } else { @@ -796,7 +814,7 @@ bool Project::reveal_media(Media *media, QModelIndex parent) { } void Project::import_dialog() { - QFileDialog fd(this, "Import media...", "", "All Files (*)"); + QFileDialog fd(this, tr("Import media..."), "", tr("All Files") + " (*)"); fd.setFileMode(QFileDialog::ExistingFiles); if (fd.exec()) { @@ -807,7 +825,10 @@ void Project::import_dialog() { void Project::delete_clips_using_selected_media() { if (sequence == NULL) { - QMessageBox::critical(this, "No active sequence", "No sequence is active, please open the sequence you want to delete clips from.", QMessageBox::Ok); + QMessageBox::critical(this, + tr("No active sequence"), + tr("No sequence is active, please open the sequence you want to delete clips from."), + QMessageBox::Ok); } else { ComboAction* ca = new ComboAction(); bool deleted = false; diff --git a/panels/timeline.cpp b/panels/timeline.cpp index c03d61f12..c45246c33 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -400,10 +400,11 @@ void Timeline::update_sequence() { addButton->setEnabled(!null_sequence); headers->setEnabled(!null_sequence); + QString title = tr("Timeline: "); if (null_sequence) { - setWindowTitle("Timeline: "); + setWindowTitle(title + tr("")); } else { - setWindowTitle("Timeline: " + sequence->name); + setWindowTitle(title + sequence->name); update_ui(false); } } @@ -1010,15 +1011,15 @@ void Timeline::paste(bool insert) { } if (found >= 0 && ask_conflict) { QMessageBox box(this); - box.setWindowTitle("Effect already exists"); - box.setText("Clip '" + c->name + "' already contains a '" + e->meta->name + "' effect. Would you like to replace it with the pasted one or add it as a separate effect?"); + box.setWindowTitle(tr("Effect already exists")); + box.setText(tr("Clip '%1' already contains a '%2' effect. Would you like to replace it with the pasted one or add it as a separate effect?").arg(c->name, e->meta->name)); box.setIcon(QMessageBox::Icon::Question); - box.addButton("Add", QMessageBox::YesRole); - QPushButton* replace_button = box.addButton("Replace", QMessageBox::NoRole); - QPushButton* skip_button = box.addButton("Skip", QMessageBox::RejectRole); + box.addButton(tr("Add"), QMessageBox::YesRole); + QPushButton* replace_button = box.addButton(tr("Replace"), QMessageBox::NoRole); + QPushButton* skip_button = box.addButton(tr("Skip"), QMessageBox::RejectRole); - QCheckBox* future_box = new QCheckBox("Do this for all conflicts found"); + QCheckBox* future_box = new QCheckBox(tr("Do this for all conflicts found")); box.setCheckBox(future_box); box.exec(); @@ -1392,8 +1393,8 @@ void Timeline::set_marker() { if (!add_marker) { QInputDialog d(this); - d.setWindowTitle("Set Marker"); - d.setLabelText("Set marker name:"); + d.setWindowTitle(tr("Set Marker")); + d.setLabelText(tr("Set marker name:")); d.setInputMode(QInputDialog::TextInput); add_marker = (d.exec() == QDialog::Accepted); marker_name = d.textValue(); @@ -1481,29 +1482,29 @@ void Timeline::add_btn_click() { QMenu add_menu(this); QAction* titleMenuItem = new QAction(&add_menu); - titleMenuItem->setText("Title..."); + titleMenuItem->setText(tr("Title...")); titleMenuItem->setData(ADD_OBJ_TITLE); add_menu.addAction(titleMenuItem); QAction* solidMenuItem = new QAction(&add_menu); - solidMenuItem->setText("Solid Color..."); + solidMenuItem->setText(tr("Solid Color...")); solidMenuItem->setData(ADD_OBJ_SOLID); add_menu.addAction(solidMenuItem); QAction* barsMenuItem = new QAction(&add_menu); - barsMenuItem->setText("Bars..."); + barsMenuItem->setText(tr("Bars...")); barsMenuItem->setData(ADD_OBJ_BARS); add_menu.addAction(barsMenuItem); add_menu.addSeparator(); QAction* toneMenuItem = new QAction(&add_menu); - toneMenuItem->setText("Tone..."); + toneMenuItem->setText(tr("Tone...")); toneMenuItem->setData(ADD_OBJ_TONE); add_menu.addAction(toneMenuItem); QAction* noiseMenuItem = new QAction(&add_menu); - noiseMenuItem->setText("Noise..."); + noiseMenuItem->setText(tr("Noise...")); noiseMenuItem->setData(ADD_OBJ_NOISE); add_menu.addAction(noiseMenuItem); @@ -1525,11 +1526,16 @@ void Timeline::setScroll(int s) { void Timeline::record_btn_click() { if (project_url.isEmpty()) { - QMessageBox::critical(this, "Unsaved Project", "You must save this project before you can record audio in it.", QMessageBox::Ok); + QMessageBox::critical(this, + tr("Unsaved Project"), + tr("You must save this project before you can record audio in it."), + QMessageBox::Ok); } else { creating = true; creating_object = ADD_OBJ_AUDIO; - mainWindow->statusBar()->showMessage("Click on the timeline where you want to start recording (drag to limit the recording to a certain timeframe)", 10000); + mainWindow->statusBar()->showMessage( + tr("Click on the timeline where you want to start recording (drag to limit the recording to a certain timeframe)"), + 10000); } } @@ -1608,7 +1614,7 @@ void Timeline::setup_ui() { arrow_icon.addFile(QStringLiteral(":/icons/arrow-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); toolArrowButton->setIcon(arrow_icon); toolArrowButton->setCheckable(true); - toolArrowButton->setToolTip("Pointer Tool (V)"); + toolArrowButton->setToolTip(tr("Pointer Tool") + " (V)"); toolArrowButton->setProperty("tool", TIMELINE_TOOL_POINTER); connect(toolArrowButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolArrowButton); @@ -1619,7 +1625,7 @@ void Timeline::setup_ui() { icon1.addFile(QStringLiteral(":/icons/beam-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); toolEditButton->setIcon(icon1); toolEditButton->setCheckable(true); - toolEditButton->setToolTip("Edit Tool (X)"); + toolEditButton->setToolTip(tr("Edit Tool") + " (X)"); toolEditButton->setProperty("tool", TIMELINE_TOOL_EDIT); connect(toolEditButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolEditButton); @@ -1630,7 +1636,7 @@ void Timeline::setup_ui() { icon2.addFile(QStringLiteral(":/icons/ripple-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); toolRippleButton->setIcon(icon2); toolRippleButton->setCheckable(true); - toolRippleButton->setToolTip("Ripple Tool (B)"); + toolRippleButton->setToolTip(tr("Ripple Tool") + " (B)"); toolRippleButton->setProperty("tool", TIMELINE_TOOL_RIPPLE); connect(toolRippleButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolRippleButton); @@ -1641,7 +1647,7 @@ void Timeline::setup_ui() { icon4.addFile(QStringLiteral(":/icons/razor-disabled.png"), QSize(), QIcon::Disabled, QIcon::Off); toolRazorButton->setIcon(icon4); toolRazorButton->setCheckable(true); - toolRazorButton->setToolTip("Razor Tool (C)"); + toolRazorButton->setToolTip(tr("Razor Tool") + " (C)"); toolRazorButton->setProperty("tool", TIMELINE_TOOL_RAZOR); connect(toolRazorButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolRazorButton); @@ -1652,7 +1658,7 @@ void Timeline::setup_ui() { icon5.addFile(QStringLiteral(":/icons/slip-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); toolSlipButton->setIcon(icon5); toolSlipButton->setCheckable(true); - toolSlipButton->setToolTip("Slip Tool (Y)"); + toolSlipButton->setToolTip(tr("Slip Tool") + " (Y)"); toolSlipButton->setProperty("tool", TIMELINE_TOOL_SLIP); connect(toolSlipButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolSlipButton); @@ -1663,7 +1669,7 @@ void Timeline::setup_ui() { icon6.addFile(QStringLiteral(":/icons/slide-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); toolSlideButton->setIcon(icon6); toolSlideButton->setCheckable(true); - toolSlideButton->setToolTip("Slide Tool (U)"); + toolSlideButton->setToolTip(tr("Slide Tool") + " (U)"); toolSlideButton->setProperty("tool", TIMELINE_TOOL_SLIDE); connect(toolSlideButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolSlideButton); @@ -1674,7 +1680,7 @@ void Timeline::setup_ui() { icon7.addFile(QStringLiteral(":/icons/hand-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); toolHandButton->setIcon(icon7); toolHandButton->setCheckable(true); - toolHandButton->setToolTip("Hand Tool (H)"); + toolHandButton->setToolTip(tr("Hand Tool") + " (H)"); toolHandButton->setProperty("tool", TIMELINE_TOOL_HAND); connect(toolHandButton, SIGNAL(clicked(bool)), this, SLOT(set_tool())); tool_buttons_layout->addWidget(toolHandButton); @@ -1685,7 +1691,7 @@ void Timeline::setup_ui() { icon8.addFile(QStringLiteral(":/icons/transition-tool-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); toolTransitionButton->setIcon(icon8); toolTransitionButton->setCheckable(true); - toolTransitionButton->setToolTip("Transition Tool (T)"); + toolTransitionButton->setToolTip(tr("Transition Tool") + " (T)"); connect(toolTransitionButton, SIGNAL(clicked(bool)), this, SLOT(transition_tool_click())); tool_buttons_layout->addWidget(toolTransitionButton); @@ -1696,7 +1702,7 @@ void Timeline::setup_ui() { snappingButton->setIcon(icon9); snappingButton->setCheckable(true); snappingButton->setChecked(true); - snappingButton->setToolTip("Snapping (S)"); + snappingButton->setToolTip(tr("Snapping") + " (S)"); connect(snappingButton, SIGNAL(toggled(bool)), this, SLOT(snapping_clicked(bool))); tool_buttons_layout->addWidget(snappingButton); @@ -1705,7 +1711,7 @@ void Timeline::setup_ui() { icon10.addFile(QStringLiteral(":/icons/zoomin.png"), QSize(), QIcon::Normal, QIcon::On); icon10.addFile(QStringLiteral(":/icons/zoomin-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); zoomInButton->setIcon(icon10); - zoomInButton->setToolTip("Zoom In (=)"); + zoomInButton->setToolTip(tr("Zoom In") + " (=)"); connect(zoomInButton, SIGNAL(clicked(bool)), this, SLOT(zoom_in())); tool_buttons_layout->addWidget(zoomInButton); @@ -1714,7 +1720,7 @@ void Timeline::setup_ui() { icon11.addFile(QStringLiteral(":/icons/zoomout.png"), QSize(), QIcon::Normal, QIcon::On); icon11.addFile(QStringLiteral(":/icons/zoomout-disabled.png"), QSize(), QIcon::Disabled, QIcon::On); zoomOutButton->setIcon(icon11); - zoomOutButton->setToolTip("Zoom Out (-)"); + zoomOutButton->setToolTip(tr("Zoom Out") + " (-)"); connect(zoomOutButton, SIGNAL(clicked(bool)), this, SLOT(zoom_out())); tool_buttons_layout->addWidget(zoomOutButton); @@ -1723,7 +1729,7 @@ void Timeline::setup_ui() { 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("Record audio"); + recordButton->setToolTip(tr("Record audio")); connect(recordButton, SIGNAL(clicked(bool)), this, SLOT(record_btn_click())); tool_buttons_layout->addWidget(recordButton); @@ -1733,7 +1739,7 @@ void Timeline::setup_ui() { 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); addButton->setIcon(icon13); - addButton->setToolTip("Add title, solid, bars, etc."); + addButton->setToolTip(tr("Add title, solid, bars, etc.")); connect(addButton, SIGNAL(clicked()), this, SLOT(add_btn_click())); tool_buttons_layout->addWidget(addButton); diff --git a/panels/viewer.cpp b/panels/viewer.cpp index be165cfd7..36a75a881 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -44,7 +44,7 @@ Viewer::Viewer(QWidget *parent) : seq(NULL), created_sequence(false), cue_recording_internal(false), - panel_name("Viewer: "), + panel_name(tr("Viewer: ")), minimum_zoom(1.0) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); @@ -785,7 +785,7 @@ void Viewer::set_sequence(bool main, Sequence *s) { update_playhead_timecode(0); update_end_timecode(); - setWindowTitle(panel_name + "(none)"); + setWindowTitle(panel_name + tr("(none)")); } update_header_zoom(); diff --git a/playback/audio.cpp b/playback/audio.cpp index 71c71b81b..9f96759ec 100644 --- a/playback/audio.cpp +++ b/playback/audio.cpp @@ -292,7 +292,7 @@ bool start_recording() { return false; } - QString audio_path = project_url + " Audio"; + QString audio_path = project_url + " " + QCoreApplication::translate("Audio", "Audio"); QDir audio_dir(audio_path); if (!audio_dir.exists() && !audio_dir.mkpath(".")) { qCritical() << "Failed to create audio directory"; @@ -303,7 +303,7 @@ bool start_recording() { int file_number = 0; do { file_number++; - audio_filename = audio_path + "/Recording " + QString::number(file_number) + ".wav"; + audio_filename = audio_path + "/" + QCoreApplication::translate("Audio", "Recording") + " " + QString::number(file_number) + ".wav"; } while (QFile(audio_filename).exists()); output_recording.setFileName(audio_filename); diff --git a/playback/cacher.cpp b/playback/cacher.cpp index cc6cddd56..6a0cbc0fd 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -749,7 +749,7 @@ void open_clip_worker(Clip* clip) { bool stabilize = false; if (stabilize) { AVFilterContext* stab_filter; - int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=/media/matt/Home/samples/transforms.trf", NULL, clip->filter_graph); + int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=", NULL, clip->filter_graph); if (stab_ret < 0) { char err[100]; av_strerror(stab_ret, err, sizeof(err)); diff --git a/project/effect.cpp b/project/effect.cpp index 14400133e..a40393f2c 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -43,6 +43,7 @@ #include #include #include +#include bool shaders_are_enabled = true; QVector effects; @@ -71,7 +72,9 @@ Effect* create_effect(Clip* c, const EffectMeta* em) { } } else { qCritical() << "Invalid effect data"; - QMessageBox::critical(mainWindow, "Invalid effect", "No candidate for effect '" + em->name + "'. This effect may be corrupt. Try reinstalling it or Olive."); + QMessageBox::critical(mainWindow, + QCoreApplication::translate("Effect", "Invalid effect"), + QCoreApplication::translate("Effect", "No candidate for effect '%1'. This effect may be corrupt. Try reinstalling it or Olive.").arg(em->name)); } return NULL; } @@ -86,7 +89,7 @@ const EffectMeta* get_internal_meta(int internal_id, int type) { } void load_internal_effects() { - qWarning() << "Shaders are disabled, some effects may be nonfunctional"; + if (!shaders_are_enabled) qWarning() << "Shaders are disabled, some effects may be nonfunctional"; EffectMeta em; @@ -545,18 +548,18 @@ void Effect::show_context_menu(const QPoint& pos) { int index = get_index_in_clip(); if (index > 0) { - QAction* move_up = menu.addAction("Move &Up"); + QAction* move_up = menu.addAction(tr("Move &Up")); connect(move_up, SIGNAL(triggered(bool)), this, SLOT(move_up())); } if (index < parent_clip->effects.size() - 1) { - QAction* move_down = menu.addAction("Move &Down"); + QAction* move_down = menu.addAction(tr("Move &Down")); connect(move_down, SIGNAL(triggered(bool)), this, SLOT(move_down())); } menu.addSeparator(); - QAction* del_action = menu.addAction("D&elete"); + QAction* del_action = menu.addAction(tr("D&elete")); connect(del_action, SIGNAL(triggered(bool)), this, SLOT(delete_self())); menu.exec(container->title_bar->mapToGlobal(pos)); diff --git a/project/effectrow.cpp b/project/effectrow.cpp index 4735e8def..7ab647d3d 100644 --- a/project/effectrow.cpp +++ b/project/effectrow.cpp @@ -64,7 +64,10 @@ void EffectRow::set_keyframe_enabled(bool enabled) { set_keyframe_now(ca); undo_stack.push(ca); } else { - if (QMessageBox::question(panel_effect_controls, "Disable Keyframes", "Disabling keyframes will delete all current keyframes. Are you sure you want to do this?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { + if (QMessageBox::question(panel_effect_controls, + tr("Disable Keyframes"), + tr("Disabling keyframes will delete all current keyframes. Are you sure you want to do this?"), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { // clear ComboAction* ca = new ComboAction(); for (int i=0;i +#include #include "debug.h" @@ -19,18 +20,18 @@ extern "C" { QString get_interlacing_name(int interlacing) { switch (interlacing) { - case VIDEO_PROGRESSIVE: return "None (Progressive)"; - case VIDEO_TOP_FIELD_FIRST: return "Top Field First"; - case VIDEO_BOTTOM_FIELD_FIRST: return "Bottom Field First"; - default: return "Invalid"; + case VIDEO_PROGRESSIVE: return QCoreApplication::translate("InterlacingName", "None (Progressive)"); + case VIDEO_TOP_FIELD_FIRST: return QCoreApplication::translate("InterlacingName", "Top Field First"); + case VIDEO_BOTTOM_FIELD_FIRST: return QCoreApplication::translate("InterlacingName", "Bottom Field First"); + default: return QCoreApplication::translate("InterlacingName", "Invalid"); } } QString get_channel_layout_name(int channels, uint64_t layout) { switch (channels) { - case 0: return "Invalid"; break; - case 1: return "Mono"; break; - case 2: return "Stereo"; break; + case 0: return QCoreApplication::translate("ChannelLayoutName", "Invalid"); break; + case 1: return QCoreApplication::translate("ChannelLayoutName", "Mono"); break; + case 2: return QCoreApplication::translate("ChannelLayoutName", "Stereo"); break; default: { char buf[50]; av_get_channel_layout_string(buf, sizeof(buf), channels, layout); @@ -76,7 +77,7 @@ void Media::set_sequence(Sequence *s) { } void Media::set_folder() { - if (folder_name.isEmpty()) folder_name = "New Folder"; + if (folder_name.isEmpty()) folder_name = QCoreApplication::translate("Media", "New Folder"); set_icon(QIcon(":/icons/folder.png")); type = MEDIA_TYPE_FOLDER; object = NULL; @@ -95,11 +96,11 @@ void Media::update_tooltip(const QString& error) { case MEDIA_TYPE_FOOTAGE: { Footage* f = to_footage(); - tooltip = "Name: " + f->name + "\nFilename: " + f->url + "\n"; + tooltip = QCoreApplication::translate("Media", "Name:") + " " + f->name + "\n" + QCoreApplication::translate("Media", "Filename:") + " " + f->url + "\n"; if (error.isEmpty()) { if (f->video_tracks.size() > 0) { - tooltip += "Video Dimensions: "; + tooltip += QCoreApplication::translate("Media", "Video Dimensions:") + " "; for (int i=0;ivideo_tracks.size();i++) { if (i > 0) { tooltip += ", "; @@ -109,7 +110,7 @@ void Media::update_tooltip(const QString& error) { tooltip += "\n"; if (!f->video_tracks.at(0).infinite_length) { - tooltip += "Frame Rate: "; + tooltip += QCoreApplication::translate("Media", "Frame Rate:") + " "; for (int i=0;ivideo_tracks.size();i++) { if (i > 0) { tooltip += ", "; @@ -117,14 +118,16 @@ void Media::update_tooltip(const QString& error) { if (f->video_tracks.at(i).video_interlacing == VIDEO_PROGRESSIVE) { tooltip += QString::number(f->video_tracks.at(i).video_frame_rate * f->speed); } else { - tooltip += QString::number(f->video_tracks.at(i).video_frame_rate * f->speed * 2); - tooltip += " fields (" + QString::number(f->video_tracks.at(i).video_frame_rate * f->speed) + " frames)"; + tooltip += QCoreApplication::translate("Media", "%1 fields (%2 frames)").arg( + QString::number(f->video_tracks.at(i).video_frame_rate * f->speed * 2), + QString::number(f->video_tracks.at(i).video_frame_rate * f->speed) + ); } } tooltip += "\n"; } - tooltip += "Interlacing: "; + tooltip += QCoreApplication::translate("Media", "Interlacing:") + " "; for (int i=0;ivideo_tracks.size();i++) { if (i > 0) { tooltip += ", "; @@ -136,7 +139,7 @@ void Media::update_tooltip(const QString& error) { if (f->audio_tracks.size() > 0) { tooltip += "\n"; - tooltip += "Audio Frequency: "; + tooltip += QCoreApplication::translate("Media", "Audio Frequency:") + " "; for (int i=0;iaudio_tracks.size();i++) { if (i > 0) { tooltip += ", "; @@ -145,7 +148,7 @@ void Media::update_tooltip(const QString& error) { } tooltip += "\n"; - tooltip += "Audio Channels: "; + tooltip += QCoreApplication::translate("Media", "Audio Channels:") + " "; for (int i=0;iaudio_tracks.size();i++) { if (i > 0) { tooltip += ", "; @@ -162,11 +165,19 @@ void Media::update_tooltip(const QString& error) { case MEDIA_TYPE_SEQUENCE: { Sequence* s = to_sequence(); - tooltip = "Name: " + s->name - + "\nVideo Dimensions: " + QString::number(s->width) + "x" + QString::number(s->height) - + "\nFrame Rate: " + QString::number(s->frame_rate) - + "\nAudio Frequency: " + QString::number(s->audio_frequency) - + "\nAudio Layout: " + get_channel_layout_name(av_get_channel_layout_nb_channels(s->audio_layout), s->audio_layout); + + tooltip = QCoreApplication::translate("Media", "Name: %1" + "\nVideo Dimensions: %2x%3" + "\nFrame Rate: %4" + "\nAudio Frequency: %5" + "\nAudio Layout: %6").arg( + s->name, + QString::number(s->width), + QString::number(s->height), + QString::number(s->frame_rate), + QString::number(s->audio_frequency), + get_channel_layout_name(av_get_channel_layout_nb_channels(s->audio_layout), s->audio_layout) + ); } break; } @@ -268,9 +279,9 @@ QVariant Media::data(int column, int role) { break; case Qt::DisplayRole: switch (column) { - case 0: return (root) ? "Name" : get_name(); + case 0: return (root) ? QCoreApplication::translate("Media", "Name") : get_name(); case 1: - if (root) return "Duration"; + if (root) return QCoreApplication::translate("Media", "Duration"); if (get_type() == MEDIA_TYPE_SEQUENCE) { Sequence* s = to_sequence(); return frame_to_timecode(s->getEndFrame(), config.timecode_view, s->frame_rate); @@ -287,7 +298,7 @@ QVariant Media::data(int column, int role) { } break; case 2: - if (root) return "Rate"; + if (root) return QCoreApplication::translate("Media", "Rate"); if (get_type() == MEDIA_TYPE_SEQUENCE) return QString::number(get_frame_rate()) + " FPS"; if (get_type() == MEDIA_TYPE_FOOTAGE) { Footage* f = to_footage(); diff --git a/project/sequence.cpp b/project/sequence.cpp index 1a902966d..198878f20 100644 --- a/project/sequence.cpp +++ b/project/sequence.cpp @@ -3,6 +3,8 @@ #include "clip.h" #include "transition.h" +#include + #include "debug.h" Sequence::Sequence() : @@ -24,7 +26,7 @@ Sequence::~Sequence() { Sequence* Sequence::copy() { Sequence* s = new Sequence(); - s->name = name + " (copy)"; + s->name = QCoreApplication::translate("Sequence", "%1 (copy)").arg(name); s->width = width; s->height = height; s->frame_rate = frame_rate; diff --git a/project/sourcescommon.cpp b/project/sourcescommon.cpp index 04d6dc781..ddffd89d2 100644 --- a/project/sourcescommon.cpp +++ b/project/sourcescommon.cpp @@ -49,10 +49,10 @@ void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& it selected_items = items; - QAction* import_action = menu.addAction("Import..."); + QAction* import_action = menu.addAction(tr("Import...")); QObject::connect(import_action, SIGNAL(triggered(bool)), project_parent, SLOT(import_dialog())); - QMenu* new_menu = menu.addMenu("New"); + QMenu* new_menu = menu.addMenu(tr("New")); mainWindow->make_new_menu(new_menu); if (items.size() > 0) { @@ -62,20 +62,20 @@ void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& it // replace footage int type = m->get_type(); if (type == MEDIA_TYPE_FOOTAGE) { - QAction* replace_action = menu.addAction("Replace/Relink Media"); + QAction* replace_action = menu.addAction(tr("Replace/Relink Media")); QObject::connect(replace_action, SIGNAL(triggered(bool)), project_parent, SLOT(replace_selected_file())); #if defined(Q_OS_WIN) - QAction* reveal_in_explorer = menu.addAction("Reveal in Explorer"); + QAction* reveal_in_explorer = menu.addAction(tr("Reveal in Explorer")); #elif defined(Q_OS_MAC) - QAction* reveal_in_explorer = menu.addAction("Reveal in Finder"); + QAction* reveal_in_explorer = menu.addAction(tr("Reveal in Finder")); #else - QAction* reveal_in_explorer = menu.addAction("Reveal in File Manager"); + QAction* reveal_in_explorer = menu.addAction(tr("Reveal in File Manager")); #endif QObject::connect(reveal_in_explorer, SIGNAL(triggered(bool)), this, SLOT(reveal_in_browser())); } if (type != MEDIA_TYPE_FOLDER) { - QAction* replace_clip_media = menu.addAction("Replace Clips Using This Media"); + QAction* replace_clip_media = menu.addAction(tr("Replace Clips Using This Media")); QObject::connect(replace_clip_media, SIGNAL(triggered(bool)), project_parent, SLOT(replace_clip_media())); } } @@ -93,41 +93,41 @@ void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& it } // create sequence from - QAction* create_seq_from = menu.addAction("Create Sequence With This Media"); + QAction* create_seq_from = menu.addAction(tr("Create Sequence With This Media")); QObject::connect(create_seq_from, SIGNAL(triggered(bool)), this, SLOT(create_seq_from_selected())); // ONLY sequences are selected if (all_sequences) { // ONLY sequences are selected - QAction* duplicate_action = menu.addAction("Duplicate"); + QAction* duplicate_action = menu.addAction(tr("Duplicate")); QObject::connect(duplicate_action, SIGNAL(triggered(bool)), project_parent, SLOT(duplicate_selected())); } // ONLY footage is selected if (all_footage) { - QAction* delete_footage_from_sequences = menu.addAction("Delete All Clips Using This Media"); + 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())); } // delete media - QAction* delete_action = menu.addAction("Delete"); + QAction* delete_action = menu.addAction(tr("Delete")); QObject::connect(delete_action, SIGNAL(triggered(bool)), project_parent, SLOT(delete_selected_media())); if (items.size() == 1) { - QAction* properties_action = menu.addAction("Properties..."); + QAction* properties_action = menu.addAction(tr("Properties...")); QObject::connect(properties_action, SIGNAL(triggered(bool)), project_parent, SLOT(open_properties())); } } menu.addSeparator(); - QAction* tree_view_action = menu.addAction("Tree View"); + QAction* tree_view_action = menu.addAction(tr("Tree View")); connect(tree_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_tree_view())); - QAction* icon_view_action = menu.addAction("Icon View"); + QAction* icon_view_action = menu.addAction(tr("Icon View")); connect(icon_view_action, SIGNAL(triggered(bool)), project_parent, SLOT(set_icon_view())); - QAction* toolbar_action = menu.addAction("Show Toolbar"); + QAction* toolbar_action = menu.addAction(tr("Show Toolbar")); toolbar_action->setCheckable(true); toolbar_action->setChecked(project_parent->toolbar_widget->isVisible()); connect(toolbar_action, SIGNAL(triggered(bool)), project_parent->toolbar_widget, SLOT(setVisible(bool))); @@ -183,7 +183,11 @@ void SourcesCommon::dropEvent(QWidget* parent, QDropEvent *event, const QModelIn && m->get_type() == MEDIA_TYPE_FOOTAGE && !QFileInfo(paths.at(0)).isDir() && config.drop_on_media_to_replace - && QMessageBox::question(parent, "Replace Media", "You dropped a file onto '" + m->get_name() + "'. Would you like to replace it with the dropped file?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { + && QMessageBox::question( + parent, + tr("Replace Media"), + tr("You dropped a file onto '%1'. Would you like to replace it with the dropped file?").arg(m->get_name()), + QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { replace = true; project_parent->replace_media(m, paths.at(0)); } diff --git a/project/transition.cpp b/project/transition.cpp index 3badb5ca3..a76ac53f7 100644 --- a/project/transition.cpp +++ b/project/transition.cpp @@ -19,12 +19,13 @@ #include "panels/timeline.h" #include +#include Transition::Transition(Clip* c, Clip* s, const EffectMeta* em) : Effect(c, em), secondary_clip(s), length(30) { - length_field = add_row("Length:", false)->add_field(EFFECT_FIELD_DOUBLE, "length"); + length_field = add_row(tr("Length:"), false)->add_field(EFFECT_FIELD_DOUBLE, "length"); connect(length_field, SIGNAL(changed()), this, SLOT(set_length_from_slider())); length_field->set_double_default_value(30); length_field->set_double_minimum_value(0); @@ -74,7 +75,10 @@ Transition* get_transition_from_meta(Clip* c, Clip* s, const EffectMeta* em) { } } else { qCritical() << "Invalid transition data"; - QMessageBox::critical(mainWindow, "Invalid transition", "No candidate for transition '" + em->name + "'. This transition may be corrupt. Try reinstalling it or Olive."); + QMessageBox::critical(mainWindow, + QCoreApplication::translate("transition", "Invalid transition"), + QCoreApplication::translate("transition", "No candidate for transition '%1'. This transition may be corrupt. Try reinstalling it or Olive.").arg(em->name) + ); } return NULL; } diff --git a/ui/collapsiblewidget.cpp b/ui/collapsiblewidget.cpp index fddebc040..104e43892 100644 --- a/ui/collapsiblewidget.cpp +++ b/ui/collapsiblewidget.cpp @@ -33,7 +33,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) { collapse_button = new QPushButton(); collapse_button->setIconSize(QSize(8, 8)); collapse_button->setStyleSheet("QPushButton { border: none; }"); - setText(""); + setText(tr("")); title_bar_layout->addWidget(collapse_button); title_bar_layout->addWidget(enabled_check); title_bar_layout->addWidget(header); diff --git a/ui/colorbutton.cpp b/ui/colorbutton.cpp index 026d1c42d..c48dc8249 100644 --- a/ui/colorbutton.cpp +++ b/ui/colorbutton.cpp @@ -31,7 +31,7 @@ void ColorButton::set_button_color() { } void ColorButton::open_dialog() { - QColor new_color = QColorDialog::getColor(color, NULL, "Set Color"); + QColor new_color = QColorDialog::getColor(color, NULL, tr("Set Color")); if (new_color.isValid() && color != new_color) { set_color(new_color); set_button_color(); diff --git a/ui/embeddedfilechooser.cpp b/ui/embeddedfilechooser.cpp index adb1e8484..140149a25 100644 --- a/ui/embeddedfilechooser.cpp +++ b/ui/embeddedfilechooser.cpp @@ -35,7 +35,7 @@ void EmbeddedFileChooser::setFilename(const QString &s) { } void EmbeddedFileChooser::update_label() { - QString l = "File: "; + QString l = "" + tr("File:") + " "; if (filename.isEmpty()) { l += "(none)"; } else { diff --git a/ui/graphview.cpp b/ui/graphview.cpp index fc1b82db0..efb9aa134 100644 --- a/ui/graphview.cpp +++ b/ui/graphview.cpp @@ -58,14 +58,14 @@ GraphView::GraphView(QWidget* parent) : void GraphView::show_context_menu(const QPoint& pos) { QMenu menu(this); - QAction* zoom_to_selection = menu.addAction("Zoom to Selection"); + QAction* zoom_to_selection = menu.addAction(tr("Zoom to Selection")); if (selected_keys.size() == 0 || row == NULL) { zoom_to_selection->setEnabled(false); } else { connect(zoom_to_selection, SIGNAL(triggered(bool)), this, SLOT(set_view_to_selection())); } - QAction* zoom_to_all = menu.addAction("Zoom to Show All"); + QAction* zoom_to_all = menu.addAction(tr("Zoom to Show All")); if (row == NULL) { zoom_to_all->setEnabled(false); } else { @@ -74,7 +74,7 @@ void GraphView::show_context_menu(const QPoint& pos) { menu.addSeparator(); - QAction* reset_action = menu.addAction("Reset View"); + QAction* reset_action = menu.addAction(tr("Reset View")); if (row == NULL) { reset_action->setEnabled(false); } else { diff --git a/ui/keyframenavigator.cpp b/ui/keyframenavigator.cpp index f5495a135..b3bb95c32 100644 --- a/ui/keyframenavigator.cpp +++ b/ui/keyframenavigator.cpp @@ -53,7 +53,7 @@ KeyframeNavigator::KeyframeNavigator(QWidget *parent) : QWidget(parent) { keyframe_enable->setMaximumSize(button_size); keyframe_enable->setIconSize(clock_size); keyframe_enable->setCheckable(true); - keyframe_enable->setToolTip("Enable Keyframes"); + keyframe_enable->setToolTip(tr("Enable Keyframes")); connect(keyframe_enable, SIGNAL(clicked(bool)), this, SIGNAL(keyframe_enabled_changed(bool))); connect(keyframe_enable, SIGNAL(toggled(bool)), this, SLOT(keyframe_ui_enabled(bool))); connect(keyframe_enable, SIGNAL(clicked(bool)), this, SIGNAL(clicked())); diff --git a/ui/keyframeview.cpp b/ui/keyframeview.cpp index 812e34878..014029b08 100644 --- a/ui/keyframeview.cpp +++ b/ui/keyframeview.cpp @@ -50,11 +50,11 @@ void KeyframeView::show_context_menu(const QPoint& pos) { if (selected_fields.size() > 0) { QMenu menu(this); - QAction* linear = menu.addAction("Linear"); + QAction* linear = menu.addAction(tr("Linear")); linear->setData(KEYFRAME_TYPE_LINEAR); - QAction* bezier = menu.addAction("Bezier"); + QAction* bezier = menu.addAction(tr("Bezier")); bezier->setData(KEYFRAME_TYPE_BEZIER); - QAction* hold = menu.addAction("Hold"); + QAction* hold = menu.addAction(tr("Hold")); hold->setData(KEYFRAME_TYPE_HOLD); menu.addSeparator(); menu.addAction("Graph Editor"); diff --git a/ui/labelslider.cpp b/ui/labelslider.cpp index 7395ad752..d83b2b9f7 100644 --- a/ui/labelslider.cpp +++ b/ui/labelslider.cpp @@ -147,8 +147,8 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) { if (display_type == LABELSLIDER_FRAMENUMBER) { QString s = QInputDialog::getText( this, - "Set Value", - "New value:", + tr("Set Value"), + tr("New value:"), QLineEdit::Normal, valueToString(internal_value) ); @@ -158,8 +158,8 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) { bool ok; d = QInputDialog::getDouble( this, - "Set Value", - "New value:", + tr("Set Value"), + tr("New value:"), (display_type == LABELSLIDER_PERCENT) ? internal_value * 100 : internal_value, (min_enabled) ? min_value : INT_MIN, (max_enabled) ? max_value : INT_MAX, diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 44b69ffdc..96bd251f1 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -221,10 +221,12 @@ void TimelineWidget::tooltip_timer_timeout() { Clip* c = sequence->clips.at(tooltip_clip); if (c != NULL) { QToolTip::showText(QCursor::pos(), - c->name - + "\nStart: " + frame_to_timecode(c->timeline_in, config.timecode_view, sequence->frame_rate) - + "\nEnd: " + frame_to_timecode(c->timeline_out, config.timecode_view, sequence->frame_rate) - + "\nDuration: " + frame_to_timecode(c->getLength(), config.timecode_view, sequence->frame_rate)); + tr("%1\nStart: %2\nEnd: %3\nDuration: %4").arg( + c->name, + frame_to_timecode(c->timeline_in, config.timecode_view, sequence->frame_rate), + frame_to_timecode(c->timeline_out, config.timecode_view, sequence->frame_rate), + frame_to_timecode(c->getLength(), config.timecode_view, sequence->frame_rate) + )); } } } @@ -241,8 +243,8 @@ void TimelineWidget::rename_clip() { } if (selected_clips.size() > 0) { QString s = QInputDialog::getText(this, - (selected_clips.size() == 1) ? "Rename '" + selected_clips.at(0)->name + "'" : "Rename multiple clips", - "Enter a new name for this clip:", + (selected_clips.size() == 1) ? tr("Rename '%1'").arg(selected_clips.at(0)->name) : tr("Rename multiple clips"), + tr("Enter a new name for this clip:"), QLineEdit::Normal, selected_clips.at(0)->name ); @@ -275,7 +277,7 @@ void TimelineWidget::open_sequence_properties() { return; } } - QMessageBox::critical(this, "Error", "Couldn't locate media wrapper for sequence."); + QMessageBox::critical(this, tr("Error"), tr("Couldn't locate media wrapper for sequence.")); } bool same_sign(int a, int b) { @@ -827,27 +829,27 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { switch (panel_timeline->creating_object) { case ADD_OBJ_TITLE: - c->name = "Title"; + c->name = tr("Title"); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_TEXT, EFFECT_TYPE_EFFECT))); break; case ADD_OBJ_SOLID: - c->name = "Solid Color"; + c->name = tr("Solid Color"); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_SOLID, EFFECT_TYPE_EFFECT))); break; case ADD_OBJ_BARS: { - c->name = "Bars"; + c->name = tr("Bars"); Effect* e = create_effect(c, get_internal_meta(EFFECT_INTERNAL_SOLID, EFFECT_TYPE_EFFECT)); e->row(0)->field(0)->set_combo_index(1); c->effects.append(e); } break; case ADD_OBJ_TONE: - c->name = "Tone"; + c->name = tr("Tone"); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_TONE, EFFECT_TYPE_EFFECT))); break; case ADD_OBJ_NOISE: - c->name = "Noise"; + c->name = tr("Noise"); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_NOISE, EFFECT_TYPE_EFFECT))); break; } @@ -1575,7 +1577,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } if (g != NULL) { - tip += " Duration: "; + tip += " " + tr("Duration:") + " "; long len = (g->old_out-g->old_in); if (panel_timeline->trim_in_point) { len -= frame_diff; diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index f8adf8313..8736b96fc 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -87,14 +87,14 @@ void ViewerWidget::set_waveform_scroll(int s) { void ViewerWidget::show_context_menu() { QMenu menu(this); - QAction* save_frame_as_image = menu.addAction("Save Frame as Image..."); + QAction* save_frame_as_image = menu.addAction(tr("Save Frame as Image...")); connect(save_frame_as_image, SIGNAL(triggered(bool)), this, SLOT(save_frame())); - QAction* show_fullscreen_action = menu.addAction("Show Fullscreen"); + QAction* show_fullscreen_action = menu.addAction(tr("Show Fullscreen")); connect(show_fullscreen_action, SIGNAL(triggered()), this, SLOT(show_fullscreen())); - QMenu zoom_menu("Zoom"); - QAction* fit_zoom = zoom_menu.addAction("Fit"); + QMenu zoom_menu(tr("Zoom")); + QAction* fit_zoom = zoom_menu.addAction(tr("Fit")); connect(fit_zoom, SIGNAL(triggered(bool)), this, SLOT(set_fit_zoom())); zoom_menu.addAction("10%")->setData(0.1); zoom_menu.addAction("25%")->setData(0.25); @@ -104,13 +104,13 @@ void ViewerWidget::show_context_menu() { zoom_menu.addAction("150%")->setData(1.5); zoom_menu.addAction("200%")->setData(2.0); zoom_menu.addAction("400%")->setData(4.0); - QAction* custom_zoom = zoom_menu.addAction("Custom"); + QAction* custom_zoom = zoom_menu.addAction(tr("Custom")); connect(custom_zoom, SIGNAL(triggered(bool)), this, SLOT(set_custom_zoom())); connect(&zoom_menu, SIGNAL(triggered(QAction*)), this, SLOT(set_menu_zoom(QAction*))); menu.addMenu(&zoom_menu); if (!viewer->is_main_sequence()) { - menu.addAction("Close Media", viewer, SLOT(close_media())); + menu.addAction(tr("Close Media"), viewer, SLOT(close_media())); } menu.exec(QCursor::pos()); @@ -120,7 +120,7 @@ void ViewerWidget::save_frame() { QFileDialog fd(this); fd.setAcceptMode(QFileDialog::AcceptSave); fd.setFileMode(QFileDialog::AnyFile); - fd.setWindowTitle("Save Frame"); + fd.setWindowTitle(tr("Save Frame")); fd.setNameFilter("Portable Network Graphic (*.png);;JPEG (*.jpg);;Windows Bitmap (*.bmp);;Portable Pixmap (*.ppm);;X11 Bitmap (*.xbm);;X11 Pixmap (*.xpm)"); if (fd.exec()) { @@ -159,7 +159,10 @@ void ViewerWidget::set_fit_zoom() { void ViewerWidget::set_custom_zoom() { bool ok; - double d = QInputDialog::getDouble(this, "Viewer Zoom", "Set Custom Zoom Value:", container->zoom*100, 0, 2147483647, 2, &ok); + double d = QInputDialog::getDouble(this, + tr("Viewer Zoom"), + tr("Set Custom Zoom Value:"), + container->zoom*100, 0, 2147483647, 2, &ok); if (ok) { container->fit = false; container->zoom = d*0.01; From 9a78ffdfac441ddf372827ef2296cf28e8f0fd44 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 12:04:41 +1100 Subject: [PATCH 19/25] fixed #306 --- io/loadthread.cpp | 12 ++++++++++-- panels/project.cpp | 9 ++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/io/loadthread.cpp b/io/loadthread.cpp index 06d0fc3c7..a65942c70 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -238,7 +238,11 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { item->set_footage(m); - project_model.appendChild(find_loaded_folder_by_id(folder), item); + if (folder == 0) { + project_model.appendChild(NULL, item); + } else { + find_loaded_folder_by_id(folder)->appendChild(item); + } // analyze media to see if it's the same loaded_media_items.append(item); @@ -568,7 +572,11 @@ void LoadThread::run() { for (int i=0;itemp_id2; - project_model.appendChild(find_loaded_folder_by_id(parent), folder); + if (folder->temp_id2 == 0) { + project_model.appendChild(NULL, folder); + } else { + find_loaded_folder_by_id(parent)->appendChild(folder); + } } cont = load_worker(file, stream, MEDIA_TYPE_FOOTAGE); diff --git a/panels/project.cpp b/panels/project.cpp index 8742eecca..66d40039c 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -372,7 +372,11 @@ Media* Project::new_sequence(ComboAction *ca, Sequence *s, bool open, Media* par ca->append(new NewSequenceCommand(item, parent)); if (open) ca->append(new ChangeSequenceAction(s)); } else { - project_model.appendChild(NULL, item); + if (parent == project_model.get_root()) { + project_model.appendChild(parent, item); + } else { + parent->appendChild(item); + } if (open) set_sequence(s); } return item; @@ -868,7 +872,6 @@ void Project::load_project(bool autorecovery) { } void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, const QModelIndex& parent) { - bool root = (!parent.parent().isValid()); for (int i=0;itemp_id; + int folder = (m->parentItem() != NULL) ? m->parentItem()->temp_id : 0; if (type == MEDIA_TYPE_FOOTAGE) { Footage* f = m->to_footage(); f->save_id = media_id; From a8e37ac76a0e38a598312d9c2db2cc489e666319 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 12:57:15 +1100 Subject: [PATCH 20/25] changed NULLs to nullptr --- debug.cpp | 2 +- dialogs/actionsearch.cpp | 18 +- dialogs/actionsearch.h | 2 +- dialogs/debugdialog.cpp | 2 +- dialogs/exportdialog.cpp | 8 +- dialogs/newsequencedialog.cpp | 10 +- dialogs/preferencesdialog.cpp | 6 +- dialogs/preferencesdialog.h | 2 +- dialogs/replaceclipmediadialog.cpp | 2 +- dialogs/speeddialog.cpp | 6 +- effects/internal/cornerpineffect.cpp | 4 +- effects/internal/crossdissolvetransition.cpp | 2 +- effects/internal/cubetransition.cpp | 8 +- effects/internal/shakeeffect.cpp | 2 +- effects/internal/transformeffect.cpp | 14 +- effects/internal/voideffect.cpp | 2 +- effects/internal/vsthostwin.cpp | 80 ++++---- icons/icons.qrc | 1 + icons/olive64.png | Bin 0 -> 8354 bytes io/clipboard.cpp | 3 +- io/exportthread.cpp | 66 +++---- io/loadthread.cpp | 52 ++--- io/loadthread.h | 68 +++---- io/previewgenerator.cpp | 42 ++--- io/qpainterwrapper.cpp | 2 +- main.cpp | 13 +- mainwindow.cpp | 38 ++-- olive.pro | 8 +- panels/effectcontrols.cpp | 36 ++-- panels/grapheditor.cpp | 10 +- panels/panels.cpp | 18 +- panels/project.cpp | 85 ++++----- panels/project.h | 2 +- panels/timeline.cpp | 170 ++++++++--------- panels/viewer.cpp | 52 ++--- playback/audio.cpp | 22 +-- playback/cacher.cpp | 58 +++--- playback/playback.cpp | 32 ++-- project/clip.cpp | 66 +++---- project/effect.cpp | 58 +++--- project/effectfield.cpp | 4 +- project/effectgizmo.cpp | 16 +- project/effectrow.cpp | 8 +- project/footage.cpp | 6 +- project/media.cpp | 18 +- project/projectmodel.cpp | 18 +- project/projectmodel.h | 4 +- project/sequence.cpp | 22 +-- project/sourcescommon.cpp | 14 +- project/transition.cpp | 10 +- project/undo.cpp | 70 +++---- ui/audiomonitor.cpp | 2 +- ui/collapsiblewidget.cpp | 4 +- ui/colorbutton.cpp | 2 +- ui/graphview.cpp | 28 +-- ui/timelineheader.cpp | 10 +- ui/timelinewidget.cpp | 188 +++++++++---------- ui/viewercontainer.cpp | 4 +- ui/viewerwidget.cpp | 70 +++---- 59 files changed, 785 insertions(+), 785 deletions(-) create mode 100644 icons/olive64.png diff --git a/debug.cpp b/debug.cpp index ed43cea42..405cb010a 100644 --- a/debug.cpp +++ b/debug.cpp @@ -65,7 +65,7 @@ void debug_message_handler(QtMsgType type, const QMessageLogContext &context, co fflush(stderr); abort(); } - if (debug_dialog->isVisible()) { + if (debug_dialog != nullptr && debug_dialog->isVisible()) { QMetaObject::invokeMethod(debug_dialog, "update_log", Qt::QueuedConnection); } debug_mutex.unlock(); diff --git a/dialogs/actionsearch.cpp b/dialogs/actionsearch.cpp index 3f5593dbe..1a30fb197 100644 --- a/dialogs/actionsearch.cpp +++ b/dialogs/actionsearch.cpp @@ -21,7 +21,7 @@ ActionSearch::ActionSearch(QWidget *parent) : ActionSearchEntry* entry_field = new ActionSearchEntry(); QFont entry_field_font = entry_field->font(); - entry_field_font.setPointSize(entry_field_font.pointSize()*1.2); + entry_field_font.setPointSize(qRound(entry_field_font.pointSize()*1.2)); entry_field->setFont(entry_field_font); entry_field->setPlaceholderText("Search for action..."); connect(entry_field, SIGNAL(textChanged(const QString&)), this, SLOT(search_update(const QString &))); @@ -32,7 +32,7 @@ ActionSearch::ActionSearch(QWidget *parent) : list_widget = new ActionSearchList(); QFont list_widget_font = list_widget->font(); - list_widget_font.setPointSize(list_widget_font.pointSize()*1.2); + list_widget_font.setPointSize(qRound(list_widget_font.pointSize()*1.2)); list_widget->setFont(list_widget_font); layout->addWidget(list_widget); connect(list_widget, SIGNAL(dbl_click()), this, SLOT(perform_action())); @@ -43,7 +43,7 @@ ActionSearch::ActionSearch(QWidget *parent) : } void ActionSearch::search_update(const QString &s, const QString &p, QMenu *parent) { - if (parent == NULL) { + if (parent == nullptr) { list_widget->clear(); QList menus = mainWindow->menuBar()->actions(); for (int i=0;iisSeparator()) { - if (a->menu() != NULL) { + if (a->menu() != nullptr) { search_update(s, menu_text, a->menu()); } else { QString comp = a->text().replace("&", ""); @@ -88,9 +88,9 @@ void ActionSearch::perform_action() { void ActionSearch::move_selection_up() { int lim = list_widget->count(); for (int i=1;iitem(i)->isSelected()) { + if (list_widget->item(i)->isSelected()) { list_widget->item(i-1)->setSelected(true); - list_widget->scrollToItem(list_widget->item(i-1)); + list_widget->scrollToItem(list_widget->item(i-1)); break; } } @@ -99,9 +99,9 @@ void ActionSearch::move_selection_up() { void ActionSearch::move_selection_down() { int lim = list_widget->count()-1; for (int i=0;iitem(i)->isSelected()) { + if (list_widget->item(i)->isSelected()) { list_widget->item(i+1)->setSelected(true); - list_widget->scrollToItem(list_widget->item(i+1)); + list_widget->scrollToItem(list_widget->item(i+1)); break; } } @@ -120,6 +120,6 @@ void ActionSearchEntry::keyPressEvent(QKeyEvent * event) { } } -void ActionSearchList::mouseDoubleClickEvent(QMouseEvent *event) { +void ActionSearchList::mouseDoubleClickEvent(QMouseEvent *) { emit dbl_click(); } diff --git a/dialogs/actionsearch.h b/dialogs/actionsearch.h index 72d7d7153..4147f8900 100644 --- a/dialogs/actionsearch.h +++ b/dialogs/actionsearch.h @@ -22,7 +22,7 @@ class ActionSearch : public QDialog public: ActionSearch(QWidget* parent = 0); private slots: - void search_update(const QString& s, const QString &p = 0, QMenu *parent = NULL); + void search_update(const QString& s, const QString &p = 0, QMenu *parent = nullptr); void perform_action(); void move_selection_up(); void move_selection_down(); diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index b70b24bab..4e4c16236 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -5,7 +5,7 @@ #include "debug.h" -DebugDialog* debug_dialog = NULL; +DebugDialog* debug_dialog = nullptr; DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { setWindowTitle("Debug Log"); diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index edcafc1f9..bf558946b 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -292,16 +292,16 @@ void ExportDialog::format_changed(int index) AVCodec* codec_info; for (int i=0;iaddItem("NULL"); + if (codec_info == nullptr) { + vcodecCombobox->addItem("nullptr"); } else { vcodecCombobox->addItem(codec_info->long_name); } } for (int i=0;iaddItem("NULL"); + if (codec_info == nullptr) { + acodecCombobox->addItem("nullptr"); } else { acodecCombobox->addItem(codec_info->long_name); } diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index 0451aa886..2560b0908 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -29,7 +29,7 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : { setup_ui(); - if (existing != NULL) { + if (existing != nullptr) { existing_sequence = existing->to_sequence(); setWindowTitle("Editing \"" + existing_sequence->name + "\""); @@ -50,7 +50,7 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : } } } else { - existing_sequence = NULL; + existing_sequence = nullptr; setWindowTitle("New Sequence"); } } @@ -63,7 +63,7 @@ void NewSequenceDialog::set_sequence_name(const QString& s) { } void NewSequenceDialog::create() { - if (existing_sequence == NULL) { + if (existing_sequence == nullptr) { Sequence* s = new Sequence(); s->name = sequence_name_edit->text(); @@ -74,7 +74,7 @@ void NewSequenceDialog::create() { s->audio_layout = AV_CH_LAYOUT_STEREO; ComboAction* ca = new ComboAction(); - panel_project->new_sequence(ca, s, true, NULL); + panel_project->new_sequence(ca, s, true, nullptr); undo_stack.push(ca); } else { ComboAction* ca = new ComboAction(); @@ -92,7 +92,7 @@ void NewSequenceDialog::create() { for (int i=0;iclips.size();i++) { Clip* c = existing_sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { c->refactor_frame_rate(ca, multiplier, true); } } diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index a730d6bb5..fa664c165 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -76,7 +76,7 @@ void PreferencesDialog::setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent->addChild(item); - if (a->menu() != NULL) { + if (a->menu() != nullptr) { item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); setup_kbd_shortcut_worker(a->menu(), item); } else { @@ -150,7 +150,7 @@ void PreferencesDialog::reset_all_shortcuts() { } bool PreferencesDialog::refine_shortcut_list(const QString &s, QTreeWidgetItem* parent) { - if (parent == NULL) { + if (parent == nullptr) { for (int i=0;itopLevelItemCount();i++) { refine_shortcut_list(s, keyboard_tree->topLevelItem(i)); } @@ -169,7 +169,7 @@ bool PreferencesDialog::refine_shortcut_list(const QString &s, QTreeWidgetItem* all_children_are_hidden = false; } else { QString shortcut; - if (keyboard_tree->itemWidget(item, 1) != NULL) { + if (keyboard_tree->itemWidget(item, 1) != nullptr) { shortcut = static_cast(keyboard_tree->itemWidget(item, 1))->keySequence().toString(); } if (item->text(0).contains(s, Qt::CaseInsensitive) || shortcut.contains(s, Qt::CaseInsensitive)) { diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index 0b1344c71..49758151f 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -39,7 +39,7 @@ private slots: void save(); void reset_default_shortcut(); void reset_all_shortcuts(); - bool refine_shortcut_list(const QString &, QTreeWidgetItem* parent = NULL); + bool refine_shortcut_list(const QString &, QTreeWidgetItem* parent = nullptr); void load_shortcut_file(); void save_shortcut_file(); void browse_css_file(); diff --git a/dialogs/replaceclipmediadialog.cpp b/dialogs/replaceclipmediadialog.cpp index 5243cc71c..2583830f6 100644 --- a/dialogs/replaceclipmediadialog.cpp +++ b/dialogs/replaceclipmediadialog.cpp @@ -82,7 +82,7 @@ void ReplaceClipMediaDialog::replace() { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && c->media == media) { + if (c != nullptr && c->media == media) { rcmc->clips.append(c); } } diff --git a/dialogs/speeddialog.cpp b/dialogs/speeddialog.cpp index ff4c52a14..af3211b53 100644 --- a/dialogs/speeddialog.cpp +++ b/dialogs/speeddialog.cpp @@ -84,10 +84,10 @@ void SpeedDialog::run() { clip_percent = c->speed; if (c->track < 0) { bool process_video = true; - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { Footage* m = c->media->to_footage(); FootageStream* ms = m->get_stream_from_file_index(true, c->media_stream); - if (ms != NULL && ms->infinite_length) { + if (ms != nullptr && ms->infinite_length) { process_video = false; } } @@ -304,7 +304,7 @@ void set_speed(ComboAction* ca, Clip* c, double speed, bool ripple, long& ep, lo if (!ripple && proposed_out > c->timeline_out) { for (int i=0;isequence->clips.size();i++) { Clip* compare = c->sequence->clips.at(i); - if (compare != NULL + if (compare != nullptr && compare->track == c->track && compare->timeline_in >= c->timeline_out && compare->timeline_in < proposed_out) { proposed_out = compare->timeline_in; diff --git a/effects/internal/cornerpineffect.cpp b/effects/internal/cornerpineffect.cpp index 5be93b671..6febf3bd0 100644 --- a/effects/internal/cornerpineffect.cpp +++ b/effects/internal/cornerpineffect.cpp @@ -47,7 +47,7 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em) fragPath = "cornerpin.frag"; } -void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords, int data) { +void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords, int) { coords.vertexTopLeftX += top_left_x->get_double_value(timecode); coords.vertexTopLeftY += top_left_y->get_double_value(timecode); @@ -69,7 +69,7 @@ void CornerPinEffect::process_shader(double timecode, GLTextureCoords &coords) { glslProgram->setUniformValue("perspective", perspective->get_bool_value(timecode)); } -void CornerPinEffect::gizmo_draw(double timecode, GLTextureCoords &coords) { +void CornerPinEffect::gizmo_draw(double, GLTextureCoords &coords) { top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY); top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY); bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY); diff --git a/effects/internal/crossdissolvetransition.cpp b/effects/internal/crossdissolvetransition.cpp index ef2d684ac..f792b379a 100644 --- a/effects/internal/crossdissolvetransition.cpp +++ b/effects/internal/crossdissolvetransition.cpp @@ -9,7 +9,7 @@ CrossDissolveTransition::CrossDissolveTransition(Clip* c, Clip* s, const EffectM } void CrossDissolveTransition::process_coords(double progress, GLTextureCoords&, int data) { - if (!(data == TA_CLOSING_TRANSITION && secondary_clip != NULL)) { + if (!(data == TA_CLOSING_TRANSITION && secondary_clip != nullptr)) { float color[4]; glGetFloatv(GL_CURRENT_COLOR, color); if (data == TA_CLOSING_TRANSITION) progress = 1.0 - progress; diff --git a/effects/internal/cubetransition.cpp b/effects/internal/cubetransition.cpp index e97cf0c66..a2058e230 100644 --- a/effects/internal/cubetransition.cpp +++ b/effects/internal/cubetransition.cpp @@ -3,11 +3,11 @@ #include "debug.h" CubeTransition::CubeTransition(Clip* c, Clip* s, const EffectMeta* em) : Transition(c, s, em) { - enable_coords = true; + enable_coords = true; } -void CubeTransition::process_coords(double progress, GLTextureCoords& coords, int data) { +void CubeTransition::process_coords(double, GLTextureCoords& coords, int) { - coords.vertexTopLeftZ = 1; - coords.vertexBottomLeftZ = 1; + coords.vertexTopLeftZ = 1; + coords.vertexBottomLeftZ = 1; } diff --git a/effects/internal/shakeeffect.cpp b/effects/internal/shakeeffect.cpp index 92975fe8a..968e6c3f5 100644 --- a/effects/internal/shakeeffect.cpp +++ b/effects/internal/shakeeffect.cpp @@ -40,7 +40,7 @@ ShakeEffect::ShakeEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { } } -void ShakeEffect::process_coords(double timecode, GLTextureCoords& coords, int data) { +void ShakeEffect::process_coords(double timecode, GLTextureCoords& coords, int) { int lim = RANDOM_VAL_SIZE/6; double multiplier = intensity_val->get_double_value(timecode)/lim; diff --git a/effects/internal/transformeffect.cpp b/effects/internal/transformeffect.cpp index e1cf1dde7..e0d95d95c 100644 --- a/effects/internal/transformeffect.cpp +++ b/effects/internal/transformeffect.cpp @@ -134,7 +134,7 @@ void adjust_field(EffectField* field, double old_offset, double new_offset) { } void TransformEffect::refresh() { - if (parent_clip != NULL && parent_clip->sequence != NULL) { + if (parent_clip != nullptr && parent_clip->sequence != nullptr) { double new_default_pos_x = parent_clip->sequence->width/2; double new_default_pos_y = parent_clip->sequence->height/2; @@ -180,13 +180,13 @@ void TransformEffect::toggle_uniform_scale(bool enabled) { top_center_gizmo->y_field1 = enabled ? scale_x : scale_y; bottom_center_gizmo->y_field1 = enabled ? scale_x : scale_y; - top_left_gizmo->y_field1 = enabled ? NULL : scale_y; - top_right_gizmo->y_field1 = enabled ? NULL : scale_y; - bottom_left_gizmo->y_field1 = enabled ? NULL : scale_y; - bottom_right_gizmo->y_field1 = enabled ? NULL : scale_y; + top_left_gizmo->y_field1 = enabled ? nullptr : scale_y; + top_right_gizmo->y_field1 = enabled ? nullptr : scale_y; + bottom_left_gizmo->y_field1 = enabled ? nullptr : scale_y; + bottom_right_gizmo->y_field1 = enabled ? nullptr : scale_y; } -void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int data) { +void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int) { // position glTranslatef(position_x->get_double_value(timecode)-(parent_clip->sequence->width/2), position_y->get_double_value(timecode)-(parent_clip->sequence->height/2), 0); @@ -234,7 +234,7 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i glColor4f(1.0, 1.0, 1.0, color[3]*(opacity->get_double_value(timecode)*0.01)); } -void TransformEffect::gizmo_draw(double timecode, GLTextureCoords& coords) { +void TransformEffect::gizmo_draw(double, GLTextureCoords& coords) { top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY); top_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopLeftX, coords.vertexTopRightX, 0.5), lerp(coords.vertexTopLeftY, coords.vertexTopRightY, 0.5)); top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY); diff --git a/effects/internal/voideffect.cpp b/effects/internal/voideffect.cpp index 11a8c25ff..61c805ba9 100644 --- a/effects/internal/voideffect.cpp +++ b/effects/internal/voideffect.cpp @@ -7,7 +7,7 @@ #include "ui/collapsiblewidget.h" #include "debug.h" -VoidEffect::VoidEffect(Clip *c, const QString& n) : Effect(c, NULL) { +VoidEffect::VoidEffect(Clip *c, const QString& n) : Effect(c, nullptr) { name = n; QString display_name; if (n.isEmpty()) { diff --git a/effects/internal/vsthostwin.cpp b/effects/internal/vsthostwin.cpp index 302cb5d34..961564991 100644 --- a/effects/internal/vsthostwin.cpp +++ b/effects/internal/vsthostwin.cpp @@ -20,15 +20,13 @@ // C callbacks extern "C" { // Main host callback - VstIntPtr VSTCALLBACK hostCallback(AEffect *effect, int opcode, int index, long long value, void *ptr, float opt) { + VstIntPtr VSTCALLBACK hostCallback(AEffect *effect, int opcode, int, long long, void *, float) { switch(opcode) { case audioMasterVersion: return 2400; case audioMasterIdle: - effect->dispatcher(effect, effEditIdle, 0, 0, 0, 0); + effect->dispatcher(effect, effEditIdle, 0, 0, nullptr, 0); break; - case 6: // audioMasterWantMidi - return 0; case audioMasterGetCurrentProcessLevel: return 0; // Handle other opcodes here... there will be lots of them @@ -39,6 +37,7 @@ extern "C" { qInfo() << "Plugin requested unhandled opcode" << opcode; break; } + return 0; } } @@ -58,7 +57,7 @@ void VSTHostWin::loadPlugin() { LPCWSTR dll_fn_w = reinterpret_cast(dll_fn.utf16()); modulePtr = LoadLibrary(dll_fn_w); - if(modulePtr == NULL) { + if(modulePtr == nullptr) { DWORD dll_err = GetLastError(); qCritical() << "Failed to load VST" << dll_fn_w << "-" << dll_err; QString msg_err = "Failed to load VST plugin \"" + dll_fn + "\": " + QString::number(dll_err); @@ -74,16 +73,16 @@ void VSTHostWin::loadPlugin() { } vstPluginFuncPtr mainEntryPoint = - (vstPluginFuncPtr)GetProcAddress(modulePtr, "VSTPluginMain"); + reinterpret_cast(GetProcAddress(modulePtr, "VSTPluginMain")); // Instantiate the plugin plugin = mainEntryPoint(hostCallback); } void VSTHostWin::freePlugin() { - if (plugin != NULL) { + if (plugin != nullptr) { stopPlugin(); FreeLibrary(modulePtr); - plugin = NULL; + plugin = nullptr; } } @@ -98,22 +97,22 @@ bool VSTHostWin::configurePluginCallbacks() { } // Create dispatcher handle - dispatcher = (dispatcherFuncPtr)(plugin->dispatcher); + dispatcher = reinterpret_cast(plugin->dispatcher); // Set up plugin callback functions - plugin->getParameter = (getParameterFuncPtr)plugin->getParameter; - plugin->processReplacing = (processFuncPtr)plugin->processReplacing; - plugin->setParameter = (setParameterFuncPtr)plugin->setParameter; + plugin->getParameter = reinterpret_cast(plugin->getParameter); + plugin->processReplacing = reinterpret_cast(plugin->processReplacing); + plugin->setParameter = reinterpret_cast(plugin->setParameter); return true; } void VSTHostWin::startPlugin() { - dispatcher(plugin, effOpen, 0, 0, NULL, 0.0f); + dispatcher(plugin, effOpen, 0, 0, nullptr, 0.0f); // Set some default properties - dispatcher(plugin, effSetSampleRate, 0, 0, NULL, current_audio_freq()); - dispatcher(plugin, effSetBlockSize, 0, BLOCK_SIZE, NULL, 0.0f); + dispatcher(plugin, effSetSampleRate, 0, 0, nullptr, current_audio_freq()); + dispatcher(plugin, effSetBlockSize, 0, BLOCK_SIZE, nullptr, 0.0f); resumePlugin(); } @@ -121,19 +120,19 @@ void VSTHostWin::startPlugin() { void VSTHostWin::stopPlugin() { suspendPlugin(); - dispatcher(plugin, effClose, 0, 0, NULL, 0); + dispatcher(plugin, effClose, 0, 0, nullptr, 0); } void VSTHostWin::resumePlugin() { - dispatcher(plugin, effMainsChanged, 0, 1, NULL, 0.0f); + dispatcher(plugin, effMainsChanged, 0, 1, nullptr, 0.0f); } void VSTHostWin::suspendPlugin() { - dispatcher(plugin, effMainsChanged, 0, 0, NULL, 0.0f); + dispatcher(plugin, effMainsChanged, 0, 0, nullptr, 0.0f); } bool VSTHostWin::canPluginDo(char *canDoString) { - return (dispatcher(plugin, effCanDo, 0, 0, (void*)canDoString, 0.0f) > 0); + return (dispatcher(plugin, effCanDo, 0, 0, static_cast(canDoString), 0.0f) > 0); } void VSTHostWin::initializeIO() { @@ -158,11 +157,11 @@ void VSTHostWin::processAudio(long numFrames) { } VSTHostWin::VSTHostWin(Clip* c, const EffectMeta *em) : Effect(c, em) { - plugin = NULL; + plugin = nullptr; initializeIO(); - file_field = add_row("Plugin", true, false)->add_field(EFFECT_FIELD_FILE, "filename"); + file_field = add_row("Plugin", true, false)->add_field(EFFECT_FIELD_FILE, "filename", true); connect(file_field, SIGNAL(changed()), this, SLOT(change_plugin())); EffectRow* interface_row = add_row("Interface", false, false); @@ -183,8 +182,8 @@ VSTHostWin::~VSTHostWin() { freePlugin(); } -void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) { - if (plugin != NULL) { +void VSTHostWin::process_audio(double, double, quint8* samples, int nb_bytes, int) { + if (plugin != nullptr) { int interval = BLOCK_SIZE*4; for (int i=0;i>2; inputs[0][index] = float(left_sample) / float(INT16_MAX); @@ -207,13 +206,13 @@ void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint for (int j=i;j>2; - qint16 left_sample = qRound(outputs[0][index] * INT16_MAX); - qint16 right_sample = qRound(outputs[1][index] * INT16_MAX); + qint16 left_sample = qint16(qRound(outputs[0][index] * INT16_MAX)); + qint16 right_sample = qint16(qRound(outputs[1][index] * INT16_MAX)); - samples[j+3] = (quint8) (right_sample >> 8); - samples[j+2] = (quint8) right_sample; - samples[j+1] = (quint8) (left_sample >> 8); - samples[j] = (quint8) left_sample; + samples[j+3] = quint8(right_sample >> 8); + samples[j+2] = quint8(right_sample); + samples[j+1] = quint8(left_sample >> 8); + samples[j] = quint8(left_sample); } } } @@ -223,18 +222,17 @@ void VSTHostWin::custom_load(QXmlStreamReader &stream) { if (stream.name() == "plugindata") { stream.readNext(); QByteArray b = QByteArray::fromBase64(stream.text().toUtf8()); - const char* data = b.constData(); - if (plugin != NULL) { - dispatcher(plugin, effSetChunk, 0, (VstInt32) b.size(), (void*) b.constData(), 0); + if (plugin != nullptr) { + dispatcher(plugin, effSetChunk, 0, VstInt32(b.size()), static_cast(b.data()), 0); } } } void VSTHostWin::save(QXmlStreamWriter &stream) { Effect::save(stream); - if (plugin != NULL) { - char* p = NULL; - VstInt32 length = dispatcher(plugin, effGetChunk, 0, 0, &p, 0); + if (plugin != nullptr) { + char* p = nullptr; + VstInt32 length = VstInt32(dispatcher(plugin, effGetChunk, 0, 0, &p, 0)); QByteArray b(p, length); stream.writeTextElement("plugindata", b.toBase64()); } @@ -251,18 +249,18 @@ void VSTHostWin::uncheck_show_button() { void VSTHostWin::change_plugin() { freePlugin(); loadPlugin(); - if (plugin != NULL) { + if (plugin != nullptr) { if (configurePluginCallbacks()) { startPlugin(); dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->winId()), 0); - ERect* eRect = NULL; + ERect* eRect = nullptr; plugin->dispatcher(plugin, effEditGetRect, 0, 0, &eRect, 0); dialog->setFixedWidth(eRect->right); dialog->setFixedHeight(eRect->bottom); } else { FreeLibrary(modulePtr); - plugin = NULL; + plugin = nullptr; } } - show_interface_btn->setEnabled(plugin != NULL); + show_interface_btn->setEnabled(plugin != nullptr); } diff --git a/icons/icons.qrc b/icons/icons.qrc index 57624c16c..a2981fd4c 100644 --- a/icons/icons.qrc +++ b/icons/icons.qrc @@ -58,5 +58,6 @@ tri-up.png hand.png hand-disabled.png + olive64.png diff --git a/icons/olive64.png b/icons/olive64.png new file mode 100644 index 0000000000000000000000000000000000000000..d5e31af4e462737d289fccd5754bf226192ffea8 GIT binary patch literal 8354 zcmV;TAYI>yP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000%uNkl8`4K@BUHU z)jh*RhKDit^En@Ss;H`ae)pW;J?Gqe#mg_h%n7!cz)ipupb97e3_x&ln+6n+1P%dP zfTw|1PUNN5aXxoG@F*~?tgI|hQBgrO8YK`2U>F8MoNV0z5L#fiM)SAz`m6w-OUS3XHTid8Z&4*s^ z?&^LExEkm@830@X{8vp)P2|*5Pd(yhM{fu92kU9T%vak$`!cZZlg{9P#)^KLcnUoil9|6QCpL{aCv9Yl!1Hzh5wW_0#;61?OW5w|w-x*dtjBq&YUpyE;$XmPKVsHCi zLa`8$ScE_%fEBhd115&$k)ReD!!S+?2udo@AeBVA632FMQV!`vnq*g!WLJ_g6=S%3 z+~o`}9_~MvPN!*XYNVyP<#FJ?V*%ja%Au7%I`x!OF-_CIxPISy*6&(RxF}4dBtkeA zCRh-}44GI#%O80m1PFYBJdx4Qx&Yd<1gRv-Rk)6eowP|MQY5>QB-#=rJCl5A{Fk_N z%%!I8<-;B;3sZoB zKl)kLMuRxckRS`3p$*>^gcfL}F{FVJHZTiJ%&}tO(g6D^Uj$EKqwSq%$PA^=gytWfnoWx zLw^8PR99C=@(FK6!wPnG?j%|nB~l(C7z<*BEwI2fT(4tF=M=|NTyyfL$NulsXq2HK z2v(s*Km;fd1t_JcKUB~2??2DnNpk@xEiGl(uwjv=rlwbbiv|MVl2}n}#_-|8{gHoj z-Cp6;H@vcXb508dp8sq~dU&~t!wd)HA|SxBHHfEBeM=#6?- z(Ifu-BP&0kHH5&5S%lmW1$F_ewy&bLqLvY*BLJuzQb|vD&y&E&d;rcbj24b4EiLt5 z_{P3BFpEqA#Q}^$0~J&_!r^NLU!&A0znj2m0isn=49ocZ6we1hdDfV<1f$R(P!yoPv7Qf_KVV|zL;!|V3?beV{~<8V zw}6t85+8s~O`9;ICPu`704Sl5N}|zh>)b|DV-t-B8mX?TCal5;DL!B2vjFIfJE|Nx zngu3S)Z)!OZ!%%X1OQ4(N&uz;h6Q}3xVSiw4O&`zTiM>eoxLgx!g2!`roo>?%L74a zg+ieNAi@GsAlP`|_gpjX8UV`5%INCqy2%2jL?RI%fPLM2A*j)oLJAkH6ixyrOs=T*!et=wE~qHIHBn1?eO)?a9)8082MG5q)HMJAsif( zQvUQNwe&4Oqag@e?X46w6>-{P4#--CQVOlSDO?IkTBiF~u!PmWtd&+NgaV;J zDHEkK!DgNd_;G(ov$p#UCM3VWBNHEC;r}hfs1O*zT&KrJ#&d4;JjNG}XLNKlAtQ7| zze_`nFoOM0FcVF;QlqtBkBRJmbh9Xw2P@tf5fvc&>sK< z=&0s}y)QDoY&t(Z@1OXv`$I0Oxrm?JWTu*CHD~WW1sHsS{R&w*$n|W;2V=TCA0SkY#kTvhGVPwfjW}iKq zE2mt^*<;Qo-WzAlwl%D5Sjnc=O>Er15w%;PdKI!)f(En1q|53;*aF?`eakAgkV+ms z=+b@36O}2YN$Ewi16e>H7f=#MIUqquucGs5E&!lijdUcxY4{D7f8la&`uR;f^{uBE zUp=0G`M-Z*$+jgdd3OodopBwDu3E(0bLTSiteH5a+8LO{aO#OZlYh6JGt~RhI8x zPSQ+z6(0eZ^eMF94&DM#-f!h9pVRsSVEBcMj7TLtH~0hM*ba8wCf%LJ>2+{j4_T=t z9dxi_#|r8u*U?EQH~;s|?C;pmirFg|6&Zz5WU#ttHFqt)iMf_9Yr4(QF&S=)kW2;Xjs95XBIFbHiDsrLm5{yj=Qe9 zi(jt!C5?@Z*rrV&5;(T?N1fx1tQ%w#IjIN10ZJ*9t00+I{?gh<@Mr)W=sv)>@^JuE z#47lkbN_~W*WAnED;87tqdFGPUCe1Er*X&fJD7CZBo^JUh>J&DOl@T?&E3ts_TFo( z{$Mpbot*?v4I-sHVwGu70A&0hiNC6()F3!Or4=$EaeG~qo5=*F8nisR@lkKO%Cs4^ zGw5vWL;@jlX+?8_vA} zEi$pZJTb}YkWHG7;DA0PXiJoo;3pO8m}FhcT5f*!8*Ke#D~a9&OJ84#N=er3UdK)6 z-Gnq<{(k-6v0?A;cebKa2i_>1SiNlSN2&MXa!A6)qZoMs!9lE>VKoMKT zQa=EWZ~?6pN*M^H{8E>n4iCZwFkxNSI@bLA8r&8aZG%;5($Mu0Bg#iGYuwfR_n}u< z*6=JXU9J3L?k~7!`Cl>p$J4p(i??z0Syxk2QNyy=m*KRym=z|3I4&3PLt>>-Iy0C@ z3x$=^2&ue4$jAX82MYi|7|dZ7qQvlmn4n#%cS9x7*#cjsl%sY2m@Q%RK_Yv zI!O-p9Axvs&1`7e!1{yhIbVsqDK9(er$ru<+EZ+!4ZpN@|# zAIYK_i`X)M3%|PLSJVb-aeG~)+ppi*Swty+8vJw;%*4)yYoLvO%U|mFEuj8TJ(rEX z%-hORR8Duin`?f44cgV1v5wlA}qjyXZJnJ z(!XDd>Qv~I_VyzL1tKIciVTbr!&7u105W>@Z%4R*&zKq0$*-)Oh`h2Rx1Z5*9q+o( zh=@Q$1Up)Hcw7-HL1qh4{V2!dcPct!w z7!YRQ{$|1GS1cJ2083kb2${{Nvq+wZeBAXh8$aHd+wzjf*eG~x-D5sLe>U~cC^Cvz zyLBxK&RxKrlkQ|*?L2OqbQ=x#H1Ou_Z&LS#Iz&WZL=B8W0}&D)5$3%UnMt2BdIUwV zKLFYQRQ|<)2zUvQEj@9h|F?3~@rzPC@%9q{^rm~gk#em|4H;@4lKAW`6Pg6oZVz6JYM;CfTBpYwPn|D*vlOPNbvh87I< zM_;+hmp(q_9;XP+H=q6{8+L3!goSSf+V%XjLw0cEFK(o#w}+Y`HK?TGD-*xMtTSiv z?zVUNk6ZtPEqk_b=a27X>8ndQ)OLsq$6v^juPi~eE3}AOa#F{Cc1t4rhQES3S<} zyKUP5n+@PUdwY9*#ioy%j<7|}kMc*~)hFxr-R#{zMa!= zKAk%szmqKuTX^`IhtcgCQeGdibEA%(krd3FG_(KczYD1BR@oVWKww?|{=f%UKFHe# z-u5;Z1VrDg>yNk>K&LgjC$pj(69`Lq*OD4DZBiO8rPXdl6nppbV-Ia>w5^#od>RkU zc__D$x}zP(b}j|hW<%jO9mm<1PNz=`g}my+*U$Mn@9cWV3tAL?Q%`ZkvhQct1W=f_ z45u^%Ktu&HC^_sN_6jC4R}A&ZFRjrj&D<}}?X!W}v7NoZ+Wuwn`SC>DH7tpAGXbp3k=~`&J)|NhA_TDZhhv z&XA)40I)$y8Iww$Z5g}^uX&$eKkz&F2h4K7d&eXB?{o7iJr0~d z`h4!2bsv{ZxTMc2S3D8NPTNa>2L_yEj&f+~K45V)8Wq7{u+NS6_Poc+Eh~BFqj!)( z=B7!JcS1y*M3c`hk>>$wD1!^eT|nJgb(}rw>^_e=jzdpRj|LXu9rEOO0D#P~xro<} zTnlVF!1@o@({P}Hrj91s;%%heG-)S&Qr$mfg$P+8%A@5}l~gghdNdbLyqHrePC4TL z_V)JD+uNH0W&^7}HOv^~+2Io470a?N42Q$?w}wBJX4^KYR0`L1H)Pnpa}diHgKC|? zMXu{!5s%0J)v~P9L!r>03=p<$lTN2`U3V|u(b?Y)_Ss`SJG=%M>ALPEuIoOSNF=5O z0s$)&3Xvtt&-yH}zkVSlwrykEwu^Uo`fs!0?Xk4uJw3iQBZlKRvmD3yb6_$s6o`CA sVN!N3=mnaA4}j-^=Q6Z-T(^b07*qoM6N<$f*8L7;Q#;t literal 0 HcmV?d00001 diff --git a/io/clipboard.cpp b/io/clipboard.cpp index 1c3a8075b..344a4d6ce 100644 --- a/io/clipboard.cpp +++ b/io/clipboard.cpp @@ -2,13 +2,14 @@ #include "project/clip.h" #include "project/effect.h" +#include "project/transition.h" int clipboard_type = CLIPBOARD_TYPE_CLIP; QVector clipboard; QVector clipboard_transitions; void clear_clipboard() { - uint clipboard_size = clipboard.size(); + int clipboard_size = clipboard.size(); for (int i=0;i(clipboard.at(i)); diff --git a/io/exportthread.cpp b/io/exportthread.cpp index 5993f0316..9ec00ba0c 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -27,19 +27,19 @@ extern "C" { ExportThread::ExportThread() : continueEncode(true) { surface.create(); - fmt_ctx = NULL; - video_stream = NULL; - vcodec = NULL; - vcodec_ctx = NULL; - video_frame = NULL; - sws_frame = NULL; - sws_ctx = NULL; - audio_stream = NULL; - acodec = NULL; - audio_frame = NULL; - swr_frame = NULL; - acodec_ctx = NULL; - swr_ctx = NULL; + fmt_ctx = nullptr; + video_stream = nullptr; + vcodec = nullptr; + vcodec_ctx = nullptr; + video_frame = nullptr; + sws_frame = nullptr; + sws_ctx = nullptr; + audio_stream = nullptr; + acodec = nullptr; + audio_frame = nullptr; + swr_frame = nullptr; + acodec_ctx = nullptr; + swr_ctx = nullptr; vpkt_alloc = false; apkt_alloc = false; @@ -133,7 +133,7 @@ bool ExportThread::setupVideo() { } } - ret = avcodec_open2(vcodec_ctx, vcodec, NULL); + ret = avcodec_open2(vcodec_ctx, vcodec, nullptr); if (ret < 0) { qCritical() << "Could not open output video encoder." << ret; ed->export_error = "could not open output video encoder (" + QString::number(ret) + ")"; @@ -166,9 +166,9 @@ bool ExportThread::setupVideo() { video_height, vcodec_ctx->pix_fmt, SWS_FAST_BILINEAR, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr ); sws_frame = av_frame_alloc(); @@ -228,7 +228,7 @@ bool ExportThread::setupAudio() { } // open encoder - ret = avcodec_open2(acodec_ctx, acodec, NULL); + ret = avcodec_open2(acodec_ctx, acodec, nullptr); if (ret < 0) { qCritical() << "Could not open output audio encoder." << ret; ed->export_error = "could not open output audio encoder (" + QString::number(ret) + ")"; @@ -245,7 +245,7 @@ bool ExportThread::setupAudio() { // init audio resampler context swr_ctx = swr_alloc_set_opts( - NULL, + nullptr, acodec_ctx->channel_layout, acodec_ctx->sample_fmt, acodec_ctx->sample_rate, @@ -253,7 +253,7 @@ bool ExportThread::setupAudio() { AV_SAMPLE_FMT_S16, sequence->audio_frequency, 0, - NULL + nullptr ); swr_init(swr_ctx); @@ -272,7 +272,7 @@ bool ExportThread::setupAudio() { ed->export_error = "could not allocate audio buffer (" + QString::number(ret) + ")"; return false; } - aframe_bytes = av_samples_get_buffer_size(NULL, audio_frame->channels, audio_frame->nb_samples, static_cast(audio_frame->format), 0); + aframe_bytes = av_samples_get_buffer_size(nullptr, audio_frame->channels, audio_frame->nb_samples, static_cast(audio_frame->format), 0); // init converted audio frame swr_frame = av_frame_alloc(); @@ -288,7 +288,7 @@ bool ExportThread::setupAudio() { } bool ExportThread::setupContainer() { - avformat_alloc_output_context2(&fmt_ctx, NULL, NULL, c_filename); + avformat_alloc_output_context2(&fmt_ctx, nullptr, nullptr, c_filename); if (!fmt_ctx) { qCritical() << "Could not create output context"; ed->export_error = "could not create output format context"; @@ -328,7 +328,7 @@ void ExportThread::run() { if (audio_enabled && continueEncode) continueEncode = setupAudio(); if (continueEncode) { - ret = avformat_write_header(fmt_ctx, NULL); + ret = avformat_write_header(fmt_ctx, nullptr); if (ret < 0) { qCritical() << "Could not write output file header." << ret; ed->export_error = "could not write output file header (" + QString::number(ret) + ")"; @@ -412,7 +412,7 @@ void ExportThread::run() { if (audio_enabled) apkt_alloc = true; } - panel_sequence_viewer->viewer_widget->default_fbo = NULL; + panel_sequence_viewer->viewer_widget->default_fbo = nullptr; rendering = false; fbo.release(); @@ -420,7 +420,7 @@ void ExportThread::run() { if (audio_enabled && continueEncode) { // flush swresample do { - swr_convert_frame(swr_ctx, swr_frame, NULL); + swr_convert_frame(swr_ctx, swr_frame, nullptr); if (swr_frame->nb_samples == 0) break; swr_frame->pts = file_audio_samples; if (!encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) continueEncode = false; @@ -433,8 +433,8 @@ void ExportThread::run() { if (continueEncode) { // flush remaining packets while (continueVideo && continueAudio) { - if (continueVideo && video_enabled) continueVideo = encode(fmt_ctx, vcodec_ctx, NULL, &video_pkt, video_stream, false); - if (continueAudio && audio_enabled) continueAudio = encode(fmt_ctx, acodec_ctx, NULL, &audio_pkt, audio_stream, true); + if (continueVideo && video_enabled) continueVideo = encode(fmt_ctx, vcodec_ctx, nullptr, &video_pkt, video_stream, false); + if (continueAudio && audio_enabled) continueAudio = encode(fmt_ctx, acodec_ctx, nullptr, &audio_pkt, audio_stream, true); } ret = av_write_trailer(fmt_ctx); @@ -450,26 +450,26 @@ void ExportThread::run() { avio_closep(&fmt_ctx->pb); if (vpkt_alloc) av_packet_unref(&video_pkt); - if (video_frame != NULL) av_frame_free(&video_frame); - if (vcodec_ctx != NULL) { + if (video_frame != nullptr) av_frame_free(&video_frame); + if (vcodec_ctx != nullptr) { avcodec_close(vcodec_ctx); avcodec_free_context(&vcodec_ctx); } if (apkt_alloc) av_packet_unref(&audio_pkt); - if (audio_frame != NULL) av_frame_free(&audio_frame); - if (acodec_ctx != NULL) { + if (audio_frame != nullptr) av_frame_free(&audio_frame); + if (acodec_ctx != nullptr) { avcodec_close(acodec_ctx); avcodec_free_context(&acodec_ctx); } avformat_free_context(fmt_ctx); - if (sws_ctx != NULL) { + if (sws_ctx != nullptr) { sws_freeContext(sws_ctx); av_frame_free(&sws_frame); } - if (swr_ctx != NULL) { + if (swr_ctx != nullptr) { swr_free(&swr_ctx); av_frame_free(&swr_frame); } diff --git a/io/loadthread.cpp b/io/loadthread.cpp index a65942c70..147e4b6c7 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -43,7 +43,7 @@ const EffectMeta* get_meta_from_name(const QString& name) { return &effects.at(j); } } - return NULL; + return nullptr; } void LoadThread::load_effect(QXmlStreamReader& stream, Clip* c) { @@ -67,7 +67,7 @@ void LoadThread::load_effect(QXmlStreamReader& stream, Clip* c) { // wait for effects to be loaded panel_effect_controls->effects_loaded.lock(); - const EffectMeta* meta = NULL; + const EffectMeta* meta = nullptr; // find effect with this name if (!effect_name.isEmpty()) { @@ -168,7 +168,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { switch (type) { case MEDIA_TYPE_FOLDER: { - Media* folder = panel_project->new_folder(0); + Media* folder = panel_project->new_folder(nullptr); folder->temp_id2 = 0; for (int j=0;jset_footage(m); if (folder == 0) { - project_model.appendChild(NULL, item); + project_model.appendChild(nullptr, item); } else { find_loaded_folder_by_id(folder)->appendChild(item); } @@ -250,7 +250,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { break; case MEDIA_TYPE_SEQUENCE: { - Media* parent = NULL; + Media* parent = nullptr; Sequence* s = new Sequence(); // load attributes about sequence @@ -304,8 +304,8 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { s->markers.append(m); } else if (stream.name() == "transition" && stream.isStartElement()) { TransitionData td; - td.otc = NULL; - td.ctc = NULL; + td.otc = nullptr; + td.ctc = nullptr; for (int j=0;jautoscale = false; - c->media = NULL; + c->media = nullptr; for (int j=0;jmedia = NULL; + c->media = nullptr; c->media_stream = attr.value().toInt(); loaded_clips.append(c); } @@ -468,16 +468,16 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { const TransitionData& td = transition_data.at(i); Clip* primary = td.otc; Clip* secondary = td.ctc; - if (primary != NULL || secondary != NULL) { - if (primary == NULL) { + if (primary != nullptr || secondary != nullptr) { + if (primary == nullptr) { primary = secondary; - secondary = NULL; + secondary = nullptr; } const EffectMeta* meta = get_meta_from_name(td.name); - if (meta == NULL) { + if (meta == nullptr) { qWarning() << "Failed to link transition with name:" << td.name; - if (td.otc != NULL) td.otc->opening_transition = -1; - if (td.ctc != NULL) td.ctc->closing_transition = -1; + if (td.otc != nullptr) td.otc->opening_transition = -1; + if (td.ctc != nullptr) td.ctc->closing_transition = -1; } else { emit start_create_dual_transition(&td, primary, secondary, meta); @@ -486,7 +486,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { } } - Media* m = panel_project->new_sequence(NULL, s, false, parent); + Media* m = panel_project->new_sequence(nullptr, s, false, parent); loaded_sequences.append(m); } @@ -503,14 +503,14 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { } Media* LoadThread::find_loaded_folder_by_id(int id) { - if (id == 0) return NULL; + if (id == 0) return nullptr; for (int j=0;jtemp_id == id) { return parent_item; } } - return NULL; + return nullptr; } void LoadThread::run() { @@ -538,7 +538,7 @@ void LoadThread::run() { show_err = true; // temp variables for loading (unnecessary?) - open_seq = NULL; + open_seq = nullptr; loaded_folders.clear(); loaded_media_items.clear(); loaded_clips.clear(); @@ -573,7 +573,7 @@ void LoadThread::run() { Media* folder = loaded_folders.at(i); int parent = folder->temp_id2; if (folder->temp_id2 == 0) { - project_model.appendChild(NULL, folder); + project_model.appendChild(nullptr, folder); } else { find_loaded_folder_by_id(parent)->appendChild(folder); } @@ -601,7 +601,7 @@ void LoadThread::run() { // attach nested sequence clips to their sequences for (int i=0;imedia == NULL && loaded_clips.at(i)->media_stream == loaded_sequences.at(j)->to_sequence()->save_id) { + if (loaded_clips.at(i)->media == nullptr && loaded_clips.at(i)->media_stream == loaded_sequences.at(j)->to_sequence()->save_id) { loaded_clips.at(i)->media = loaded_sequences.at(j); loaded_clips.at(i)->refresh(); break; @@ -659,7 +659,7 @@ void LoadThread::success_func() { } mainWindow->setWindowModified(autorecovery); - if (open_seq != NULL) set_sequence(open_seq); + if (open_seq != nullptr) set_sequence(open_seq); update_ui(false); } @@ -695,7 +695,7 @@ void LoadThread::create_effect_ui( if (cancelled) return; if (type == TA_NO_TRANSITION) { - if (meta == NULL) { + if (meta == nullptr) { // create void effect VoidEffect* ve = new VoidEffect(c, *effect_name); ve->set_enabled(effect_enabled); @@ -709,7 +709,7 @@ void LoadThread::create_effect_ui( c->effects.append(e); } } else { - int transition_index = create_transition(c, NULL, meta); + int transition_index = create_transition(c, nullptr, meta); Transition* t = c->sequence->transitions.at(transition_index); if (effect_length > -1) t->set_length(effect_length); t->set_enabled(effect_enabled); @@ -728,7 +728,7 @@ void LoadThread::create_effect_ui( void LoadThread::create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta) { int transition_index = create_transition(primary, secondary, meta); primary->sequence->transitions.at(transition_index)->set_length(td->length); - if (td->otc != NULL) td->otc->opening_transition = transition_index; - if (td->ctc != NULL) td->ctc->closing_transition = transition_index; + if (td->otc != nullptr) td->otc->opening_transition = transition_index; + if (td->ctc != nullptr) td->ctc->closing_transition = transition_index; waitCond.wakeAll(); } diff --git a/io/loadthread.h b/io/loadthread.h index e3ae55fe3..f591fb966 100644 --- a/io/loadthread.h +++ b/io/loadthread.h @@ -12,60 +12,60 @@ struct Footage; struct Clip; struct Sequence; class LoadDialog; -class TransitionData; +struct TransitionData; struct EffectMeta; class LoadThread : public QThread { - Q_OBJECT + Q_OBJECT public: - LoadThread(LoadDialog* l, bool a); - void run(); - void cancel(); + LoadThread(LoadDialog* l, bool a); + void run(); + void cancel(); signals: - void success(); + void success(); void error(); - void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); + void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); void start_create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta); - void report_progress(int p); + void report_progress(int p); private slots: void error_func(); - void success_func(); - void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); + void success_func(); + void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); void create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta); private: - LoadDialog* ld; - bool autorecovery; + LoadDialog* ld; + bool autorecovery; - bool load_worker(QFile& f, QXmlStreamReader& stream, int type); - void load_effect(QXmlStreamReader& stream, Clip* c); + bool load_worker(QFile& f, QXmlStreamReader& stream, int type); + void load_effect(QXmlStreamReader& stream, Clip* c); - void read_next(QXmlStreamReader& stream); - void read_next_start_element(QXmlStreamReader& stream); - void update_current_element_count(QXmlStreamReader& stream); + void read_next(QXmlStreamReader& stream); + void read_next_start_element(QXmlStreamReader& stream); + void update_current_element_count(QXmlStreamReader& stream); - Sequence* open_seq; - QVector loaded_media_items; - QDir proj_dir; - QDir internal_proj_dir; - QString internal_proj_url; - bool show_err; - QString error_str; + Sequence* open_seq; + QVector loaded_media_items; + QDir proj_dir; + QDir internal_proj_dir; + QString internal_proj_url; + bool show_err; + QString error_str; - bool is_element(QXmlStreamReader& stream); + bool is_element(QXmlStreamReader& stream); - QVector loaded_folders; - QVector loaded_clips; - QVector loaded_sequences; - Media* find_loaded_folder_by_id(int id); + QVector loaded_folders; + QVector loaded_clips; + QVector loaded_sequences; + Media* find_loaded_folder_by_id(int id); - int current_element_count; - int total_element_count; + int current_element_count; + int total_element_count; - QMutex mutex; - QWaitCondition waitCond; + QMutex mutex; + QWaitCondition waitCond; - bool cancelled; + bool cancelled; bool xml_error; }; diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index cbc386743..4755c77e9 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -31,7 +31,7 @@ QSemaphore sem(5); // only 5 preview generators can run at one time PreviewGenerator::PreviewGenerator(Media* i, Footage* m, bool r) : QThread(0), - fmt_ctx(NULL), + fmt_ctx(nullptr), media(i), footage(m), retrieve_duration(false), @@ -52,7 +52,7 @@ void PreviewGenerator::parse_media() { // detect video/audio streams in file for (int i=0;i<(int)fmt_ctx->nb_streams;i++) { // Find the decoder for the video stream - if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == NULL) { + if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == nullptr) { qCritical() << "Unsupported codec in stream" << i << "of file" << footage->name; } else { FootageStream ms; @@ -219,13 +219,13 @@ void PreviewGenerator::generate_waveform() { AVCodecContext** codec_ctx = new AVCodecContext* [fmt_ctx->nb_streams]; int64_t* media_lengths = new int64_t[fmt_ctx->nb_streams]{0}; for (unsigned int i=0;inb_streams;i++) { - codec_ctx[i] = NULL; + codec_ctx[i] = nullptr; if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { AVCodec* codec = avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id); - if (codec != NULL) { + if (codec != nullptr) { codec_ctx[i] = avcodec_alloc_context3(codec); avcodec_parameters_to_context(codec_ctx[i], fmt_ctx->streams[i]->codecpar); - avcodec_open2(codec_ctx[i], codec, NULL); + avcodec_open2(codec_ctx[i], codec, nullptr); if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && codec_ctx[i]->channel_layout == 0) { codec_ctx[i]->channel_layout = av_get_default_channel_layout(fmt_ctx->streams[i]->codecpar->channels); } @@ -241,11 +241,11 @@ void PreviewGenerator::generate_waveform() { // get the ball rolling do { av_read_frame(fmt_ctx, packet); - } while (codec_ctx[packet->stream_index] == NULL); + } while (codec_ctx[packet->stream_index] == nullptr); avcodec_send_packet(codec_ctx[packet->stream_index], packet); while (!end_of_file) { - while (codec_ctx[packet->stream_index] == NULL || avcodec_receive_frame(codec_ctx[packet->stream_index], temp_frame) == AVERROR(EAGAIN)) { + while (codec_ctx[packet->stream_index] == nullptr || avcodec_receive_frame(codec_ctx[packet->stream_index], temp_frame) == AVERROR(EAGAIN)) { av_packet_unref(packet); int read_ret = av_read_frame(fmt_ctx, packet); @@ -256,7 +256,7 @@ void PreviewGenerator::generate_waveform() { if (read_ret != AVERROR_EOF) qCritical() << "Failed to read packet for preview generation" << read_ret; break; } - if (codec_ctx[packet->stream_index] != NULL) { + if (codec_ctx[packet->stream_index] != nullptr) { int send_ret = avcodec_send_packet(codec_ctx[packet->stream_index], packet); if (send_ret < 0 && send_ret != AVERROR(EAGAIN)) { qCritical() << "Failed to send packet for preview generation - aborting" << send_ret; @@ -267,7 +267,7 @@ void PreviewGenerator::generate_waveform() { } if (!end_of_file) { FootageStream* s = footage->get_stream_from_file_index(fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO, packet->stream_index); - if (s != NULL) { + if (s != nullptr) { if (fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (!s->preview_done) { int dstH = 120; @@ -282,9 +282,9 @@ void PreviewGenerator::generate_waveform() { dstH, static_cast(AV_PIX_FMT_RGBA), SWS_FAST_BILINEAR, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr ); int linesize[AV_NUM_DATA_POINTERS]; @@ -304,7 +304,7 @@ void PreviewGenerator::generate_waveform() { if (!retrieve_duration) { avcodec_close(codec_ctx[packet->stream_index]); - codec_ctx[packet->stream_index] = NULL; + codec_ctx[packet->stream_index] = nullptr; } } media_lengths[packet->stream_index]++; @@ -317,7 +317,7 @@ void PreviewGenerator::generate_waveform() { swr_frame->format = AV_SAMPLE_FMT_S16P; swr_ctx = swr_alloc_set_opts( - NULL, + nullptr, temp_frame->channel_layout, static_cast(swr_frame->format), temp_frame->sample_rate, @@ -325,7 +325,7 @@ void PreviewGenerator::generate_waveform() { static_cast(temp_frame->format), temp_frame->sample_rate, 0, - NULL + nullptr ); swr_init(swr_ctx); @@ -394,7 +394,7 @@ void PreviewGenerator::generate_waveform() { av_frame_free(&temp_frame); av_packet_free(&packet); for (unsigned int i=0;inb_streams;i++) { - if (codec_ctx[i] != NULL) { + if (codec_ctx[i] != nullptr) { avcodec_close(codec_ctx[i]); } } @@ -422,8 +422,8 @@ QString PreviewGenerator::get_waveform_path(const QString& hash, const FootageSt } void PreviewGenerator::run() { - Q_ASSERT(footage != NULL); - Q_ASSERT(media != NULL); + Q_ASSERT(footage != nullptr); + Q_ASSERT(media != nullptr); QByteArray ba = footage->url.toUtf8(); char* filename = new char[ba.size()+1]; @@ -431,14 +431,14 @@ void PreviewGenerator::run() { QString errorStr; bool error = false; - int errCode = avformat_open_input(&fmt_ctx, filename, NULL, NULL); + int errCode = avformat_open_input(&fmt_ctx, filename, nullptr, nullptr); if(errCode != 0) { char err[1024]; av_strerror(errCode, err, 1024); errorStr = "Could not open file - " + QString(err); error = true; } else { - errCode = avformat_find_stream_info(fmt_ctx, NULL); + errCode = avformat_find_stream_info(fmt_ctx, nullptr); if (errCode < 0) { char err[1024]; av_strerror(errCode, err, 1024); @@ -490,7 +490,7 @@ void PreviewGenerator::run() { } delete [] filename; - footage->preview_gen = NULL; + footage->preview_gen = nullptr; } void PreviewGenerator::cancel() { diff --git a/io/qpainterwrapper.cpp b/io/qpainterwrapper.cpp index 024fac1b8..b86a05441 100644 --- a/io/qpainterwrapper.cpp +++ b/io/qpainterwrapper.cpp @@ -15,7 +15,7 @@ QColor get_color_from_string(const QString& s) { // workaround for alpha if (s.at(0) == '#' && s.length() == 9) { QColor color(s.left(7)); - color.setAlpha(s.mid(7).toInt(NULL, 16)); + color.setAlpha(s.mid(7).toInt(nullptr, 16)); return color; } else { return QColor(s); diff --git a/main.cpp b/main.cpp index 11668c0ae..f2806308e 100644 --- a/main.cpp +++ b/main.cpp @@ -25,19 +25,19 @@ int main(int argc, char *argv[]) { if (argc > 1) { for (int i=1;i actions = menu->actions(); for (int i=0;imenu() != NULL) { + if (a->menu() != nullptr) { kbd_shortcut_processor(file, a->menu(), save, first); } else if (!a->isSeparator()) { if (save) { @@ -415,7 +415,7 @@ void MainWindow::zoom_out() { } void MainWindow::export_dialog() { - if (sequence == NULL) { + if (sequence == nullptr) { QMessageBox::information(this, "No active sequence", "Please open the sequence you wish to export.", QMessageBox::Ok); } else { ExportDialog e(this); @@ -424,7 +424,7 @@ void MainWindow::export_dialog() { } void MainWindow::ripple_delete() { - if (sequence != NULL) panel_timeline->delete_selection(sequence->selections, true); + if (sequence != nullptr) panel_timeline->delete_selection(sequence->selections, true); } void MainWindow::editMenu_About_To_Be_Shown() { @@ -445,11 +445,11 @@ void MainWindow::redo() { } void MainWindow::open_speed_dialog() { - if (sequence != NULL) { + if (sequence != nullptr) { SpeedDialog s(this); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { s.clips.append(c); } } @@ -458,7 +458,7 @@ void MainWindow::open_speed_dialog() { } void MainWindow::cut() { - if (sequence != NULL) { + if (sequence != nullptr) { QDockWidget* focused_panel = get_focused_panel(); if (panel_timeline == focused_panel) { panel_timeline->copy(true); @@ -469,7 +469,7 @@ void MainWindow::cut() { } void MainWindow::copy() { - if (sequence != NULL) { + if (sequence != nullptr) { QDockWidget* focused_panel = get_focused_panel(); if (panel_timeline == focused_panel) { panel_timeline->copy(false); @@ -481,7 +481,7 @@ void MainWindow::copy() { void MainWindow::paste() { QDockWidget* focused_panel = get_focused_panel(); - if ((panel_timeline == focused_panel || panel_effect_controls == focused_panel) && sequence != NULL) { + if ((panel_timeline == focused_panel || panel_effect_controls == focused_panel) && sequence != nullptr) { panel_timeline->paste(false); } } @@ -918,7 +918,7 @@ void MainWindow::closeEvent(QCloseEvent *e) { if (can_close_project()) { panel_effect_controls->clear_effects(true); - set_sequence(NULL); + set_sequence(nullptr); panel_footage_viewer->set_main_sequence(); @@ -1076,13 +1076,13 @@ void MainWindow::playpause() { } void MainWindow::prev_cut() { - if (sequence != NULL && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { + if (sequence != nullptr && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { panel_timeline->previous_cut(); } } void MainWindow::next_cut() { - if (sequence != NULL && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { + if (sequence != nullptr && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { panel_timeline->next_cut(); } } @@ -1352,16 +1352,16 @@ void MainWindow::set_tsa_custom() { } void MainWindow::set_marker() { - if (sequence != NULL) panel_timeline->set_marker(); + if (sequence != nullptr) panel_timeline->set_marker(); } void MainWindow::toggle_enable_clips() { - if (sequence != NULL) { + if (sequence != nullptr) { ComboAction* ca = new ComboAction(); bool push_undo = false; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { ca->append(new SetEnableCommand(c, !c->enabled)); push_undo = true; } @@ -1384,14 +1384,14 @@ void MainWindow::edit_to_out_point() { } void MainWindow::nest() { - if (sequence != NULL) { + if (sequence != nullptr) { QVector selected_clips; long earliest_point = LONG_MAX; // get selected clips for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { selected_clips.append(i); earliest_point = qMin(c->timeline_in, earliest_point); } @@ -1424,7 +1424,7 @@ void MainWindow::nest() { } // add sequence to project - Media* m = panel_project->new_sequence(ca, s, false, NULL); + Media* m = panel_project->new_sequence(ca, s, false, nullptr); // add nested sequence to active sequence QVector media_list; @@ -1443,7 +1443,7 @@ void MainWindow::nest() { } void MainWindow::paste_insert() { - if (panel_timeline->focused() && sequence != NULL) { + if (panel_timeline->focused() && sequence != nullptr) { panel_timeline->paste(true); } } diff --git a/olive.pro b/olive.pro index 112eb4e83..e47ba1c0a 100644 --- a/olive.pro +++ b/olive.pro @@ -33,6 +33,8 @@ system("which git") { DEFINES += GITHASH=\\"\"$$GITHASHVAR\\"\" } +CONFIG += c++11 + SOURCES += \ main.cpp \ mainwindow.cpp \ @@ -221,9 +223,9 @@ FORMS += win32 { RC_FILE = packaging/windows/resources.rc LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32 -luser32 - - SOURCES += effects/internal/vsthostwin.cpp - HEADERS += effects/internal/vsthostwin.h + + SOURCES += effects/internal/vsthostwin.cpp + HEADERS += effects/internal/vsthostwin.h } mac { diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index aab9635a2..cb403d44a 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -78,14 +78,14 @@ void EffectControls::menu_select(QAction* q) { if ((c->track < 0) == (effect_menu_subtype == EFFECT_TYPE_VIDEO)) { const EffectMeta* meta = reinterpret_cast(q->data().value()); if (effect_menu_type == EFFECT_TYPE_TRANSITION) { - if (c->get_opening_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_OPENING_TRANSITION, 30)); + if (c->get_opening_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, TA_OPENING_TRANSITION, 30)); } - if (c->get_closing_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_CLOSING_TRANSITION, 30)); + if (c->get_closing_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, TA_CLOSING_TRANSITION, 30)); } } else { - ca->append(new AddEffectCommand(c, NULL, meta)); + ca->append(new AddEffectCommand(c, nullptr, meta)); } } } @@ -112,7 +112,7 @@ void EffectControls::copy(bool del) { bool cleared = false; ComboAction* ca = new ComboAction(); - EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : NULL; + EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : nullptr; for (int i=0;iclips.at(selected_clips.at(i)); for (int j=0;jeffects.size();j++) { @@ -124,16 +124,16 @@ void EffectControls::copy(bool del) { clipboard_type = CLIPBOARD_TYPE_EFFECT; } - clipboard.append(effect->copy(NULL)); + clipboard.append(effect->copy(nullptr)); - if (del_com != NULL) { + if (del_com != nullptr) { del_com->clips.append(c); del_com->fx.append(j); } } } } - if (del_com != NULL) { + if (del_com != nullptr) { if (del_com->clips.size() > 0) { ca->append(del_com); } else { @@ -168,7 +168,7 @@ void EffectControls::show_effect_menu(int type, int subtype) { bool found = false; for (int j=0;jmenu() != NULL) { + if (action->menu() != nullptr) { if (action->menu()->title() == em.category) { parent = action->menu(); found = true; @@ -214,20 +214,20 @@ void EffectControls::show_effect_menu(int type, int subtype) { void EffectControls::clear_effects(bool clear_cache) { // clear existing clips - deselect_all_effects(NULL); + deselect_all_effects(nullptr); // clear graph editor - if (panel_graph_editor != NULL) panel_graph_editor->set_row(NULL); + if (panel_graph_editor != nullptr) panel_graph_editor->set_row(nullptr); QVBoxLayout* video_layout = static_cast(video_effect_area->layout()); QVBoxLayout* audio_layout = static_cast(audio_effect_area->layout()); QLayoutItem* item; while ((item = video_layout->takeAt(0))) { - item->widget()->setParent(NULL); + item->widget()->setParent(nullptr); disconnect(static_cast(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*))); } while ((item = audio_layout->takeAt(0))) { - item->widget()->setParent(NULL); + item->widget()->setParent(nullptr); disconnect(static_cast(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*))); } lblMultipleClipsSelected->setVisible(false); @@ -455,9 +455,9 @@ void EffectControls::load_effects() { for (int j=0;jeffects.size();j++) { open_effect(layout, c->effects.at(j)); } - } else if (mode == TA_OPENING_TRANSITION && c->get_opening_transition() != NULL) { + } else if (mode == TA_OPENING_TRANSITION && c->get_opening_transition() != nullptr) { open_effect(layout, c->get_opening_transition()); - } else if (mode == TA_CLOSING_TRANSITION && c->get_closing_transition() != NULL) { + } else if (mode == TA_CLOSING_TRANSITION && c->get_closing_transition() != nullptr) { open_effect(layout, c->get_closing_transition()); } } @@ -533,14 +533,14 @@ bool EffectControls::is_focused() { if (this->hasFocus()) return true; for (int i=0;iclips.at(selected_clips.at(i)); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jeffects.size();j++) { if (c->effects.at(j)->container->is_focused()) { return true; } } } else { - qWarning() << "Tried to check focus of a NULL clip"; + qWarning() << "Tried to check focus of a nullptr clip"; } } return false; diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index 2cb44f673..311b03b72 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -17,7 +17,7 @@ #include "panels.h" #include "debug.h" -GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(NULL) { +GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(nullptr) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setWindowTitle("Graph Editor"); @@ -120,7 +120,7 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(NULL) { void GraphEditor::update_panel() { if (isVisible()) { - if (row != NULL) { + if (row != nullptr) { int slider_index = 0; for (int i=0;ifieldCount();i++) { EffectField* field = row->field(i); @@ -145,7 +145,7 @@ void GraphEditor::set_row(EffectRow *r) { slider_proxy_buttons.clear(); slider_proxy_sources.clear(); - if (row != NULL) { + if (row != nullptr) { // clear old row connections disconnect(keyframe_nav, SIGNAL(goto_previous_key()), row, SLOT(goto_previous_key())); disconnect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(toggle_key())); @@ -154,7 +154,7 @@ void GraphEditor::set_row(EffectRow *r) { bool found_vals = false; - if (r != NULL && r->isKeyframing()) { + if (r != nullptr && r->isKeyframing()) { for (int i=0;ifieldCount();i++) { EffectField* field = r->field(i); if (field->type == EFFECT_FIELD_DOUBLE) { @@ -191,7 +191,7 @@ void GraphEditor::set_row(EffectRow *r) { connect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(toggle_key())); connect(keyframe_nav, SIGNAL(goto_next_key()), row, SLOT(goto_next_key())); } else { - row = NULL; + row = nullptr; current_row_desc->setText(0); } view->set_row(row); diff --git a/panels/panels.cpp b/panels/panels.cpp index c5653a171..9a8d8b310 100644 --- a/panels/panels.cpp +++ b/panels/panels.cpp @@ -30,10 +30,10 @@ void update_effect_controls() { int aclip = -1; QVector selected_clips; int mode = TA_NO_TRANSITION; - if (sequence != NULL) { + if (sequence != nullptr) { for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL) { + if (clip != nullptr) { for (int j=0;jselections.size();j++) { const Selection& s = sequence->selections.at(j); bool add = true; @@ -113,7 +113,7 @@ void update_ui(bool modified) { } QDockWidget *get_focused_panel() { - QDockWidget* w = NULL; + QDockWidget* w = nullptr; if (config.hover_focus) { if (panel_project->underMouse()) { w = panel_project; @@ -127,7 +127,7 @@ QDockWidget *get_focused_panel() { w = panel_timeline; } } - if (w == NULL) { + if (w == nullptr) { if (panel_project->is_focused()) { w = panel_project; } else if (panel_effect_controls->keyframe_focus() || panel_effect_controls->is_focused()) { @@ -162,15 +162,15 @@ void alloc_panels(QWidget* parent) { void free_panels() { delete panel_sequence_viewer; - panel_sequence_viewer = NULL; + panel_sequence_viewer = nullptr; delete panel_footage_viewer; - panel_footage_viewer = NULL; + panel_footage_viewer = nullptr; delete panel_project; - panel_project = NULL; + panel_project = nullptr; delete panel_effect_controls; - panel_effect_controls = NULL; + panel_effect_controls = nullptr; delete panel_timeline; - panel_timeline = NULL; + panel_timeline = nullptr; } void scroll_to_frame_internal(QScrollBar* bar, long frame, double zoom, int area_width) { diff --git a/panels/project.cpp b/panels/project.cpp index 66d40039c..a063b3fb1 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -236,7 +236,7 @@ Sequence* create_sequence_from_media(QVector& media_list) { const FootageStream& ms = m->video_tracks.at(j); s->width = ms.video_width; s->height = ms.video_height; - if (ms.video_frame_rate != 0) { + if (qFuzzyCompare(ms.video_frame_rate, 0.0)) { s->frame_rate = ms.video_frame_rate * m->speed; if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2; @@ -247,13 +247,10 @@ Sequence* create_sequence_from_media(QVector& media_list) { } } } - if (!got_audio_values) { - for (int j=0;jaudio_tracks.size();j++) { - const FootageStream& ms = m->audio_tracks.at(j); - s->audio_frequency = ms.audio_frequency; - got_audio_values = true; - break; - } + if (!got_audio_values && m->audio_tracks.size() > 0) { + const FootageStream& ms = m->audio_tracks.at(0); + s->audio_frequency = ms.audio_frequency; + got_audio_values = true; } } } @@ -301,7 +298,7 @@ void Project::replace_selected_file() { if (selected_items.size() == 1) { Media* item = item_to_media(selected_items.at(0)); if (item->get_type() == MEDIA_TYPE_FOOTAGE) { - replace_media(item, 0); + replace_media(item, nullptr); } } } @@ -317,7 +314,7 @@ void Project::replace_media(Media* item, QString filename) { } void Project::replace_clip_media() { - if (sequence == NULL) { + if (sequence == nullptr) { QMessageBox::critical(this, "No active sequence", "No sequence is active, please open the sequence you want to replace clips from.", QMessageBox::Ok); } else { QModelIndexList selected_items = get_current_selected(); @@ -364,11 +361,11 @@ void Project::open_properties() { } Media* Project::new_sequence(ComboAction *ca, Sequence *s, bool open, Media* parent) { - if (parent == NULL) parent = project_model.get_root(); + if (parent == nullptr) parent = project_model.get_root(); Media* item = new Media(parent); item->set_sequence(s); - if (ca != NULL) { + if (ca != nullptr) { ca->append(new NewSequenceCommand(item, parent)); if (open) ca->append(new ChangeSequenceAction(s)); } else { @@ -397,7 +394,7 @@ bool Project::is_focused() { } Media* Project::new_folder(QString name) { - Media* item = new Media(0); + Media* item = new Media(nullptr); item->set_folder(); item->set_name(name); return item; @@ -466,14 +463,14 @@ void Project::delete_selected_media() { Sequence* s = sequence_items.at(j)->to_sequence(); for (int k=0;kclips.size();k++) { Clip* c = s->clips.at(k); - if (c != NULL && c->media == item) { + if (c != nullptr && c->media == item) { if (!confirm_delete) { // we found a reference, so we know we'll need to ask if the user wants to delete it QMessageBox confirm(this); confirm.setWindowTitle("Delete media in use?"); confirm.setText("The media '" + media->name + "' is currently used in '" + s->name + "'. Deleting it will remove all instances in the sequence. Are you sure you want to do this?"); QAbstractButton* yes_button = confirm.addButton(QMessageBox::Yes); - QAbstractButton* skip_button = NULL; + QAbstractButton* skip_button = nullptr; if (items.size() > 1) skip_button = confirm.addButton("Skip", QMessageBox::NoRole); QAbstractButton* abort_button = confirm.addButton(QMessageBox::Cancel); confirm.exec(); @@ -484,7 +481,7 @@ void Project::delete_selected_media() { } else if (confirm.clickedButton() == skip_button) { // remove media item and any folders containing it from the remove list Media* parent = item; - while (parent != NULL) { + while (parent != nullptr) { parents.append(parent); // re-add item's siblings @@ -531,7 +528,7 @@ void Project::delete_selected_media() { // remove if (remove) { panel_effect_controls->clear_effects(true); - if (sequence != NULL) sequence->selections.clear(); + if (sequence != nullptr) sequence->selections.clear(); // remove media and parents for (int m=0;mto_sequence(); if (s == sequence) { - ca->append(new ChangeSequenceAction(NULL)); + ca->append(new ChangeSequenceAction(nullptr)); } if (s == panel_footage_viewer->seq) { - panel_footage_viewer->set_media(NULL); + panel_footage_viewer->set_media(nullptr); } } else if (items.at(i)->get_type() == MEDIA_TYPE_FOOTAGE) { - if (panel_footage_viewer->seq != NULL) { + if (panel_footage_viewer->seq != nullptr) { for (int j=0;jseq->clips.size();j++) { Clip* c = panel_footage_viewer->seq->clips.at(j); - if (c != NULL && c->media == items.at(i)) { - panel_footage_viewer->set_media(NULL); + if (c != nullptr && c->media == items.at(i)) { + panel_footage_viewer->set_media(nullptr); break; } } @@ -603,8 +600,8 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla if (!recursive) last_imported_media.clear(); - bool create_undo_action = (!recursive && replace == NULL); - ComboAction* ca; + bool create_undo_action = (!recursive && replace == nullptr); + ComboAction* ca = nullptr; if (create_undo_action) ca = new ComboAction(); for (int i=0;iappend(new AddMediaCommand(folder, parent)); @@ -711,7 +708,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla Media* item; Footage* m; - if (replace != NULL) { + if (replace != nullptr) { item = replace; m = replace->to_footage(); m->reset(); @@ -728,7 +725,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla last_imported_media.append(item); - if (replace == NULL) { + if (replace == nullptr) { if (create_undo_action) { ca->append(new AddMediaCommand(item, parent)); } else { @@ -747,7 +744,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla for (int i=0;iget_type() == MEDIA_TYPE_FOLDER) return m; } - return NULL; + return nullptr; } bool Project::reveal_media(Media *media, QModelIndex parent) { @@ -805,12 +802,12 @@ void Project::import_dialog() { if (fd.exec()) { QStringList files = fd.selectedFiles(); - process_file_list(files, false, NULL, get_selected_folder()); + process_file_list(files, false, nullptr, get_selected_folder()); } } void Project::delete_clips_using_selected_media() { - if (sequence == NULL) { + if (sequence == nullptr) { QMessageBox::critical(this, "No active sequence", "No sequence is active, please open the sequence you want to delete clips from.", QMessageBox::Ok); } else { ComboAction* ca = new ComboAction(); @@ -818,7 +815,7 @@ void Project::delete_clips_using_selected_media() { QModelIndexList items = get_current_selected(); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jmedia == m) { @@ -849,7 +846,7 @@ void Project::clear() { QVector sequences = list_all_project_sequences(); for (int i=0;ito_sequence(); - sequences.at(i)->set_sequence(NULL); + sequences.at(i)->set_sequence(nullptr); } // delete everything else @@ -858,8 +855,8 @@ void Project::clear() { void Project::new_project() { // clear existing project - set_sequence(NULL); - panel_footage_viewer->set_media(NULL); + set_sequence(nullptr); + panel_footage_viewer->set_media(nullptr); clear(); mainWindow->setWindowModified(false); } @@ -895,7 +892,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, } // save_folder(stream, item, type, set_ids_only); } else { - int folder = (m->parentItem() != NULL) ? m->parentItem()->temp_id : 0; + int folder = (m->parentItem() != nullptr) ? m->parentItem()->temp_id : 0; if (type == MEDIA_TYPE_FOOTAGE) { Footage* f = m->to_footage(); f->save_id = media_id; @@ -955,7 +952,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, for (int j=0;jtransitions.size();j++) { Transition* t = s->transitions.at(j); - if (t != NULL) { + if (t != nullptr) { stream.writeStartElement("transition"); stream.writeAttribute("id", QString::number(j)); stream.writeAttribute("length", QString::number(t->get_true_length())); @@ -966,7 +963,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL) { + if (c != nullptr) { stream.writeStartElement("clip"); // clip stream.writeAttribute("id", QString::number(j)); stream.writeAttribute("enabled", QString::number(c->enabled)); @@ -987,7 +984,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, stream.writeAttribute("maintainpitch", QString::number(c->maintain_audio_pitch)); stream.writeAttribute("reverse", QString::number(c->reverse)); - if (c->media != NULL) { + if (c->media != nullptr) { stream.writeAttribute("type", QString::number(c->media->get_type())); switch (c->media->get_type()) { case MEDIA_TYPE_FOOTAGE: @@ -1184,7 +1181,7 @@ void Project::list_all_sequences_worker(QVector* list, Media* parent) { QVector Project::list_all_project_sequences() { QVector list; - list_all_sequences_worker(&list, NULL); + list_all_sequences_worker(&list, nullptr); return list; } @@ -1198,7 +1195,7 @@ QModelIndexList Project::get_current_selected() { #define THROBBER_LIMIT 20 #define THROBBER_SIZE 50 -MediaThrobber::MediaThrobber(Media *i) : pixmap(":/icons/throbber.png"), animation(0), item(i), animator(NULL) {} +MediaThrobber::MediaThrobber(Media *i) : pixmap(":/icons/throbber.png"), animation(0), item(i), animator(nullptr) {} void MediaThrobber::start() { // set up throbber @@ -1218,7 +1215,7 @@ void MediaThrobber::animation_update() { } void MediaThrobber::stop(int icon_type, bool replace) { - if (animator != NULL) { + if (animator != nullptr) { animator->stop(); delete animator; } @@ -1236,7 +1233,7 @@ void MediaThrobber::stop(int icon_type, bool replace) { Sequence* s = sequences.at(i)->to_sequence(); for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL) { + if (c != nullptr) { c->refresh(); } } @@ -1246,6 +1243,6 @@ void MediaThrobber::stop(int icon_type, bool replace) { update_ui(replace); panel_project->tree_view->viewport()->update(); - item->throbber = NULL; + item->throbber = nullptr; deleteLater(); } diff --git a/panels/project.h b/panels/project.h index 00e2b0bb7..25eace33a 100644 --- a/panels/project.h +++ b/panels/project.h @@ -48,7 +48,7 @@ public: void clear(); Media* new_sequence(ComboAction *ca, Sequence* s, bool open, Media* parent); QString get_next_sequence_name(QString start = 0); - void process_file_list(QStringList& files, bool recursive = false, Media* replace = NULL, Media *parent = NULL); + void process_file_list(QStringList& files, bool recursive = false, Media* replace = nullptr, Media *parent = nullptr); void replace_media(Media* item, QString filename); Media *get_selected_folder(); bool reveal_media(Media *media, QModelIndex parent = QModelIndex()); diff --git a/panels/timeline.cpp b/panels/timeline.cpp index c03d61f12..4bf1a2953 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -112,7 +112,7 @@ void Timeline::previous_cut() { long p_cut = 0; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_out > p_cut && c->timeline_out < sequence->playhead) { p_cut = c->timeline_out; } else if (c->timeline_in > p_cut && c->timeline_in < sequence->playhead) { @@ -129,7 +129,7 @@ void Timeline::next_cut() { long n_cut = LONG_MAX; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_in < n_cut && c->timeline_in > sequence->playhead) { n_cut = c->timeline_in; seek_enabled = true; @@ -164,10 +164,10 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector bool can_import = true; Media* medium = media_list.at(i); - Footage* m = NULL; - Sequence* s = NULL; - void* media = NULL; - long sequence_length; + Footage* m = nullptr; + Sequence* s = nullptr; + void* media = nullptr; + long sequence_length = 0; long default_clip_in = 0; long default_clip_out = 0; @@ -186,7 +186,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector case MEDIA_TYPE_SEQUENCE: s = medium->to_sequence(); sequence_length = s->getEndFrame(); - if (seq != NULL) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, seq->frame_rate); + if (seq != nullptr) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, seq->frame_rate); media = s; can_import = (s != seq && sequence_length != 0); if (s->using_workarea) { @@ -205,7 +205,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector g.old_clip_in = g.clip_in = default_clip_in; g.media = medium; g.in = entry_point; - g.transition = NULL; + g.transition = nullptr; switch (medium->get_type()) { case MEDIA_TYPE_FOOTAGE: @@ -240,7 +240,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector case MEDIA_TYPE_SEQUENCE: g.out = entry_point + sequence_length - default_clip_in; - if (s->using_workarea && s->enable_workarea) { + if (s->using_workarea && s->enable_workarea) { g.out -= (sequence_length - default_clip_out); } @@ -354,13 +354,13 @@ void Timeline::add_transition() { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && is_clip_selected(c, true)) { - if (c->get_opening_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); + if (c != nullptr && is_clip_selected(c, true)) { + if (c->get_opening_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); adding = true; } - if (c->get_closing_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); + if (c->get_closing_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); adding = true; } } @@ -388,7 +388,7 @@ int Timeline::calculate_track_height(int track, int value) { } void Timeline::update_sequence() { - bool null_sequence = (sequence == NULL); + bool null_sequence = (sequence == nullptr); for (int i=0;isetEnabled(!null_sequence); @@ -413,14 +413,14 @@ int Timeline::get_snap_range() { } bool Timeline::focused() { - return (sequence != NULL && (headers->hasFocus() || video_area->hasFocus() || audio_area->hasFocus())); + return (sequence != nullptr && (headers->hasFocus() || video_area->hasFocus() || audio_area->hasFocus())); } void Timeline::repaint_timeline() { if (!block_repaints) { bool draw = true; - if (sequence != NULL + if (sequence != nullptr && !horizontalScrollBar->isSliderDown() && !horizontalScrollBar->is_resizing() && panel_sequence_viewer->playing @@ -446,7 +446,7 @@ void Timeline::repaint_timeline() { video_area->update(); audio_area->update(); - if (sequence != NULL) { + if (sequence != nullptr) { set_sb_max(); if (last_frame != sequence->playhead) { @@ -459,11 +459,11 @@ void Timeline::repaint_timeline() { } void Timeline::select_all() { - if (sequence != NULL) { + if (sequence != nullptr) { sequence->selections.clear(); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { Selection s; s.in = c->timeline_in; s.out = c->timeline_out; @@ -476,31 +476,31 @@ void Timeline::select_all() { } void Timeline::scroll_to_frame(long frame) { - scroll_to_frame_internal(horizontalScrollBar, frame, zoom, timeline_area->width()); + scroll_to_frame_internal(horizontalScrollBar, frame, zoom, timeline_area->width()); } void Timeline::select_from_playhead() { - sequence->selections.clear(); - for (int i=0;iclips.size();i++) { - Clip* c = sequence->clips.at(i); - if (c != NULL - && c->timeline_in <= sequence->playhead - && c->timeline_out > sequence->playhead) { - Selection s; - s.in = c->timeline_in; - s.out = c->timeline_out; - s.track = c->track; - sequence->selections.append(s); - } - } + sequence->selections.clear(); + for (int i=0;iclips.size();i++) { + Clip* c = sequence->clips.at(i); + if (c != nullptr + && c->timeline_in <= sequence->playhead + && c->timeline_out > sequence->playhead) { + Selection s; + s.in = c->timeline_in; + s.out = c->timeline_out; + s.track = c->track; + sequence->selections.append(s); + } + } } -void Timeline::resizeEvent(QResizeEvent *event) { - if (sequence != NULL) set_sb_max(); +void Timeline::resizeEvent(QResizeEvent *) { + if (sequence != nullptr) set_sb_max(); } void Timeline::delete_in_out(bool ripple) { - if (sequence != NULL && sequence->using_workarea) { + if (sequence != nullptr && sequence->using_workarea) { QVector areas; int video_tracks = 0, audio_tracks = 0; sequence->getTrackLimits(&video_tracks, &audio_tracks); @@ -545,7 +545,7 @@ void Timeline::delete_selection(QVector& selections, bool ripple_dele bool can_ripple = true; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && c->timeline_in < ripple_point && c->timeline_out > ripple_point) { + if (c != nullptr && c->timeline_in < ripple_point && c->timeline_out > ripple_point) { // conflict detected, but this clip may be getting deleted so let's check bool deleted = false; for (int j=0;j& selections, bool ripple_dele if (!deleted) { for (int j=0;jclips.size();j++) { Clip* cc = sequence->clips.at(j); - if (cc != NULL + if (cc != nullptr && cc->track == c->track && cc->timeline_in > c->timeline_out && cc->timeline_in < c->timeline_out + ripple_length) { @@ -646,7 +646,7 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame) { Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) { Clip* pre = sequence->clips.at(p); - if (pre != NULL && pre->timeline_in < frame && pre->timeline_out > frame) { // guard against attempts to split at in/out points + if (pre != nullptr && pre->timeline_in < frame && pre->timeline_out > frame) { // guard against attempts to split at in/out points Clip* post = pre->copy(sequence); long new_clip_length = frame - pre->timeline_in; @@ -656,11 +656,11 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) { move_clip(ca, pre, pre->timeline_in, frame, pre->clip_in, pre->track); - if (pre->get_opening_transition() != NULL) { - /*if (frame < pre->timeline_in + pre->get_opening_transition()->length && pre->get_opening_transition()->secondary_clip != NULL) { + if (pre->get_opening_transition() != nullptr) { + /*if (frame < pre->timeline_in + pre->get_opening_transition()->length && pre->get_opening_transition()->secondary_clip != nullptr) { // separate shared transition - ca->append(new SetPointer((void**) &pre->get_opening_transition()->secondary_clip, NULL)); - pre->get_opening_transition()->secondary_clip->closing_transition = pre->get_opening_transition()->copy(pre->get_opening_transition()->secondary_clip, NULL); + ca->append(new SetPointer((void**) &pre->get_opening_transition()->secondary_clip, nullptr)); + pre->get_opening_transition()->secondary_clip->closing_transition = pre->get_opening_transition()->copy(pre->get_opening_transition()->secondary_clip, nullptr); }*/ if (pre->get_opening_transition()->get_true_length() > new_clip_length) { @@ -669,14 +669,14 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) { post->sequence->hard_delete_transition(post, TA_OPENING_TRANSITION); } - if (pre->get_closing_transition() != NULL) { + if (pre->get_closing_transition() != nullptr) { ca->append(new DeleteTransitionCommand(pre->sequence, pre->closing_transition)); - if (pre->get_closing_transition()->secondary_clip == NULL) post->get_closing_transition()->set_length(qMin((long) post->get_closing_transition()->get_true_length(), post->getLength())); + if (pre->get_closing_transition()->secondary_clip == nullptr) post->get_closing_transition()->set_length(qMin((long) post->get_closing_transition()->get_true_length(), post->getLength())); } return post; } - return NULL; + return nullptr; } bool Timeline::has_clip_been_split(int c) { @@ -697,14 +697,14 @@ bool Timeline::split_clip_and_relink(ComboAction *ca, int clip, long frame, bool split_cache.append(clip); Clip* c = sequence->clips.at(clip); - if (c != NULL) { + if (c != nullptr) { QVector pre_clips; QVector post_clips; Clip* post = split_clip(ca, clip, frame); // if alt is not down, split clips links too - if (post == NULL) { + if (post == nullptr) { return false; } else { post_clips.append(post); @@ -721,7 +721,7 @@ bool Timeline::split_clip_and_relink(ComboAction *ca, int clip, long frame, bool if ((original_clip_is_selected && is_clip_selected(link, true)) || !original_clip_is_selected) { split_cache.append(l); Clip* s = split_clip(ca, l, frame); - if (s != NULL) { + if (s != nullptr) { pre_clips.append(l); post_clips.append(s); } @@ -770,15 +770,15 @@ void Timeline::clean_up_selections(QVector& areas) { bool selection_contains_transition(const Selection& s, Clip* c, int type) { if (type == TA_OPENING_TRANSITION) { - return c->get_opening_transition() != NULL + return c->get_opening_transition() != nullptr && s.out == c->timeline_in + c->get_opening_transition()->get_true_length() - && ((c->get_opening_transition()->secondary_clip == NULL && s.in == c->timeline_in) - || (c->get_opening_transition()->secondary_clip != NULL && s.in == c->timeline_in - c->get_opening_transition()->get_true_length())); + && ((c->get_opening_transition()->secondary_clip == nullptr && s.in == c->timeline_in) + || (c->get_opening_transition()->secondary_clip != nullptr && s.in == c->timeline_in - c->get_opening_transition()->get_true_length())); } else { - return c->get_closing_transition() != NULL + return c->get_closing_transition() != nullptr && s.in == c->timeline_out - c->get_closing_transition()->get_true_length() - && ((c->get_closing_transition()->secondary_clip == NULL && s.out == c->timeline_out) - || (c->get_closing_transition()->secondary_clip != NULL && s.out == c->timeline_out + c->get_closing_transition()->get_true_length())); + && ((c->get_closing_transition()->secondary_clip == nullptr && s.out == c->timeline_out) + || (c->get_closing_transition()->secondary_clip != nullptr && s.out == c->timeline_out + c->get_closing_transition()->get_true_length())); } } @@ -792,7 +792,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector& area const Selection& s = areas.at(i); for (int j=0;jclips.size();j++) { Clip* c = sequence->clips.at(j); - if (c != NULL && c->track == s.track && !c->undeletable) { + if (c != nullptr && c->track == s.track && !c->undeletable) { if (selection_contains_transition(s, c, TA_OPENING_TRANSITION)) { // delete opening transition ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); @@ -814,7 +814,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector& area // only out point is in deletion area move_clip(ca, c, c->timeline_in, s.in, c->clip_in, c->track); - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { if (s.in < c->timeline_out - c->get_closing_transition()->get_true_length()) { ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition)); } else { @@ -825,7 +825,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector& area // only in point is in deletion area move_clip(ca, c, s.out, c->timeline_out, c->clip_in + (s.out - c->timeline_in), c->track); - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { if (s.out > c->timeline_in + c->get_opening_transition()->get_true_length()) { ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); } else { @@ -848,7 +848,7 @@ void Timeline::copy(bool del) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jselections.size();j++) { const Selection& s = sequence->selections.at(j); if (s.track == c->track && !((c->timeline_in <= s.in && c->timeline_out <= s.in) || (c->timeline_in >= s.out && c->timeline_out >= s.out))) { @@ -858,7 +858,7 @@ void Timeline::copy(bool del) { clipboard_type = CLIPBOARD_TYPE_CLIP; } - Clip* copied_clip = c->copy(NULL); + Clip* copied_clip = c->copy(nullptr); // copy linked IDs (we correct these later in paste()) copied_clip->linked = c->linked; @@ -993,7 +993,7 @@ void Timeline::paste(bool insert) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && is_clip_selected(c, true)) { + if (c != nullptr && is_clip_selected(c, true)) { for (int j=0;j(clipboard.at(j)); if ((c->track < 0) == (e->meta->subtype == EFFECT_TYPE_VIDEO)) { @@ -1039,10 +1039,10 @@ void Timeline::paste(bool insert) { delcom->fx.append(found); ca->append(delcom); - ca->append(new AddEffectCommand(c, e->copy(c), NULL, found)); + ca->append(new AddEffectCommand(c, e->copy(c), nullptr, found)); push = true; } else { - ca->append(new AddEffectCommand(c, e->copy(c), NULL)); + ca->append(new AddEffectCommand(c, e->copy(c), nullptr)); push = true; } } @@ -1061,7 +1061,7 @@ void Timeline::paste(bool insert) { } void Timeline::ripple_to_in_point(bool in, bool ripple) { - if (sequence != NULL) { + if (sequence != nullptr) { if (sequence->clips.size() > 0) { // get track count int track_min = INT_MAX; @@ -1076,7 +1076,7 @@ void Timeline::ripple_to_in_point(bool in, bool ripple) { // find closest in point to playhead for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { track_min = qMin(track_min, c->track); track_max = qMax(track_max, c->track); @@ -1180,7 +1180,7 @@ bool Timeline::split_selection(ComboAction* ca) { // find clips within selection and split for (int j=0;jclips.size();j++) { Clip* clip = sequence->clips.at(j); - if (clip != NULL) { + if (clip != nullptr) { for (int i=0;iselections.size();i++) { const Selection& s = sequence->selections.at(i); if (s.track == clip->track) { @@ -1197,12 +1197,12 @@ bool Timeline::split_selection(ComboAction* ca) { split_B->timeline_in = s.out; secondary_post_splits.append(split_B); - if (clip->get_opening_transition() != NULL) { + if (clip->get_opening_transition() != nullptr) { split_B->sequence->hard_delete_transition(split_B, TA_OPENING_TRANSITION); split_A->sequence->hard_delete_transition(split_A, TA_OPENING_TRANSITION); } - if (clip->get_closing_transition() != NULL) { + if (clip->get_closing_transition() != nullptr) { ca->append(new DeleteTransitionCommand(clip->sequence, clip->closing_transition)); split_A->sequence->hard_delete_transition(split_A, TA_CLOSING_TRANSITION); @@ -1213,13 +1213,13 @@ bool Timeline::split_selection(ComboAction* ca) { } else { Clip* post_a = split_clip(ca, j, s.in); Clip* post_b = split_clip(ca, j, s.out); - if (post_a != NULL) { + if (post_a != nullptr) { pre_splits.append(j); post_splits.append(post_a); split = true; } - if (post_b != NULL) { - if (post_a != NULL) { + if (post_b != nullptr) { + if (post_a != nullptr) { pre_splits.append(j); post_splits.append(post_b); } else { @@ -1249,7 +1249,7 @@ bool Timeline::split_all_clips_at_point(ComboAction* ca, long point) { bool split = false; for (int j=0;jclips.size();j++) { Clip* c = sequence->clips.at(j); - if (c != NULL) { + if (c != nullptr) { // always relinks if (split_clip_and_relink(ca, j, point, true)) { split = true; @@ -1270,9 +1270,9 @@ void Timeline::split_at_playhead() { QVector post_clips; for (int j=0;jclips.size();j++) { Clip* clip = sequence->clips.at(j); - if (clip != NULL && is_clip_selected(clip, true)) { + if (clip != nullptr && is_clip_selected(clip, true)) { Clip* s = split_clip(ca, j, sequence->playhead); - if (s != NULL) { + if (s != nullptr) { pre_clips.append(j); post_clips.append(s); split_selected = true; @@ -1368,15 +1368,15 @@ bool Timeline::snap_to_timeline(long* l, bool use_playhead, bool use_markers, bo // snap to clip/transition for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (snap_to_point(c->timeline_in, l)) { return true; } else if (snap_to_point(c->timeline_out, l)) { return true; - } else if (c->get_opening_transition() != NULL + } else if (c->get_opening_transition() != nullptr && snap_to_point(c->timeline_in + c->get_opening_transition()->get_true_length(), l)) { return true; - } else if (c->get_closing_transition() != NULL + } else if (c->get_closing_transition() != nullptr && snap_to_point(c->timeline_out - c->get_closing_transition()->get_true_length(), l)) { return true; } @@ -1410,7 +1410,7 @@ void Timeline::toggle_links() { command->s = sequence; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && is_clip_selected(c, true)) { + if (c != nullptr && is_clip_selected(c, true)) { if (!command->clips.contains(i)) command->clips.append(i); if (c->linked.size() > 0) { @@ -1822,16 +1822,16 @@ void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int ca->append(new MoveClipAction(c, iin, iout, iclip_in, itrack, relative)); if (verify_transitions) { - if (c->get_opening_transition() != NULL && c->get_opening_transition()->secondary_clip != NULL && c->get_opening_transition()->secondary_clip->timeline_out != iin) { + if (c->get_opening_transition() != nullptr && c->get_opening_transition()->secondary_clip != nullptr && c->get_opening_transition()->secondary_clip->timeline_out != iin) { // separate transition - ca->append(new SetPointer((void**) &c->get_opening_transition()->secondary_clip, NULL)); - ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, NULL, c->get_opening_transition(), NULL, TA_CLOSING_TRANSITION, 0)); + ca->append(new SetPointer((void**) &c->get_opening_transition()->secondary_clip, nullptr)); + ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, nullptr, c->get_opening_transition(), nullptr, TA_CLOSING_TRANSITION, 0)); } - if (c->get_closing_transition() != NULL && c->get_closing_transition()->secondary_clip != NULL && c->get_closing_transition()->parent_clip->timeline_in != iout) { + if (c->get_closing_transition() != nullptr && c->get_closing_transition()->secondary_clip != nullptr && c->get_closing_transition()->parent_clip->timeline_in != iout) { // separate transition - ca->append(new SetPointer((void**) &c->get_closing_transition()->secondary_clip, NULL)); - ca->append(new AddTransitionCommand(c, NULL, c->get_closing_transition(), NULL, TA_CLOSING_TRANSITION, 0)); + ca->append(new SetPointer((void**) &c->get_closing_transition()->secondary_clip, nullptr)); + ca->append(new AddTransitionCommand(c, nullptr, c->get_closing_transition(), nullptr, TA_CLOSING_TRANSITION, 0)); } } } diff --git a/panels/viewer.cpp b/panels/viewer.cpp index be165cfd7..b6ed06df5 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -40,8 +40,8 @@ Viewer::Viewer(QWidget *parent) : QDockWidget(parent), playing(false), just_played(false), - media(NULL), - seq(NULL), + media(nullptr), + seq(nullptr), created_sequence(false), cue_recording_internal(false), panel_name("Viewer: "), @@ -57,7 +57,7 @@ Viewer::Viewer(QWidget *parent) : viewer_container->viewer = this; viewer_widget = viewer_container->child; viewer_widget->viewer = this; - set_media(NULL); + set_media(nullptr); currentTimecode->setEnabled(false); currentTimecode->set_minimum_value(0); @@ -101,13 +101,13 @@ void Viewer::set_main_sequence() { void Viewer::reset_all_audio() { // reset all clip audio - if (seq != NULL) { + if (seq != nullptr) { audio_ibuffer_frame = seq->playhead; audio_ibuffer_timecode = (double) audio_ibuffer_frame / seq->frame_rate; for (int i=0;iclips.size();i++) { Clip* c = seq->clips.at(i); - if (c != NULL) c->reset_audio(); + if (c != nullptr) c->reset_audio(); } } clear_audio_ibuffer(); @@ -257,19 +257,19 @@ void Viewer::seek(long p) { } void Viewer::go_to_start() { - if (seq != NULL) seek(0); + if (seq != nullptr) seek(0); } void Viewer::go_to_end() { - if (seq != NULL) seek(seq->getEndFrame()); + if (seq != nullptr) seek(seq->getEndFrame()); } void Viewer::close_media() { - set_media(NULL); + set_media(nullptr); } void Viewer::go_to_in() { - if (seq != NULL) { + if (seq != nullptr) { if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_in); } else { @@ -279,15 +279,15 @@ void Viewer::go_to_in() { } void Viewer::previous_frame() { - if (seq != NULL && seq->playhead > 0) seek(seq->playhead-1); + if (seq != nullptr && seq->playhead > 0) seek(seq->playhead-1); } void Viewer::next_frame() { - if (seq != NULL) seek(seq->playhead+1); + if (seq != nullptr) seek(seq->playhead+1); } void Viewer::go_to_out() { - if (seq != NULL) { + if (seq != nullptr) { if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_out); } else { @@ -327,7 +327,7 @@ void Viewer::play() { if (panel_sequence_viewer->playing) panel_sequence_viewer->pause(); if (panel_footage_viewer->playing) panel_footage_viewer->pause(); - if (seq != NULL) { + if (seq != nullptr) { if (!is_recording_cued() && seq->playhead >= get_seq_out() && (config.loop || !main_sequence)) { @@ -352,7 +352,7 @@ void Viewer::play_wake() { if (just_played) { start_msecs = QDateTime::currentMSecsSinceEpoch(); playback_updater.start(); - if (audio_thread != NULL) audio_thread->notifyReceiver(); + if (audio_thread != nullptr) audio_thread->notifyReceiver(); just_played = false; } } @@ -406,11 +406,11 @@ void Viewer::update_playhead_timecode(long p) { } void Viewer::update_end_timecode() { - endTimecode->setText((seq == NULL) ? frame_to_timecode(0, config.timecode_view, 30) : frame_to_timecode(seq->getEndFrame(), config.timecode_view, seq->frame_rate)); + endTimecode->setText((seq == nullptr) ? frame_to_timecode(0, config.timecode_view, 30) : frame_to_timecode(seq->getEndFrame(), config.timecode_view, seq->frame_rate)); } void Viewer::update_header_zoom() { - if (seq != NULL) { + if (seq != nullptr) { long sequenceEndFrame = seq->getEndFrame(); if (cached_end_frame != sequenceEndFrame) { minimum_zoom = (sequenceEndFrame > 0) ? ((double) headers->width() / (double) sequenceEndFrame) : 1; @@ -431,8 +431,8 @@ void Viewer::update_parents(bool reload_fx) { } } -void Viewer::resizeEvent(QResizeEvent *event) { - if (seq != NULL) { +void Viewer::resizeEvent(QResizeEvent *) { + if (seq != nullptr) { set_sb_max(); } } @@ -440,7 +440,7 @@ void Viewer::resizeEvent(QResizeEvent *event) { void Viewer::update_viewer() { update_header_zoom(); viewer_widget->update(); - if (seq != NULL) update_playhead_timecode(seq->playhead); + if (seq != nullptr) update_playhead_timecode(seq->playhead); update_end_timecode(); } @@ -466,7 +466,7 @@ void Viewer::clear_inout_point() { } void Viewer::toggle_enable_inout() { - if (seq != NULL && seq->using_workarea) { + if (seq != nullptr && seq->using_workarea) { undo_stack.push(new SetBool(&seq->enable_workarea, !seq->enable_workarea)); update_parents(); } @@ -481,7 +481,7 @@ void Viewer::set_out_point() { } void Viewer::set_zoom(bool in) { - if (seq != NULL) { + if (seq != nullptr) { set_zoom_value(in ? headers->get_zoom()*2 : qMax(minimum_zoom, headers->get_zoom()*0.5)); } } @@ -492,7 +492,7 @@ void Viewer::set_zoom_value(double d) { viewer_widget->waveform_zoom = d; viewer_widget->update(); } - if (seq != NULL) { + if (seq != nullptr) { set_sb_max(); if (!horizontal_bar->is_resizing()) center_scroll_to_playhead(horizontal_bar, headers->get_zoom(), seq->playhead); @@ -617,7 +617,7 @@ void Viewer::set_media(Media* m) { main_sequence = false; media = m; clean_created_seq(); - if (media != NULL) { + if (media != nullptr) { switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { @@ -741,7 +741,7 @@ void Viewer::clean_created_seq() { }*/ delete seq; - seq = NULL; + seq = nullptr; created_sequence = false; } } @@ -751,14 +751,14 @@ void Viewer::set_sequence(bool main, Sequence *s) { reset_all_audio(); - if (seq != NULL) { + if (seq != nullptr) { closeActiveClips(seq); } main_sequence = main; seq = (main) ? sequence : s; - bool null_sequence = (seq == NULL); + bool null_sequence = (seq == nullptr); headers->setEnabled(!null_sequence); currentTimecode->setEnabled(!null_sequence); diff --git a/playback/audio.cpp b/playback/audio.cpp index 71c71b81b..eaa03137b 100644 --- a/playback/audio.cpp +++ b/playback/audio.cpp @@ -27,7 +27,7 @@ QIODevice* audio_io_device; bool audio_device_set = false; bool audio_scrub = false; QMutex audio_write_lock; -QAudioInput* audio_input = NULL; +QAudioInput* audio_input = nullptr; QFile output_recording; bool recording = false; @@ -36,7 +36,7 @@ int audio_ibuffer_read = 0; long audio_ibuffer_frame = 0; double audio_ibuffer_timecode = 0; -AudioSenderThread* audio_thread = NULL; +AudioSenderThread* audio_thread = nullptr; bool is_audio_device_set() { return audio_device_set; @@ -60,7 +60,7 @@ void init_audio() { dout << " " << devs.at(i).deviceName(); } if (info.isNull() && devs.size() > 0) { - qWarning() << "Default audio returned NULL, attempting to use first device found..."; + qWarning() << "Default audio returned nullptr, attempting to use first device found..."; info = devs.at(0); } qInfo() << "Using audio device" << info.deviceName(); @@ -76,8 +76,8 @@ void init_audio() { // connect audio_io_device = audio_output->start(); - if (audio_io_device == NULL) { - qWarning() << "Received NULL audio device. No compatible audio output was found."; + if (audio_io_device == nullptr) { + qWarning() << "Received nullptr audio device. No compatible audio output was found."; } else { audio_device_set = true; @@ -101,10 +101,10 @@ void stop_audio() { } void clear_audio_ibuffer() { - if (audio_thread != NULL) audio_thread->lock.lock(); + if (audio_thread != nullptr) audio_thread->lock.lock(); memset(audio_ibuffer, 0, audio_ibuffer_size); audio_ibuffer_read = 0; - if (audio_thread != NULL) audio_thread->lock.unlock(); + if (audio_thread != nullptr) audio_thread->lock.unlock(); } int current_audio_freq() { @@ -169,14 +169,14 @@ int AudioSenderThread::send_audio_to_output(int offset, int max) { // send samples to audio monitor cache // TODO make this work for the footage viewer - currently, enabling it causes crash due to an ASSERT - Sequence* s = NULL; + Sequence* s = nullptr; /*if (panel_footage_viewer->playing) { s = panel_footage_viewer->seq; }*/ if (panel_sequence_viewer->playing) { s = panel_sequence_viewer->seq; } - if (s != NULL) { + if (s != nullptr) { if (panel_timeline->audio_monitor->sample_cache_offset == -1) { panel_timeline->audio_monitor->sample_cache_offset = s->playhead; } @@ -287,7 +287,7 @@ void write_wave_trailer(QFile& f) { } bool start_recording() { - if (sequence == NULL) { + if (sequence == nullptr) { qCritical() << "No active sequence to record into"; return false; } @@ -338,7 +338,7 @@ void stop_recording() { output_recording.close(); delete audio_input; - audio_input = NULL; + audio_input = nullptr; recording = false; } } diff --git a/playback/cacher.cpp b/playback/cacher.cpp index cc6cddd56..998f356c1 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -51,8 +51,8 @@ void apply_audio_effects(Clip* c, double timecode_start, AVFrame* frame, int nb_ Effect* e = c->effects.at(j); if (e->is_enabled()) e->process_audio(timecode_start, timecode_end, frame->data[0], nb_bytes, 2); } - if (c->get_opening_transition() != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->get_opening_transition() != nullptr) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { double transition_start = (c->get_clip_in_with_transition() / c->sequence->frame_rate); double transition_end = (c->get_clip_in_with_transition() + c->get_opening_transition()->get_length()) / c->sequence->frame_rate; if (timecode_end < transition_end) { @@ -63,8 +63,8 @@ void apply_audio_effects(Clip* c, double timecode_start, AVFrame* frame, int nb_ } } } - if (c->get_closing_transition() != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->get_closing_transition() != nullptr) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { long length_with_transitions = c->get_timeline_out_with_transition() - c->get_timeline_in_with_transition(); double transition_start = (c->get_clip_in_with_transition() + length_with_transitions - c->get_closing_transition()->get_length()) / c->sequence->frame_rate; double transition_end = (c->get_clip_in_with_transition() + length_with_transitions) / c->sequence->frame_rate; @@ -117,7 +117,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { AVFrame* frame; int nb_bytes = INT_MAX; - if (c->media == NULL) { + if (c->media == nullptr) { frame = c->frame; nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; while ((c->frame_sample_index == -1 || c->frame_sample_index >= nb_bytes) && nb_bytes > 0) { @@ -390,7 +390,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { audio_write_lock.unlock(); if (scrubbing) { - if (audio_thread != NULL) audio_thread->notifyReceiver(); + if (audio_thread != nullptr) audio_thread->notifyReceiver(); } if (c->frame_sample_index == nb_bytes) { @@ -541,7 +541,7 @@ void cache_video_worker(Clip* c, long playhead) { void reset_cache(Clip* c, long target_frame) { // if we seek to a whole other place in the timeline, we'll need to reset the cache with new values - if (c->media == NULL) { + if (c->media == nullptr) { if (c->track >= 0) { // tone clip c->reached_end = false; @@ -625,7 +625,7 @@ Cacher::Cacher(Clip* c) : clip(c) {} AVSampleFormat sample_format = AV_SAMPLE_FMT_S16; void open_clip_worker(Clip* clip) { - if (clip->media == NULL) { + if (clip->media == nullptr) { if (clip->track >= 0) { clip->frame = av_frame_alloc(); clip->frame->format = sample_format; @@ -649,8 +649,8 @@ void open_clip_worker(Clip* clip) { int errCode = avformat_open_input( &clip->formatCtx, filename, - NULL, - NULL + nullptr, + nullptr ); if (errCode != 0) { char err[1024]; @@ -659,7 +659,7 @@ void open_clip_worker(Clip* clip) { return; } - errCode = avformat_find_stream_info(clip->formatCtx, NULL); + errCode = avformat_find_stream_info(clip->formatCtx, nullptr); if (errCode < 0) { char err[1024]; av_strerror(errCode, err, 1024); @@ -692,7 +692,7 @@ void open_clip_worker(Clip* clip) { if (ms->video_interlacing != VIDEO_PROGRESSIVE) clip->max_queue_size *= 2; - clip->opts = NULL; + clip->opts = nullptr; // optimized decoding settings if ((clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG && @@ -714,7 +714,7 @@ void open_clip_worker(Clip* clip) { // allocate filtergraph clip->filter_graph = avfilter_graph_alloc(); - if (clip->filter_graph == NULL) { + if (clip->filter_graph == nullptr) { qCritical() << "Could not create filtergraph"; } char filter_args[512]; @@ -730,8 +730,8 @@ void open_clip_worker(Clip* clip) { clip->stream->codecpar->sample_aspect_ratio.den ); - avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("buffer"), "in", filter_args, NULL, clip->filter_graph); - avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("buffersink"), "out", NULL, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("buffer"), "in", filter_args, nullptr, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("buffersink"), "out", nullptr, nullptr, clip->filter_graph); AVFilterContext* last_filter = clip->buffersrc_ctx; @@ -739,7 +739,7 @@ void open_clip_worker(Clip* clip) { AVFilterContext* yadif_filter; char yadif_args[100]; snprintf(yadif_args, sizeof(yadif_args), "mode=3:parity=%d", ((ms->video_interlacing == VIDEO_TOP_FIELD_FIRST) ? 0 : 1)); // there's a CUDA version if we start using nvdec/nvenc - avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", yadif_args, NULL, clip->filter_graph); + avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", yadif_args, nullptr, clip->filter_graph); avfilter_link(last_filter, 0, yadif_filter, 0); last_filter = yadif_filter; @@ -749,7 +749,7 @@ void open_clip_worker(Clip* clip) { bool stabilize = false; if (stabilize) { AVFilterContext* stab_filter; - int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=/media/matt/Home/samples/transforms.trf", NULL, clip->filter_graph); + int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=/media/matt/Home/samples/transforms.trf", nullptr, clip->filter_graph); if (stab_ret < 0) { char err[100]; av_strerror(stab_ret, err, sizeof(err)); @@ -765,18 +765,18 @@ void open_clip_worker(Clip* clip) { AV_PIX_FMT_NONE }; - clip->pix_fmt = avcodec_find_best_pix_fmt_of_list(valid_pix_fmts, static_cast(clip->stream->codecpar->format), 1, NULL); + clip->pix_fmt = avcodec_find_best_pix_fmt_of_list(valid_pix_fmts, static_cast(clip->stream->codecpar->format), 1, nullptr); const char* chosen_format = av_get_pix_fmt_name(static_cast(clip->pix_fmt)); char format_args[100]; snprintf(format_args, sizeof(format_args), "pix_fmts=%s", chosen_format); AVFilterContext* format_conv; - avfilter_graph_create_filter(&format_conv, avfilter_get_by_name("format"), "fmt", format_args, NULL, clip->filter_graph); + avfilter_graph_create_filter(&format_conv, avfilter_get_by_name("format"), "fmt", format_args, nullptr, clip->filter_graph); avfilter_link(last_filter, 0, format_conv, 0); avfilter_link(format_conv, 0, clip->buffersink_ctx, 0); - avfilter_graph_config(clip->filter_graph, NULL); + avfilter_graph_config(clip->filter_graph, nullptr); } else if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { if (clip->codecCtx->channel_layout == 0) clip->codecCtx->channel_layout = av_get_default_channel_layout(clip->stream->codecpar->channels); @@ -802,8 +802,8 @@ void open_clip_worker(Clip* clip) { clip->codecCtx->channel_layout ); - avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("abuffer"), "in", filter_args, NULL, clip->filter_graph); - avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("abuffersink"), "out", NULL, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("abuffer"), "in", filter_args, nullptr, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("abuffersink"), "out", nullptr, nullptr, clip->filter_graph); enum AVSampleFormat sample_fmts[] = { sample_format, static_cast(-1) }; if (av_opt_set_int_list(clip->buffersink_ctx, "sample_fmts", sample_fmts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { @@ -837,16 +837,16 @@ void open_clip_worker(Clip* clip) { if (whole2 > 0) { snprintf(speed_param, sizeof(speed_param), "%f", base); for (int i=0;ifilter_graph); + AVFilterContext* tempo_filter = nullptr; + avfilter_graph_create_filter(&tempo_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, nullptr, clip->filter_graph); avfilter_link(previous_filter, 0, tempo_filter, 0); previous_filter = tempo_filter; } } snprintf(speed_param, sizeof(speed_param), "%f", qPow(base, speedlog)); - last_filter = NULL; - avfilter_graph_create_filter(&last_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, NULL, clip->filter_graph); + last_filter = nullptr; + avfilter_graph_create_filter(&last_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, nullptr, clip->filter_graph); avfilter_link(previous_filter, 0, last_filter, 0); // } @@ -861,7 +861,7 @@ void open_clip_worker(Clip* clip) { qCritical() << "Could not set output sample rates"; } - avfilter_graph_config(clip->filter_graph, NULL); + avfilter_graph_config(clip->filter_graph, nullptr); clip->audio_reset = true; } @@ -885,7 +885,7 @@ void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QV clip->audio_reset = false; } - if (clip->media == NULL) { + if (clip->media == nullptr) { if (clip->track >= 0) { cache_audio_worker(clip, scrubbing, nests); } @@ -901,7 +901,7 @@ void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QV void close_clip_worker(Clip* clip) { clip->finished_opening = false; - if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { clip->queue_clear(); avfilter_graph_free(&clip->filter_graph); diff --git a/playback/playback.cpp b/playback/playback.cpp index d6faaa28f..8a30a9c6d 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -37,7 +37,7 @@ bool texture_failed = false; bool rendering = false; bool clip_uses_cacher(Clip* clip) { - return (clip->media == NULL && clip->track >= 0) || (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE); + return (clip->media == nullptr && clip->track >= 0) || (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_FOOTAGE); } void open_clip(Clip* clip, bool multithreaded) { @@ -63,20 +63,20 @@ void open_clip(Clip* clip, bool multithreaded) { void close_clip(Clip* clip, bool wait) { // destroy opengl texture in main thread - if (clip->texture != NULL) { + if (clip->texture != nullptr) { delete clip->texture; - clip->texture = NULL; + clip->texture = nullptr; } for (int i=0;ieffects.size();i++) { if (clip->effects.at(i)->is_open()) clip->effects.at(i)->close(); } - if (clip->fbo != NULL) { + if (clip->fbo != nullptr) { delete clip->fbo[0]; delete clip->fbo[1]; delete [] clip->fbo; - clip->fbo = NULL; + clip->fbo = nullptr; } if (clip_uses_cacher(clip)) { @@ -91,7 +91,7 @@ void close_clip(Clip* clip, bool wait) { close_clip_worker(clip); } } else { - if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_SEQUENCE) + if (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_SEQUENCE) closeActiveClips(clip->media->to_sequence()); clip->open = false; @@ -129,7 +129,7 @@ void get_clip_frame(Clip* c, long playhead) { second_pts *= 2; } - AVFrame* target_frame = NULL; + AVFrame* target_frame = nullptr; bool reset = false; bool cache = true; @@ -222,7 +222,7 @@ void get_clip_frame(Clip* c, long playhead) { #ifdef GCF_DEBUG dout << "GCF ==> RESET" << target_pts << "(" << target_frame->pts << "-" << target_frame->pts+target_frame->pkt_duration << ")"; #endif - if (!config.fast_seeking) target_frame = NULL; + if (!config.fast_seeking) target_frame = nullptr; reset = true; c->last_invalid_ts = target_pts; } else { @@ -231,7 +231,7 @@ void get_clip_frame(Clip* c, long playhead) { #endif if (c->queue.size() >= c->max_queue_size) c->queue_remove_earliest(); c->ignore_reverse = true; - target_frame = NULL; + target_frame = nullptr; } } } @@ -240,13 +240,13 @@ void get_clip_frame(Clip* c, long playhead) { reset = true; } - if (target_frame == NULL || reset) { + if (target_frame == nullptr || reset) { // reset cache texture_failed = true; qInfo() << "Frame queue couldn't keep up - either the user seeked or the system is overloaded (queue size:" << c->queue.size() << ")"; } - if (target_frame != NULL) { + if (target_frame != nullptr) { int nb_components = av_pix_fmt_desc_get(static_cast(c->pix_fmt))->nb_components; glPixelStorei(GL_UNPACK_ROW_LENGTH, target_frame->linesize[0]/nb_components); @@ -291,7 +291,7 @@ double playhead_to_clip_seconds(Clip* c, long playhead) { long clip_frame = playhead_to_clip_frame(c, playhead); if (c->reverse) clip_frame = c->getMaximumLength() - clip_frame - 1; double secs = ((double) clip_frame/c->sequence->frame_rate)*c->speed; - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) secs *= c->media->to_footage()->speed; + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) secs *= c->media->to_footage()->speed; return secs; } @@ -330,7 +330,7 @@ int retrieve_next_frame(Clip* c, AVFrame* f) { } } else { if (read_ret == AVERROR_EOF) { - int send_ret = avcodec_send_packet(c->codecCtx, NULL); + int send_ret = avcodec_send_packet(c->codecCtx, nullptr); if (send_ret < 0) { qCritical() << "Failed to send packet to decoder." << send_ret; return send_ret; @@ -365,11 +365,11 @@ void set_sequence(Sequence* s) { } void closeActiveClips(Sequence *s) { - if (s != NULL) { + if (s != nullptr) { for (int i=0;iclips.size();i++) { Clip* c = s->clips.at(i); - if (c != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { + if (c != nullptr) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { closeActiveClips(c->media->to_sequence()); if (c->open) close_clip(c, true); } else if (c->open) { diff --git a/project/clip.cpp b/project/clip.cpp index 05758928c..f57213b2f 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -25,7 +25,7 @@ Clip::Clip(Sequence* s) : timeline_in(0), timeline_out(0), track(0), - media(NULL), + media(nullptr), speed(1.0), reverse(false), maintain_audio_pitch(false), @@ -36,9 +36,9 @@ Clip::Clip(Sequence* s) : replaced(false), ignore_reverse(false), use_existing_frame(false), - filter_graph(NULL), - fbo(NULL), - opts(NULL) + filter_graph(nullptr), + fbo(nullptr), + opts(nullptr) { pkt = av_packet_alloc(); reset(); @@ -67,10 +67,10 @@ Clip* Clip::copy(Sequence* s) { copy->effects.append(effects.at(i)->copy(copy)); } - copy->cached_fr = (this->sequence == NULL) ? cached_fr : this->sequence->frame_rate; + copy->cached_fr = (this->sequence == nullptr) ? cached_fr : this->sequence->frame_rate; - if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip == NULL) copy->opening_transition = get_opening_transition()->copy(copy, NULL); - if (get_closing_transition() != NULL && get_closing_transition()->secondary_clip == NULL) copy->closing_transition = get_closing_transition()->copy(copy, NULL); + if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip == nullptr) copy->opening_transition = get_opening_transition()->copy(copy, nullptr); + if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip == nullptr) copy->closing_transition = get_closing_transition()->copy(copy, nullptr); copy->recalculateMaxLength(); @@ -86,16 +86,16 @@ void Clip::reset() { frame_sample_index = -1; audio_buffer_write = false; texture_frame = -1; - formatCtx = NULL; - stream = NULL; - codec = NULL; - codecCtx = NULL; - texture = NULL; + formatCtx = nullptr; + stream = nullptr; + codec = nullptr; + codecCtx = nullptr; + texture = nullptr; last_invalid_ts = -1; } void Clip::reset_audio() { - if (media == NULL || media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (media == nullptr || media->get_type() == MEDIA_TYPE_FOOTAGE) { audio_reset = true; frame_sample_index = -1; audio_buffer_write = 0; @@ -103,14 +103,14 @@ void Clip::reset_audio() { Sequence* nested_sequence = media->to_sequence(); for (int i=0;iclips.size();i++) { Clip* c = nested_sequence->clips.at(i); - if (c != NULL) c->reset_audio(); + if (c != nullptr) c->reset_audio(); } } } void Clip::refresh() { // validates media if it was replaced - if (replaced && media != NULL && media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (replaced && media != nullptr && media->get_type() == MEDIA_TYPE_FOOTAGE) { Footage* m = media->to_footage(); if (track < 0 && m->video_tracks.size() > 0) { @@ -150,24 +150,24 @@ void Clip::queue_remove_earliest() { Transition* Clip::get_opening_transition() { if (opening_transition > -1) { - if (this->sequence == NULL) { + if (this->sequence == nullptr) { return clipboard_transitions.at(opening_transition); } else { return this->sequence->transitions.at(opening_transition); } } - return NULL; + return nullptr; } Transition* Clip::get_closing_transition() { if (closing_transition > -1) { - if (this->sequence == NULL) { + if (this->sequence == nullptr) { return clipboard_transitions.at(closing_transition); } else { return this->sequence->transitions.at(closing_transition); } } - return NULL; + return nullptr; } Clip::~Clip() { @@ -185,7 +185,7 @@ Clip::~Clip() { } long Clip::get_clip_in_with_transition() { - if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip != NULL) { + if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) { // we must be the secondary clip, so return (timeline in - length) return clip_in - get_opening_transition()->get_true_length(); } @@ -193,7 +193,7 @@ long Clip::get_clip_in_with_transition() { } long Clip::get_timeline_in_with_transition() { - if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip != NULL) { + if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) { // we must be the secondary clip, so return (timeline in - length) return timeline_in - get_opening_transition()->get_true_length(); } @@ -201,7 +201,7 @@ long Clip::get_timeline_in_with_transition() { } long Clip::get_timeline_out_with_transition() { - if (get_closing_transition() != NULL && get_closing_transition()->secondary_clip != NULL) { + if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip != nullptr) { // we must be the primary clip, so return (timeline out + length2) return timeline_out + get_closing_transition()->get_true_length(); } else { @@ -216,29 +216,29 @@ long Clip::getLength() { double Clip::getMediaFrameRate() { Q_ASSERT(track < 0); - if (media != NULL) { + if (media != nullptr) { double rate = media->get_frame_rate(media_stream); if (!qIsNaN(rate)) return rate; } - if (sequence != NULL) return sequence->frame_rate; + if (sequence != nullptr) return sequence->frame_rate; return qSNaN(); } void Clip::recalculateMaxLength() { - if (sequence != NULL) { + if (sequence != nullptr) { double fr = this->sequence->frame_rate; fr /= speed; calculated_length = LONG_MAX; - if (media != NULL) { + if (media != nullptr) { switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { Footage* m = media->to_footage(); const FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream); - if (ms != NULL && ms->infinite_length) { + if (ms != nullptr && ms->infinite_length) { calculated_length = LONG_MAX; } else { calculated_length = m->get_length_in_frames(fr); @@ -261,13 +261,13 @@ long Clip::getMaximumLength() { } int Clip::getWidth() { - if (media == NULL && sequence != NULL) return sequence->width; + if (media == nullptr && sequence != nullptr) return sequence->width; switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); - if (ms != NULL) return ms->video_width; - if (sequence != NULL) return sequence->width; + if (ms != nullptr) return ms->video_width; + if (sequence != nullptr) return sequence->width; } case MEDIA_TYPE_SEQUENCE: { @@ -279,13 +279,13 @@ int Clip::getWidth() { } int Clip::getHeight() { - if (media == NULL && sequence != NULL) return sequence->height; + if (media == nullptr && sequence != nullptr) return sequence->height; switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); - if (ms != NULL) return ms->video_height; - if (sequence != NULL) return sequence->height; + if (ms != nullptr) return ms->video_height; + if (sequence != nullptr) return sequence->height; } case MEDIA_TYPE_SEQUENCE: { diff --git a/project/effect.cpp b/project/effect.cpp index 14400133e..c28f20a53 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -73,7 +73,7 @@ Effect* create_effect(Clip* c, const EffectMeta* em) { qCritical() << "Invalid effect data"; QMessageBox::critical(mainWindow, "Invalid effect", "No candidate for effect '" + em->name + "'. This effect may be corrupt. Try reinstalling it or Olive."); } - return NULL; + return nullptr; } const EffectMeta* get_internal_meta(int internal_id, int type) { @@ -82,11 +82,11 @@ const EffectMeta* get_internal_meta(int internal_id, int type) { return &effects.at(i); } } - return NULL; + return nullptr; } void load_internal_effects() { - qWarning() << "Shaders are disabled, some effects may be nonfunctional"; + qWarning() << "Shaders are disabled, some effects may be nonfunctional"; EffectMeta em; @@ -266,8 +266,8 @@ Effect::Effect(Clip* c, const EffectMeta *em) : enable_coords(false), enable_superimpose(false), enable_image(false), - glslProgram(NULL), - texture(NULL), + glslProgram(nullptr), + texture(nullptr), isOpen(false), bound(false), enable_always_update(false) @@ -283,7 +283,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) : connect(container->title_bar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&))); - if (em != NULL) { + if (em != nullptr) { // set up UI from effect file container->setText(em->name); @@ -504,7 +504,7 @@ void Effect::copy_field_keyframes(Effect* e) { } EffectRow* Effect::add_row(const QString& name, bool savable, bool keyframable) { - EffectRow* row = new EffectRow(this, savable, ui_layout, name, rows.size()); + EffectRow* row = new EffectRow(this, savable, ui_layout, name, rows.size(), keyframable); rows.append(row); return row; } @@ -590,7 +590,7 @@ void Effect::move_down() { } int Effect::get_index_in_clip() { - if (parent_clip != NULL) { + if (parent_clip != nullptr) { for (int i=0;ieffects.size();i++) { if (parent_clip->effects.at(i) == this) { return i; @@ -729,7 +729,7 @@ void Effect::load(QXmlStreamReader& stream) { } } -void Effect::custom_load(QXmlStreamReader &stream) {} +void Effect::custom_load(QXmlStreamReader &) {} void Effect::save(QXmlStreamWriter& stream) { stream.writeAttribute("name", meta->name); @@ -788,9 +788,9 @@ void Effect::open() { if (isOpen) { qWarning() << "Tried to open an effect that was already open"; close(); - } - if (shaders_are_enabled && enable_shader) { - if (QOpenGLContext::currentContext() == NULL) { + } + if (shaders_are_enabled && enable_shader) { + if (QOpenGLContext::currentContext() == nullptr) { qWarning() << "No current context to create a shader program for - will retry next repaint"; } else { glslProgram = new QOpenGLShaderProgram(); @@ -835,15 +835,15 @@ void Effect::close() { qWarning() << "Tried to close an effect that was already closed"; } delete_texture(); - if (glslProgram != NULL) { + if (glslProgram != nullptr) { delete glslProgram; - glslProgram = NULL; + glslProgram = nullptr; } isOpen = false; } bool Effect::is_glsl_linked() { - return glslProgram != NULL && glslProgram->isLinked(); + return glslProgram != nullptr && glslProgram->isLinked(); } void Effect::startEffect() { @@ -851,11 +851,11 @@ void Effect::startEffect() { open(); qWarning() << "Tried to start a closed effect - opening"; } - if (shaders_are_enabled - && enable_shader - && glslProgram->isLinked()) { - bound = glslProgram->bind(); - } + if (shaders_are_enabled + && enable_shader + && glslProgram->isLinked()) { + bound = glslProgram->bind(); + } } void Effect::endEffect() { @@ -903,7 +903,7 @@ void Effect::process_shader(double timecode, GLTextureCoords&) { } } -void Effect::process_coords(double, GLTextureCoords&, int data) {} +void Effect::process_coords(double, GLTextureCoords&, int) {} GLuint Effect::process_superimpose(double timecode) { bool recreate_texture = false; @@ -919,7 +919,7 @@ GLuint Effect::process_superimpose(double timecode) { redraw(timecode); } - if (texture != NULL) { + if (texture != nullptr) { if (recreate_texture || texture->width() != img.width() || texture->height() != img.height()) { delete_texture(); texture = new QOpenGLTexture(QOpenGLTexture::Target2D); @@ -939,21 +939,21 @@ void Effect::gizmo_draw(double, GLTextureCoords &) {} void Effect::gizmo_move(EffectGizmo* gizmo, int x_movement, int y_movement, double timecode, bool done) { for (int i=0;ix_field1 != NULL) { + if (gizmo->x_field1 != nullptr) { gizmo->x_field1->set_double_value(gizmo->x_field1->get_double_value(timecode) + x_movement*gizmo->x_field_multi1); gizmo->x_field1->make_key_from_change(ca); } - if (gizmo->y_field1 != NULL) { + if (gizmo->y_field1 != nullptr) { gizmo->y_field1->set_double_value(gizmo->y_field1->get_double_value(timecode) + y_movement*gizmo->y_field_multi1); gizmo->y_field1->make_key_from_change(ca); } - if (gizmo->x_field2 != NULL) { + if (gizmo->x_field2 != nullptr) { gizmo->x_field2->set_double_value(gizmo->x_field2->get_double_value(timecode) + x_movement*gizmo->x_field_multi2); gizmo->x_field2->make_key_from_change(ca); } - if (gizmo->y_field2 != NULL) { + if (gizmo->y_field2 != nullptr) { gizmo->y_field2->set_double_value(gizmo->y_field2->get_double_value(timecode) + y_movement*gizmo->y_field_multi2); gizmo->y_field2->make_key_from_change(ca); } @@ -1063,9 +1063,9 @@ bool Effect::valueHasChanged(double timecode) { } void Effect::delete_texture() { - if (texture != NULL) { + if (texture != nullptr) { delete texture; - texture = NULL; + texture = nullptr; } } diff --git a/project/effectfield.cpp b/project/effectfield.cpp index f6626dc91..4f3ec79be 100644 --- a/project/effectfield.cpp +++ b/project/effectfield.cpp @@ -270,7 +270,7 @@ QVariant EffectField::validate_keyframe_data(double timecode, bool async) { void EffectField::ui_element_change() { bool dragging_double = (type == EFFECT_FIELD_DOUBLE && static_cast(ui_element)->is_dragging()); - ComboAction* ca = NULL; + ComboAction* ca = nullptr; if (!dragging_double) ca = new ComboAction(); make_key_from_change(ca); if (!dragging_double) undo_stack.push(ca); @@ -280,7 +280,7 @@ void EffectField::ui_element_change() { void EffectField::make_key_from_change(ComboAction* ca) { if (parent_row->isKeyframing()) { parent_row->set_keyframe_now(ca); - } else if (ca != NULL) { + } else if (ca != nullptr) { // set undo ca->append(new EffectFieldUndo(this)); } diff --git a/project/effectgizmo.cpp b/project/effectgizmo.cpp index 65bf0cc31..8b21eb771 100644 --- a/project/effectgizmo.cpp +++ b/project/effectgizmo.cpp @@ -4,13 +4,13 @@ #include "effectfield.h" EffectGizmo::EffectGizmo(int type) : - x_field1(NULL), + x_field1(nullptr), x_field_multi1(1.0), - y_field1(NULL), + y_field1(nullptr), y_field_multi1(1.0), - x_field2(NULL), + x_field2(nullptr), x_field_multi2(1.0), - y_field2(NULL), + y_field2(nullptr), y_field_multi2(1.0), type(type), cursor(-1) @@ -23,10 +23,10 @@ EffectGizmo::EffectGizmo(int type) : } void EffectGizmo::set_previous_value() { - if (x_field1 != NULL) static_cast(x_field1->ui_element)->set_previous_value(); - if (y_field1 != NULL) static_cast(y_field1->ui_element)->set_previous_value(); - if (x_field2 != NULL) static_cast(x_field2->ui_element)->set_previous_value(); - if (y_field2 != NULL) static_cast(y_field2->ui_element)->set_previous_value(); + if (x_field1 != nullptr) static_cast(x_field1->ui_element)->set_previous_value(); + if (y_field1 != nullptr) static_cast(y_field1->ui_element)->set_previous_value(); + if (x_field2 != nullptr) static_cast(x_field2->ui_element)->set_previous_value(); + if (y_field2 != nullptr) static_cast(y_field2->ui_element)->set_previous_value(); } int EffectGizmo::get_point_count() { diff --git a/project/effectrow.cpp b/project/effectrow.cpp index 4735e8def..5b4d4acac 100644 --- a/project/effectrow.cpp +++ b/project/effectrow.cpp @@ -31,7 +31,7 @@ EffectRow::EffectRow(Effect *parent, bool save, QGridLayout *uilayout, const QSt column_count = 1; - if (parent_effect->meta != NULL + if (parent_effect->meta != nullptr && parent_effect->meta->type != EFFECT_TYPE_TRANSITION && keyframable) { connect(label, SIGNAL(clicked()), this, SLOT(focus_row())); @@ -209,7 +209,7 @@ void EffectRow::set_keyframe_now(ComboAction* ca) { field(i)->keyframes[unsafe_keys.at(i)].data = field(i)->get_current_data(); } - if (ca != NULL) { + if (ca != nullptr) { for (int i=0;iappend(new KeyframeFieldSet(field(i), unsafe_keys.at(i))); ca->append(new SetQVariant(&field(i)->keyframes[unsafe_keys.at(i)].data, unsafe_old_data.at(i), field(i)->get_current_data())); @@ -225,7 +225,7 @@ void EffectRow::set_keyframe_now(ComboAction* ca) { - /*if (ca != NULL) { + /*if (ca != nullptr) { just_made_unsafe_keyframe = false; } else { if (!just_made_unsafe_keyframe) { @@ -248,7 +248,7 @@ void EffectRow::set_keyframe_now(ComboAction* ca) { KeyframeSet* ks = new KeyframeSet(this, index, time, just_made_unsafe_keyframe); - if (ca != NULL) { + if (ca != nullptr) { just_made_unsafe_keyframe = false; ca->append(ks); } else { diff --git a/project/footage.cpp b/project/footage.cpp index e63d343f2..2f3651017 100644 --- a/project/footage.cpp +++ b/project/footage.cpp @@ -11,7 +11,7 @@ extern "C" { #include "project/clip.h" -Footage::Footage() : ready(false), preview_gen(NULL), invalid(false), in(0), out(0), speed(1.0) { +Footage::Footage() : ready(false), preview_gen(nullptr), invalid(false), in(0), out(0), speed(1.0) { ready_lock.lock(); } @@ -20,7 +20,7 @@ Footage::~Footage() { } void Footage::reset() { - if (preview_gen != NULL) { + if (preview_gen != nullptr) { preview_gen->cancel(); preview_gen->wait(); } @@ -48,7 +48,7 @@ FootageStream* Footage::get_stream_from_file_index(bool video, int index) { } } } - return NULL; + return nullptr; } void FootageStream::make_square_thumb() { diff --git a/project/media.cpp b/project/media.cpp index 1ecb0cc8b..69d25f6f4 100644 --- a/project/media.cpp +++ b/project/media.cpp @@ -28,9 +28,9 @@ QString get_interlacing_name(int interlacing) { QString get_channel_layout_name(int channels, uint64_t layout) { switch (channels) { - case 0: return "Invalid"; break; - case 1: return "Mono"; break; - case 2: return "Stereo"; break; + case 0: return "Invalid"; + case 1: return "Mono"; + case 2: return "Stereo"; default: { char buf[50]; av_get_channel_layout_string(buf, sizeof(buf), channels, layout); @@ -41,7 +41,7 @@ QString get_channel_layout_name(int channels, uint64_t layout) { Media::Media(Media* iparent) : parent(iparent), - throbber(NULL), + throbber(nullptr), root(false), type(-1) {} @@ -49,9 +49,9 @@ Media::Media(Media* iparent) : Media::~Media() { switch (get_type()) { case MEDIA_TYPE_FOOTAGE: delete to_footage(); break; - case MEDIA_TYPE_SEQUENCE: if (object != NULL) delete to_sequence(); break; + case MEDIA_TYPE_SEQUENCE: if (object != nullptr) delete to_sequence(); break; } - if (throbber != NULL) delete throbber; + if (throbber != nullptr) delete throbber; qDeleteAll(children); } @@ -72,14 +72,14 @@ void Media::set_sequence(Sequence *s) { set_icon(QIcon(":/icons/sequence.png")); type = MEDIA_TYPE_SEQUENCE; object = s; - if (s != NULL) update_tooltip(); + if (s != nullptr) update_tooltip(); } void Media::set_folder() { if (folder_name.isEmpty()) folder_name = "New Folder"; set_icon(QIcon(":/icons/folder.png")); type = MEDIA_TYPE_FOLDER; - object = NULL; + object = nullptr; } void Media::set_icon(const QIcon &ico) { @@ -207,7 +207,7 @@ double Media::get_frame_rate(int stream) { } case MEDIA_TYPE_SEQUENCE: return to_sequence()->frame_rate; } - return NULL; + return 0; } int Media::get_sampling_rate(int stream) { diff --git a/project/projectmodel.cpp b/project/projectmodel.cpp index 4105e5a54..acec09122 100644 --- a/project/projectmodel.cpp +++ b/project/projectmodel.cpp @@ -6,7 +6,7 @@ #include "project/media.h" #include "debug.h" -ProjectModel::ProjectModel(QObject *parent) : QAbstractItemModel(parent), root_item(NULL) { +ProjectModel::ProjectModel(QObject *parent) : QAbstractItemModel(parent), root_item(nullptr) { root_item = new Media(0); root_item->root = true; } @@ -16,10 +16,10 @@ ProjectModel::~ProjectModel() { } void ProjectModel::destroy_root() { - if (panel_sequence_viewer != NULL) panel_sequence_viewer->viewer_widget->delete_function(); - if (panel_footage_viewer != NULL) panel_footage_viewer->viewer_widget->delete_function(); + if (panel_sequence_viewer != nullptr) panel_sequence_viewer->viewer_widget->delete_function(); + if (panel_footage_viewer != nullptr) panel_footage_viewer->viewer_widget->delete_function(); - if (root_item != NULL) { + if (root_item != nullptr) { delete root_item; } } @@ -143,14 +143,14 @@ void ProjectModel::set_icon(Media* m, const QIcon &ico) { } void ProjectModel::appendChild(Media *parent, Media *child) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; beginInsertRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), parent->childCount(), parent->childCount()); parent->appendChild(child); endInsertRows(); } void ProjectModel::moveChild(Media *child, Media *to) { - if (to == NULL) to = root_item; + if (to == nullptr) to = root_item; Media* from = child->parentItem(); beginMoveRows( from == root_item ? QModelIndex() : createIndex(from->row(), 0, from), @@ -165,18 +165,18 @@ void ProjectModel::moveChild(Media *child, Media *to) { } void ProjectModel::removeChild(Media* parent, Media* m) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; beginRemoveRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), m->row(), m->row()); parent->removeChild(m->row()); endRemoveRows(); } Media* ProjectModel::child(int i, Media* parent) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; return parent->child(i); } int ProjectModel::childCount(Media *parent) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; return parent->childCount(); } diff --git a/project/projectmodel.h b/project/projectmodel.h index b37836f6b..03ea9eadb 100644 --- a/project/projectmodel.h +++ b/project/projectmodel.h @@ -31,8 +31,8 @@ public: void appendChild(Media* parent, Media* child); void moveChild(Media *child, Media *to); void removeChild(Media *parent, Media* m); - Media *child(int i, Media* parent = NULL); - int childCount(Media* parent = NULL); + Media *child(int i, Media* parent = nullptr); + int childCount(Media* parent = nullptr); void set_icon(Media* m, const QIcon &ico); private: diff --git a/project/sequence.cpp b/project/sequence.cpp index 1a902966d..c0380ad17 100644 --- a/project/sequence.cpp +++ b/project/sequence.cpp @@ -33,8 +33,8 @@ Sequence* Sequence::copy() { s->clips.resize(clips.size()); for (int i=0;iclips[i] = NULL; + if (c == nullptr) { + s->clips[i] = nullptr; } else { Clip* copy = c->copy(s); copy->linked = c->linked; @@ -48,7 +48,7 @@ long Sequence::getEndFrame() { long end = 0; for (int j=0;jtimeline_out > end) { + if (c != nullptr && c->timeline_out > end) { end = c->timeline_out; } } @@ -61,10 +61,10 @@ void Sequence::hard_delete_transition(Clip *c, int type) { bool del = true; Transition* t = transitions.at(transition_index); - if (t->secondary_clip != NULL) { + if (t->secondary_clip != nullptr) { for (int i=0;iopening_transition == transition_index || c->closing_transition == transition_index)) { @@ -74,14 +74,14 @@ void Sequence::hard_delete_transition(Clip *c, int type) { } del = false; - t->secondary_clip = NULL; + t->secondary_clip = nullptr; } } } if (del) { delete transitions.at(transition_index); - transitions[transition_index] = NULL; + transitions[transition_index] = nullptr; } if (type == TA_OPENING_TRANSITION) { @@ -97,7 +97,7 @@ void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) { int at = 0; for (int j=0;jtrack < 0 && c->track < vt) { // video clip vt = c->track; } else if (c->track > at) { @@ -105,9 +105,9 @@ void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) { } } } - if (video_tracks != NULL) *video_tracks = vt; - if (audio_tracks != NULL) *audio_tracks = at; + if (video_tracks != nullptr) *video_tracks = vt; + if (audio_tracks != nullptr) *audio_tracks = at; } // static variable for the currently active sequence -Sequence* sequence = NULL; +Sequence* sequence = nullptr; diff --git a/project/sourcescommon.cpp b/project/sourcescommon.cpp index 04d6dc781..eea4a1ee7 100644 --- a/project/sourcescommon.cpp +++ b/project/sourcescommon.cpp @@ -18,8 +18,8 @@ #include SourcesCommon::SourcesCommon(Project* parent) : - project_parent(parent), - editing_item(NULL) + editing_item(nullptr), + project_parent(parent) { rename_timer.setInterval(1000); connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval())); @@ -39,7 +39,7 @@ void SourcesCommon::create_seq_from_selected() { panel_timeline->create_ghosts_from_media(s, 0, media_list); panel_timeline->add_clips_from_ghosts(ca, s); - project_parent->new_sequence(ca, s, true, NULL); + project_parent->new_sequence(ca, s, true, nullptr); undo_stack.push(ca); } } @@ -148,7 +148,7 @@ void SourcesCommon::item_click(Media *m, const QModelIndex& index) { } } -void SourcesCommon::mouseDoubleClickEvent(QMouseEvent *e, const QModelIndexList& selected_items) { +void SourcesCommon::mouseDoubleClickEvent(QMouseEvent *, const QModelIndexList& selected_items) { stop_rename_timer(); if (selected_items.size() == 0) { project_parent->import_dialog(); @@ -196,7 +196,7 @@ void SourcesCommon::dropEvent(QWidget* parent, QDropEvent *event, const QModelIn parent = drop_item.parent(); } } - project_parent->process_file_list(paths, false, NULL, panel_project->item_to_media(parent)); + project_parent->process_file_list(paths, false, nullptr, panel_project->item_to_media(parent)); } } event->acceptProposedAction(); @@ -271,7 +271,7 @@ void SourcesCommon::stop_rename_timer() { void SourcesCommon::rename_interval() { stop_rename_timer(); - if (view->hasFocus() && editing_item != NULL) { + if (view->hasFocus() && editing_item != nullptr) { view->edit(editing_index); } } @@ -280,6 +280,6 @@ void SourcesCommon::item_renamed(Media* item) { if (editing_item == item) { MediaRename* mr = new MediaRename(item, "idk"); undo_stack.push(mr); - editing_item = NULL; + editing_item = nullptr; } } diff --git a/project/transition.cpp b/project/transition.cpp index 3badb5ca3..2c81dfcc6 100644 --- a/project/transition.cpp +++ b/project/transition.cpp @@ -31,7 +31,7 @@ Transition::Transition(Clip* c, Clip* s, const EffectMeta* em) : LabelSlider* length_ui_ele = static_cast(length_field->ui_element); length_ui_ele->set_display_type(LABELSLIDER_FRAMENUMBER); - length_ui_ele->set_frame_rate(parent_clip->sequence == NULL ? parent_clip->cached_fr : parent_clip->sequence->frame_rate); + length_ui_ele->set_frame_rate(parent_clip->sequence == nullptr ? parent_clip->cached_fr : parent_clip->sequence->frame_rate); } int Transition::copy(Clip *c, Clip* s) { @@ -48,7 +48,7 @@ long Transition::get_true_length() { } long Transition::get_length() { - if (secondary_clip != NULL) { + if (secondary_clip != nullptr) { return length * 2; } return length; @@ -76,14 +76,14 @@ Transition* get_transition_from_meta(Clip* c, Clip* s, const EffectMeta* em) { qCritical() << "Invalid transition data"; QMessageBox::critical(mainWindow, "Invalid transition", "No candidate for transition '" + em->name + "'. This transition may be corrupt. Try reinstalling it or Olive."); } - return NULL; + return nullptr; } int create_transition(Clip* c, Clip* s, const EffectMeta* em, long length) { Transition* t = get_transition_from_meta(c, s, em); - if (t != NULL) { + if (t != nullptr) { if (length >= 0) t->set_length(length); - QVector& transition_list = (c->sequence == NULL) ? clipboard_transitions : c->sequence->transitions; + QVector& transition_list = (c->sequence == nullptr) ? clipboard_transitions : c->sequence->transitions; transition_list.append(t); return transition_list.size() - 1; } diff --git a/project/undo.cpp b/project/undo.cpp index d8660a7b5..f37e13793 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -116,7 +116,7 @@ DeleteClipAction::DeleteClipAction(Sequence* s, int clip) : {} DeleteClipAction::~DeleteClipAction() { - if (ref != NULL) delete ref; + if (ref != nullptr) delete ref; } void DeleteClipAction::undo() { @@ -141,7 +141,7 @@ void DeleteClipAction::undo() { seq->clips.at(linkClipIndex.at(i))->linked.insert(linkLinkIndex.at(i), index); } - ref = NULL; + ref = nullptr; mainWindow->setWindowModified(old_project_changed); } @@ -152,18 +152,18 @@ void DeleteClipAction::redo() { if (ref->open) { close_clip(ref, true); } - seq->clips[index] = NULL; + seq->clips[index] = nullptr; // save shared transitions - if (ref->opening_transition > -1 && ref->get_opening_transition()->secondary_clip != NULL) { + if (ref->opening_transition > -1 && ref->get_opening_transition()->secondary_clip != nullptr) { opening_transition = ref->opening_transition; ref->get_opening_transition()->parent_clip = ref->get_opening_transition()->secondary_clip; - ref->get_opening_transition()->secondary_clip = NULL; + ref->get_opening_transition()->secondary_clip = nullptr; ref->opening_transition = -1; } - if (ref->closing_transition > -1 && ref->get_closing_transition()->secondary_clip != NULL) { + if (ref->closing_transition > -1 && ref->get_closing_transition()->secondary_clip != nullptr) { closing_transition = ref->closing_transition; - ref->get_closing_transition()->secondary_clip = NULL; + ref->get_closing_transition()->secondary_clip = nullptr; ref->closing_transition = -1; } @@ -172,7 +172,7 @@ void DeleteClipAction::redo() { linkLinkIndex.clear(); for (int i=0;iclips.size();i++) { Clip* c = seq->clips.at(i); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jlinked.size();j++) { if (c->linked.at(j) == index) { linkClipIndex.append(i); @@ -256,7 +256,7 @@ AddEffectCommand::AddEffectCommand(Clip* c, Effect* e, const EffectMeta *m, int {} AddEffectCommand::~AddEffectCommand() { - if (!done && ref != NULL) delete ref; + if (!done && ref != nullptr) delete ref; } void AddEffectCommand::undo() { @@ -271,7 +271,7 @@ void AddEffectCommand::undo() { } void AddEffectCommand::redo() { - if (ref == NULL) { + if (ref == nullptr) { ref = create_effect(clip, meta); } if (pos < 0) { @@ -295,14 +295,14 @@ AddTransitionCommand::AddTransitionCommand(Clip* c, Clip *s, Transition* copy, c void AddTransitionCommand::undo() { clip->sequence->hard_delete_transition(clip, type); - if (secondary != NULL) secondary->sequence->hard_delete_transition(secondary, (type == TA_OPENING_TRANSITION) ? TA_CLOSING_TRANSITION : TA_OPENING_TRANSITION); + if (secondary != nullptr) secondary->sequence->hard_delete_transition(secondary, (type == TA_OPENING_TRANSITION) ? TA_CLOSING_TRANSITION : TA_OPENING_TRANSITION); if (type == TA_OPENING_TRANSITION) { clip->opening_transition = old_ptransition; - if (secondary != NULL) secondary->closing_transition = old_stransition; + if (secondary != nullptr) secondary->closing_transition = old_stransition; } else { clip->closing_transition = old_ptransition; - if (secondary != NULL) secondary->opening_transition = old_stransition; + if (secondary != nullptr) secondary->opening_transition = old_stransition; } mainWindow->setWindowModified(old_project_changed); @@ -311,8 +311,8 @@ void AddTransitionCommand::undo() { void AddTransitionCommand::redo() { if (type == TA_OPENING_TRANSITION) { old_ptransition = clip->opening_transition; - clip->opening_transition = (transition_to_copy == NULL) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, NULL); - if (secondary != NULL) { + clip->opening_transition = (transition_to_copy == nullptr) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, nullptr); + if (secondary != nullptr) { old_stransition = secondary->closing_transition; secondary->closing_transition = clip->opening_transition; } @@ -321,8 +321,8 @@ void AddTransitionCommand::redo() { } } else { old_ptransition = clip->closing_transition; - clip->closing_transition = (transition_to_copy == NULL) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, NULL); - if (secondary != NULL) { + clip->closing_transition = (transition_to_copy == nullptr) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, nullptr); + if (secondary != nullptr) { old_stransition = secondary->opening_transition; secondary->opening_transition = clip->closing_transition; } @@ -356,30 +356,30 @@ void ModifyTransitionCommand::redo() { DeleteTransitionCommand::DeleteTransitionCommand(Sequence* s, int transition_index) : seq(s), index(transition_index), - transition(NULL), - otc(NULL), - ctc(NULL), + transition(nullptr), + otc(nullptr), + ctc(nullptr), old_project_changed(mainWindow->isWindowModified()) {} DeleteTransitionCommand::~DeleteTransitionCommand() { - if (transition != NULL) delete transition; + if (transition != nullptr) delete transition; } void DeleteTransitionCommand::undo() { seq->transitions[index] = transition; - if (otc != NULL) otc->opening_transition = index; - if (ctc != NULL) ctc->closing_transition = index; + if (otc != nullptr) otc->opening_transition = index; + if (ctc != nullptr) ctc->closing_transition = index; - transition = NULL; + transition = nullptr; mainWindow->setWindowModified(old_project_changed); } void DeleteTransitionCommand::redo() { for (int i=0;iclips.size();i++) { Clip* c = seq->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->opening_transition == index) { otc = c; c->opening_transition = -1; @@ -392,7 +392,7 @@ void DeleteTransitionCommand::redo() { } transition = seq->transitions.at(index); - seq->transitions[index] = NULL; + seq->transitions[index] = nullptr; mainWindow->setWindowModified(true); } @@ -403,7 +403,7 @@ NewSequenceCommand::NewSequenceCommand(Media *s, Media* iparent) : done(false), old_project_changed(mainWindow->isWindowModified()) { - if (parent == NULL) parent = project_model.get_root(); + if (parent == nullptr) parent = project_model.get_root(); } NewSequenceCommand::~NewSequenceCommand() { @@ -518,8 +518,8 @@ void AddClipCommand::redo() { for (int j=0;jlinked.size();j++) { copy->linked[j] = original->linked.at(j) + linkOffset; } - if (original->opening_transition > -1) copy->opening_transition = original->get_opening_transition()->copy(copy, NULL); - if (original->closing_transition > -1) copy->closing_transition = original->get_closing_transition()->copy(copy, NULL); + if (original->opening_transition > -1) copy->opening_transition = original->get_opening_transition()->copy(copy, nullptr); + if (original->closing_transition > -1) copy->closing_transition = original->get_closing_transition()->copy(copy, nullptr); seq->clips.append(copy); } } @@ -591,7 +591,7 @@ void ReplaceMediaCommand::replace(QString& filename) { Sequence* s = all_sequences.at(i)->to_sequence(); for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL && c->media == item && c->open) { + if (c != nullptr && c->media == item && c->open) { close_clip(c, true); c->replaced = true; } @@ -602,7 +602,7 @@ void ReplaceMediaCommand::replace(QString& filename) { QStringList files; files.append(filename); item->to_footage()->ready_lock.lock(); - panel_project->process_file_list(files, false, item, NULL); + panel_project->process_file_list(files, false, item, nullptr); } void ReplaceMediaCommand::undo() { @@ -713,7 +713,7 @@ void MediaMove::undo() { } void MediaMove::redo() { - if (to == NULL) to = project_model.get_root(); + if (to == nullptr) to = project_model.get_root(); froms.resize(items.size()); for (int i=0;iparentItem(); @@ -998,7 +998,7 @@ void EditSequenceCommand::update() { item->set_sequence(seq); for (int i=0;iclips.size();i++) { - if (seq->clips.at(i) != NULL) seq->clips.at(i)->refresh(); + if (seq->clips.at(i) != nullptr) seq->clips.at(i)->refresh(); } if (sequence == seq) { @@ -1157,7 +1157,7 @@ void RippleAction::redo() { for (int i=0;iclips.size();i++) { if (!ignore.contains(i)) { Clip* c = s->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_in >= point) { move_clip(ca, c, length, length, 0, 0, true, true); } @@ -1265,7 +1265,7 @@ void RefreshClips::redo() { Sequence* s = all_sequences.at(i)->to_sequence(); for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL && c->media == media) { + if (c != nullptr && c->media == media) { c->replaced = true; c->refresh(); } diff --git a/ui/audiomonitor.cpp b/ui/audiomonitor.cpp index 5e136aada..12738aa4b 100644 --- a/ui/audiomonitor.cpp +++ b/ui/audiomonitor.cpp @@ -35,7 +35,7 @@ void AudioMonitor::resizeEvent(QResizeEvent *e) { } void AudioMonitor::paintEvent(QPaintEvent *) { - if (sequence != NULL) { + if (sequence != nullptr) { QPainter p(this); int channel_x = AUDIO_MONITOR_GAP; int channel_count = av_get_channel_layout_nb_channels(sequence->audio_layout); diff --git a/ui/collapsiblewidget.cpp b/ui/collapsiblewidget.cpp index fddebc040..57b90bbdd 100644 --- a/ui/collapsiblewidget.cpp +++ b/ui/collapsiblewidget.cpp @@ -44,7 +44,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) { set_button_icon(true); - contents = NULL; + contents = nullptr; } void CollapsibleWidget::header_click(bool s, bool deselect) { @@ -74,7 +74,7 @@ void CollapsibleWidget::set_button_icon(bool open) { } void CollapsibleWidget::setContents(QWidget* c) { - bool existing = (contents != NULL); + bool existing = (contents != nullptr); contents = c; if (!existing) { layout->addWidget(contents); diff --git a/ui/colorbutton.cpp b/ui/colorbutton.cpp index 026d1c42d..843478b39 100644 --- a/ui/colorbutton.cpp +++ b/ui/colorbutton.cpp @@ -31,7 +31,7 @@ void ColorButton::set_button_color() { } void ColorButton::open_dialog() { - QColor new_color = QColorDialog::getColor(color, NULL, "Set Color"); + QColor new_color = QColorDialog::getColor(color, nullptr, "Set Color"); if (new_color.isValid() && color != new_color) { set_color(new_color); set_button_color(); diff --git a/ui/graphview.cpp b/ui/graphview.cpp index fc1b82db0..36251f308 100644 --- a/ui/graphview.cpp +++ b/ui/graphview.cpp @@ -42,7 +42,7 @@ GraphView::GraphView(QWidget* parent) : y_scroll(0), mousedown(false), zoom(1.0), - row(NULL), + row(nullptr), moved_keys(false), current_handle(BEZIER_HANDLE_NONE), rect_select(false), @@ -59,14 +59,14 @@ void GraphView::show_context_menu(const QPoint& pos) { QMenu menu(this); QAction* zoom_to_selection = menu.addAction("Zoom to Selection"); - if (selected_keys.size() == 0 || row == NULL) { + if (selected_keys.size() == 0 || row == nullptr) { zoom_to_selection->setEnabled(false); } else { connect(zoom_to_selection, SIGNAL(triggered(bool)), this, SLOT(set_view_to_selection())); } QAction* zoom_to_all = menu.addAction("Zoom to Show All"); - if (row == NULL) { + if (row == nullptr) { zoom_to_all->setEnabled(false); } else { connect(zoom_to_all, SIGNAL(triggered(bool)), this, SLOT(set_view_to_all())); @@ -75,7 +75,7 @@ void GraphView::show_context_menu(const QPoint& pos) { menu.addSeparator(); QAction* reset_action = menu.addAction("Reset View"); - if (row == NULL) { + if (row == nullptr) { reset_action->setEnabled(false); } else { connect(reset_action, SIGNAL(triggered(bool)), this, SLOT(reset_view())); @@ -93,7 +93,7 @@ void GraphView::reset_view() { } void GraphView::set_view_to_selection() { - if (row != NULL && selected_keys.size() > 0) { + if (row != nullptr && selected_keys.size() > 0) { long min_time = LONG_MAX; long max_time = LONG_MIN; double min_dbl = DBL_MAX; @@ -110,7 +110,7 @@ void GraphView::set_view_to_selection() { } void GraphView::set_view_to_all() { - if (row != NULL) { + if (row != nullptr) { bool can_set = false; long min_time = LONG_MAX; @@ -201,7 +201,7 @@ QVector sort_keys_from_field(EffectField* field) { void GraphView::paintEvent(QPaintEvent *) { QPainter p(this); - if (panel_sequence_viewer->seq != NULL) { + if (panel_sequence_viewer->seq != nullptr) { // draw grid lines p.setPen(Qt::gray); @@ -210,7 +210,7 @@ void GraphView::paintEvent(QPaintEvent *) { draw_lines(p, false); // draw keyframes - if (row != NULL) { + if (row != nullptr) { QPen line_pen; line_pen.setWidth(BEZIER_LINE_SIZE); @@ -329,7 +329,7 @@ void GraphView::paintEvent(QPaintEvent *) { } void GraphView::mousePressEvent(QMouseEvent *event) { - if (row != NULL) { + if (row != nullptr) { mousedown = true; start_x = event->pos().x(); start_y = event->pos().y(); @@ -530,7 +530,7 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) { break; } } - } else if (row != NULL) { + } else if (row != nullptr) { // clicking on the curve click_add = false; @@ -665,7 +665,7 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) { } } -void GraphView::mouseReleaseEvent(QMouseEvent *e) { +void GraphView::mouseReleaseEvent(QMouseEvent *) { if (click_add_proc) { undo_stack.push(new KeyframeFieldSet(click_add_field, click_add_key)); } else if (moved_keys && selected_keys.size() > 0) { @@ -742,7 +742,7 @@ void GraphView::set_row(EffectRow *r) { selected_keys_old_doubles.clear(); emit selection_changed(false, -1); row = r; - if (row != NULL) { + if (row != nullptr) { field_visibility.resize(row->fieldCount()); field_visibility.fill(true); visible_in = row->parent_effect->parent_clip->timeline_in; @@ -771,7 +771,7 @@ void GraphView::set_field_visibility(int field, bool b) { } void GraphView::delete_selected_keys() { - if (row != NULL) { + if (row != nullptr) { QVector fields; for (int i=0;ifield(selected_keys_fields.at(i))); @@ -781,7 +781,7 @@ void GraphView::delete_selected_keys() { } void GraphView::select_all() { - if (row != NULL) { + if (row != nullptr) { selected_keys.clear(); selected_keys_fields.clear(); for (int i=0;ifieldCount();i++) { diff --git a/ui/timelineheader.cpp b/ui/timelineheader.cpp index 5e7cf4b6a..f8ef7b4c7 100644 --- a/ui/timelineheader.cpp +++ b/ui/timelineheader.cpp @@ -118,7 +118,7 @@ void TimelineHeader::show_text(bool enable) { } void TimelineHeader::mousePressEvent(QMouseEvent* event) { - if (viewer->seq != NULL && event->buttons() & Qt::LeftButton) { + if (viewer->seq != nullptr && event->buttons() & Qt::LeftButton) { if (resizing_workarea) { sequence_end = viewer->seq->getEndFrame(); } else { @@ -168,7 +168,7 @@ void TimelineHeader::mousePressEvent(QMouseEvent* event) { } void TimelineHeader::mouseMoveEvent(QMouseEvent* event) { - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { if (dragging) { if (resizing_workarea) { long frame = getHeaderFrameFromScreenPoint(event->pos().x()); @@ -214,7 +214,7 @@ void TimelineHeader::mouseMoveEvent(QMouseEvent* event) { } else { resizing_workarea = false; unsetCursor(); - if (viewer->seq != NULL && viewer->seq->using_workarea) { + if (viewer->seq != nullptr && viewer->seq->using_workarea) { long min_frame = getHeaderFrameFromScreenPoint(event->pos().x() - CLICK_RANGE) - 1; long max_frame = getHeaderFrameFromScreenPoint(event->pos().x() + CLICK_RANGE) + 1; if (viewer->seq->workarea_in > min_frame && viewer->seq->workarea_in < max_frame) { @@ -235,7 +235,7 @@ void TimelineHeader::mouseMoveEvent(QMouseEvent* event) { } void TimelineHeader::mouseReleaseEvent(QMouseEvent*) { - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { dragging = false; if (resizing_workarea) { undo_stack.push(new SetTimelineInOutCommand(viewer->seq, true, temp_workarea_in, temp_workarea_out)); @@ -294,7 +294,7 @@ void TimelineHeader::delete_markers() { } void TimelineHeader::paintEvent(QPaintEvent*) { - if (viewer->seq != NULL && zoom > 0) { + if (viewer->seq != nullptr && zoom > 0) { QPainter p(this); int yoff = (text_enabled) ? height()/2 : 0; diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 44b69ffdc..17c971fde 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -48,8 +48,8 @@ #define TRANSITION_BETWEEN_RANGE 40 TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) { - selection_command = NULL; - self_created_sequence = NULL; + selection_command = nullptr; + self_created_sequence = nullptr; scroll = 0; bottom_align = false; @@ -79,7 +79,7 @@ void TimelineWidget::right_click_ripple() { } void TimelineWidget::show_context_menu(const QPoint& pos) { - if (sequence != NULL) { + if (sequence != nullptr) { // hack because sometimes right clicking doesn't trigger mouse release event panel_timeline->rect_select_init = false; panel_timeline->rect_select_proc = false; @@ -98,7 +98,7 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { QVector selected_clips; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { selected_clips.append(c); } } @@ -115,7 +115,7 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_in > panel_timeline->cursor_frame || c->timeline_out > panel_timeline->cursor_frame) { at_end_of_sequence = false; } @@ -163,7 +163,7 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { for (int i=0;itrack < 0) { video_clip_count++; - if (selected_clips.at(i)->media == NULL + if (selected_clips.at(i)->media == nullptr || selected_clips.at(i)->media->get_type() != MEDIA_TYPE_FOOTAGE) { all_video_is_footage = false; } @@ -204,7 +204,7 @@ void TimelineWidget::toggle_autoscale() { SetAutoscaleAction* action = new SetAutoscaleAction(); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { action->clips.append(c); } } @@ -216,10 +216,10 @@ void TimelineWidget::toggle_autoscale() { } void TimelineWidget::tooltip_timer_timeout() { - if (sequence != NULL) { + if (sequence != nullptr) { if (tooltip_clip < sequence->clips.size()) { Clip* c = sequence->clips.at(tooltip_clip); - if (c != NULL) { + if (c != nullptr) { QToolTip::showText(QCursor::pos(), c->name + "\nStart: " + frame_to_timecode(c->timeline_in, config.timecode_view, sequence->frame_rate) @@ -235,7 +235,7 @@ void TimelineWidget::rename_clip() { QVector selected_clips; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { selected_clips.append(c); } } @@ -343,7 +343,7 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) { long entry_point; Sequence* seq = sequence; - if (seq == NULL) { + if (seq == nullptr) { // if no sequence, we're going to create a new one using the clips as a reference entry_point = 0; @@ -365,7 +365,7 @@ void TimelineWidget::dragMoveEvent(QDragMoveEvent *event) { if (panel_timeline->importing) { event->acceptProposedAction(); - if (sequence != NULL) { + if (sequence != nullptr) { QPoint pos = event->pos(); update_ghosts(pos, event->keyboardModifiers() & Qt::ShiftModifier); panel_timeline->move_insert = ((event->keyboardModifiers() & Qt::ControlModifier) && (panel_timeline->tool == TIMELINE_TOOL_POINTER || panel_timeline->importing)); @@ -403,9 +403,9 @@ void TimelineWidget::dragLeaveEvent(QDragLeaveEvent* event) { panel_timeline->importing = false; update_ui(false); } - if (self_created_sequence != NULL) { + if (self_created_sequence != nullptr) { delete self_created_sequence; - self_created_sequence = NULL; + self_created_sequence = nullptr; } } @@ -453,7 +453,7 @@ void insert_clips(ComboAction* ca) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { // don't split any clips that are moving bool found = false; for (int j=0;jghosts.size();j++) { @@ -511,10 +511,10 @@ void TimelineWidget::dropEvent(QDropEvent* event) { Sequence* s = sequence; // if we're dropping into nothing, create a new sequences based on the clip being dragged - if (s == NULL) { + if (s == nullptr) { s = self_created_sequence; - panel_project->new_sequence(ca, self_created_sequence, true, NULL); - self_created_sequence = NULL; + panel_project->new_sequence(ca, self_created_sequence, true, nullptr); + self_created_sequence = nullptr; } else if (event->keyboardModifiers() & Qt::ControlModifier) { insert_clips(ca); } else { @@ -552,7 +552,7 @@ bool isLiveEditing() { } void TimelineWidget::mousePressEvent(QMouseEvent *event) { - if (sequence != NULL) { + if (sequence != nullptr) { int tool = panel_timeline->tool; if (event->button() == Qt::MiddleButton) { tool = TIMELINE_TOOL_HAND; @@ -602,7 +602,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { Ghost g; g.in = g.old_in = g.out = g.old_out = panel_timeline->drag_frame_start; g.track = g.old_track = panel_timeline->drag_track_start; - g.transition = NULL; + g.transition = nullptr; g.clip = -1; g.trimming = true; g.trim_in = false; @@ -626,7 +626,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { } else { if (clip_index >= 0) { Clip* clip = sequence->clips.at(clip_index); - if (clip != NULL) { + if (clip != nullptr) { if (panel_timeline->is_clip_selected(clip, true)) { if (shift) { panel_timeline->deselect_area(clip->timeline_in, clip->timeline_out, clip->track); @@ -648,14 +648,14 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { Selection s; s.track = clip->track; - if (panel_timeline->transition_select == TA_OPENING_TRANSITION && clip->get_opening_transition() != NULL) { + if (panel_timeline->transition_select == TA_OPENING_TRANSITION && clip->get_opening_transition() != nullptr) { s.in = clip->timeline_in; - if (clip->get_opening_transition()->secondary_clip != NULL) s.in -= clip->get_opening_transition()->get_true_length(); + if (clip->get_opening_transition()->secondary_clip != nullptr) s.in -= clip->get_opening_transition()->get_true_length(); s.out = clip->timeline_in + clip->get_opening_transition()->get_true_length(); - } else if (panel_timeline->transition_select == TA_CLOSING_TRANSITION && clip->get_closing_transition() != NULL) { + } else if (panel_timeline->transition_select == TA_CLOSING_TRANSITION && clip->get_closing_transition() != nullptr) { s.in = clip->timeline_out - clip->get_closing_transition()->get_true_length(); s.out = clip->timeline_out; - if (clip->get_closing_transition()->secondary_clip != NULL) s.out += clip->get_closing_transition()->get_true_length(); + if (clip->get_closing_transition()->secondary_clip != nullptr) s.out += clip->get_closing_transition()->get_true_length(); } sequence->selections.append(s); } @@ -673,12 +673,12 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { if (panel_timeline->tool == TIMELINE_TOOL_POINTER) { if (panel_timeline->transition_select == TA_OPENING_TRANSITION) { s.out = clip->timeline_in + clip->get_opening_transition()->get_true_length(); - if (clip->get_opening_transition()->secondary_clip != NULL) s.in -= clip->get_opening_transition()->get_true_length(); + if (clip->get_opening_transition()->secondary_clip != nullptr) s.in -= clip->get_opening_transition()->get_true_length(); } if (panel_timeline->transition_select == TA_CLOSING_TRANSITION) { s.in = clip->timeline_out - clip->get_closing_transition()->get_true_length(); - if (clip->get_closing_transition()->secondary_clip != NULL) s.out += clip->get_closing_transition()->get_true_length(); + if (clip->get_closing_transition()->secondary_clip != nullptr) s.out += clip->get_closing_transition()->get_true_length(); } } @@ -749,10 +749,10 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transition_start, long transition_end, bool delete_old_transitions) { // make room for transition if (type == TA_OPENING_TRANSITION) { - if (delete_old_transitions && c->get_opening_transition() != NULL) { + if (delete_old_transitions && c->get_opening_transition() != nullptr) { ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { if (transition_end >= c->timeline_out) { ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition)); } else if (transition_end > c->timeline_out - c->get_closing_transition()->get_true_length()) { @@ -760,10 +760,10 @@ void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transitio } } } else { - if (delete_old_transitions && c->get_closing_transition() != NULL) { + if (delete_old_transitions && c->get_closing_transition() != nullptr) { ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition)); } - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { if (transition_start <= c->timeline_in) { ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); } else if (transition_start < c->timeline_in + c->get_opening_transition()->get_true_length()) { @@ -775,7 +775,7 @@ void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transitio void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { QToolTip::hideText(); - if (sequence != NULL) { + if (sequence != nullptr) { bool alt = (event->modifiers() & Qt::AltModifier); bool shift = (event->modifiers() & Qt::ShiftModifier); bool ctrl = (event->modifiers() & Qt::ControlModifier); @@ -794,7 +794,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { panel_timeline->creating = false; } else if (g.in != g.out) { Clip* c = new Clip(sequence); - c->media = NULL; + c->media = nullptr; c->timeline_in = qMin(g.in, g.out); c->timeline_out = qMax(g.in, g.out); c->clip_in = 0; @@ -955,9 +955,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { const Ghost& g = panel_timeline->ghosts.at(i); sequence->clips.at(g.clip)->undeletable = true; - if (g.transition != NULL) { + if (g.transition != nullptr) { g.transition->parent_clip->undeletable = true; - if (g.transition->secondary_clip != NULL) g.transition->secondary_clip->undeletable = true; + if (g.transition->secondary_clip != nullptr) g.transition->secondary_clip->undeletable = true; } Selection s; @@ -970,9 +970,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { for (int i=0;ighosts.size();i++) { const Ghost& g = panel_timeline->ghosts.at(i); sequence->clips.at(g.clip)->undeletable = false; - if (g.transition != NULL) { + if (g.transition != nullptr) { g.transition->parent_clip->undeletable = false; - if (g.transition->secondary_clip != NULL) g.transition->secondary_clip->undeletable = false; + if (g.transition->secondary_clip != nullptr) g.transition->secondary_clip->undeletable = false; } } } @@ -981,14 +981,14 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { // step 3 - move clips Clip* c = sequence->clips.at(g.clip); - if (g.transition == NULL) { + if (g.transition == nullptr) { move_clip(ca, c, (g.in - g.old_in), (g.out - g.old_out), (g.clip_in - g.old_clip_in), (g.track - g.old_track), true, true); // adjust transitions if we need to long new_clip_length = (g.out - g.in); - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { long max_open_length = new_clip_length; - if (c->get_closing_transition() != NULL && !panel_timeline->trim_in_point) { + if (c->get_closing_transition() != nullptr && !panel_timeline->trim_in_point) { max_open_length -= c->get_closing_transition()->get_true_length(); } if (max_open_length <= 0) { @@ -997,9 +997,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, max_open_length)); } } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { long max_open_length = new_clip_length; - if (c->get_opening_transition() != NULL && panel_timeline->trim_in_point) { + if (c->get_opening_transition() != nullptr && panel_timeline->trim_in_point) { max_open_length -= c->get_opening_transition()->get_true_length(); } if (max_open_length <= 0) { @@ -1011,12 +1011,12 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { } else { bool is_opening_transition = (g.transition == c->get_opening_transition()); long new_transition_length = g.out - g.in; - if (g.transition->secondary_clip != NULL) new_transition_length >>= 1; + if (g.transition->secondary_clip != nullptr) new_transition_length >>= 1; ca->append(new ModifyTransitionCommand(c, is_opening_transition ? TA_OPENING_TRANSITION : TA_CLOSING_TRANSITION, new_transition_length)); long clip_length = c->getLength(); - if (g.transition->secondary_clip != NULL) { + if (g.transition->secondary_clip != nullptr) { if (g.in != g.old_in && !g.trimming) { long movement = g.in - g.old_in; move_clip(ca, g.transition->parent_clip, movement, 0, movement, 0, false, true); @@ -1106,9 +1106,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { } if (panel_timeline->transition_tool_post_clip > -1) { - ca->append(new AddTransitionCommand(pre, post, NULL, panel_timeline->transition_tool_meta, TA_OPENING_TRANSITION, transition_end - pre->timeline_in)); + ca->append(new AddTransitionCommand(pre, post, nullptr, panel_timeline->transition_tool_meta, TA_OPENING_TRANSITION, transition_end - pre->timeline_in)); } else { - ca->append(new AddTransitionCommand(pre, NULL, NULL, panel_timeline->transition_tool_meta, panel_timeline->transition_tool_type, transition_end - transition_start)); + ca->append(new AddTransitionCommand(pre, nullptr, nullptr, panel_timeline->transition_tool_meta, panel_timeline->transition_tool_type, transition_end - transition_start)); } push_undo = true; @@ -1130,10 +1130,10 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { // remove duplicate selections panel_timeline->clean_up_selections(sequence->selections); - if (selection_command != NULL) { + if (selection_command != nullptr) { selection_command->new_data = sequence->selections; ca->append(selection_command); - selection_command = NULL; + selection_command = nullptr; push_undo = true; } @@ -1180,7 +1180,7 @@ void TimelineWidget::init_ghosts() { g.in = g.old_in = c->get_timeline_in_with_transition(); g.out = g.old_out = c->get_timeline_out_with_transition(); g.ghost_length = g.old_out - g.old_in; - } else if (g.transition == NULL) { + } else if (g.transition == nullptr) { // this ghost is for a clip g.in = g.old_in = c->timeline_in; g.out = g.old_out = c->timeline_out; @@ -1277,11 +1277,11 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { long temp_frame_diff = frame_diff; // cache to see if we change it (thus cancelling any snap) for (int i=0;ighosts.size();i++) { const Ghost& g = panel_timeline->ghosts.at(i); - Clip* c = NULL; + Clip* c = nullptr; if (g.clip != -1) c = sequence->clips.at(g.clip); - const FootageStream* ms = NULL; - if (g.clip != -1 && c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + const FootageStream* ms = nullptr; + if (g.clip != -1 && c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); } @@ -1289,8 +1289,8 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { if (panel_timeline->creating) { // i feel like we might need something here but we haven't so far? } else if (effective_tool == TIMELINE_TOOL_SLIP) { - if ((c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) - || (ms != NULL && !ms->infinite_length)) { + if ((c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) + || (ms != nullptr && !ms->infinite_length)) { // prevent slip moving a clip below 0 clip_in validator = g.old_clip_in - frame_diff; if (validator < 0) frame_diff += validator; @@ -1312,8 +1312,8 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } // prevent clip_in from going below 0 - if ((c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) - || (ms != NULL && !ms->infinite_length)) { + if ((c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + frame_diff; if (validator < 0) frame_diff -= validator; } @@ -1323,15 +1323,15 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { if (validator < 1) frame_diff += (1 - validator); // prevent clip length exceeding media length - if ((c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) - || (ms != NULL && !ms->infinite_length)) { + if ((c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + g.ghost_length + frame_diff; if (validator > g.media_length) frame_diff -= validator - g.media_length; } } // prevent dual transition from going below 0 on the primary or media length on the secondary - if (g.transition != NULL && g.transition->secondary_clip != NULL) { + if (g.transition != nullptr && g.transition->secondary_clip != nullptr) { Clip* otc = g.transition->parent_clip; Clip* ctc = g.transition->secondary_clip; @@ -1387,8 +1387,8 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { validator = g.old_in + frame_diff; if (validator < 0) frame_diff -= validator; - if (g.transition != NULL) { - if (g.transition->secondary_clip != NULL) { + if (g.transition != nullptr) { + if (g.transition->secondary_clip != nullptr) { // prevent dual transitions from going below 0 on the primary or above media length on the secondary validator = g.transition->parent_clip->get_clip_in_with_transition() + frame_diff; @@ -1405,14 +1405,14 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } else { // prevent clip_in from going below 0 if (c->media->get_type() == MEDIA_TYPE_SEQUENCE - || (ms != NULL && !ms->infinite_length)) { + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + frame_diff; if (validator < 0) frame_diff -= validator; } // prevent clip length exceeding media length if (c->media->get_type() == MEDIA_TYPE_SEQUENCE - || (ms != NULL && !ms->infinite_length)) { + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + g.ghost_length + frame_diff; if (validator > g.media_length) frame_diff -= validator - g.media_length; } @@ -1482,7 +1482,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } // apply changes - if (g.transition != NULL && g.transition->secondary_clip != NULL) { + if (g.transition != nullptr && g.transition->secondary_clip != nullptr) { if (g.trim_in) ghost_diff = -ghost_diff; g.in = g.old_in - ghost_diff; g.out = g.old_out + ghost_diff; @@ -1497,7 +1497,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { g.in = g.old_in + frame_diff; g.out = g.old_out + frame_diff; - if (g.transition != NULL && g.transition == sequence->clips.at(g.clip)->get_opening_transition()) { + if (g.transition != nullptr && g.transition == sequence->clips.at(g.clip)->get_opening_transition()) { g.clip_in = g.old_clip_in + frame_diff; } @@ -1566,7 +1566,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { QString tip = ((frame_diff < 0) ? "-" : "+") + frame_to_timecode(qAbs(frame_diff), config.timecode_view, sequence->frame_rate); if (panel_timeline->trim_target > -1) { // find which clip is being moved - const Ghost* g = NULL; + const Ghost* g = nullptr; for (int i=0;ighosts.size();i++) { if (panel_timeline->ghosts.at(i).clip == panel_timeline->trim_target) { g = &panel_timeline->ghosts.at(i); @@ -1574,7 +1574,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } } - if (g != NULL) { + if (g != nullptr) { tip += " Duration: "; long len = (g->old_out-g->old_in); if (panel_timeline->trim_in_point) { @@ -1591,7 +1591,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { tooltip_timer.stop(); - if (sequence != NULL) { + if (sequence != nullptr) { bool alt = (event->modifiers() & Qt::AltModifier); panel_timeline->cursor_frame = panel_timeline->getTimelineFrameFromScreenPoint(event->pos().x()); @@ -1690,14 +1690,14 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { // create ghosts for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { Ghost g; - g.transition = NULL; + g.transition = nullptr; bool add = panel_timeline->is_clip_selected(c, true); // if a whole clip is not selected, maybe just a transition is - if (panel_timeline->tool == TIMELINE_TOOL_POINTER && (c->get_opening_transition() != NULL || c->get_closing_transition() != NULL)) { + if (panel_timeline->tool == TIMELINE_TOOL_POINTER && (c->get_opening_transition() != nullptr || c->get_closing_transition() != nullptr)) { // check if any selections contain the whole clip or transition for (int j=0;jselections.size();j++) { const Selection& s = sequence->selections.at(j); @@ -1715,7 +1715,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } - if (add && g.transition != NULL) { + if (add && g.transition != nullptr) { // check for duplicate transitions for (int j=0;jghosts.size();j++) { if (panel_timeline->ghosts.at(j).transition == g.transition) { @@ -1771,7 +1771,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { if (!found) { // add ghost for this clip with opposite trim_in Ghost gh; - gh.transition = NULL; + gh.transition = nullptr; gh.clip = j; gh.trimming = (panel_timeline->trim_target > -1); gh.trim_in = !panel_timeline->trim_in_point; @@ -1795,7 +1795,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { panel_timeline->ghosts[i].trimming = false; for (int j=0;jclips.size();j++) { Clip* c = sequence->clips.at(j); - if (c != NULL && c->track == ghost_clip->track) { + if (c != nullptr && c->track == ghost_clip->track) { bool found = false; for (int k=0;kghosts.at(k).clip == j) { @@ -1807,7 +1807,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { bool is_in = (c->timeline_in == ghost_clip->timeline_out); if (is_in || c->timeline_out == ghost_clip->timeline_in) { Ghost gh; - gh.transition = NULL; + gh.transition = nullptr; gh.clip = j; gh.trimming = true; gh.trim_in = is_in; @@ -1836,7 +1836,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && !panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && !panel_timeline->is_clip_selected(c, true)) { bool clip_is_post = (c->timeline_in >= axis); // see if this a clip on this track is already in the list, and if it's closer @@ -1912,7 +1912,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { QVector selected_clips; for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL && + if (clip != nullptr && clip->track >= track_min && clip->track <= track_max && !(clip->timeline_in < frame_min && clip->timeline_out < frame_min) && @@ -1983,7 +1983,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { panel_timeline->transition_select = TA_NO_TRANSITION; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { min_track = qMin(min_track, c->track); max_track = qMax(max_track, c->track); if (c->track == mouse_track) { @@ -1994,9 +1994,9 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { tooltip_timer.start(); tooltip_clip = i; - if (c->get_opening_transition() != NULL && panel_timeline->cursor_frame <= c->timeline_in + c->get_opening_transition()->get_true_length()) { + if (c->get_opening_transition() != nullptr && panel_timeline->cursor_frame <= c->timeline_in + c->get_opening_transition()->get_true_length()) { panel_timeline->transition_select = TA_OPENING_TRANSITION; - } else if (c->get_closing_transition() != NULL && panel_timeline->cursor_frame >= c->timeline_out - c->get_closing_transition()->get_true_length()) { + } else if (c->get_closing_transition() != nullptr && panel_timeline->cursor_frame >= c->timeline_out - c->get_closing_transition()->get_true_length()) { panel_timeline->transition_select = TA_CLOSING_TRANSITION; } } @@ -2019,7 +2019,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } if (panel_timeline->tool == TIMELINE_TOOL_POINTER) { - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { long transition_point = c->timeline_in + c->get_opening_transition()->get_true_length(); if (transition_point > mouse_frame_lower && transition_point < mouse_frame_upper) { @@ -2033,7 +2033,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { long transition_point = c->timeline_out - c->get_closing_transition()->get_true_length(); if (transition_point > mouse_frame_lower && transition_point < mouse_frame_upper) { int nc = qAbs(transition_point + 1 - panel_timeline->cursor_frame); @@ -2150,7 +2150,7 @@ void TimelineWidget::leaveEvent(QEvent*) { } int color_brightness(int r, int g, int b) { - return (0.2126*r + 0.7152*g + 0.0722*b); + return qRound(0.2126*r + 0.7152*g + 0.0722*b); } void draw_waveform(Clip* clip, const FootageStream* ms, long media_length, QPainter *p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom) { @@ -2186,7 +2186,7 @@ void draw_waveform(Clip* clip, const FootageStream* ms, long media_length, QPain void draw_transition(QPainter& p, Clip* c, const QRect& clip_rect, QRect& text_rect, int transition_type) { Transition* t = (transition_type == TA_OPENING_TRANSITION) ? c->get_opening_transition() : c->get_closing_transition(); - if (t != NULL) { + if (t != nullptr) { QColor transition_color(255, 0, 0, 16); int transition_width = getScreenPointFromFrame(panel_timeline->zoom, t->get_true_length()); int transition_height = clip_rect.height(); @@ -2206,7 +2206,7 @@ void draw_transition(QPainter& p, Clip* c, const QRect& clip_rect, QRect& text_r bool draw_text = true; p.setPen(QColor(0, 0, 0, 96)); - if (t->secondary_clip == NULL) { + if (t->secondary_clip == nullptr) { if (transition_type == TA_OPENING_TRANSITION) { p.drawLine(transition_rect.bottomLeft(), transition_rect.topRight()); } else { @@ -2236,7 +2236,7 @@ void draw_transition(QPainter& p, Clip* c, const QRect& clip_rect, QRect& text_r void TimelineWidget::paintEvent(QPaintEvent*) { // Draw clips - if (sequence != NULL) { + if (sequence != nullptr) { QPainter p(this); // get widget width and height @@ -2244,7 +2244,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { int audio_track_limit = 0; for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL) { + if (clip != nullptr) { video_track_limit = qMin(video_track_limit, clip->track); audio_track_limit = qMax(audio_track_limit, clip->track); } @@ -2268,7 +2268,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL && is_track_visible(clip->track)) { + if (clip != nullptr && is_track_visible(clip->track)) { QRect clip_rect(panel_timeline->getTimelineScreenPointFromFrame(clip->timeline_in), getScreenPointFromTrack(clip->track), getScreenPointFromFrame(panel_timeline->zoom, clip->getLength()), panel_timeline->calculate_track_height(clip->track, -1)); QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - 1, clip_rect.height() - CLIP_TEXT_PADDING - 1); if (clip_rect.left() < width() && clip_rect.right() >= 0 && clip_rect.top() < height() && clip_rect.bottom() >= 0) { @@ -2281,12 +2281,12 @@ void TimelineWidget::paintEvent(QPaintEvent*) { int thumb_x = clip_rect.x() + 1; - if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { bool draw_checkerboard = false; QRect checkerboard_rect(clip_rect); Footage* m = clip->media->to_footage(); FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream); - if (ms == NULL) { + if (ms == nullptr) { draw_checkerboard = true; } else if (ms->preview_done) { // draw top and tail triangles @@ -2332,12 +2332,12 @@ void TimelineWidget::paintEvent(QPaintEvent*) { int thumb_y = p.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING; if (thumb_x < width() && thumb_y < height()) { int space_for_thumb = clip_rect.width()-1; - if (clip->get_opening_transition() != NULL) { + if (clip->get_opening_transition() != nullptr) { int ot_width = getScreenPointFromFrame(panel_timeline->zoom, clip->get_opening_transition()->get_true_length()); thumb_x += ot_width; space_for_thumb -= ot_width; } - if (clip->get_closing_transition() != NULL) { + if (clip->get_closing_transition() != nullptr) { space_for_thumb -= getScreenPointFromFrame(panel_timeline->zoom, clip->get_closing_transition()->get_true_length()); } int thumb_height = clip_rect.height()-thumb_y; @@ -2642,7 +2642,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { } } -void TimelineWidget::resizeEvent(QResizeEvent *event) { +void TimelineWidget::resizeEvent(QResizeEvent *) { scrollBar->setPageStep(height()); } @@ -2692,7 +2692,7 @@ int TimelineWidget::getScreenPointFromTrack(int track) { int TimelineWidget::getClipIndexFromCoords(long frame, int track) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && c->track == track && frame >= c->timeline_in && frame < c->timeline_out) { + if (c != nullptr && c->track == track && frame >= c->timeline_in && frame < c->timeline_out) { return i; } } diff --git a/ui/viewercontainer.cpp b/ui/viewercontainer.cpp index 5c109b077..21f709b1c 100644 --- a/ui/viewercontainer.cpp +++ b/ui/viewercontainer.cpp @@ -14,7 +14,7 @@ ViewerContainer::ViewerContainer(QWidget *parent) : QScrollArea(parent), fit(true), - child(NULL) + child(nullptr) { setFrameShadow(QFrame::Plain); setFrameShape(QFrame::NoFrame); @@ -50,7 +50,7 @@ void ViewerContainer::dragScrollMove(const QPoint &p) { } void ViewerContainer::adjust() { - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { if (child->waveform) { child->move(0, 0); child->resize(size()); diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index f8adf8313..e64509b07 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -46,10 +46,10 @@ extern "C" { ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent), - default_fbo(NULL), + default_fbo(nullptr), waveform(false), dragging(false), - selected_gizmo(NULL), + selected_gizmo(nullptr), waveform_zoom(1.0), waveform_scroll(0) { @@ -70,7 +70,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) : void ViewerWidget::delete_function() { // destroy all textures as well - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { makeCurrent(); closeActiveClips(viewer->seq); doneCurrent(); @@ -143,7 +143,7 @@ void ViewerWidget::save_frame() { img.save(fn); fbo.release(); - default_fbo = NULL; + default_fbo = nullptr; rendering = false; } } @@ -204,7 +204,7 @@ void ViewerWidget::seek_from_click(int x) { } EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) { - if (gizmos != NULL) { + if (gizmos != nullptr) { double multiplier = (double) viewer->seq->width / (double) width(); QPoint mouse_pos(qRound(x*multiplier), qRound(y*multiplier)); int dot_size = 2 * qRound(GIZMO_DOT_SIZE * multiplier); @@ -238,11 +238,11 @@ EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) { } } - return NULL; + return nullptr; } void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) { - if (selected_gizmo != NULL) { + if (selected_gizmo != nullptr) { double multiplier = (double) viewer->seq->width / (double) width(); int x_movement = (event->pos().x() - drag_start_x)*multiplier; @@ -274,7 +274,7 @@ void ViewerWidget::mousePressEvent(QMouseEvent* event) { selected_gizmo = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); - if (selected_gizmo != NULL) { + if (selected_gizmo != nullptr) { selected_gizmo->set_previous_value(); } } @@ -291,7 +291,7 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) { seek_from_click(event->x()); } else if (event->buttons() & Qt::MiddleButton || panel_timeline->tool == TIMELINE_TOOL_HAND) { container->dragScrollMove(event->pos()); - } else if (gizmos == NULL) { + } else if (gizmos == nullptr) { QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; mimeData->setText("h"); // QMimeData will fail without some kind of data @@ -303,7 +303,7 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) { } } else { EffectGizmo* g = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); - if (g != NULL) { + if (g != nullptr) { if (g->get_cursor() > -1) { setCursor(static_cast(g->get_cursor())); } @@ -420,7 +420,7 @@ GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bo // restore previous blendFunc glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha); - if (default_fbo != NULL) default_fbo->bind(); + if (default_fbo != nullptr) default_fbo->bind(); glPopMatrix(); return fbo->texture(); @@ -441,7 +441,7 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture if (e->enable_superimpose) { GLuint superimpose_texture = e->process_superimpose(timecode); if (superimpose_texture == 0) { - qWarning() << "Superimpose texture was NULL, retrying..."; + qWarning() << "Superimpose texture was nullptr, retrying..."; texture_failed = true; } else { composite_texture = draw_clip(c->fbo[!fbo_switcher], superimpose_texture, false); @@ -466,7 +466,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) playhead = refactor_frame_number(playhead, nests.at(i)->sequence->frame_rate, s->frame_rate); } - if (nests.last()->fbo != NULL) { + if (nests.last()->fbo != nullptr) { nests.last()->fbo[0]->bind(); glClear(GL_COLOR_BUFFER_BIT); nests.last()->fbo[0]->release(); @@ -481,16 +481,16 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) Clip* c = s->clips.at(i); // if clip starts within one second and/or hasn't finished yet - if (c != NULL) { + if (c != nullptr) { if (!(!nests.isEmpty() && !same_sign(c->track, nests.last()->track))) { bool clip_is_active = false; - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { Footage* m = c->media->to_footage(); if (!m->invalid && !(c->track >= 0 && !is_audio_device_set())) { if (m->ready) { const FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream); - if (ms != NULL && is_clip_active(c, playhead)) { + if (ms != nullptr && is_clip_active(c, playhead)) { // if thread is already working, we don't want to touch this, // but we also don't want to hang the UI thread if (!c->open) { @@ -545,7 +545,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) Clip* c = current_clips.at(i); - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE && !c->finished_opening) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE && !c->finished_opening) { qWarning() << "Tried to display clip" << i << "but it's closed"; texture_failed = true; } else { @@ -554,11 +554,11 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) int video_width = c->getWidth(); int video_height = c->getHeight(); - if (c->media != NULL) { + if (c->media != nullptr) { switch (c->media->get_type()) { case MEDIA_TYPE_FOOTAGE: // set up opengl texture - if (c->texture == NULL) { + if (c->texture == nullptr) { c->texture = new QOpenGLTexture(QOpenGLTexture::Target2D); c->texture->setSize(c->stream->codecpar->width, c->stream->codecpar->height); c->texture->setFormat(get_gl_tex_fmt_from_av(c->pix_fmt)); @@ -575,14 +575,14 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } } - if (textureID == 0 && c->media != NULL) { + if (textureID == 0 && c->media != nullptr) { qWarning() << "Texture hasn't been created yet"; texture_failed = true; } else if (playhead >= c->get_timeline_in_with_transition()) { glPushMatrix(); // start preparing cache - if (c->fbo == NULL) { + if (c->fbo == nullptr) { c->fbo = new QOpenGLFramebufferObject* [2]; c->fbo[0] = new QOpenGLFramebufferObject(video_width, video_height); c->fbo[1] = new QOpenGLFramebufferObject(video_width, video_height); @@ -602,7 +602,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) GLuint composite_texture; - if (c->media == NULL) { + if (c->media == nullptr) { c->fbo[fbo_switcher]->bind(); glClear(GL_COLOR_BUFFER_BIT); c->fbo[fbo_switcher]->release(); @@ -644,35 +644,35 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) // EFFECT CODE START double timecode = get_timecode(c, playhead); - Effect* first_gizmo_effect = NULL; - Effect* selected_effect = NULL; + Effect* first_gizmo_effect = nullptr; + Effect* selected_effect = nullptr; for (int j=0;jeffects.size();j++) { Effect* e = c->effects.at(j); process_effect(c, e, timecode, coords, composite_texture, fbo_switcher, TA_NO_TRANSITION); if (e->are_gizmos_enabled()) { - if (first_gizmo_effect == NULL) first_gizmo_effect = e; + if (first_gizmo_effect == nullptr) first_gizmo_effect = e; if (e->container->selected) selected_effect = e; } } if (!rendering) { - if (selected_effect != NULL) { + if (selected_effect != nullptr) { gizmos = selected_effect; } else if (panel_timeline->is_clip_selected(c, true)) { gizmos = first_gizmo_effect; } } - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { int transition_progress = playhead - c->get_timeline_in_with_transition(); if (transition_progress < c->get_opening_transition()->get_length()) { process_effect(c, c->get_opening_transition(), (double)transition_progress/(double)c->get_opening_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_OPENING_TRANSITION); } } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { int transition_progress = playhead - (c->get_timeline_out_with_transition() - c->get_closing_transition()->get_length()); if (transition_progress >= 0 && transition_progress < c->get_closing_transition()->get_length()) { process_effect(c, c->get_closing_transition(), (double)transition_progress/(double)c->get_closing_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_CLOSING_TRANSITION); @@ -750,7 +750,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glBindTexture(GL_TEXTURE_2D, 0); // unbind texture - if (gizmos != NULL && !drawn_gizmos) { + if (gizmos != nullptr && !drawn_gizmos) { gizmos->gizmo_draw(timecode, coords); // set correct gizmo coords gizmos->gizmo_world_to_screen(); @@ -759,7 +759,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) if (!nests.isEmpty()) { nests.last()->fbo[0]->release(); - if (default_fbo != NULL) default_fbo->bind(); + if (default_fbo != nullptr) default_fbo->bind(); } glPopMatrix(); @@ -774,7 +774,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } } else { if (render_audio || (config.enable_audio_scrubbing && audio_scrub)) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { nests.append(c); compose_sequence(nests, render_audio); nests.removeLast(); @@ -810,7 +810,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glPopMatrix(); - if (!nests.isEmpty() && nests.last()->fbo != NULL) { + if (!nests.isEmpty() && nests.last()->fbo != nullptr) { // returns nested clip's texture return nests.last()->fbo[0]->texture(); } @@ -821,8 +821,8 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) void ViewerWidget::paintGL() { drawn_gizmos = false; force_quit = false; - if (viewer->seq != NULL) { - gizmos = NULL; + if (viewer->seq != nullptr) { + gizmos = nullptr; bool render_audio = (viewer->playing || rendering); bool loop = false; @@ -883,7 +883,7 @@ void ViewerWidget::paintGL() { drawTitleSafeArea(); } - if (gizmos != NULL && drawn_gizmos) { + if (gizmos != nullptr && drawn_gizmos) { float color[4]; glGetFloatv(GL_CURRENT_COLOR, color); From 6c31e458f7a8a84929cf1ab2bda763a6124b3a1d Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 13:29:10 +1100 Subject: [PATCH 21/25] updated some casts and warnings --- effects/internal/texteffect.cpp | 18 ++++++++++++++---- effects/internal/toneeffect.cpp | 18 +++++++----------- panels/timeline.cpp | 19 ++++++++----------- project/effect.cpp | 23 +++++++++++++---------- ui/graphview.cpp | 3 ++- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/effects/internal/texteffect.cpp b/effects/internal/texteffect.cpp index 56b609f80..84f209bb6 100644 --- a/effects/internal/texteffect.cpp +++ b/effects/internal/texteffect.cpp @@ -142,7 +142,6 @@ void TextEffect::redraw(double timecode) { switch (halign_field->get_combo_data(timecode).toInt()) { case Qt::AlignLeft: text_x = 0; break; - case Qt::AlignHCenter: text_x = (width/2) - (fm.width(lines.at(i))/2); break; case Qt::AlignRight: text_x = width - fm.width(lines.at(i)); break; case Qt::AlignJustify: // add spaces until the string is too big @@ -167,12 +166,23 @@ void TextEffect::redraw(double timecode) { } } break; + case Qt::AlignHCenter: + default: + text_x = (width/2) - (fm.width(lines.at(i))/2); + break; } switch (valign_field->get_combo_data(timecode).toInt()) { - case Qt::AlignTop: text_y = (fm.height()*i)+fm.ascent(); break; - case Qt::AlignVCenter: text_y = ((height/2) - (text_height/2) - fm.descent()) + (fm.height()*(i+1)); break; - case Qt::AlignBottom: text_y = (height - text_height - fm.descent()) + (fm.height()*(i+1)); break; + case Qt::AlignTop: + text_y = (fm.height()*i)+fm.ascent(); + break; + case Qt::AlignBottom: + text_y = (height - text_height - fm.descent()) + (fm.height()*(i+1)); + break; + case Qt::AlignVCenter: + default: + text_y = ((height/2) - (text_height/2) - fm.descent()) + (fm.height()*(i+1)); + break; } path.addText(text_x, text_y, font, lines.at(i)); diff --git a/effects/internal/toneeffect.cpp b/effects/internal/toneeffect.cpp index 1df21ff5c..dc5f4fc26 100644 --- a/effects/internal/toneeffect.cpp +++ b/effects/internal/toneeffect.cpp @@ -31,26 +31,22 @@ void ToneEffect::process_audio(double timecode_start, double timecode_end, quint for (int i=0;iget_double_value(timecode, true))/parent_clip->sequence->audio_frequency)*log_volume(amount_val->get_double_value(timecode, true)*0.01)*INT16_MAX; + qint16 left_tone_sample = qint16(qRound(qSin((2*M_PI*sinX*freq_val->get_double_value(timecode, true))/parent_clip->sequence->audio_frequency)*log_volume(amount_val->get_double_value(timecode, true)*0.01)*INT16_MAX)); qint16 right_tone_sample = left_tone_sample; // mix with source audio if (mix_val->get_bool_value(timecode, true)) { - qint16 left_sample = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF)); - qint16 right_sample = (qint16) (((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF)); + qint16 left_sample = qint16(((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF)); + qint16 right_sample = qint16(((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF)); left_tone_sample = mix_audio_sample(left_tone_sample, left_sample); right_tone_sample = mix_audio_sample(right_tone_sample, right_sample); } - samples[i+3] = (quint8) (right_tone_sample >> 8); - samples[i+2] = (quint8) right_tone_sample; - samples[i+1] = (quint8) (left_tone_sample >> 8); - samples[i] = (quint8) left_tone_sample; + samples[i+3] = quint8(right_tone_sample >> 8); + samples[i+2] = quint8(right_tone_sample); + samples[i+1] = quint8(left_tone_sample >> 8); + samples[i] = quint8(left_tone_sample); - int presin = sinX; sinX++; - if (sinX < presin) { - qWarning() << "Tone effect overflowed"; - } } } diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 4bf1a2953..2188004e7 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -40,7 +40,7 @@ #include long refactor_frame_number(long framenumber, double source_frame_rate, double target_frame_rate) { - return qRound(((double)framenumber/source_frame_rate)*target_frame_rate); + return qRound((double(framenumber)/source_frame_rate)*target_frame_rate); } Timeline::Timeline(QWidget *parent) : @@ -78,7 +78,7 @@ Timeline::Timeline(QWidget *parent) : setup_ui(); - default_track_height = (QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96) * TRACK_DEFAULT_HEIGHT; + default_track_height = qRound((QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96) * TRACK_DEFAULT_HEIGHT); headers->viewer = panel_sequence_viewer; @@ -150,7 +150,7 @@ void Timeline::toggle_show_all() { showing_all = !showing_all; if (showing_all) { old_zoom = zoom; - set_zoom_value((double) (timeline_area->width() - 200) / (double) sequence->getEndFrame()); + set_zoom_value(double(timeline_area->width() - 200) / double(sequence->getEndFrame())); } else { set_zoom_value(old_zoom); } @@ -166,7 +166,6 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector Media* medium = media_list.at(i); Footage* m = nullptr; Sequence* s = nullptr; - void* media = nullptr; long sequence_length = 0; long default_clip_in = 0; long default_clip_out = 0; @@ -174,7 +173,6 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector switch (medium->get_type()) { case MEDIA_TYPE_FOOTAGE: m = medium->to_footage(); - media = m; can_import = m->ready; if (m->using_inout) { double source_fr = 30; @@ -187,7 +185,6 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector s = medium->to_sequence(); sequence_length = s->getEndFrame(); if (seq != nullptr) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, seq->frame_rate); - media = s; can_import = (s != seq && sequence_length != 0); if (s->using_workarea) { default_clip_in = refactor_frame_number(s->workarea_in, s->frame_rate, seq->frame_rate); @@ -671,7 +668,7 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) { } if (pre->get_closing_transition() != nullptr) { ca->append(new DeleteTransitionCommand(pre->sequence, pre->closing_transition)); - if (pre->get_closing_transition()->secondary_clip == nullptr) post->get_closing_transition()->set_length(qMin((long) post->get_closing_transition()->get_true_length(), post->getLength())); + if (pre->get_closing_transition()->secondary_clip == nullptr) post->get_closing_transition()->set_length(qMin(long(post->get_closing_transition()->get_true_length()), post->getLength())); } return post; @@ -1458,7 +1455,7 @@ void Timeline::deselect() { } long getFrameFromScreenPoint(double zoom, int x) { - long f = qCeil((float) x / zoom); + long f = qCeil(double(x) / zoom); if (f < 0) { return 0; } @@ -1466,7 +1463,7 @@ long getFrameFromScreenPoint(double zoom, int x) { } int getScreenPointFromFrame(double zoom, long frame) { - return (int) qFloor(frame*zoom); + return qFloor(double(frame)*zoom); } long Timeline::getTimelineFrameFromScreenPoint(int x) { @@ -1824,13 +1821,13 @@ void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int if (verify_transitions) { if (c->get_opening_transition() != nullptr && c->get_opening_transition()->secondary_clip != nullptr && c->get_opening_transition()->secondary_clip->timeline_out != iin) { // separate transition - ca->append(new SetPointer((void**) &c->get_opening_transition()->secondary_clip, nullptr)); + ca->append(new SetPointer(reinterpret_cast(&c->get_opening_transition()->secondary_clip), nullptr)); ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, nullptr, c->get_opening_transition(), nullptr, TA_CLOSING_TRANSITION, 0)); } if (c->get_closing_transition() != nullptr && c->get_closing_transition()->secondary_clip != nullptr && c->get_closing_transition()->parent_clip->timeline_in != iout) { // separate transition - ca->append(new SetPointer((void**) &c->get_closing_transition()->secondary_clip, nullptr)); + ca->append(new SetPointer(reinterpret_cast(&c->get_closing_transition()->secondary_clip), nullptr)); ca->append(new AddTransitionCommand(c, nullptr, c->get_closing_transition(), nullptr, TA_CLOSING_TRANSITION, 0)); } } diff --git a/project/effect.cpp b/project/effect.cpp index c28f20a53..6e3b398c7 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -268,9 +268,9 @@ Effect::Effect(Clip* c, const EffectMeta *em) : enable_image(false), glslProgram(nullptr), texture(nullptr), + enable_always_update(false), isOpen(false), - bound(false), - enable_always_update(false) + bound(false) { // set up base UI container = new CollapsibleWidget(); @@ -366,11 +366,11 @@ Effect::Effect(Clip* c, const EffectMeta *em) : } else if (attr.name() == "b") { color.setBlue(attr.value().toInt()); } else if (attr.name() == "rf") { - color.setRedF(attr.value().toFloat()); + color.setRedF(attr.value().toDouble()); } else if (attr.name() == "gf") { - color.setGreenF(attr.value().toFloat()); + color.setGreenF(attr.value().toDouble()); } else if (attr.name() == "bf") { - color.setBlueF(attr.value().toFloat()); + color.setBlueF(attr.value().toDouble()); } else if (attr.name() == "hex") { color.setNamedColor(attr.value().toString()); } @@ -655,7 +655,6 @@ void Effect::load(QXmlStreamReader& stream) { if (stream.name() == "field" && stream.isStartElement()) { if (field_count < row->fieldCount()) { // match field using ID - bool found_field_by_id = false; int field_number = field_count; for (int k=0;kfieldCount();l++) { if (row->field(l)->id == attr.value()) { field_number = l; - found_field_by_id = true; qInfo() << "Found field by ID"; break; } @@ -874,7 +872,7 @@ Effect* Effect::copy(Clip* c) { void Effect::process_shader(double timecode, GLTextureCoords&) { glslProgram->setUniformValue("resolution", parent_clip->getWidth(), parent_clip->getHeight()); - glslProgram->setUniformValue("time", (GLfloat) timecode); + glslProgram->setUniformValue("time", GLfloat(timecode)); for (int i=0;iid.isEmpty()) { switch (field->type) { case EFFECT_FIELD_DOUBLE: - glslProgram->setUniformValue(field->id.toUtf8().constData(), (GLfloat) field->get_double_value(timecode)); + glslProgram->setUniformValue(field->id.toUtf8().constData(), GLfloat(field->get_double_value(timecode))); break; case EFFECT_FIELD_COLOR: - glslProgram->setUniformValue(field->id.toUtf8().constData(), field->get_color_value(timecode).redF(), field->get_color_value(timecode).greenF(), field->get_color_value(timecode).blueF()); + glslProgram->setUniformValue( + field->id.toUtf8().constData(), + GLfloat(field->get_color_value(timecode).redF()), + GLfloat(field->get_color_value(timecode).greenF()), + GLfloat(field->get_color_value(timecode).blueF()) + ); break; case EFFECT_FIELD_STRING: break; // can you even send a string to a uniform value? case EFFECT_FIELD_BOOL: diff --git a/ui/graphview.cpp b/ui/graphview.cpp index 36251f308..21d89a1c0 100644 --- a/ui/graphview.cpp +++ b/ui/graphview.cpp @@ -221,7 +221,8 @@ void GraphView::paintEvent(QPaintEvent *) { // sort keyframes by time QVector sorted_keys = sort_keys_from_field(field); - int last_key_x, last_key_y; + int last_key_x = 0; + int last_key_y = 0; // draw lines for (int j=0;j Date: Sat, 12 Jan 2019 15:18:40 +1100 Subject: [PATCH 22/25] wrapped all string literals with tr() --- dialogs/preferencesdialog.cpp | 144 ++++++++------- mainwindow.cpp | 338 ++++++++++++++++++++-------------- 2 files changed, 269 insertions(+), 213 deletions(-) diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index d0486029e..5e8997ace 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -40,13 +40,13 @@ void KeySequenceEditor::reset_to_default() { } QString KeySequenceEditor::action_name() { - return action->text().replace("&", ""); + return action->property("id").toString(); } QString KeySequenceEditor::export_shortcut() { QString ks = keySequence().toString(); if (ks != action->property("default")) { - return action->text().replace("&", "") + "\t" + keySequence().toString(); + return action->property("id").toString() + "\t" + keySequence().toString(); } return 0; } @@ -54,7 +54,7 @@ QString KeySequenceEditor::export_shortcut() { PreferencesDialog::PreferencesDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle(tr("Preferences")); + setWindowTitle(tr("Preferences")); setup_ui(); accurateSeekButton->setChecked(!config.fast_seeking); @@ -102,24 +102,26 @@ void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) { } for (int i=0;isetItemWidget(key_shortcut_items.at(i), 1, editor); - key_shortcut_fields.append(editor); + if (!key_shortcut_actions.at(i)->property("id").isNull()) { + KeySequenceEditor* editor = new KeySequenceEditor(keyboard_tree, key_shortcut_actions.at(i)); + keyboard_tree->setItemWidget(key_shortcut_items.at(i), 1, editor); + key_shortcut_fields.append(editor); + } } } void PreferencesDialog::save() { - if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) { - QMessageBox::critical( - this, - tr("Invalid CSS File"), - tr("CSS file '%1' does not exist.").arg(custom_css_fn->text()) - ); - return; - } + if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) { + QMessageBox::critical( + this, + tr("Invalid CSS File"), + tr("CSS file '%1' does not exist.").arg(custom_css_fn->text()) + ); + return; + } - config.css_path = custom_css_fn->text(); - mainWindow->load_css_from_file(config.css_path); + config.css_path = custom_css_fn->text(); + mainWindow->load_css_from_file(config.css_path); config.recording_mode = recordingComboBox->currentIndex() + 1; config.img_seq_formats = imgSeqFormatEdit->text(); config.fast_seeking = fastSeekButton->isChecked(); @@ -146,11 +148,11 @@ void PreferencesDialog::reset_default_shortcut() { } void PreferencesDialog::reset_all_shortcuts() { - if (QMessageBox::question( - this, - tr("Confirm Reset All Shortcuts"), - tr("Are you sure you wish to reset all keyboard shortcuts to their defaults?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + if (QMessageBox::question( + this, + tr("Confirm Reset All Shortcuts"), + tr("Are you sure you wish to reset all keyboard shortcuts to their defaults?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { for (int i=0;ireset_to_default(); } @@ -199,7 +201,7 @@ bool PreferencesDialog::refine_shortcut_list(const QString &s, QTreeWidgetItem* } void PreferencesDialog::load_shortcut_file() { - QString fn = QFileDialog::getOpenFileName(this, tr("Import Keyboard Shortcuts")); + QString fn = QFileDialog::getOpenFileName(this, tr("Import Keyboard Shortcuts")); if (!fn.isEmpty()) { QFile f(fn); if (f.exists() && f.open(QFile::ReadOnly)) { @@ -214,24 +216,24 @@ void PreferencesDialog::load_shortcut_file() { while (index < ba.size() && ba.at(index) != '\n') { ks.append(ba.at(index)); index++; - } + } key_shortcut_fields.at(i)->setKeySequence(ks); } else { key_shortcut_fields.at(i)->reset_to_default(); } } } else { - QMessageBox::critical( - this, - tr("Error saving shortcuts"), - tr("Failed to open file for reading") - ); + QMessageBox::critical( + this, + tr("Error saving shortcuts"), + tr("Failed to open file for reading") + ); } } } void PreferencesDialog::save_shortcut_file() { - QString fn = QFileDialog::getSaveFileName(this, tr("Export Keyboard Shortcuts")); + QString fn = QFileDialog::getSaveFileName(this, tr("Export Keyboard Shortcuts")); if (!fn.isEmpty()) { QFile f(fn); if (f.open(QFile::WriteOnly)) { @@ -244,19 +246,19 @@ void PreferencesDialog::save_shortcut_file() { start = false; } } - QMessageBox::information(this, tr("Export Shortcuts"), tr("Shortcuts exported successfully")); f.close(); + QMessageBox::information(this, tr("Export Shortcuts"), tr("Shortcuts exported successfully")); } else { - QMessageBox::critical(this, tr("Error saving shortcuts"), tr("Failed to open file for writing")); + QMessageBox::critical(this, tr("Error saving shortcuts"), tr("Failed to open file for writing")); } - } + } } void PreferencesDialog::browse_css_file() { - QString fn = QFileDialog::getOpenFileName(this, tr("Browse for CSS file")); - if (!fn.isEmpty()) { - custom_css_fn->setText(fn); - } + QString fn = QFileDialog::getOpenFileName(this, tr("Browse for CSS file")); + if (!fn.isEmpty()) { + custom_css_fn->setText(fn); + } } void PreferencesDialog::setup_ui() { @@ -266,120 +268,120 @@ void PreferencesDialog::setup_ui() { QTabWidget* general_tab = new QTabWidget(); QGridLayout* general_layout = new QGridLayout(general_tab); - general_layout->addWidget(new QLabel(tr("Custom CSS:")), 0, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Custom CSS:")), 0, 0, 1, 1); - custom_css_fn = new QLineEdit(general_tab); - custom_css_fn->setText(config.css_path); - general_layout->addWidget(custom_css_fn, 0, 1, 1, 1); + custom_css_fn = new QLineEdit(general_tab); + custom_css_fn->setText(config.css_path); + general_layout->addWidget(custom_css_fn, 0, 1, 1, 1); - QPushButton* custom_css_browse = new QPushButton(tr("Browse"), general_tab); - connect(custom_css_browse, SIGNAL(clicked(bool)), this, SLOT(browse_css_file())); - general_layout->addWidget(custom_css_browse, 0, 2, 1, 1); + QPushButton* custom_css_browse = new QPushButton(tr("Browse"), general_tab); + connect(custom_css_browse, SIGNAL(clicked(bool)), this, SLOT(browse_css_file())); + general_layout->addWidget(custom_css_browse, 0, 2, 1, 1); - general_layout->addWidget(new QLabel(tr("Image sequence formats:")), 1, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Image sequence formats:")), 1, 0, 1, 1); imgSeqFormatEdit = new QLineEdit(general_tab); - general_layout->addWidget(imgSeqFormatEdit, 1, 1, 1, 2); + general_layout->addWidget(imgSeqFormatEdit, 1, 1, 1, 2); - general_layout->addWidget(new QLabel(tr("Audio Recording:")), 2, 0, 1, 1); + general_layout->addWidget(new QLabel(tr("Audio Recording:")), 2, 0, 1, 1); recordingComboBox = new QComboBox(general_tab); - recordingComboBox->addItem(tr("Mono")); - recordingComboBox->addItem(tr("Stereo")); + recordingComboBox->addItem(tr("Mono")); + recordingComboBox->addItem(tr("Stereo")); - general_layout->addWidget(recordingComboBox, 2, 1, 1, 2); + general_layout->addWidget(recordingComboBox, 2, 1, 1, 2); - tabWidget->addTab(general_tab, tr("General")); + tabWidget->addTab(general_tab, tr("General")); QWidget* behavior_tab = new QWidget(); - tabWidget->addTab(behavior_tab, tr("Behavior")); + tabWidget->addTab(behavior_tab, tr("Behavior")); // Playback QWidget* playback_tab = new QWidget(); 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")); disable_img_multithread->setChecked(config.disable_multithreading_for_images); playback_tab_layout->addWidget(disable_img_multithread); // Playback -> Seeking QGroupBox* seeking_group = new QGroupBox(playback_tab); - seeking_group->setTitle(tr("Seeking")); + seeking_group->setTitle(tr("Seeking")); QVBoxLayout* seeking_group_layout = new QVBoxLayout(seeking_group); accurateSeekButton = new QRadioButton(seeking_group); - accurateSeekButton->setText(tr("Accurate Seeking\nAlways show the correct frame (visual may pause briefly as correct frame is retrieved)")); + accurateSeekButton->setText(tr("Accurate Seeking\nAlways show the correct frame (visual may pause briefly as correct frame is retrieved)")); seeking_group_layout->addWidget(accurateSeekButton); fastSeekButton = new QRadioButton(seeking_group); - fastSeekButton->setText(tr("Fast Seeking\nSeek quickly (may briefly show inaccurate frames when seeking - doesn't affect playback/export)")); + fastSeekButton->setText(tr("Fast Seeking\nSeek quickly (may briefly show inaccurate frames when seeking - doesn't affect playback/export)")); seeking_group_layout->addWidget(fastSeekButton); playback_tab_layout->addWidget(seeking_group); // Playback -> Memory Usage QGroupBox* memory_usage_group = new QGroupBox(playback_tab); - memory_usage_group->setTitle(tr("Memory Usage")); + 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); + memory_usage_layout->addWidget(new QLabel(tr("Upcoming Frame Queue:")), 0, 0); upcoming_queue_spinbox = new QDoubleSpinBox(); 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->addItem(tr("frames")); - upcoming_queue_type->addItem(tr("seconds")); + 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); + memory_usage_layout->addWidget(new QLabel(tr("Previous Frame Queue:")), 1, 0); previous_queue_spinbox = new QDoubleSpinBox(); 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->addItem(tr("frames")); - previous_queue_type->addItem(tr("seconds")); + previous_queue_type->addItem(tr("frames")); + previous_queue_type->addItem(tr("seconds")); previous_queue_type->setCurrentIndex(config.previous_queue_type); memory_usage_layout->addWidget(previous_queue_type, 1, 2); playback_tab_layout->addWidget(memory_usage_group); - tabWidget->addTab(playback_tab, tr("Playback")); + tabWidget->addTab(playback_tab, tr("Playback")); QWidget* shortcut_tab = new QWidget(); QVBoxLayout* shortcut_layout = new QVBoxLayout(shortcut_tab); QLineEdit* key_search_line = new QLineEdit(); - key_search_line->setPlaceholderText(tr("Search for action or shortcut")); + 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(); QTreeWidgetItem* tree_header = keyboard_tree->headerItem(); - tree_header->setText(0, tr("Action")); - tree_header->setText(1, tr("Shortcut")); + tree_header->setText(0, tr("Action")); + tree_header->setText(1, tr("Shortcut")); shortcut_layout->addWidget(keyboard_tree); QHBoxLayout* reset_shortcut_layout = new QHBoxLayout(); - QPushButton* import_shortcut_button = new QPushButton(tr("Import")); + QPushButton* import_shortcut_button = new QPushButton(tr("Import")); 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")); 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")); 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")); reset_shortcut_layout->addWidget(reset_all_shortcut_button); connect(reset_all_shortcut_button, SIGNAL(clicked(bool)), this, SLOT(reset_all_shortcuts())); shortcut_layout->addLayout(reset_shortcut_layout); - tabWidget->addTab(shortcut_tab, tr("Keyboard")); + tabWidget->addTab(shortcut_tab, tr("Keyboard")); verticalLayout->addWidget(tabWidget); diff --git a/mainwindow.cpp b/mainwindow.cpp index d87a37630..5a1b6e88f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -217,7 +217,7 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) : // detect auto-recovery file autorecovery_filename = data_dir + "/autorecovery.ove"; if (QFile::exists(autorecovery_filename)) { - if (QMessageBox::question(nullptr, "Auto-recovery", "Olive didn't close properly and an autorecovery file was detected. Would you like to open it?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { + if (QMessageBox::question(nullptr, tr("Auto-recovery"), tr("Olive didn't close properly and an autorecovery file was detected. Would you like to open it?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { enable_launch_with_project = false; open_project_worker(autorecovery_filename, true); } @@ -244,20 +244,20 @@ void MainWindow::launch_with_project(const QString& s) { } void MainWindow::make_new_menu(QMenu *parent) { - parent->addAction("&Project", this, SLOT(new_project()), QKeySequence("Ctrl+N")); + parent->addAction(tr("&Project"), this, SLOT(new_project()), QKeySequence("Ctrl+N"))->setProperty("id", "newproj"); parent->addSeparator(); - parent->addAction("&Sequence", this, SLOT(new_sequence()), QKeySequence("Ctrl+Shift+N")); - parent->addAction("&Folder", this, SLOT(new_folder())); + parent->addAction(tr("&Sequence"), this, SLOT(new_sequence()), QKeySequence("Ctrl+Shift+N"))->setProperty("id", "newseq"); + parent->addAction(tr("&Folder"), this, SLOT(new_folder()))->setProperty("id", "newfolder"); } void MainWindow::make_inout_menu(QMenu *parent) { - parent->addAction("Set In Point", this, SLOT(set_in_point()), QKeySequence("I")); - parent->addAction("Set Out Point", this, SLOT(set_out_point()), QKeySequence("O")); - parent->addAction("Enable/Disable In/Out Point", this, SLOT(enable_inout())); + parent->addAction(tr("Set In Point"), this, SLOT(set_in_point()), QKeySequence("I"))->setProperty("id", "setinpoint"); + parent->addAction(tr("Set Out Point"), this, SLOT(set_out_point()), QKeySequence("O"))->setProperty("id", "setoutpoint"); + parent->addAction(tr("Enable/Disable In/Out Point"), this, SLOT(enable_inout()))->setProperty("id", "enableinout"); parent->addSeparator(); - parent->addAction("Reset In Point", this, SLOT(clear_in())); - parent->addAction("Reset Out Point", this, SLOT(clear_out())); - parent->addAction("Clear In/Out Point", this, SLOT(clear_inout()), QKeySequence("G")); + parent->addAction(tr("Reset In Point"), this, SLOT(clear_in()))->setProperty("id", "resetin"); + parent->addAction(tr("Reset Out Point"), this, SLOT(clear_out()))->setProperty("id", "resetout"); + parent->addAction(tr("Clear In/Out Point"), this, SLOT(clear_inout()), QKeySequence("G"))->setProperty("id", "clearinout"); } void kbd_shortcut_processor(QByteArray& file, QMenu* menu, bool save, bool first) { @@ -274,7 +274,7 @@ void kbd_shortcut_processor(QByteArray& file, QMenu* menu, bool save, bool first if (a->shortcut() != defks) { // custom shortcut if (!file.isEmpty()) file.append('\n'); - file.append(a->text().replace("&", "")); + file.append(a->property("id").toString()); file.append('\t'); file.append(a->shortcut().toString()); } @@ -288,18 +288,20 @@ void kbd_shortcut_processor(QByteArray& file, QMenu* menu, bool save, bool first // restore default shortcut a->setShortcut(a->property("default").toString()); } - QString comp_str = a->text().replace("&", ""); - int shortcut_index = file.indexOf(comp_str); - if (shortcut_index == 0 || (shortcut_index > 0 && file.at(shortcut_index-1) == '\n')) { - shortcut_index += comp_str.size() + 1; - QString shortcut; - while (shortcut_index < file.size() && file.at(shortcut_index) != '\n') { - shortcut.append(file.at(shortcut_index)); - shortcut_index++; - } - QKeySequence ks(shortcut); - if (!ks.isEmpty()) { - a->setShortcut(ks); + if (!a->property("id").isNull()) { + QString comp_str = a->property("id").toString(); + int shortcut_index = file.indexOf(comp_str); + if (shortcut_index == 0 || (shortcut_index > 0 && file.at(shortcut_index-1) == '\n')) { + shortcut_index += comp_str.size() + 1; + QString shortcut; + while (shortcut_index < file.size() && file.at(shortcut_index) != '\n') { + shortcut.append(file.at(shortcut_index)); + shortcut_index++; + } + QKeySequence ks(shortcut); + if (!ks.isEmpty()) { + a->setShortcut(ks); + } } } } @@ -416,7 +418,7 @@ void MainWindow::zoom_out() { void MainWindow::export_dialog() { if (sequence == nullptr) { - QMessageBox::information(this, "No active sequence", "Please open the sequence you wish to export.", QMessageBox::Ok); + QMessageBox::information(this, tr("No active sequence"), tr("Please open the sequence you wish to export."), QMessageBox::Ok); } else { ExportDialog e(this); e.exec(); @@ -506,7 +508,7 @@ void MainWindow::autorecover_interval() { } bool MainWindow::save_project_as() { - QString fn = QFileDialog::getSaveFileName(this, "Save Project As...", "", OLIVE_FILE_FILTER); + QString fn = QFileDialog::getSaveFileName(this, tr("Save Project As..."), "", OLIVE_FILE_FILTER); if (!fn.isEmpty()) { if (!fn.endsWith(".ove", Qt::CaseInsensitive)) { fn += ".ove"; @@ -531,8 +533,8 @@ bool MainWindow::can_close_project() { if (isWindowModified()) { QMessageBox* m = new QMessageBox( QMessageBox::Question, - "Unsaved Project", - "This project has changed since it was last saved. Would you like to save it before closing?", + tr("Unsaved Project"), + tr("This project has changed since it was last saved. Would you like to save it before closing?"), QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, this ); @@ -553,341 +555,390 @@ void MainWindow::setup_menus() { // INITIALIZE FILE MENU - QMenu* file_menu = menuBar->addMenu("&File"); + QMenu* file_menu = menuBar->addMenu(tr("&File")); connect(file_menu, SIGNAL(aboutToShow()), this, SLOT(fileMenu_About_To_Be_Shown())); - QMenu* new_menu = file_menu->addMenu("&New"); + QMenu* new_menu = file_menu->addMenu(tr("&New")); make_new_menu(new_menu); - file_menu->addAction("&Open Project", this, SLOT(open_project()), QKeySequence("Ctrl+O")); + file_menu->addAction(tr("&Open Project"), this, SLOT(open_project()), QKeySequence("Ctrl+O"))->setProperty("id", "openproj"); - clear_open_recent_action = new QAction("Clear Recent List"); + clear_open_recent_action = new QAction(tr("Clear Recent List")); + clear_open_recent_action->setProperty("id", "clearopenrecent"); connect(clear_open_recent_action, SIGNAL(triggered()), panel_project, SLOT(clear_recent_projects())); - open_recent = file_menu->addMenu("Open Recent"); + open_recent = file_menu->addMenu(tr("Open Recent")); open_recent->addAction(clear_open_recent_action); - file_menu->addAction("&Save Project", this, SLOT(save_project()), QKeySequence("Ctrl+S")); - file_menu->addAction("Save Project &As", this, SLOT(save_project_as()), QKeySequence("Ctrl+Shift+S")); + file_menu->addAction(tr("&Save Project"), this, SLOT(save_project()), QKeySequence("Ctrl+S"))->setProperty("id", "saveproj"); + file_menu->addAction(tr("Save Project &As"), this, SLOT(save_project_as()), QKeySequence("Ctrl+Shift+S"))->setProperty("id", "saveprojas"); file_menu->addSeparator(); - file_menu->addAction("&Import...", panel_project, SLOT(import_dialog()), QKeySequence("Ctrl+I")); + file_menu->addAction(tr("&Import..."), panel_project, SLOT(import_dialog()), QKeySequence("Ctrl+I"))->setProperty("id", "import"); file_menu->addSeparator(); - file_menu->addAction("&Export...", this, SLOT(export_dialog()), QKeySequence("Ctrl+M")); + file_menu->addAction(tr("&Export..."), this, SLOT(export_dialog()), QKeySequence("Ctrl+M"))->setProperty("id", "export"); file_menu->addSeparator(); - file_menu->addAction("E&xit", this, SLOT(close())); + file_menu->addAction(tr("E&xit"), this, SLOT(close()))->setProperty("id", "exit"); // INITIALIZE EDIT MENU - QMenu* edit_menu = menuBar->addMenu("&Edit"); + QMenu* edit_menu = menuBar->addMenu(tr("&Edit")); connect(edit_menu, SIGNAL(aboutToShow()), this, SLOT(editMenu_About_To_Be_Shown())); - undo_action = edit_menu->addAction("&Undo", this, SLOT(undo()), QKeySequence("Ctrl+Z")); - redo_action = edit_menu->addAction("Redo", this, SLOT(redo()), QKeySequence("Ctrl+Shift+Z")); + undo_action = edit_menu->addAction(tr("&Undo"), this, SLOT(undo()), QKeySequence("Ctrl+Z")); + undo_action->setProperty("id", "undo"); + redo_action = edit_menu->addAction(tr("Redo"), this, SLOT(redo()), QKeySequence("Ctrl+Shift+Z")); + redo_action->setProperty("id", "redo"); edit_menu->addSeparator(); - edit_menu->addAction("Cu&t", this, SLOT(cut()), QKeySequence("Ctrl+X")); - edit_menu->addAction("Cop&y", this, SLOT(copy()), QKeySequence("Ctrl+C")); - edit_menu->addAction("&Paste", this, SLOT(paste()), QKeySequence("Ctrl+V")); - edit_menu->addAction("Paste Insert", this, SLOT(paste_insert()), QKeySequence("Ctrl+Shift+V")); - edit_menu->addAction("Duplicate", this, SLOT(duplicate()), QKeySequence("Ctrl+D")); - edit_menu->addAction("Delete", this, SLOT(delete_slot()), QKeySequence("Del")); - edit_menu->addAction("Ripple Delete", this, SLOT(ripple_delete()), QKeySequence("Shift+Del")); - edit_menu->addAction("Split", panel_timeline, SLOT(split_at_playhead()), QKeySequence("Ctrl+K")); + edit_menu->addAction(tr("Cu&t"), this, SLOT(cut()), QKeySequence("Ctrl+X"))->setProperty("id", "cut"); + edit_menu->addAction(tr("Cop&y"), this, SLOT(copy()), QKeySequence("Ctrl+C"))->setProperty("id", "copy"); + edit_menu->addAction(tr("&Paste"), this, SLOT(paste()), QKeySequence("Ctrl+V"))->setProperty("id", "paste"); + edit_menu->addAction(tr("Paste Insert"), this, SLOT(paste_insert()), QKeySequence("Ctrl+Shift+V"))->setProperty("id", "pasteinsert"); + edit_menu->addAction(tr("Duplicate"), this, SLOT(duplicate()), QKeySequence("Ctrl+D"))->setProperty("id", "duplicate"); + edit_menu->addAction(tr("Delete"), this, SLOT(delete_slot()), QKeySequence("Del"))->setProperty("id", "delete"); + edit_menu->addAction(tr("Ripple Delete"), this, SLOT(ripple_delete()), QKeySequence("Shift+Del"))->setProperty("id", "rippledelete"); + edit_menu->addAction(tr("Split"), panel_timeline, SLOT(split_at_playhead()), QKeySequence("Ctrl+K"))->setProperty("id", "split"); edit_menu->addSeparator(); - edit_menu->addAction("Select &All", this, SLOT(select_all()), QKeySequence("Ctrl+A")); + edit_menu->addAction(tr("Select &All"), this, SLOT(select_all()), QKeySequence("Ctrl+A"))->setProperty("id", "selectall"); - edit_menu->addAction("Deselect All", panel_timeline, SLOT(deselect()), QKeySequence("Ctrl+Shift+A")); + edit_menu->addAction(tr("Deselect All"), panel_timeline, SLOT(deselect()), QKeySequence("Ctrl+Shift+A"))->setProperty("id", "deselectall"); edit_menu->addSeparator(); - edit_menu->addAction("Add Default Transition", this, SLOT(add_default_transition()), QKeySequence("Ctrl+Shift+D")); - edit_menu->addAction("Link/Unlink", panel_timeline, SLOT(toggle_links()), QKeySequence("Ctrl+L")); - edit_menu->addAction("Enable/Disable", this, SLOT(toggle_enable_clips()), QKeySequence("Shift+E")); - edit_menu->addAction("Nest", this, SLOT(nest())); + edit_menu->addAction(tr("Add Default Transition"), this, SLOT(add_default_transition()), QKeySequence("Ctrl+Shift+D"))->setProperty("id", "deftransition"); + edit_menu->addAction(tr("Link/Unlink"), panel_timeline, SLOT(toggle_links()), QKeySequence("Ctrl+L"))->setProperty("id", "linkunlink"); + edit_menu->addAction(tr("Enable/Disable"), this, SLOT(toggle_enable_clips()), QKeySequence("Shift+E"))->setProperty("id", "enabledisable"); + edit_menu->addAction(tr("Nest"), this, SLOT(nest()))->setProperty("id", "nest"); edit_menu->addSeparator(); - edit_menu->addAction("Ripple to In Point", this, SLOT(ripple_to_in_point()), QKeySequence("Q")); - edit_menu->addAction("Ripple to Out Point", this, SLOT(ripple_to_out_point()), QKeySequence("W")); - edit_menu->addAction("Edit to In Point", this, SLOT(edit_to_in_point()), QKeySequence("Ctrl+Alt+Q")); - edit_menu->addAction("Edit to Out Point", this, SLOT(edit_to_out_point()), QKeySequence("Ctrl+Alt+W")); + edit_menu->addAction(tr("Ripple to In Point"), this, SLOT(ripple_to_in_point()), QKeySequence("Q"))->setProperty("id", "rippletoin"); + edit_menu->addAction(tr("Ripple to Out Point"), this, SLOT(ripple_to_out_point()), QKeySequence("W"))->setProperty("id", "rippletoout"); + edit_menu->addAction(tr("Edit to In Point"), this, SLOT(edit_to_in_point()), QKeySequence("Ctrl+Alt+Q"))->setProperty("id", "edittoin"); + edit_menu->addAction(tr("Edit to Out Point"), this, SLOT(edit_to_out_point()), QKeySequence("Ctrl+Alt+W"))->setProperty("id", "edittoout"); edit_menu->addSeparator(); make_inout_menu(edit_menu); - edit_menu->addAction("Delete In/Out Point", this, SLOT(delete_inout()), QKeySequence(";")); - edit_menu->addAction("Ripple Delete In/Out Point", this, SLOT(ripple_delete_inout()), QKeySequence("'")); + edit_menu->addAction(tr("Delete In/Out Point"), this, SLOT(delete_inout()), QKeySequence(";"))->setProperty("id", "deleteinout"); + edit_menu->addAction(tr("Ripple Delete In/Out Point"), this, SLOT(ripple_delete_inout()), QKeySequence("'"))->setProperty("id", "rippledeleteinout"); edit_menu->addSeparator(); - edit_menu->addAction("Set/Edit Marker", this, SLOT(set_marker()), QKeySequence("M")); + edit_menu->addAction(tr("Set/Edit Marker"), this, SLOT(set_marker()), QKeySequence("M"))->setProperty("id", "marker"); // INITIALIZE VIEW MENU - QMenu* view_menu = menuBar->addMenu("&View"); + QMenu* view_menu = menuBar->addMenu(tr("&View")); connect(view_menu, SIGNAL(aboutToShow()), this, SLOT(viewMenu_About_To_Be_Shown())); - view_menu->addAction("Zoom In", this, SLOT(zoom_in()), QKeySequence("=")); - view_menu->addAction("Zoom Out", this, SLOT(zoom_out()), QKeySequence("-")); - view_menu->addAction("Increase Track Height", this, SLOT(zoom_in_tracks()), QKeySequence("Ctrl+=")); - view_menu->addAction("Decrease Track Height", this, SLOT(zoom_out_tracks()), QKeySequence("Ctrl+-")); + view_menu->addAction(tr("Zoom In"), this, SLOT(zoom_in()), QKeySequence("="))->setProperty("id", "zoomin"); + view_menu->addAction(tr("Zoom Out"), this, SLOT(zoom_out()), QKeySequence("-"))->setProperty("id", "zoomout"); + view_menu->addAction(tr("Increase Track Height"), this, SLOT(zoom_in_tracks()), QKeySequence("Ctrl+="))->setProperty("id", "vzoomin"); + view_menu->addAction(tr("Decrease Track Height"), this, SLOT(zoom_out_tracks()), QKeySequence("Ctrl+-"))->setProperty("id", "vzoomout"); - show_all = view_menu->addAction("Toggle Show All", panel_timeline, SLOT(toggle_show_all()), QKeySequence("\\")); + show_all = view_menu->addAction(tr("Toggle Show All"), panel_timeline, SLOT(toggle_show_all()), QKeySequence("\\")); + show_all->setProperty("id", "showall"); show_all->setCheckable(true); view_menu->addSeparator(); - track_lines = view_menu->addAction("Track Lines", this, SLOT(toggle_bool_action())); + track_lines = view_menu->addAction(tr("Track Lines"), this, SLOT(toggle_bool_action())); + track_lines->setProperty("id", "tracklines"); track_lines->setCheckable(true); track_lines->setData(reinterpret_cast(&config.show_track_lines)); - rectified_waveforms = view_menu->addAction("Rectified Waveforms", this, SLOT(toggle_bool_action())); + rectified_waveforms = view_menu->addAction(tr("Rectified Waveforms"), this, SLOT(toggle_bool_action())); + rectified_waveforms->setProperty("id", "rectifiedwaveforms"); rectified_waveforms->setCheckable(true); rectified_waveforms->setData(reinterpret_cast(&config.rectified_waveforms)); view_menu->addSeparator(); - frames_action = view_menu->addAction("Frames", this, SLOT(set_timecode_view())); + frames_action = view_menu->addAction(tr("Frames"), this, SLOT(set_timecode_view())); + frames_action->setProperty("id", "modeframes"); frames_action->setData(TIMECODE_FRAMES); frames_action->setCheckable(true); - drop_frame_action = view_menu->addAction("Drop Frame", this, SLOT(set_timecode_view())); + drop_frame_action = view_menu->addAction(tr("Drop Frame"), this, SLOT(set_timecode_view())); + drop_frame_action->setProperty("id", "modedropframe"); drop_frame_action->setData(TIMECODE_DROP); drop_frame_action->setCheckable(true); - nondrop_frame_action = view_menu->addAction("Non-Drop Frame", this, SLOT(set_timecode_view())); + nondrop_frame_action = view_menu->addAction(tr("Non-Drop Frame"), this, SLOT(set_timecode_view())); + nondrop_frame_action->setProperty("id", "modenondropframe"); nondrop_frame_action->setData(TIMECODE_NONDROP); nondrop_frame_action->setCheckable(true); - milliseconds_action = view_menu->addAction("Milliseconds", this, SLOT(set_timecode_view())); + milliseconds_action = view_menu->addAction(tr("Milliseconds"), this, SLOT(set_timecode_view())); + milliseconds_action->setProperty("id", "milliseconds"); milliseconds_action->setData(TIMECODE_MILLISECONDS); milliseconds_action->setCheckable(true); view_menu->addSeparator(); - QMenu* title_safe_area_menu = view_menu->addMenu("Title/Action Safe Area"); + QMenu* title_safe_area_menu = view_menu->addMenu(tr("Title/Action Safe Area")); - title_safe_off = title_safe_area_menu->addAction("Off"); + title_safe_off = title_safe_area_menu->addAction(tr("Off")); + title_safe_off->setProperty("id", "titlesafeoff"); title_safe_off->setCheckable(true); connect(title_safe_off, SIGNAL(triggered(bool)), this, SLOT(set_tsa_disable())); - title_safe_default = title_safe_area_menu->addAction("Default"); + title_safe_default = title_safe_area_menu->addAction(tr("Default")); + title_safe_default->setProperty("id", "titlesafedefault"); title_safe_default->setCheckable(true); connect(title_safe_default, SIGNAL(triggered(bool)), this, SLOT(set_tsa_default())); - title_safe_43 = title_safe_area_menu->addAction("4:3"); + title_safe_43 = title_safe_area_menu->addAction(tr("4:3")); + title_safe_43->setProperty("id", "titlesafe43"); title_safe_43->setCheckable(true); connect(title_safe_43, SIGNAL(triggered(bool)), this, SLOT(set_tsa_43())); - title_safe_169 = title_safe_area_menu->addAction("16:9"); + title_safe_169 = title_safe_area_menu->addAction(tr("16:9")); + title_safe_169->setProperty("id", "titlesafe169"); title_safe_169->setCheckable(true); connect(title_safe_169, SIGNAL(triggered(bool)), this, SLOT(set_tsa_169())); - title_safe_custom = title_safe_area_menu->addAction("Custom"); + title_safe_custom = title_safe_area_menu->addAction(tr("Custom")); + title_safe_custom->setProperty("id", "titlesafecustom"); title_safe_custom->setCheckable(true); connect(title_safe_custom, SIGNAL(triggered(bool)), this, SLOT(set_tsa_custom())); view_menu->addSeparator(); - full_screen = view_menu->addAction("Full Screen", this, SLOT(toggle_full_screen()), QKeySequence("F11")); + full_screen = view_menu->addAction(tr("Full Screen"), this, SLOT(toggle_full_screen()), QKeySequence("F11")); + full_screen->setProperty("id", "fullscreen"); full_screen->setCheckable(true); // INITIALIZE PLAYBACK MENU - QMenu* playback_menu = menuBar->addMenu("&Playback"); + QMenu* playback_menu = menuBar->addMenu(tr("&Playback")); - playback_menu->addAction("Go to Start", this, SLOT(go_to_start()), QKeySequence("Home")); - playback_menu->addAction("Previous Frame", this, SLOT(prev_frame()), QKeySequence("Left")); - playback_menu->addAction("Play/Pause", this, SLOT(playpause()), QKeySequence("Space")); - playback_menu->addAction("Next Frame", this, SLOT(next_frame()), QKeySequence("Right")); - playback_menu->addAction("Go to End", this, SLOT(go_to_end()), QKeySequence("End")); + playback_menu->addAction(tr("Go to Start"), this, SLOT(go_to_start()), QKeySequence("Home"))->setProperty("id", "gotostart"); + playback_menu->addAction(tr("Previous Frame"), this, SLOT(prev_frame()), QKeySequence("Left"))->setProperty("id", "prevframe"); + playback_menu->addAction(tr("Play/Pause"), this, SLOT(playpause()), QKeySequence("Space"))->setProperty("id", "playpause"); + playback_menu->addAction(tr("Next Frame"), this, SLOT(next_frame()), QKeySequence("Right"))->setProperty("id", "nextframe"); + playback_menu->addAction(tr("Go to End"), this, SLOT(go_to_end()), QKeySequence("End"))->setProperty("id", "gotoend"); playback_menu->addSeparator(); - playback_menu->addAction("Go to Previous Cut", this, SLOT(prev_cut()), QKeySequence("Up")); - playback_menu->addAction("Go to Next Cut", this, SLOT(next_cut()), QKeySequence("Down")); + playback_menu->addAction(tr("Go to Previous Cut"), this, SLOT(prev_cut()), QKeySequence("Up"))->setProperty("id", "prevcut"); + playback_menu->addAction(tr("Go to Next Cut"), this, SLOT(next_cut()), QKeySequence("Down"))->setProperty("id", "nextcut"); playback_menu->addSeparator(); - playback_menu->addAction("Go to In Point", this, SLOT(go_to_in()), QKeySequence("Shift+I")); - playback_menu->addAction("Go to Out Point", this, SLOT(go_to_out()), QKeySequence("Shift+O")); + playback_menu->addAction(tr("Go to In Point"), this, SLOT(go_to_in()), QKeySequence("Shift+I"))->setProperty("id", "gotoin"); + playback_menu->addAction(tr("Go to Out Point"), this, SLOT(go_to_out()), QKeySequence("Shift+O"))->setProperty("id", "gotoout"); // INITIALIZE WINDOW MENU - window_menu = menuBar->addMenu("&Window"); + window_menu = menuBar->addMenu(tr("&Window")); connect(window_menu, SIGNAL(aboutToShow()), this, SLOT(windowMenu_About_To_Be_Shown())); - QAction* window_project_action = window_menu->addAction("Project", this, SLOT(toggle_panel_visibility())); + QAction* window_project_action = window_menu->addAction(tr("Project"), this, SLOT(toggle_panel_visibility())); + window_project_action->setProperty("id", "panelproject"); window_project_action->setCheckable(true); window_project_action->setData(reinterpret_cast(panel_project)); - QAction* window_effectcontrols_action = window_menu->addAction("Effect Controls", this, SLOT(toggle_panel_visibility())); + QAction* window_effectcontrols_action = window_menu->addAction(tr("Effect Controls"), this, SLOT(toggle_panel_visibility())); + window_effectcontrols_action->setProperty("id", "paneleffectcontrols"); window_effectcontrols_action->setCheckable(true); window_effectcontrols_action->setData(reinterpret_cast(panel_effect_controls)); - QAction* window_timeline_action = window_menu->addAction("Timeline", this, SLOT(toggle_panel_visibility())); + QAction* window_timeline_action = window_menu->addAction(tr("Timeline"), this, SLOT(toggle_panel_visibility())); + window_timeline_action->setProperty("id", "paneltimeline"); window_timeline_action->setCheckable(true); window_timeline_action->setData(reinterpret_cast(panel_timeline)); - QAction* window_graph_editor_action = window_menu->addAction("Graph Editor", this, SLOT(toggle_panel_visibility())); + QAction* window_graph_editor_action = window_menu->addAction(tr("Graph Editor"), this, SLOT(toggle_panel_visibility())); + window_graph_editor_action->setProperty("id", "panelgrapheditor"); window_graph_editor_action->setCheckable(true); window_graph_editor_action->setData(reinterpret_cast(panel_graph_editor)); - QAction* window_footageviewer_action = window_menu->addAction("Footage Viewer", this, SLOT(toggle_panel_visibility())); + QAction* window_footageviewer_action = window_menu->addAction(tr("Footage Viewer"), this, SLOT(toggle_panel_visibility())); + window_footageviewer_action->setProperty("id", "panelfootageviewer"); window_footageviewer_action->setCheckable(true); window_footageviewer_action->setData(reinterpret_cast(panel_footage_viewer)); - QAction* window_sequenceviewer_action = window_menu->addAction("Sequence Viewer", this, SLOT(toggle_panel_visibility())); + QAction* window_sequenceviewer_action = window_menu->addAction(tr("Sequence Viewer"), this, SLOT(toggle_panel_visibility())); + window_sequenceviewer_action->setProperty("id", "panelsequenceviewer"); window_sequenceviewer_action->setCheckable(true); window_sequenceviewer_action->setData(reinterpret_cast(panel_sequence_viewer)); window_menu->addSeparator(); - window_menu->addAction("Reset to Default Layout", this, SLOT(reset_layout())); + window_menu->addAction(tr("Reset to Default Layout"), this, SLOT(reset_layout()))->setProperty("id", "resetdefaultlayout"); // INITIALIZE TOOLS MENU - QMenu* tools_menu = menuBar->addMenu("&Tools"); + QMenu* tools_menu = menuBar->addMenu(tr("&Tools")); connect(tools_menu, SIGNAL(aboutToShow()), this, SLOT(toolMenu_About_To_Be_Shown())); - pointer_tool_action = tools_menu->addAction("Pointer Tool", this, SLOT(menu_click_button()), QKeySequence("V")); + pointer_tool_action = tools_menu->addAction(tr("Pointer Tool"), this, SLOT(menu_click_button()), QKeySequence("V")); + pointer_tool_action->setProperty("id", "pointertool"); pointer_tool_action->setCheckable(true); pointer_tool_action->setData(reinterpret_cast(panel_timeline->toolArrowButton)); - edit_tool_action = tools_menu->addAction("Edit Tool", this, SLOT(menu_click_button()), QKeySequence("X")); + edit_tool_action = tools_menu->addAction(tr("Edit Tool"), this, SLOT(menu_click_button()), QKeySequence("X")); + edit_tool_action->setProperty("id", "edittool"); edit_tool_action->setCheckable(true); edit_tool_action->setData(reinterpret_cast(panel_timeline->toolEditButton)); - ripple_tool_action = tools_menu->addAction("Ripple Tool", this, SLOT(menu_click_button()), QKeySequence("B")); + ripple_tool_action = tools_menu->addAction(tr("Ripple Tool"), this, SLOT(menu_click_button()), QKeySequence("B")); + ripple_tool_action->setProperty("id", "rippletool"); ripple_tool_action->setCheckable(true); ripple_tool_action->setData(reinterpret_cast(panel_timeline->toolRippleButton)); - razor_tool_action = tools_menu->addAction("Razor Tool", this, SLOT(menu_click_button()), QKeySequence("C")); + razor_tool_action = tools_menu->addAction(tr("Razor Tool"), this, SLOT(menu_click_button()), QKeySequence("C")); + razor_tool_action->setProperty("id", "razortool"); razor_tool_action->setCheckable(true); razor_tool_action->setData(reinterpret_cast(panel_timeline->toolRazorButton)); - slip_tool_action = tools_menu->addAction("Slip Tool", this, SLOT(menu_click_button()), QKeySequence("Y")); + slip_tool_action = tools_menu->addAction(tr("Slip Tool"), this, SLOT(menu_click_button()), QKeySequence("Y")); + slip_tool_action->setProperty("id", "sliptool"); slip_tool_action->setCheckable(true); slip_tool_action->setData(reinterpret_cast(panel_timeline->toolSlipButton)); - slide_tool_action = tools_menu->addAction("Slide Tool", this, SLOT(menu_click_button()), QKeySequence("U")); + slide_tool_action = tools_menu->addAction(tr("Slide Tool"), this, SLOT(menu_click_button()), QKeySequence("U")); + slide_tool_action->setProperty("id", "slidetool"); slide_tool_action->setCheckable(true); slide_tool_action->setData(reinterpret_cast(panel_timeline->toolSlideButton)); - hand_tool_action = tools_menu->addAction("Hand Tool", this, SLOT(menu_click_button()), QKeySequence("H")); + hand_tool_action = tools_menu->addAction(tr("Hand Tool"), this, SLOT(menu_click_button()), QKeySequence("H")); + hand_tool_action->setProperty("id", "handtool"); hand_tool_action->setCheckable(true); hand_tool_action->setData(reinterpret_cast(panel_timeline->toolHandButton)); - transition_tool_action = tools_menu->addAction("Transition Tool", this, SLOT(menu_click_button()), QKeySequence("T")); + transition_tool_action = tools_menu->addAction(tr("Transition Tool"), this, SLOT(menu_click_button()), QKeySequence("T")); + transition_tool_action->setProperty("id", "transitiontool"); transition_tool_action->setCheckable(true); transition_tool_action->setData(reinterpret_cast(panel_timeline->toolTransitionButton)); tools_menu->addSeparator(); - snap_toggle = tools_menu->addAction("Enable Snapping", this, SLOT(menu_click_button()), QKeySequence("S")); + snap_toggle = tools_menu->addAction(tr("Enable Snapping"), this, SLOT(menu_click_button()), QKeySequence("S")); + snap_toggle->setProperty("id", "snapping"); snap_toggle->setCheckable(true); snap_toggle->setData(reinterpret_cast(panel_timeline->snappingButton)); tools_menu->addSeparator(); - selecting_also_seeks = tools_menu->addAction("Selecting Also Seeks", this, SLOT(toggle_bool_action())); + selecting_also_seeks = tools_menu->addAction(tr("Selecting Also Seeks"), this, SLOT(toggle_bool_action())); + selecting_also_seeks->setProperty("id", "selectingalsoseeks"); selecting_also_seeks->setCheckable(true); selecting_also_seeks->setData(reinterpret_cast(&config.select_also_seeks)); - edit_tool_also_seeks = tools_menu->addAction("Edit Tool Also Seeks", this, SLOT(toggle_bool_action())); + edit_tool_also_seeks = tools_menu->addAction(tr("Edit Tool Also Seeks"), this, SLOT(toggle_bool_action())); + edit_tool_also_seeks->setProperty("id", "editalsoseeks"); edit_tool_also_seeks->setCheckable(true); edit_tool_also_seeks->setData(reinterpret_cast(&config.edit_tool_also_seeks)); - edit_tool_selects_links = tools_menu->addAction("Edit Tool Selects Links", this, SLOT(toggle_bool_action())); + edit_tool_selects_links = tools_menu->addAction(tr("Edit Tool Selects Links"), this, SLOT(toggle_bool_action())); + edit_tool_selects_links->setProperty("id", "editselectslinks"); edit_tool_selects_links->setCheckable(true); edit_tool_selects_links->setData(reinterpret_cast(&config.edit_tool_selects_links)); - seek_also_selects = tools_menu->addAction("Seek Also Selects", this, SLOT(toggle_bool_action())); + seek_also_selects = tools_menu->addAction(tr("Seek Also Selects"), this, SLOT(toggle_bool_action())); + seek_also_selects->setProperty("id", "seekalsoselects"); seek_also_selects->setCheckable(true); seek_also_selects->setData(reinterpret_cast(&config.seek_also_selects)); - seek_to_end_of_pastes = tools_menu->addAction("Seek to the End of Pastes", this, SLOT(toggle_bool_action())); + seek_to_end_of_pastes = tools_menu->addAction(tr("Seek to the End of Pastes"), this, SLOT(toggle_bool_action())); + seek_to_end_of_pastes->setProperty("id", "seektoendofpastes"); seek_to_end_of_pastes->setCheckable(true); seek_to_end_of_pastes->setData(reinterpret_cast(&config.paste_seeks)); - scroll_wheel_zooms = tools_menu->addAction("Scroll Wheel Zooms", this, SLOT(toggle_bool_action())); + scroll_wheel_zooms = tools_menu->addAction(tr("Scroll Wheel Zooms"), this, SLOT(toggle_bool_action())); + scroll_wheel_zooms->setProperty("id", "scrollwheelzooms"); scroll_wheel_zooms->setCheckable(true); scroll_wheel_zooms->setData(reinterpret_cast(&config.scroll_zooms)); - enable_drag_files_to_timeline = tools_menu->addAction("Enable Drag Files to Timeline", this, SLOT(toggle_bool_action())); + enable_drag_files_to_timeline = tools_menu->addAction(tr("Enable Drag Files to Timeline"), this, SLOT(toggle_bool_action())); + enable_drag_files_to_timeline->setProperty("id", "enabledragfilestotimeline"); enable_drag_files_to_timeline->setCheckable(true); enable_drag_files_to_timeline->setData(reinterpret_cast(&config.enable_drag_files_to_timeline)); - autoscale_by_default = tools_menu->addAction("Auto-Scale By Default", this, SLOT(toggle_bool_action())); + autoscale_by_default = tools_menu->addAction(tr("Auto-Scale By Default"), this, SLOT(toggle_bool_action())); + autoscale_by_default->setProperty("id", "autoscalebydefault"); autoscale_by_default->setCheckable(true); autoscale_by_default->setData(reinterpret_cast(&config.autoscale_by_default)); - enable_seek_to_import = tools_menu->addAction("Enable Seek to Import", this, SLOT(toggle_bool_action())); + enable_seek_to_import = tools_menu->addAction(tr("Enable Seek to Import"), this, SLOT(toggle_bool_action())); + enable_seek_to_import->setProperty("id", "enableseektoimport"); enable_seek_to_import->setCheckable(true); enable_seek_to_import->setData(reinterpret_cast(&config.enable_seek_to_import)); - enable_audio_scrubbing = tools_menu->addAction("Audio Scrubbing", this, SLOT(toggle_bool_action())); + enable_audio_scrubbing = tools_menu->addAction(tr("Audio Scrubbing"), this, SLOT(toggle_bool_action())); + enable_audio_scrubbing->setProperty("id", "audioscrubbing"); enable_audio_scrubbing->setCheckable(true); enable_audio_scrubbing->setData(reinterpret_cast(&config.enable_audio_scrubbing)); - enable_drop_on_media_to_replace = tools_menu->addAction("Enable Drop on Media to Replace", this, SLOT(toggle_bool_action())); + enable_drop_on_media_to_replace = tools_menu->addAction(tr("Enable Drop on Media to Replace"), this, SLOT(toggle_bool_action())); + enable_drop_on_media_to_replace->setProperty("id", "enabledropmediareplace"); enable_drop_on_media_to_replace->setCheckable(true); enable_drop_on_media_to_replace->setData(reinterpret_cast(&config.drop_on_media_to_replace)); - enable_hover_focus = tools_menu->addAction("Enable Hover Focus", this, SLOT(toggle_bool_action())); + enable_hover_focus = tools_menu->addAction(tr("Enable Hover Focus"), this, SLOT(toggle_bool_action())); + enable_hover_focus->setProperty("id", "hoverfocus"); enable_hover_focus->setCheckable(true); enable_hover_focus->setData(reinterpret_cast(&config.hover_focus)); - set_name_and_marker = tools_menu->addAction("Ask For Name When Setting Marker", this, SLOT(toggle_bool_action())); + set_name_and_marker = tools_menu->addAction(tr("Ask For Name When Setting Marker"), this, SLOT(toggle_bool_action())); + set_name_and_marker->setProperty("id", "asknamemarkerset"); set_name_and_marker->setCheckable(true); set_name_and_marker->setData(reinterpret_cast(&config.set_name_with_marker)); - loop_action = tools_menu->addAction("Loop", this, SLOT(toggle_bool_action())); + loop_action = tools_menu->addAction(tr("Loop"), this, SLOT(toggle_bool_action())); + loop_action->setProperty("id", "loop"); loop_action->setCheckable(true); loop_action->setData(reinterpret_cast(&config.loop)); - pause_at_out_point_action = tools_menu->addAction("Pause At Out Point", this, SLOT(toggle_bool_action())); + pause_at_out_point_action = tools_menu->addAction(tr("Pause At Out Point"), this, SLOT(toggle_bool_action())); + pause_at_out_point_action->setProperty("id", "pauseoutpoint"); pause_at_out_point_action->setCheckable(true); pause_at_out_point_action->setData(reinterpret_cast(&config.pause_at_out_point)); tools_menu->addSeparator(); - no_autoscroll = tools_menu->addAction("No Auto-Scroll", this, SLOT(set_autoscroll())); + no_autoscroll = tools_menu->addAction(tr("No Auto-Scroll"), this, SLOT(set_autoscroll())); + no_autoscroll->setProperty("id", "autoscrollno"); no_autoscroll->setData(AUTOSCROLL_NO_SCROLL); no_autoscroll->setCheckable(true); - page_autoscroll = tools_menu->addAction("Page Auto-Scroll", this, SLOT(set_autoscroll())); + page_autoscroll = tools_menu->addAction(tr("Page Auto-Scroll"), this, SLOT(set_autoscroll())); + page_autoscroll->setProperty("id", "autoscrollpage"); page_autoscroll->setData(AUTOSCROLL_PAGE_SCROLL); page_autoscroll->setCheckable(true); - smooth_autoscroll = tools_menu->addAction("Smooth Auto-Scroll", this, SLOT(set_autoscroll())); + smooth_autoscroll = tools_menu->addAction(tr("Smooth Auto-Scroll"), this, SLOT(set_autoscroll())); + smooth_autoscroll->setProperty("id", "autoscrollsmooth"); smooth_autoscroll->setData(AUTOSCROLL_SMOOTH_SCROLL); smooth_autoscroll->setCheckable(true); tools_menu->addSeparator(); - tools_menu->addAction("Preferences", this, SLOT(preferences()), QKeySequence("Ctrl+.")); + tools_menu->addAction(tr("Preferences"), this, SLOT(preferences()), QKeySequence("Ctrl+."))->setProperty("id", "prefs"); #ifdef QT_DEBUG - tools_menu->addAction("Clear Undo", this, SLOT(clear_undo_stack())); + tools_menu->addAction(tr("Clear Undo"), this, SLOT(clear_undo_stack()))->setProperty("id", "clearundo"); #endif // INITIALIZE HELP MENU - QMenu* help_menu = menuBar->addMenu("&Help"); + QMenu* help_menu = menuBar->addMenu(tr("&Help")); - help_menu->addAction("A&ction Search", this, SLOT(show_action_search()), QKeySequence("/")); + help_menu->addAction(tr("A&ction Search"), this, SLOT(show_action_search()), QKeySequence("/"))->setProperty("id", "actionsearch"); help_menu->addSeparator(); - help_menu->addAction("Debug Log", this, SLOT(show_debug_log())); + help_menu->addAction(tr("Debug Log"), this, SLOT(show_debug_log()))->setProperty("id", "debuglog"); help_menu->addSeparator(); - help_menu->addAction("&About...", this, SLOT(show_about())); + help_menu->addAction(tr("&About..."), this, SLOT(show_about()))->setProperty("id", "about"); load_shortcuts(get_config_path() + "/shortcuts", true); } @@ -911,7 +962,7 @@ void MainWindow::set_button_action_checked(QAction *a) { void MainWindow::updateTitle(const QString& url) { project_url = url; - setWindowTitle(appName + " - " + ((project_url.isEmpty()) ? "" : project_url) + "[*]"); + setWindowTitle(appName + " - " + ((project_url.isEmpty()) ? tr("") : project_url) + "[*]"); } void MainWindow::closeEvent(QCloseEvent *e) { @@ -973,7 +1024,7 @@ void MainWindow::clear_undo_stack() { } void MainWindow::open_project() { - QString fn = QFileDialog::getOpenFileName(this, "Open Project...", "", OLIVE_FILE_FILTER); + QString fn = QFileDialog::getOpenFileName(this, tr("Open Project..."), "", OLIVE_FILE_FILTER); if (!fn.isEmpty() && can_close_project()) { open_project_worker(fn, false); } @@ -1122,8 +1173,8 @@ void MainWindow::viewMenu_About_To_Be_Shown() { title_safe_off->setChecked(!config.show_title_safe_area); title_safe_default->setChecked(config.show_title_safe_area && !config.use_custom_title_safe_ratio); - title_safe_43->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && config.custom_title_safe_ratio == 4.0/3.0); - title_safe_169->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && config.custom_title_safe_ratio == 16.0/9.0); + title_safe_43->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && qFuzzyCompare(config.custom_title_safe_ratio, 4.0/3.0)); + title_safe_169->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && qFuzzyCompare(config.custom_title_safe_ratio, 16.0/9.0)); title_safe_custom->setChecked(config.show_title_safe_area && config.use_custom_title_safe_ratio && !title_safe_43->isChecked() && !title_safe_169->isChecked()); full_screen->setChecked(windowState() == Qt::WindowFullScreen); @@ -1175,7 +1226,7 @@ void MainWindow::add_default_transition() { } void MainWindow::new_folder() { - Media* m = panel_project->new_folder(0); + Media* m = panel_project->new_folder(nullptr); undo_stack.push(new AddMediaCommand(m, panel_project->get_selected_folder())); QModelIndex index = project_model.create_index(m->row(), 0, m); @@ -1208,14 +1259,17 @@ void MainWindow::fileMenu_About_To_Be_Shown() { } void MainWindow::fileMenu_About_To_Hide() { -// open_recent->clear(); } void MainWindow::load_recent_project() { int index = static_cast(sender())->data().toInt(); QString recent_url = recent_projects.at(index); if (!QFile::exists(recent_url)) { - if (QMessageBox::question(this, "Missing recent project", "The project '" + recent_url + "' no longer exists. Would you like to remove it from the recent projects list?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { + if (QMessageBox::question( + this, + tr("Missing recent project"), + tr("The project '%1' no longer exists. Would you like to remove it from the recent projects list?").arg(recent_url), + QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { recent_projects.removeAt(index); panel_project->save_recent_projects(); } @@ -1334,10 +1388,10 @@ void MainWindow::set_tsa_custom() { do { if (invalid) { - QMessageBox::critical(this, "Invalid aspect ratio", "The aspect ratio '" + input + "' is invalid. Please try again."); + QMessageBox::critical(this, tr("Invalid aspect ratio"), tr("The aspect ratio '%1' is invalid. Please try again.").arg(input)); } - input = QInputDialog::getText(this, "Enter custom aspect ratio", "Enter the aspect ratio to use for the title/action safe area (e.g. 16:9):"); + input = QInputDialog::getText(this, tr("Enter custom aspect ratio"), tr("Enter the aspect ratio to use for the title/action safe area (e.g. 16:9):")); invalid = !arTest.exactMatch(input) && !input.isEmpty(); } while (invalid); @@ -1404,7 +1458,7 @@ void MainWindow::nest() { Sequence* s = new Sequence(); // create "nest" sequence - s->name = panel_project->get_next_sequence_name("Nested Sequence"); + s->name = panel_project->get_next_sequence_name(tr("Nested Sequence")); s->width = sequence->width; s->height = sequence->height; s->frame_rate = sequence->frame_rate; From 8289dc8ea032993194c9e567497d46274dc4282c Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 15:31:58 +1100 Subject: [PATCH 23/25] minor enhancements --- dialogs/debugdialog.cpp | 3 ++- io/exportthread.cpp | 41 ++++++++++++++++++++++------------------- olive.pro | 2 -- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index f9080a50a..9422e56c1 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -8,12 +8,13 @@ DebugDialog* debug_dialog = nullptr; DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle(tr("Debug Log")); + setWindowTitle(tr("Debug Log")); QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); textEdit = new QTextEdit(); + textEdit->setWordWrapMode(QTextOption::NoWrap); layout->addWidget(textEdit); } diff --git a/io/exportthread.cpp b/io/exportthread.cpp index b1153702e..0931b12f3 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -49,7 +49,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, ret = avcodec_send_frame(codec_ctx, frame); if (ret < 0) { qCritical() << "Failed to send frame to encoder." << ret; - ed->export_error = tr("failed to send frame to encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("failed to send frame to encoder (%1)").arg(QString::number(ret)); return false; } @@ -60,7 +60,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, } else if (ret < 0) { if (ret != AVERROR_EOF) { qCritical() << "Failed to receive packet from encoder." << ret; - ed->export_error = tr("failed to receive packet from encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("failed to receive packet from encoder (%1)").arg(QString::number(ret)); } return false; } @@ -81,7 +81,7 @@ bool ExportThread::setupVideo() { vcodec = avcodec_find_encoder((enum AVCodecID) video_codec); if (!vcodec) { qCritical() << "Could not find video encoder"; - ed->export_error = tr("could not video encoder for %1").arg(QString::number(video_codec)); + ed->export_error = tr("could not video encoder for %1").arg(QString::number(video_codec)); return false; } @@ -90,7 +90,7 @@ bool ExportThread::setupVideo() { video_stream->id = 0; if (!video_stream) { qCritical() << "Could not allocate video stream"; - ed->export_error = tr("could not allocate video stream"); + ed->export_error = tr("could not allocate video stream"); return false; } @@ -99,7 +99,7 @@ bool ExportThread::setupVideo() { vcodec_ctx = avcodec_alloc_context3(vcodec); if (!vcodec_ctx) { qCritical() << "Could not allocate video encoding context"; - ed->export_error = tr("could not allocate video encoding context"); + ed->export_error = tr("could not allocate video encoding context"); return false; } @@ -133,10 +133,13 @@ bool ExportThread::setupVideo() { } } - ret = avcodec_open2(vcodec_ctx, vcodec, nullptr); + AVDictionary* opts = nullptr; + av_dict_set(&opts, "threads", "auto", 0); + + ret = avcodec_open2(vcodec_ctx, vcodec, &opts); if (ret < 0) { qCritical() << "Could not open output video encoder." << ret; - ed->export_error = tr("could not open output video encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not open output video encoder (%1)").arg(QString::number(ret)); return false; } @@ -144,7 +147,7 @@ bool ExportThread::setupVideo() { ret = avcodec_parameters_from_context(video_stream->codecpar, vcodec_ctx); if (ret < 0) { qCritical() << "Could not copy video encoder parameters to output stream." << ret; - ed->export_error = tr("could not copy video encoder parameters to output stream (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not copy video encoder parameters to output stream (%1)").arg(QString::number(ret)); return false; } @@ -188,7 +191,7 @@ bool ExportThread::setupAudio() { acodec = avcodec_find_encoder(static_cast(audio_codec)); if (!acodec) { qCritical() << "Could not find audio encoder"; - ed->export_error = tr("could not audio encoder for %1").arg(QString::number(audio_codec)); + ed->export_error = tr("could not audio encoder for %1").arg(QString::number(audio_codec)); return false; } @@ -197,7 +200,7 @@ bool ExportThread::setupAudio() { audio_stream->id = 1; if (!audio_stream) { qCritical() << "Could not allocate audio stream"; - ed->export_error = tr("could not allocate audio stream"); + ed->export_error = tr("could not allocate audio stream"); return false; } @@ -206,7 +209,7 @@ bool ExportThread::setupAudio() { acodec_ctx = avcodec_alloc_context3(acodec); if (!acodec_ctx) { qCritical() << "Could not find allocate audio encoding context"; - ed->export_error = tr("could not allocate audio encoding context"); + ed->export_error = tr("could not allocate audio encoding context"); return false; } @@ -231,7 +234,7 @@ bool ExportThread::setupAudio() { ret = avcodec_open2(acodec_ctx, acodec, nullptr); if (ret < 0) { qCritical() << "Could not open output audio encoder." << ret; - ed->export_error = tr("could not open output audio encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not open output audio encoder (%1)").arg(QString::number(ret)); return false; } @@ -239,7 +242,7 @@ bool ExportThread::setupAudio() { ret = avcodec_parameters_from_context(audio_stream->codecpar, acodec_ctx); if (ret < 0) { qCritical() << "Could not copy audio encoder parameters to output stream." << ret; - ed->export_error = tr("could not copy audio encoder parameters to output stream (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not copy audio encoder parameters to output stream (%1)").arg(QString::number(ret)); return false; } @@ -269,7 +272,7 @@ bool ExportThread::setupAudio() { ret = av_frame_get_buffer(audio_frame, 0); if (ret < 0) { qCritical() << "Could not allocate audio buffer." << ret; - ed->export_error = tr("could not allocate audio buffer (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not allocate audio buffer (%1)").arg(QString::number(ret)); return false; } aframe_bytes = av_samples_get_buffer_size(nullptr, audio_frame->channels, audio_frame->nb_samples, static_cast(audio_frame->format), 0); @@ -291,7 +294,7 @@ bool ExportThread::setupContainer() { avformat_alloc_output_context2(&fmt_ctx, nullptr, nullptr, c_filename); if (!fmt_ctx) { qCritical() << "Could not create output context"; - ed->export_error = tr("could not create output format context"); + ed->export_error = tr("could not create output format context"); return false; } @@ -300,7 +303,7 @@ bool ExportThread::setupContainer() { ret = avio_open(&fmt_ctx->pb, c_filename, AVIO_FLAG_WRITE); if (ret < 0) { qCritical() << "Could not open output file." << ret; - ed->export_error = tr("could not open output file (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not open output file (%1)").arg(QString::number(ret)); return false; } @@ -312,7 +315,7 @@ void ExportThread::run() { if (!panel_sequence_viewer->viewer_widget->context()->makeCurrent(&surface)) { qCritical() << "Make current failed"; - ed->export_error = tr("could not make OpenGL context current"); + ed->export_error = tr("could not make OpenGL context current"); return; } @@ -331,7 +334,7 @@ void ExportThread::run() { ret = avformat_write_header(fmt_ctx, nullptr); if (ret < 0) { qCritical() << "Could not write output file header." << ret; - ed->export_error = tr("could not write output file header (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not write output file header (%1)").arg(QString::number(ret)); continueEncode = false; } } @@ -440,7 +443,7 @@ void ExportThread::run() { ret = av_write_trailer(fmt_ctx); if (ret < 0) { qCritical() << "Could not write output file trailer." << ret; - ed->export_error = tr("could not write output file trailer (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not write output file trailer (%1)").arg(QString::number(ret)); continueEncode = false; } diff --git a/olive.pro b/olive.pro index 116daabcf..e47ba1c0a 100644 --- a/olive.pro +++ b/olive.pro @@ -27,8 +27,6 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -QMAKE_CXXFLAGS += -std=c++11 -Wextra -Wshadow -Wnon-virtual-dtor -pedantic - # Tries to get the current Git short hash system("which git") { GITHASHVAR = $$system(git --git-dir $$PWD/.git --work-tree $$PWD log -1 --format=%h) From e736cfae302ff380d38ea32924e013699dd68241 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 18:25:33 +1100 Subject: [PATCH 24/25] fixed regression in #308 --- panels/project.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panels/project.cpp b/panels/project.cpp index a063b3fb1..9b6dfddaf 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -236,7 +236,7 @@ Sequence* create_sequence_from_media(QVector& media_list) { const FootageStream& ms = m->video_tracks.at(j); s->width = ms.video_width; s->height = ms.video_height; - if (qFuzzyCompare(ms.video_frame_rate, 0.0)) { + if (!qFuzzyCompare(ms.video_frame_rate, 0.0)) { s->frame_rate = ms.video_frame_rate * m->speed; if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2; From f3b0a3355c37fe82b1f4fdae9ee5371d7bc6d654 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 13 Jan 2019 09:50:25 +1100 Subject: [PATCH 25/25] extended hover focus --- mainwindow.cpp | 127 +++++++++++++++++++---------------------- panels/grapheditor.cpp | 6 +- panels/grapheditor.h | 1 + panels/panels.cpp | 8 ++- 4 files changed, 72 insertions(+), 70 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 5a1b6e88f..4ff2dbc88 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -377,9 +377,10 @@ void MainWindow::delete_slot() { } void MainWindow::select_all() { - if (panel_timeline->focused()) { + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_timeline) { panel_timeline->select_all(); - } else if (panel_graph_editor->view_is_focused()) { + } else if (focused_panel == panel_graph_editor) { panel_graph_editor->select_all(); } } @@ -1050,90 +1051,78 @@ void MainWindow::reset_layout() { } void MainWindow::go_to_in() { - if (panel_timeline->focused() - || panel_sequence_viewer->is_focused() - || panel_effect_controls->keyframe_focus() - || panel_graph_editor->view_is_focused()) { - panel_sequence_viewer->go_to_in(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->go_to_in(); - } + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->go_to_in(); + } else { + panel_sequence_viewer->go_to_in(); + } } void MainWindow::go_to_out() { - if (panel_timeline->focused() - || panel_sequence_viewer->is_focused() - || panel_effect_controls->keyframe_focus() - || panel_graph_editor->view_is_focused()) { - panel_sequence_viewer->go_to_out(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->go_to_out(); - } + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->go_to_out(); + } else { + panel_sequence_viewer->go_to_out(); + } } void MainWindow::go_to_start() { - if (panel_timeline->focused() - || panel_sequence_viewer->is_focused() - || panel_effect_controls->keyframe_focus() - || panel_graph_editor->view_is_focused()) { - panel_sequence_viewer->go_to_start(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->go_to_start(); - } + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->go_to_start(); + } else { + panel_sequence_viewer->go_to_start(); + } } void MainWindow::prev_frame() { - if (panel_timeline->focused() - || panel_sequence_viewer->is_focused() - || panel_effect_controls->keyframe_focus() - || panel_graph_editor->view_is_focused()) { - panel_sequence_viewer->previous_frame(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->previous_frame(); - } + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->previous_frame(); + } else { + panel_sequence_viewer->previous_frame(); + } } void MainWindow::next_frame() { - if (panel_timeline->focused() - || panel_sequence_viewer->is_focused() - || panel_effect_controls->keyframe_focus() - || panel_graph_editor->view_is_focused()) { - panel_sequence_viewer->next_frame(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->next_frame(); - } + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->next_frame(); + } else { + panel_sequence_viewer->next_frame(); + } } void MainWindow::go_to_end() { - if (panel_timeline->focused() - || panel_sequence_viewer->is_focused() - || panel_effect_controls->keyframe_focus() - || panel_graph_editor->view_is_focused()) { - panel_sequence_viewer->go_to_end(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->go_to_end(); - } + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->go_to_end(); + } else { + panel_sequence_viewer->go_to_end(); + } } void MainWindow::playpause() { - if (panel_timeline->focused() - || panel_sequence_viewer->is_focused() - || panel_effect_controls->keyframe_focus() - || panel_graph_editor->view_is_focused()) { - panel_sequence_viewer->toggle_play(); - } else if (panel_footage_viewer->is_focused()) { - panel_footage_viewer->toggle_play(); - } + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->toggle_play(); + } else { + panel_sequence_viewer->toggle_play(); + } } void MainWindow::prev_cut() { - if (sequence != nullptr && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { + QDockWidget* focused_panel = get_focused_panel(); + if (sequence != nullptr && (panel_timeline == focused_panel || panel_sequence_viewer == focused_panel)) { panel_timeline->previous_cut(); } } void MainWindow::next_cut() { - if (sequence != nullptr && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { + QDockWidget* focused_panel = get_focused_panel(); + if (sequence != nullptr && (panel_timeline == focused_panel || panel_sequence_viewer == focused_panel)) { panel_timeline->next_cut(); } } @@ -1430,11 +1419,13 @@ void MainWindow::toggle_enable_clips() { } void MainWindow::edit_to_in_point() { - if (panel_timeline->focused()) panel_timeline->ripple_to_in_point(true, false); + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_timeline) panel_timeline->ripple_to_in_point(true, false); } void MainWindow::edit_to_out_point() { - if (panel_timeline->focused()) panel_timeline->ripple_to_in_point(false, false); + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_timeline) panel_timeline->ripple_to_in_point(false, false); } void MainWindow::nest() { @@ -1497,7 +1488,8 @@ void MainWindow::nest() { } void MainWindow::paste_insert() { - if (panel_timeline->focused() && sequence != nullptr) { + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_timeline && sequence != nullptr) { panel_timeline->paste(true); } } @@ -1515,10 +1507,11 @@ void MainWindow::set_autoscroll() { } void MainWindow::menu_click_button() { - if (panel_timeline->focused() - || panel_effect_controls->keyframe_focus() - || panel_footage_viewer->is_focused() - || panel_sequence_viewer->is_focused()) + QDockWidget* focused_panel = get_focused_panel(); + if (focused_panel == panel_timeline + || focused_panel == panel_effect_controls + || focused_panel == panel_footage_viewer + || focused_panel == panel_sequence_viewer) reinterpret_cast(static_cast(sender())->data().value())->click(); } diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index 3bcf5a7bc..e330f15f8 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -199,7 +199,11 @@ void GraphEditor::set_row(EffectRow *r) { } bool GraphEditor::view_is_focused() { - return view->hasFocus() || header->hasFocus(); + return view->hasFocus() || header->hasFocus(); +} + +bool GraphEditor::view_is_under_mouse() { + return view->underMouse() || header->underMouse(); } void GraphEditor::delete_selected_keys() { diff --git a/panels/grapheditor.h b/panels/grapheditor.h index 1a5277b58..4617823fd 100644 --- a/panels/grapheditor.h +++ b/panels/grapheditor.h @@ -19,6 +19,7 @@ public: void update_panel(); void set_row(EffectRow* r); bool view_is_focused(); + bool view_is_under_mouse(); void delete_selected_keys(); void select_all(); private: diff --git a/panels/panels.cpp b/panels/panels.cpp index 9a8d8b310..f067cb25d 100644 --- a/panels/panels.cpp +++ b/panels/panels.cpp @@ -125,7 +125,9 @@ QDockWidget *get_focused_panel() { w = panel_footage_viewer; } else if (panel_timeline->underMouse()) { w = panel_timeline; - } + } else if (panel_graph_editor->view_is_under_mouse()) { + w = panel_graph_editor; + } } if (w == nullptr) { if (panel_project->is_focused()) { @@ -138,7 +140,9 @@ QDockWidget *get_focused_panel() { w = panel_footage_viewer; } else if (panel_timeline->focused()) { w = panel_timeline; - } + } else if (panel_graph_editor->view_is_focused()) { + w = panel_graph_editor; + } } return w; }