added configurable centered timecodes

This commit is contained in:
itsmattkc
2019-01-28 17:25:36 +11:00
parent c6da0b5912
commit be854d14d6
6 changed files with 55 additions and 25 deletions
+20 -16
View File
@@ -120,7 +120,7 @@ void PreferencesDialog::save() {
return; return;
} }
bool needs_restart = false; // save settings from UI to backend
config.css_path = custom_css_fn->text(); config.css_path = custom_css_fn->text();
mainWindow->load_css_from_file(config.css_path); 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_size = previous_queue_spinbox->value();
config.previous_queue_type = previous_queue_type->currentIndex(); config.previous_queue_type = previous_queue_type->currentIndex();
if (config.effect_textbox_lines != effect_textbox_lines_field->value()) { // the following settings may require a restart of Olive to take effect:
needs_restart = true;
} 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(); config.effect_textbox_lines = effect_textbox_lines_field->value();
if (config.use_software_fallback != use_software_fallbacks_checkbox->isChecked()) { if (config.use_software_fallback != use_software_fallbacks_checkbox->isChecked()) {
needs_restart = true; needs_restart = true;
} }
config.use_software_fallback = use_software_fallbacks_checkbox->isChecked(); config.use_software_fallback = use_software_fallbacks_checkbox->isChecked();
// save keyboard shortcuts // save keyboard shortcuts
for (int i=0;i<key_shortcut_fields.size();i++) { for (int i=0;i<key_shortcut_fields.size();i++) {
key_shortcut_fields.at(i)->set_action_shortcut(); key_shortcut_fields.at(i)->set_action_shortcut();
} }
if (needs_restart) { if (needs_restart) {
QMessageBox::information(this, tr("Warning"), tr("Some changed settings will require restarting Olive to take effect")); QMessageBox::information(this, tr("Warning"), tr("Some changed settings will require restarting Olive to take effect"));
} }
accept(); accept();
} }
@@ -319,11 +323,11 @@ void PreferencesDialog::setup_ui() {
effect_textbox_lines_field->setValue(config.effect_textbox_lines); effect_textbox_lines_field->setValue(config.effect_textbox_lines);
general_layout->addWidget(effect_textbox_lines_field, 3, 1, 1, 2); general_layout->addWidget(effect_textbox_lines_field, 3, 1, 1, 2);
// General -> Use Software Fallbacks When Possible // General -> Use Software Fallbacks When Possible
use_software_fallbacks_checkbox = new QCheckBox(general_tab); use_software_fallbacks_checkbox = new QCheckBox(general_tab);
use_software_fallbacks_checkbox->setText(tr("Use Software Fallbacks When Possible")); use_software_fallbacks_checkbox->setText(tr("Use Software Fallbacks When Possible"));
use_software_fallbacks_checkbox->setChecked(config.use_software_fallback); use_software_fallbacks_checkbox->setChecked(config.use_software_fallback);
general_layout->addWidget(use_software_fallbacks_checkbox, 4, 0, 1, 1); general_layout->addWidget(use_software_fallbacks_checkbox, 4, 0, 1, 1);
tabWidget->addTab(general_tab, tr("General")); tabWidget->addTab(general_tab, tr("General"));
+1 -1
View File
@@ -61,7 +61,7 @@ private:
QDoubleSpinBox* previous_queue_spinbox; QDoubleSpinBox* previous_queue_spinbox;
QComboBox* previous_queue_type; QComboBox* previous_queue_type;
QSpinBox* effect_textbox_lines_field; QSpinBox* effect_textbox_lines_field;
QCheckBox* use_software_fallbacks_checkbox; QCheckBox* use_software_fallbacks_checkbox;
QVector<QAction*> key_shortcut_actions; QVector<QAction*> key_shortcut_actions;
QVector<QTreeWidgetItem*> key_shortcut_items; QVector<QTreeWidgetItem*> key_shortcut_items;
+6 -1
View File
@@ -47,7 +47,8 @@ Config::Config()
loop(true), loop(true),
seek_also_selects(false), seek_also_selects(false),
effect_textbox_lines(3), effect_textbox_lines(3),
use_software_fallback(false) use_software_fallback(false),
center_timeline_timecodes(true)
{} {}
void Config::load(QString path) { void Config::load(QString path) {
@@ -169,6 +170,9 @@ void Config::load(QString path) {
} else if (stream.name() == "UseSoftwareFallback") { } else if (stream.name() == "UseSoftwareFallback") {
stream.readNext(); stream.readNext();
use_software_fallback = (stream.text() == "1"); 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("CSSPath", css_path);
stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines)); stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines));
stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback)); stream.writeTextElement("UseSoftwareFallback", QString::number(use_software_fallback));
stream.writeTextElement("CenterTimelineTimecodes", QString::number(center_timeline_timecodes));
stream.writeEndElement(); // configuration stream.writeEndElement(); // configuration
stream.writeEndDocument(); // doc stream.writeEndDocument(); // doc
+1
View File
@@ -63,6 +63,7 @@ struct Config {
QString css_path; QString css_path;
int effect_textbox_lines; int effect_textbox_lines;
bool use_software_fallback; bool use_software_fallback;
bool center_timeline_timecodes;
void load(QString path); void load(QString path);
void save(QString path); void save(QString path);
+6 -5
View File
@@ -39,6 +39,8 @@ public slots:
void nest(); void nest();
void toggle_full_screen(); void toggle_full_screen();
void toggle_bool_action();
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
@@ -126,7 +128,6 @@ private slots:
void edit_to_in_point(); void edit_to_in_point();
void edit_to_out_point(); void edit_to_out_point();
void paste_insert(); void paste_insert();
void toggle_bool_action();
void set_autoscroll(); void set_autoscroll();
void menu_click_button(); void menu_click_button();
void toggle_panel_visibility(); void toggle_panel_visibility();
@@ -142,6 +143,10 @@ private:
bool can_close_project(); bool can_close_project();
void setup_menus(); 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 // menu bar menus
QMenu* window_menu; QMenu* window_menu;
@@ -196,10 +201,6 @@ private:
QAction* undo_action; QAction* undo_action;
QAction* redo_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; bool enable_launch_with_project;
QString appName; QString appName;
+21 -2
View File
@@ -22,6 +22,9 @@
#define SUBLINE_MIN_PADDING 50 // TODO play with this #define SUBLINE_MIN_PADDING 50 // TODO play with this
#define MARKER_SIZE 4 #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) { bool center_scroll_to_playhead(QScrollBar* bar, double zoom, long playhead) {
// returns true is the scroll was changed, false if not // returns true is the scroll was changed, false if not
int target_scroll = qMin(bar->maximum(), qMax(0, getScreenPointFromFrame(zoom, playhead)-(bar->width()>>1))); 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); timecode = frame_to_timecode(frame + in_visible, config.timecode_view, viewer->seq->frame_rate);
fullTextWidth = fm.width(timecode); fullTextWidth = fm.width(timecode);
textWidth = fullTextWidth>>1; 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; lastTextBoundary = lineX+textWidth;
if (lastTextBoundary >= 0) { if (lastTextBoundary >= 0) {
draw_text = true; draw_text = true;
@@ -366,7 +378,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
// draw line markers // draw line markers
p.setPen(Qt::gray); 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 // draw sub-line markers
for (int j=1;j<sublineCount;j++) { for (int j=1;j<sublineCount;j++) {
@@ -443,6 +455,13 @@ void TimelineHeader::show_context_menu(const QPoint &pos) {
mainWindow->make_inout_menu(&menu); mainWindow->make_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<quintptr>(&config.center_timeline_timecodes));
menu.exec(mapToGlobal(pos)); menu.exec(mapToGlobal(pos));
} }