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;
}
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;i<key_shortcut_fields.size();i++) {
key_shortcut_fields.at(i)->set_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"));
+1 -1
View File
@@ -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<QAction*> key_shortcut_actions;
QVector<QTreeWidgetItem*> key_shortcut_items;
+6 -1
View File
@@ -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
+1
View File
@@ -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);
+6 -5
View File
@@ -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;
+21 -2
View File
@@ -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;j<sublineCount;j++) {
@@ -443,6 +455,13 @@ void TimelineHeader::show_context_menu(const QPoint &pos) {
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));
}