diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index da1ee09c2..4415db6ab 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -120,7 +120,7 @@ void PreferencesDialog::save() { return; } - bool needs_restart = false; + // save settings from UI to backend config.css_path = custom_css_fn->text(); mainWindow->load_css_from_file(config.css_path); @@ -133,24 +133,28 @@ void PreferencesDialog::save() { config.previous_queue_size = previous_queue_spinbox->value(); config.previous_queue_type = previous_queue_type->currentIndex(); - if (config.effect_textbox_lines != effect_textbox_lines_field->value()) { - needs_restart = true; - } + // the following settings may require a restart of Olive to take effect: + + bool needs_restart = false; + + if (config.effect_textbox_lines != effect_textbox_lines_field->value()) { + needs_restart = true; + } config.effect_textbox_lines = effect_textbox_lines_field->value(); - if (config.use_software_fallback != use_software_fallbacks_checkbox->isChecked()) { - needs_restart = true; - } - config.use_software_fallback = use_software_fallbacks_checkbox->isChecked(); + if (config.use_software_fallback != use_software_fallbacks_checkbox->isChecked()) { + needs_restart = true; + } + config.use_software_fallback = use_software_fallbacks_checkbox->isChecked(); // save keyboard shortcuts for (int i=0;iset_action_shortcut(); } - if (needs_restart) { - QMessageBox::information(this, tr("Warning"), tr("Some changed settings will require restarting Olive to take effect")); - } + if (needs_restart) { + QMessageBox::information(this, tr("Warning"), tr("Some changed settings will require restarting Olive to take effect")); + } accept(); } @@ -319,11 +323,11 @@ void PreferencesDialog::setup_ui() { effect_textbox_lines_field->setValue(config.effect_textbox_lines); general_layout->addWidget(effect_textbox_lines_field, 3, 1, 1, 2); - // General -> Use Software Fallbacks When Possible - use_software_fallbacks_checkbox = new QCheckBox(general_tab); - use_software_fallbacks_checkbox->setText(tr("Use Software Fallbacks When Possible")); - use_software_fallbacks_checkbox->setChecked(config.use_software_fallback); - general_layout->addWidget(use_software_fallbacks_checkbox, 4, 0, 1, 1); + // General -> Use Software Fallbacks When Possible + use_software_fallbacks_checkbox = new QCheckBox(general_tab); + use_software_fallbacks_checkbox->setText(tr("Use Software Fallbacks When Possible")); + use_software_fallbacks_checkbox->setChecked(config.use_software_fallback); + general_layout->addWidget(use_software_fallbacks_checkbox, 4, 0, 1, 1); tabWidget->addTab(general_tab, tr("General")); diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index e9a4e059f..9e3ad21fc 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -61,7 +61,7 @@ private: QDoubleSpinBox* previous_queue_spinbox; QComboBox* previous_queue_type; QSpinBox* effect_textbox_lines_field; - QCheckBox* use_software_fallbacks_checkbox; + QCheckBox* use_software_fallbacks_checkbox; QVector key_shortcut_actions; QVector key_shortcut_items; diff --git a/io/config.cpp b/io/config.cpp index 97e1bf88c..912fe86e9 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -47,7 +47,8 @@ Config::Config() loop(true), seek_also_selects(false), effect_textbox_lines(3), - use_software_fallback(false) + use_software_fallback(false), + center_timeline_timecodes(true) {} void Config::load(QString path) { @@ -169,6 +170,9 @@ void Config::load(QString path) { } else if (stream.name() == "UseSoftwareFallback") { stream.readNext(); use_software_fallback = (stream.text() == "1"); + } else if (stream.name() == "CenterTimelineTimecodes") { + stream.readNext(); + center_timeline_timecodes = (stream.text() == "1"); } } } @@ -230,6 +234,7 @@ void Config::save(QString path) { stream.writeTextElement("CSSPath", css_path); stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines)); stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback)); + stream.writeTextElement("CenterTimelineTimecodes", QString::number(center_timeline_timecodes)); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index 67b728b21..84bd848df 100644 --- a/io/config.h +++ b/io/config.h @@ -63,6 +63,7 @@ struct Config { QString css_path; int effect_textbox_lines; bool use_software_fallback; + bool center_timeline_timecodes; void load(QString path); void save(QString path); diff --git a/mainwindow.h b/mainwindow.h index 9bff5dd22..4652b2c24 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -39,6 +39,8 @@ public slots: void nest(); void toggle_full_screen(); + void toggle_bool_action(); + protected: void closeEvent(QCloseEvent *); void paintEvent(QPaintEvent *event); @@ -126,7 +128,6 @@ private slots: void edit_to_in_point(); void edit_to_out_point(); void paste_insert(); - void toggle_bool_action(); void set_autoscroll(); void menu_click_button(); void toggle_panel_visibility(); @@ -142,6 +143,10 @@ private: bool can_close_project(); void setup_menus(); + void set_bool_action_checked(QAction* a); + void set_int_action_checked(QAction* a, const int& i); + void set_button_action_checked(QAction* a); + // menu bar menus QMenu* window_menu; @@ -196,10 +201,6 @@ private: QAction* undo_action; QAction* redo_action; - void set_bool_action_checked(QAction* a); - void set_int_action_checked(QAction* a, const int& i); - void set_button_action_checked(QAction* a); - bool enable_launch_with_project; QString appName; diff --git a/ui/timelineheader.cpp b/ui/timelineheader.cpp index 3b4858e6a..5746028e4 100644 --- a/ui/timelineheader.cpp +++ b/ui/timelineheader.cpp @@ -22,6 +22,9 @@ #define SUBLINE_MIN_PADDING 50 // TODO play with this #define MARKER_SIZE 4 +// used only if center_timeline_timecodes is FALSE +#define TEXT_PADDING_FROM_LINE 4 + bool center_scroll_to_playhead(QScrollBar* bar, double zoom, long playhead) { // returns true is the scroll was changed, false if not int target_scroll = qMin(bar->maximum(), qMax(0, getScreenPointFromFrame(zoom, playhead)-(bar->width()>>1))); @@ -351,7 +354,16 @@ void TimelineHeader::paintEvent(QPaintEvent*) { timecode = frame_to_timecode(frame + in_visible, config.timecode_view, viewer->seq->frame_rate); fullTextWidth = fm.width(timecode); textWidth = fullTextWidth>>1; - text_x = lineX-textWidth; + + text_x = lineX; + + // centers the text to that point on the timeline, LEFT aligns it if not + if (config.center_timeline_timecodes) { + text_x -= textWidth; + } else { + text_x += TEXT_PADDING_FROM_LINE; + } + lastTextBoundary = lineX+textWidth; if (lastTextBoundary >= 0) { draw_text = true; @@ -366,7 +378,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) { // draw line markers p.setPen(Qt::gray); - p.drawLine(lineX, yoff, lineX, height()); + p.drawLine(lineX, (!config.center_timeline_timecodes && draw_text) ? 0 : yoff, lineX, height()); // draw sub-line markers for (int j=1;jmake_inout_menu(&menu); + menu.addSeparator(); + + QAction* center_timecodes = menu.addAction(tr("Center Timecodes"), mainWindow, SLOT(toggle_bool_action())); + center_timecodes->setCheckable(true); + center_timecodes->setChecked(config.center_timeline_timecodes); + center_timecodes->setData(reinterpret_cast(&config.center_timeline_timecodes)); + menu.exec(mapToGlobal(pos)); }