diff --git a/debug.cpp b/debug.cpp index 18935b40c..cbe4aa357 100644 --- a/debug.cpp +++ b/debug.cpp @@ -65,8 +65,8 @@ void debug_message_handler(QtMsgType type, const QMessageLogContext &context, co fflush(stderr); // abort(); } - if (debug_dialog != nullptr && debug_dialog->isVisible()) { - QMetaObject::invokeMethod(debug_dialog, "update_log", Qt::QueuedConnection); + if (Olive::DebugDialog != nullptr && Olive::DebugDialog->isVisible()) { + QMetaObject::invokeMethod(Olive::DebugDialog, "update_log", Qt::QueuedConnection); } debug_mutex.unlock(); } diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index 6d2718bec..b1aab93ac 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -6,7 +6,7 @@ #include "debug.h" -DebugDialog* debug_dialog = nullptr; +DebugDialog* Olive::DebugDialog = nullptr; DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Debug Log")); diff --git a/dialogs/debugdialog.h b/dialogs/debugdialog.h index a22deef8e..113777ac0 100644 --- a/dialogs/debugdialog.h +++ b/dialogs/debugdialog.h @@ -16,6 +16,8 @@ private: QTextEdit* textEdit; }; -extern DebugDialog* debug_dialog; +namespace Olive { + extern DebugDialog* DebugDialog; +} #endif // DEBUGDIALOG_H diff --git a/mainwindow.cpp b/mainwindow.cpp index db76121f9..f94db8ff9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -20,17 +20,7 @@ #include "ui/focusfilter.h" #include "panels/panels.h" -#include "panels/project.h" -#include "panels/effectcontrols.h" -#include "panels/viewer.h" -#include "panels/timeline.h" -#include "panels/grapheditor.h" -#include "dialogs/aboutdialog.h" -#include "dialogs/newsequencedialog.h" -#include "dialogs/exportdialog.h" -#include "dialogs/speeddialog.h" -#include "dialogs/actionsearch.h" #include "dialogs/debugdialog.h" #include "playback/audio.h" @@ -94,7 +84,7 @@ MainWindow::MainWindow(QWidget *parent) : open_debug_file(); - debug_dialog = new DebugDialog(this); + Olive::DebugDialog = new DebugDialog(this); Olive::MainWindow = this; @@ -168,9 +158,8 @@ MainWindow::MainWindow(QWidget *parent) : 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 - recent_proj_file = dir.filePath("recents"); - QFile f(recent_proj_file); + // search for open recents list + QFile f(Olive::Global.data()->get_recent_project_list_file()); if (f.exists() && f.open(QFile::ReadOnly | QFile::Text)) { QTextStream text_stream(&f); while (true) { @@ -339,54 +328,11 @@ void MainWindow::load_css_from_file(const QString &fn) { } } -void MainWindow::show_about() { - AboutDialog a(this); - a.exec(); -} - -void MainWindow::show_debug_log() { - debug_dialog->show(); -} - -void MainWindow::export_dialog() { - if (Olive::ActiveSequence == nullptr) { - QMessageBox::information(this, tr("No active sequence"), tr("Please open the sequence you wish to export."), QMessageBox::Ok); - } else { - ExportDialog e(this); - e.exec(); - } -} - -void MainWindow::ripple_delete() { - if (Olive::ActiveSequence != nullptr) { - if (Olive::ActiveSequence->selections.size() > 0) { - panel_timeline->delete_selection(Olive::ActiveSequence->selections, true); - } else if (config.hover_focus && get_focused_panel() == panel_timeline) { - if (panel_timeline->can_ripple_empty_space(panel_timeline->cursor_frame, panel_timeline->cursor_track)) { - panel_timeline->ripple_delete_empty_space(); - } - } - } -} - void MainWindow::editMenu_About_To_Be_Shown() { undo_action->setEnabled(Olive::UndoStack.canUndo()); redo_action->setEnabled(Olive::UndoStack.canRedo()); } -void MainWindow::open_speed_dialog() { - if (Olive::ActiveSequence != nullptr) { - SpeedDialog s(this); - for (int i=0;iclips.size();i++) { - Clip* c = Olive::ActiveSequence->clips.at(i); - if (c != nullptr && is_clip_selected(c, true)) { - s.clips.append(c); - } - } - if (s.clips.size() > 0) s.run(); - } -} - void MainWindow::setup_menus() { QMenuBar* menuBar = new QMenuBar(this); setMenuBar(menuBar); @@ -418,7 +364,7 @@ void MainWindow::setup_menus() { file_menu->addSeparator(); - file_menu->addAction(tr("&Export..."), this, SLOT(export_dialog()), QKeySequence("Ctrl+M"))->setProperty("id", "export"); + file_menu->addAction(tr("&Export..."), Olive::Global.data(), SLOT(open_export_dialog()), QKeySequence("Ctrl+M"))->setProperty("id", "export"); file_menu->addSeparator(); @@ -450,20 +396,20 @@ void MainWindow::setup_menus() { edit_menu->addSeparator(); - 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->addAction(tr("Ripple to In Point"), panel_timeline, SLOT(ripple_to_in_point()), QKeySequence("Q"))->setProperty("id", "rippletoin"); + edit_menu->addAction(tr("Ripple to Out Point"), panel_timeline, SLOT(ripple_to_out_point()), QKeySequence("W"))->setProperty("id", "rippletoout"); + edit_menu->addAction(tr("Edit to In Point"), panel_timeline, SLOT(edit_to_in_point()), QKeySequence("Ctrl+Alt+Q"))->setProperty("id", "edittoin"); + edit_menu->addAction(tr("Edit to Out Point"), panel_timeline, SLOT(edit_to_out_point()), QKeySequence("Ctrl+Alt+W"))->setProperty("id", "edittoout"); edit_menu->addSeparator(); Olive::MenuHelper.make_inout_menu(edit_menu); - 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->addAction(tr("Delete In/Out Point"), panel_timeline, SLOT(delete_inout()), QKeySequence(";"))->setProperty("id", "deleteinout"); + edit_menu->addAction(tr("Ripple Delete In/Out Point"), panel_timeline, SLOT(ripple_delete_inout()), QKeySequence("'"))->setProperty("id", "rippledeleteinout"); edit_menu->addSeparator(); - edit_menu->addAction(tr("Set/Edit Marker"), this, SLOT(set_marker()), QKeySequence("M"))->setProperty("id", "marker"); + edit_menu->addAction(tr("Set/Edit Marker"), &Olive::FocusFilter, SLOT(set_marker()), QKeySequence("M"))->setProperty("id", "marker"); // INITIALIZE VIEW MENU @@ -481,31 +427,31 @@ void MainWindow::setup_menus() { view_menu->addSeparator(); - track_lines = view_menu->addAction(tr("Track Lines"), this, SLOT(toggle_bool_action())); + track_lines = view_menu->addAction(tr("Track Lines"), &Olive::MenuHelper, 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(tr("Rectified Waveforms"), this, SLOT(toggle_bool_action())); + rectified_waveforms = view_menu->addAction(tr("Rectified Waveforms"), &Olive::MenuHelper, 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(tr("Frames"), this, SLOT(set_timecode_view())); + frames_action = view_menu->addAction(tr("Frames"), &Olive::MenuHelper, SLOT(set_timecode_view())); frames_action->setProperty("id", "modeframes"); frames_action->setData(TIMECODE_FRAMES); frames_action->setCheckable(true); - drop_frame_action = view_menu->addAction(tr("Drop Frame"), this, SLOT(set_timecode_view())); + drop_frame_action = view_menu->addAction(tr("Drop Frame"), &Olive::MenuHelper, 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(tr("Non-Drop Frame"), this, SLOT(set_timecode_view())); + nondrop_frame_action = view_menu->addAction(tr("Non-Drop Frame"), &Olive::MenuHelper, 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(tr("Milliseconds"), this, SLOT(set_timecode_view())); + milliseconds_action = view_menu->addAction(tr("Milliseconds"), &Olive::MenuHelper, SLOT(set_timecode_view())); milliseconds_action->setProperty("id", "milliseconds"); milliseconds_action->setData(TIMECODE_MILLISECONDS); milliseconds_action->setCheckable(true); @@ -517,27 +463,32 @@ void MainWindow::setup_menus() { 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_off->setData(qSNaN()); + connect(title_safe_off, SIGNAL(triggered(bool)), &Olive::MenuHelper, SLOT(set_titlesafe_from_menu())); 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_default->setData(0.0); + connect(title_safe_default, SIGNAL(triggered(bool)), &Olive::MenuHelper, SLOT(set_titlesafe_from_menu())); 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_43->setData(4.0/3.0); + connect(title_safe_43, SIGNAL(triggered(bool)), &Olive::MenuHelper, SLOT(set_titlesafe_from_menu())); 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_169->setData(16.0/9.0); + connect(title_safe_169, SIGNAL(triggered(bool)), &Olive::MenuHelper, SLOT(set_titlesafe_from_menu())); 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())); + title_safe_custom->setData(-1.0); + connect(title_safe_custom, SIGNAL(triggered(bool)), &Olive::MenuHelper, SLOT(set_titlesafe_from_menu())); view_menu->addSeparator(); @@ -545,7 +496,7 @@ void MainWindow::setup_menus() { full_screen->setProperty("id", "fullscreen"); full_screen->setCheckable(true); - view_menu->addAction(tr("Full Screen Viewer"), this, SLOT(full_screen_viewer()))->setProperty("id", "fullscreenviewer"); + view_menu->addAction(tr("Full Screen Viewer"), &Olive::FocusFilter, SLOT(set_viewer_fullscreen()))->setProperty("id", "fullscreenviewer"); // INITIALIZE PLAYBACK MENU @@ -570,7 +521,7 @@ void MainWindow::setup_menus() { playback_menu->addAction(tr("Shuttle Right"), &Olive::FocusFilter, SLOT(increase_speed()), QKeySequence("L"))->setProperty("id", "incspeed"); playback_menu->addSeparator(); - loop_action = playback_menu->addAction(tr("Loop"), this, SLOT(toggle_bool_action())); + loop_action = playback_menu->addAction(tr("Loop"), &Olive::MenuHelper, SLOT(toggle_bool_action())); loop_action->setProperty("id", "loop"); loop_action->setCheckable(true); loop_action->setData(reinterpret_cast(&config.loop)); @@ -580,32 +531,32 @@ void MainWindow::setup_menus() { 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(tr("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(tr("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(tr("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(tr("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(tr("Media Viewer"), this, SLOT(toggle_panel_visibility())); + QAction* window_footageviewer_action = window_menu->addAction(tr("Media 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(tr("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)); @@ -623,133 +574,133 @@ void MainWindow::setup_menus() { 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(tr("Pointer Tool"), this, SLOT(menu_click_button()), QKeySequence("V")); + pointer_tool_action = tools_menu->addAction(tr("Pointer Tool"), &Olive::MenuHelper, 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(tr("Edit Tool"), this, SLOT(menu_click_button()), QKeySequence("X")); + edit_tool_action = tools_menu->addAction(tr("Edit Tool"), &Olive::MenuHelper, 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(tr("Ripple Tool"), this, SLOT(menu_click_button()), QKeySequence("B")); + ripple_tool_action = tools_menu->addAction(tr("Ripple Tool"), &Olive::MenuHelper, 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(tr("Razor Tool"), this, SLOT(menu_click_button()), QKeySequence("C")); + razor_tool_action = tools_menu->addAction(tr("Razor Tool"), &Olive::MenuHelper, 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(tr("Slip Tool"), this, SLOT(menu_click_button()), QKeySequence("Y")); + slip_tool_action = tools_menu->addAction(tr("Slip Tool"), &Olive::MenuHelper, 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(tr("Slide Tool"), this, SLOT(menu_click_button()), QKeySequence("U")); + slide_tool_action = tools_menu->addAction(tr("Slide Tool"), &Olive::MenuHelper, 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(tr("Hand Tool"), this, SLOT(menu_click_button()), QKeySequence("H")); + hand_tool_action = tools_menu->addAction(tr("Hand Tool"), &Olive::MenuHelper, 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(tr("Transition Tool"), this, SLOT(menu_click_button()), QKeySequence("T")); + transition_tool_action = tools_menu->addAction(tr("Transition Tool"), &Olive::MenuHelper, 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(tr("Enable Snapping"), this, SLOT(menu_click_button()), QKeySequence("S")); + snap_toggle = tools_menu->addAction(tr("Enable Snapping"), &Olive::MenuHelper, 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(tr("Selecting Also Seeks"), this, SLOT(toggle_bool_action())); + selecting_also_seeks = tools_menu->addAction(tr("Selecting Also Seeks"), &Olive::MenuHelper, 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(tr("Edit Tool Also Seeks"), this, SLOT(toggle_bool_action())); + edit_tool_also_seeks = tools_menu->addAction(tr("Edit Tool Also Seeks"), &Olive::MenuHelper, 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(tr("Edit Tool Selects Links"), this, SLOT(toggle_bool_action())); + edit_tool_selects_links = tools_menu->addAction(tr("Edit Tool Selects Links"), &Olive::MenuHelper, 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(tr("Seek Also Selects"), this, SLOT(toggle_bool_action())); + seek_also_selects = tools_menu->addAction(tr("Seek Also Selects"), &Olive::MenuHelper, 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(tr("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"), &Olive::MenuHelper, 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(tr("Scroll Wheel Zooms"), this, SLOT(toggle_bool_action())); + scroll_wheel_zooms = tools_menu->addAction(tr("Scroll Wheel Zooms"), &Olive::MenuHelper, 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(tr("Enable Drag Files to Timeline"), this, SLOT(toggle_bool_action())); + enable_drag_files_to_timeline = tools_menu->addAction(tr("Enable Drag Files to Timeline"), &Olive::MenuHelper, 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(tr("Auto-Scale By Default"), this, SLOT(toggle_bool_action())); + autoscale_by_default = tools_menu->addAction(tr("Auto-Scale By Default"), &Olive::MenuHelper, 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(tr("Enable Seek to Import"), this, SLOT(toggle_bool_action())); + enable_seek_to_import = tools_menu->addAction(tr("Enable Seek to Import"), &Olive::MenuHelper, 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(tr("Audio Scrubbing"), this, SLOT(toggle_bool_action())); + enable_audio_scrubbing = tools_menu->addAction(tr("Audio Scrubbing"), &Olive::MenuHelper, 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(tr("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"), &Olive::MenuHelper, 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(tr("Enable Hover Focus"), this, SLOT(toggle_bool_action())); + enable_hover_focus = tools_menu->addAction(tr("Enable Hover Focus"), &Olive::MenuHelper, 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(tr("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"), &Olive::MenuHelper, 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)); tools_menu->addSeparator(); - no_autoscroll = tools_menu->addAction(tr("No Auto-Scroll"), this, SLOT(set_autoscroll())); + no_autoscroll = tools_menu->addAction(tr("No Auto-Scroll"), &Olive::MenuHelper, SLOT(set_autoscroll())); no_autoscroll->setProperty("id", "autoscrollno"); no_autoscroll->setData(AUTOSCROLL_NO_SCROLL); no_autoscroll->setCheckable(true); - page_autoscroll = tools_menu->addAction(tr("Page Auto-Scroll"), this, SLOT(set_autoscroll())); + page_autoscroll = tools_menu->addAction(tr("Page Auto-Scroll"), &Olive::MenuHelper, SLOT(set_autoscroll())); page_autoscroll->setProperty("id", "autoscrollpage"); page_autoscroll->setData(AUTOSCROLL_PAGE_SCROLL); page_autoscroll->setCheckable(true); - smooth_autoscroll = tools_menu->addAction(tr("Smooth Auto-Scroll"), this, SLOT(set_autoscroll())); + smooth_autoscroll = tools_menu->addAction(tr("Smooth Auto-Scroll"), &Olive::MenuHelper, SLOT(set_autoscroll())); smooth_autoscroll->setProperty("id", "autoscrollsmooth"); smooth_autoscroll->setData(AUTOSCROLL_SMOOTH_SCROLL); smooth_autoscroll->setCheckable(true); @@ -759,22 +710,22 @@ void MainWindow::setup_menus() { tools_menu->addAction(tr("Preferences"), Olive::Global.data(), SLOT(open_preferences()), QKeySequence("Ctrl+,"))->setProperty("id", "prefs"); #ifdef QT_DEBUG - tools_menu->addAction(tr("Clear Undo"), this, SLOT(clear_undo_stack()))->setProperty("id", "clearundo"); + tools_menu->addAction(tr("Clear Undo"), Olive::Global.data(), SLOT(clear_undo_stack()))->setProperty("id", "clearundo"); #endif // INITIALIZE HELP MENU QMenu* help_menu = menuBar->addMenu(tr("&Help")); - help_menu->addAction(tr("A&ction Search"), this, SLOT(show_action_search()), QKeySequence("/"))->setProperty("id", "actionsearch"); + help_menu->addAction(tr("A&ction Search"), Olive::Global.data(), SLOT(open_action_search()), QKeySequence("/"))->setProperty("id", "actionsearch"); help_menu->addSeparator(); - help_menu->addAction(tr("Debug Log"), this, SLOT(show_debug_log()))->setProperty("id", "debuglog"); + help_menu->addAction(tr("Debug Log"), Olive::Global.data(), SLOT(open_debug_log()))->setProperty("id", "debuglog"); help_menu->addSeparator(); - help_menu->addAction(tr("&About..."), this, SLOT(show_about()))->setProperty("id", "about"); + help_menu->addAction(tr("&About..."), Olive::Global.data(), SLOT(open_about_dialog()))->setProperty("id", "about"); load_shortcuts(get_config_path() + "/shortcuts", true); } @@ -844,15 +795,6 @@ void MainWindow::paintEvent(QPaintEvent *event) { } } -void MainWindow::clear_undo_stack() { - Olive::UndoStack.clear(); -} - -void MainWindow::show_action_search() { - ActionSearch as(this); - as.exec(); -} - void MainWindow::reset_layout() { setup_layout(true); } @@ -887,14 +829,6 @@ void MainWindow::maximize_panel() { } } -void MainWindow::full_screen_viewer() { - if (get_focused_panel() == panel_footage_viewer) { - panel_footage_viewer->viewer_widget->set_fullscreen(); - } else { - panel_sequence_viewer->viewer_widget->set_fullscreen(); - } -} - void MainWindow::windowMenu_About_To_Be_Shown() { QList window_actions = window_menu->actions(); for (int i=0;isetChecked(!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 && 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()); + 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 + && qFuzzyCompare(config.custom_title_safe_ratio, title_safe_43->data().toDouble())); + title_safe_169->setChecked(config.show_title_safe_area + && config.use_custom_title_safe_ratio + && qFuzzyCompare(config.custom_title_safe_ratio, title_safe_169->data().toDouble())); + 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); @@ -959,6 +901,16 @@ void MainWindow::toolMenu_About_To_Be_Shown() { Olive::MenuHelper.set_int_action_checked(smooth_autoscroll, config.autoscroll); } +void MainWindow::toggle_panel_visibility() { + QAction* action = static_cast(sender()); + QDockWidget* w = reinterpret_cast(action->data().value()); + w->setVisible(!w->isVisible()); + + // layout has changed, we're no longer in maximized panel mode, + // so we clear this byte array + temp_panel_state.clear(); +} + void MainWindow::fileMenu_About_To_Be_Shown() { if (recent_projects.size() > 0) { open_recent->clear(); @@ -977,14 +929,6 @@ void MainWindow::fileMenu_About_To_Be_Shown() { } } -void MainWindow::ripple_to_in_point() { - panel_timeline->ripple_to_in_point(true, true); -} - -void MainWindow::ripple_to_out_point() { - panel_timeline->ripple_to_in_point(false, true); -} - void MainWindow::toggle_full_screen() { if (windowState() == Qt::WindowFullScreen) { setWindowState(Qt::WindowNoState); // seems to be necessary for it to return to Maximized correctly on Linux @@ -993,114 +937,3 @@ void MainWindow::toggle_full_screen() { setWindowState(Qt::WindowFullScreen); } } - -void MainWindow::delete_inout() { - panel_timeline->delete_in_out(false); -} - -void MainWindow::ripple_delete_inout() { - panel_timeline->delete_in_out(true); -} - -void MainWindow::set_tsa_default() { - config.show_title_safe_area = true; - config.use_custom_title_safe_ratio = false; - panel_sequence_viewer->viewer_widget->update(); -} - -void MainWindow::set_tsa_disable() { - config.show_title_safe_area = false; - panel_sequence_viewer->viewer_widget->update(); -} - -void MainWindow::set_tsa_43() { - config.show_title_safe_area = true; - config.use_custom_title_safe_ratio = true; - config.custom_title_safe_ratio = 4.0/3.0; - panel_sequence_viewer->viewer_widget->update(); -} - -void MainWindow::set_tsa_169() { - config.show_title_safe_area = true; - config.use_custom_title_safe_ratio = true; - config.custom_title_safe_ratio = 16.0/9.0; - panel_sequence_viewer->viewer_widget->update(); -} - -void MainWindow::set_tsa_custom() { - QString input; - bool invalid = false; - QRegExp arTest("[0-9.]+:[0-9.]+"); - - do { - if (invalid) { - QMessageBox::critical(this, tr("Invalid aspect ratio"), tr("The aspect ratio '%1' is invalid. Please try again.").arg(input)); - } - - 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); - - if (!input.isEmpty()) { - QStringList inputList = input.split(':'); - - config.show_title_safe_area = true; - config.use_custom_title_safe_ratio = true; - config.custom_title_safe_ratio = inputList.at(0).toDouble()/inputList.at(1).toDouble(); - panel_sequence_viewer->viewer_widget->update(); - } -} - -void MainWindow::set_marker() { - if (Olive::ActiveSequence != nullptr) { - QDockWidget* focused_panel = get_focused_panel(); - - if (focused_panel == panel_timeline) { - panel_timeline->set_marker(); - } else if (focused_panel == panel_footage_viewer) { - panel_footage_viewer->set_marker(); - } else if (focused_panel == panel_sequence_viewer) { - panel_sequence_viewer->set_marker(); - } - } -} - -void MainWindow::edit_to_in_point() { - panel_timeline->ripple_to_in_point(true, false); -} - -void MainWindow::edit_to_out_point() { - panel_timeline->ripple_to_in_point(false, false); -} - -void MainWindow::toggle_bool_action() { - QAction* action = static_cast(sender()); - bool* variable = reinterpret_cast(action->data().value()); - *variable = !(*variable); - update_ui(false); -} - -void MainWindow::set_autoscroll() { - QAction* action = static_cast(sender()); - config.autoscroll = action->data().toInt(); -} - -void MainWindow::menu_click_button() { - reinterpret_cast(static_cast(sender())->data().value())->click(); -} - -void MainWindow::toggle_panel_visibility() { - QAction* action = static_cast(sender()); - QDockWidget* w = reinterpret_cast(action->data().value()); - w->setVisible(!w->isVisible()); - - // layout has changed, we're no longer in maximized panel mode, - // so we clear this byte array - temp_panel_state.clear(); -} - -void MainWindow::set_timecode_view() { - QAction* action = static_cast(sender()); - config.timecode_view = action->data().toInt(); - update_ui(false); -} diff --git a/mainwindow.h b/mainwindow.h index efedb5d38..79c216a70 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -22,12 +22,8 @@ public: void load_css_from_file(const QString& fn); public slots: - void open_speed_dialog(); - void toggle_full_screen(); - void toggle_bool_action(); - signals: void finished_first_paint(); @@ -36,19 +32,9 @@ protected: virtual void paintEvent(QPaintEvent *event) override; private slots: - void clear_undo_stack(); - - void show_about(); - void show_debug_log(); - - void export_dialog(); - void ripple_delete(); - void maximize_panel(); void reset_layout(); - void full_screen_viewer(); - void fileMenu_About_To_Be_Shown(); void editMenu_About_To_Be_Shown(); void windowMenu_About_To_Be_Shown(); @@ -56,29 +42,7 @@ private slots: void viewMenu_About_To_Be_Shown(); void toolMenu_About_To_Be_Shown(); - void ripple_to_in_point(); - void ripple_to_out_point(); - - void delete_inout(); - void ripple_delete_inout(); - - // title safe area functions - void set_tsa_disable(); - void set_tsa_default(); - void set_tsa_43(); - void set_tsa_169(); - void set_tsa_custom(); - - void set_marker(); - - void edit_to_in_point(); - void edit_to_out_point(); - void set_autoscroll(); - void menu_click_button(); - void toggle_panel_visibility(); - void set_timecode_view(); - - void show_action_search(); + void toggle_panel_visibility(); private: void setup_layout(bool reset); diff --git a/oliveglobal.cpp b/oliveglobal.cpp index c0816abbf..3536b05cc 100644 --- a/oliveglobal.cpp +++ b/oliveglobal.cpp @@ -10,6 +10,11 @@ #include "dialogs/demonotice.h" #include "dialogs/preferencesdialog.h" +#include "dialogs/exportdialog.h" +#include "dialogs/debugdialog.h" +#include "dialogs/aboutdialog.h" +#include "dialogs/speeddialog.h" +#include "dialogs/actionsearch.h" #include "project/sequence.h" @@ -80,6 +85,10 @@ void OliveGlobal::load_project_on_launch(const QString& s) { enable_load_project_on_init = true; } +QString OliveGlobal::get_recent_project_list_file() { + return get_data_dir().filePath("recents"); +} + void OliveGlobal::new_project() { if (can_close_project()) { // clear effects panel @@ -166,6 +175,18 @@ bool OliveGlobal::can_close_project() { return true; } +void OliveGlobal::open_export_dialog() { + if (Olive::ActiveSequence == nullptr) { + QMessageBox::information(Olive::MainWindow, + tr("No active sequence"), + tr("Please open the sequence you wish to export."), + QMessageBox::Ok); + } else { + ExportDialog e(Olive::MainWindow); + e.exec(); + } +} + void OliveGlobal::finished_initialize() { // if a project was set as a command line argument, we load it here if (enable_load_project_on_init) { @@ -230,3 +251,34 @@ void OliveGlobal::paste_insert() { panel_timeline->paste(true); } } + +void OliveGlobal::open_about_dialog() { + AboutDialog a(Olive::MainWindow); + a.exec(); +} + +void OliveGlobal::open_debug_log() { + Olive::DebugDialog->show(); +} + +void OliveGlobal::open_speed_dialog() { + if (Olive::ActiveSequence != nullptr) { + SpeedDialog s(Olive::MainWindow); + for (int i=0;iclips.size();i++) { + Clip* c = Olive::ActiveSequence->clips.at(i); + if (c != nullptr && is_clip_selected(c, true)) { + s.clips.append(c); + } + } + if (s.clips.size() > 0) s.run(); + } +} + +void OliveGlobal::clear_undo_stack() { + Olive::UndoStack.clear(); +} + +void OliveGlobal::open_action_search() { + ActionSearch as(Olive::MainWindow); + as.exec(); +} diff --git a/oliveglobal.h b/oliveglobal.h index 6615a37ab..b18d59275 100644 --- a/oliveglobal.h +++ b/oliveglobal.h @@ -4,6 +4,7 @@ #include "project/undo.h" #include +#include class OliveGlobal : public QObject { Q_OBJECT @@ -20,13 +21,39 @@ public: void load_project_on_launch(const QString& s); + QString get_recent_project_list_file(); + public slots: + /** + * @brief Undo user's last action + */ void undo(); + + /** + * @brief Redo user's last action + */ void redo(); + /** + * @brief Paste contents of clipboard + * + * Pastes contents of clipboard. Seeing as several types of data can be copied into the clipboard, this + * function will automatically determine what type of data is in the clipboard and paste it in the correct + * location (e.g. clip data will go to the Timeline, effect data will go to Effect Controls). + */ void paste(); + + /** + * @brief Paste contents of clipboard, making space for it when possible + * + * Pastes contents of clipboard (same as paste()). If the clipboard contains clip data, the clips are cut at the + * current playhead and ripple forward to make space for the clips in the clipboard. Can be considered + * semi-non-destructive as a result (as opposed to paste() overwriting clips). If the clipboard contains effect + * data, the functionality is identical to paste(). + */ void paste_insert(); + void new_project(); void open_project(); void open_recent(); @@ -35,6 +62,14 @@ public slots: bool can_close_project(); + void open_export_dialog(); + void open_about_dialog(); + void open_debug_log(); + void open_speed_dialog(); + void open_action_search(); + + void clear_undo_stack(); + /** * @brief Function called when Olive has finished starting up * diff --git a/panels/project.cpp b/panels/project.cpp index 6178f5881..b1908b47a 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -52,7 +52,6 @@ ProjectModel project_model; QString autorecovery_filename; QStringList recent_projects; -QString recent_proj_file; Project::Project(QWidget *parent) : QDockWidget(parent) @@ -1226,7 +1225,7 @@ void Project::set_tree_view() { void Project::save_recent_projects() { // save to file - QFile f(recent_proj_file); + QFile f(Olive::Global->get_recent_project_list_file()); if (f.open(QFile::WriteOnly | QFile::Truncate | QFile::Text)) { QTextStream out(&f); for (int i=0;i &media_list); @@ -107,7 +105,7 @@ private slots: void set_icon_view_size(int); void set_up_dir_enabled(); void go_up_dir(); - void make_new_menu(); + void make_new_menu(); }; class MediaThrobber : public QObject { diff --git a/panels/timeline.cpp b/panels/timeline.cpp index ab2ec1ad5..428a6aaa0 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -615,7 +615,7 @@ void Timeline::resizeEvent(QResizeEvent *) { tool_button_widget->setFixedWidth((tool_button_children.at(0)->sizeHint().width())*cols + horizontal_spacing*(cols-1) + 1); } -void Timeline::delete_in_out(bool ripple) { +void Timeline::delete_in_out_internal(bool ripple) { if (Olive::ActiveSequence != nullptr && Olive::ActiveSequence->using_workarea) { QVector areas; int video_tracks = 0, audio_tracks = 0; @@ -1231,7 +1231,7 @@ void Timeline::paste(bool insert) { } } -void Timeline::ripple_to_in_point(bool in, bool ripple) { +void Timeline::edit_to_point_internal(bool in, bool ripple) { if (Olive::ActiveSequence != nullptr) { if (Olive::ActiveSequence->clips.size() > 0) { // get track count @@ -1439,7 +1439,19 @@ void Timeline::split_at_playhead() { update_ui(true); } else { delete ca; - } + } +} + +void Timeline::ripple_delete() { + if (Olive::ActiveSequence != nullptr) { + if (Olive::ActiveSequence->selections.size() > 0) { + panel_timeline->delete_selection(Olive::ActiveSequence->selections, true); + } else if (config.hover_focus && get_focused_panel() == panel_timeline) { + if (panel_timeline->can_ripple_empty_space(panel_timeline->cursor_frame, panel_timeline->cursor_track)) { + panel_timeline->ripple_delete_empty_space(); + } + } + } } void Timeline::deselect_area(long in, long out, int track) { @@ -1565,6 +1577,30 @@ void Timeline::set_marker() { } +void Timeline::delete_inout() { + panel_timeline->delete_in_out_internal(false); +} + +void Timeline::ripple_delete_inout() { + panel_timeline->delete_in_out_internal(true); +} + +void Timeline::ripple_to_in_point() { + panel_timeline->edit_to_point_internal(true, true); +} + +void Timeline::ripple_to_out_point() { + panel_timeline->edit_to_point_internal(false, true); +} + +void Timeline::edit_to_in_point() { + panel_timeline->edit_to_point_internal(true, false); +} + +void Timeline::edit_to_out_point() { + panel_timeline->edit_to_point_internal(false, false); +} + void Timeline::toggle_links() { LinkCommand* command = new LinkCommand(); command->s = Olive::ActiveSequence; diff --git a/panels/timeline.h b/panels/timeline.h index 77f0e7c7b..96ddabedd 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -91,8 +91,8 @@ public: QVector get_tracks_of_linked_clips(int i); bool has_clip_been_split(int c); - void ripple_to_in_point(bool in, bool ripple); - void delete_in_out(bool ripple); + void edit_to_point_internal(bool in, bool ripple); + void delete_in_out_internal(bool ripple); void create_ghosts_from_media(Sequence *seq, long entry_point, QVector &media_list); void add_clips_from_ghosts(ComboAction *ca, Sequence *s); @@ -210,9 +210,18 @@ public slots: void deselect(); void toggle_links(); void split_at_playhead(); + void ripple_delete(); void ripple_delete_empty_space(); void toggle_enable_on_selected_clips(); + void delete_inout(); + void ripple_delete_inout(); + + void ripple_to_in_point(); + void ripple_to_out_point(); + void edit_to_in_point(); + void edit_to_out_point(); + void increase_track_height(); void decrease_track_height(); diff --git a/panels/viewer.cpp b/panels/viewer.cpp index 681cf6fa8..21cf08898 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -13,7 +13,6 @@ #include "project/undo.h" #include "ui/audiomonitor.h" #include "playback/playback.h" -#include "ui/viewerwidget.h" #include "ui/viewercontainer.h" #include "ui/labelslider.h" #include "ui/timelineheader.h" diff --git a/panels/viewer.h b/panels/viewer.h index 51d9396d6..c7c9a74c0 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -6,7 +6,6 @@ #include class Timeline; -class ViewerWidget; class Media; struct Sequence; class TimelineHeader; @@ -17,6 +16,7 @@ class QPushButton; class QLabel; #include "project/marker.h" +#include "ui/viewerwidget.h" bool frame_rate_is_droppable(float rate); long timecode_to_frame(const QString& s, int view, double frame_rate); @@ -27,7 +27,7 @@ class Viewer : public QDockWidget Q_OBJECT public: - explicit Viewer(QWidget *parent = 0); + explicit Viewer(QWidget *parent = nullptr); ~Viewer(); bool is_focused(); diff --git a/ui/focusfilter.cpp b/ui/focusfilter.cpp index e0f50bfbf..bc903de67 100644 --- a/ui/focusfilter.cpp +++ b/ui/focusfilter.cpp @@ -74,6 +74,28 @@ void FocusFilter::go_to_end() { } } +void FocusFilter::set_viewer_fullscreen() { + if (get_focused_panel() == panel_footage_viewer) { + panel_footage_viewer->viewer_widget->set_fullscreen(); + } else { + panel_sequence_viewer->viewer_widget->set_fullscreen(); + } +} + +void FocusFilter::set_marker() { + if (Olive::ActiveSequence != nullptr) { + QDockWidget* focused_panel = get_focused_panel(); + + if (focused_panel == panel_footage_viewer) { + panel_footage_viewer->set_marker(); + } else if (focused_panel == panel_sequence_viewer) { + panel_sequence_viewer->set_marker(); + } else { + panel_timeline->set_marker(); + } + } +} + void FocusFilter::playpause() { QDockWidget* focused_panel = get_focused_panel(); if (focused_panel == panel_footage_viewer) { diff --git a/ui/focusfilter.h b/ui/focusfilter.h index a54fcfa56..b560c9178 100644 --- a/ui/focusfilter.h +++ b/ui/focusfilter.h @@ -26,6 +26,10 @@ public slots: void next_frame(); void go_to_end(); + void set_viewer_fullscreen(); + + void set_marker(); + void set_in_point(); void set_out_point(); void clear_in(); diff --git a/ui/menuhelper.cpp b/ui/menuhelper.cpp index 95f34d7d8..ca145baf5 100644 --- a/ui/menuhelper.cpp +++ b/ui/menuhelper.cpp @@ -4,10 +4,15 @@ #include "ui/focusfilter.h" +#include "io/config.h" + #include "panels/panels.h" #include "mainwindow.h" +#include +#include + MenuHelper Olive::MenuHelper; void MenuHelper::make_new_menu(QMenu *parent) { @@ -40,7 +45,7 @@ void MenuHelper::make_edit_functions_menu(QMenu *parent) { parent->addAction(tr("Paste Insert"), Olive::Global.data(), SLOT(paste_insert()), QKeySequence("Ctrl+Shift+V"))->setProperty("id", "pasteinsert"); parent->addAction(tr("Duplicate"), &Olive::FocusFilter, SLOT(duplicate()), QKeySequence("Ctrl+D"))->setProperty("id", "duplicate"); parent->addAction(tr("Delete"), &Olive::FocusFilter, SLOT(delete_function()), QKeySequence("Del"))->setProperty("id", "delete"); - parent->addAction(tr("Ripple Delete"), this, SLOT(ripple_delete()), QKeySequence("Shift+Del"))->setProperty("id", "rippledelete"); + parent->addAction(tr("Ripple Delete"), panel_timeline, SLOT(ripple_delete()), QKeySequence("Shift+Del"))->setProperty("id", "rippledelete"); parent->addAction(tr("Split"), panel_timeline, SLOT(split_at_playhead()), QKeySequence("Ctrl+K"))->setProperty("id", "split"); } @@ -61,3 +66,83 @@ void MenuHelper::set_int_action_checked(QAction *a, const int& i) { void MenuHelper::set_button_action_checked(QAction *a) { a->setChecked(reinterpret_cast(a->data().value())->isChecked()); } + +void MenuHelper::toggle_bool_action() { + QAction* action = static_cast(sender()); + bool* variable = reinterpret_cast(action->data().value()); + *variable = !(*variable); + update_ui(false); +} + +void MenuHelper::set_titlesafe_from_menu() { + double tsa = static_cast(sender())->data().toDouble(); + + if (qIsNaN(tsa)) { + + // disable title safe area + config.show_title_safe_area = false; + + } else { + + // using title safe area + config.show_title_safe_area = true; + + // are we using the default area aspect ratio, or a specific one + if (qIsNull(tsa)) { + + // default title safe area + config.use_custom_title_safe_ratio = false; + + } else { + + // using a specific aspect ratio + config.use_custom_title_safe_ratio = true; + + if (tsa < 0.0) { + + // set a custom title safe area + QString input; + bool invalid = false; + QRegExp arTest("[0-9.]+:[0-9.]+"); + + do { + if (invalid) { + QMessageBox::critical(Olive::MainWindow, tr("Invalid aspect ratio"), tr("The aspect ratio '%1' is invalid. Please try again.").arg(input)); + } + + input = QInputDialog::getText(Olive::MainWindow, 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); + + if (!input.isEmpty()) { + QStringList inputList = input.split(':'); + config.custom_title_safe_ratio = inputList.at(0).toDouble()/inputList.at(1).toDouble(); + } + + } else { + + // specified tsa is a specific custom aspect ratio + config.custom_title_safe_ratio = tsa; + } + + } + + } + + panel_sequence_viewer->viewer_widget->update(); +} + +void MenuHelper::set_autoscroll() { + QAction* action = static_cast(sender()); + config.autoscroll = action->data().toInt(); +} + +void MenuHelper::menu_click_button() { + reinterpret_cast(static_cast(sender())->data().value())->click(); +} + +void MenuHelper::set_timecode_view() { + QAction* action = static_cast(sender()); + config.timecode_view = action->data().toInt(); + update_ui(false); +} diff --git a/ui/menuhelper.h b/ui/menuhelper.h index 6487d5da0..31273909e 100644 --- a/ui/menuhelper.h +++ b/ui/menuhelper.h @@ -58,6 +58,17 @@ public: void set_bool_action_checked(QAction* a); void set_int_action_checked(QAction* a, const int& i); void set_button_action_checked(QAction* a); + +public slots: + + void toggle_bool_action(); + + void set_titlesafe_from_menu(); + + void set_autoscroll(); + void menu_click_button(); + void set_timecode_view(); + private slots: