From 9143561bb476a8a4093ded9ea42742166fed0993 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 17 Jan 2019 23:38:42 +1100 Subject: [PATCH] added preference for effect textbox size --- dialogs/preferencesdialog.cpp | 16 +++++++++++++++- dialogs/preferencesdialog.h | 6 ++++-- io/config.cpp | 19 ++++++++++++------- io/config.h | 9 +++++---- project/effectfield.cpp | 3 +++ 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index 5e8997ace..a2dce700d 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -130,6 +130,7 @@ void PreferencesDialog::save() { config.upcoming_queue_type = upcoming_queue_type->currentIndex(); config.previous_queue_size = previous_queue_spinbox->value(); config.previous_queue_type = previous_queue_type->currentIndex(); + config.effect_textbox_lines = effect_textbox_lines_field->value(); // save keyboard shortcuts for (int i=0;i Custom CSS general_layout->addWidget(new QLabel(tr("Custom CSS:")), 0, 0, 1, 1); custom_css_fn = new QLineEdit(general_tab); @@ -278,21 +281,32 @@ void PreferencesDialog::setup_ui() { connect(custom_css_browse, SIGNAL(clicked(bool)), this, SLOT(browse_css_file())); general_layout->addWidget(custom_css_browse, 0, 2, 1, 1); + // General -> Image Sequence Formats 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 -> Audio Recording 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")); - general_layout->addWidget(recordingComboBox, 2, 1, 1, 2); + // General -> Effect Textbox Lines + general_layout->addWidget(new QLabel(tr("Effect Textbox Lines:")), 3, 0, 1, 1); + + effect_textbox_lines_field = new QSpinBox(general_tab); + effect_textbox_lines_field->setMinimum(1); + effect_textbox_lines_field->setValue(config.effect_textbox_lines); + general_layout->addWidget(effect_textbox_lines_field, 3, 1, 1, 2); + tabWidget->addTab(general_tab, tr("General")); + + // Behavior QWidget* behavior_tab = new QWidget(); tabWidget->addTab(behavior_tab, tr("Behavior")); diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index 49758151f..545f8d0af 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -12,6 +12,7 @@ class QTreeWidgetItem; class QMenu; class QCheckBox; class QDoubleSpinBox; +class QSpinBox; class KeySequenceEditor : public QKeySequenceEdit { Q_OBJECT @@ -42,13 +43,13 @@ private slots: bool refine_shortcut_list(const QString &, QTreeWidgetItem* parent = nullptr); void load_shortcut_file(); void save_shortcut_file(); - void browse_css_file(); + void browse_css_file(); private: void setup_ui(); void setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent); - QLineEdit* custom_css_fn; + QLineEdit* custom_css_fn; QLineEdit* imgSeqFormatEdit; QComboBox* recordingComboBox; QRadioButton* accurateSeekButton; @@ -59,6 +60,7 @@ private: QComboBox* upcoming_queue_type; QDoubleSpinBox* previous_queue_spinbox; QComboBox* previous_queue_type; + QSpinBox* effect_textbox_lines_field; QVector key_shortcut_actions; QVector key_shortcut_items; diff --git a/io/config.cpp b/io/config.cpp index 18d0bc540..cd77bf374 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -46,7 +46,8 @@ Config::Config() upcoming_queue_type(FRAME_QUEUE_TYPE_SECONDS), loop(true), pause_at_out_point(true), - seek_also_selects(false) + seek_also_selects(false), + effect_textbox_lines(3) {} void Config::load(QString path) { @@ -162,10 +163,13 @@ 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(); - } + } else if (stream.name() == "CSSPath") { + stream.readNext(); + css_path = stream.text().toString(); + } else if (stream.name() == "EffectTextboxLines") { + stream.readNext(); + effect_textbox_lines = stream.text().toInt(); + } } } if (stream.hasError()) { @@ -223,8 +227,9 @@ 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("CSSPath", css_path); + stream.writeTextElement("SeekAlsoSelects", QString::number(seek_also_selects)); + stream.writeTextElement("CSSPath", css_path); + stream.writeTextElement("EffectTextboxLines", QString::number(effect_textbox_lines)); stream.writeEndElement(); // configuration stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index 9983839d9..a3782b2ee 100644 --- a/io/config.h +++ b/io/config.h @@ -58,10 +58,11 @@ struct Config { int previous_queue_type; double upcoming_queue_size; int upcoming_queue_type; - bool loop; - bool pause_at_out_point; - bool seek_also_selects; - QString css_path; + bool loop; + bool pause_at_out_point; + bool seek_also_selects; + QString css_path; + int effect_textbox_lines; void load(QString path); void save(QString path); diff --git a/project/effectfield.cpp b/project/effectfield.cpp index 4f3ec79be..30fe376f4 100644 --- a/project/effectfield.cpp +++ b/project/effectfield.cpp @@ -8,6 +8,8 @@ #include "ui/fontcombobox.h" #include "ui/embeddedfilechooser.h" +#include "io/config.h" + #include "effectrow.h" #include "effect.h" @@ -44,6 +46,7 @@ EffectField::EffectField(EffectRow *parent, int t, const QString &i) : case EFFECT_FIELD_STRING: { TextEditEx* edit = new TextEditEx(); + edit->setFixedHeight(edit->fontMetrics().lineSpacing()*config.effect_textbox_lines); edit->setUndoRedoEnabled(true); ui_element = edit; connect(edit, SIGNAL(textChanged()), this, SLOT(ui_element_change()));