reimplemented text field

This commit is contained in:
itsmattkc
2019-03-13 01:10:17 +11:00
parent df2c5be7a7
commit d01e868d60
5 changed files with 53 additions and 21 deletions
+13 -3
View File
@@ -24,6 +24,7 @@
#include "io/config.h"
#include "io/path.h"
#include "rendering/audio.h"
#include "panels/panels.h"
#include "mainwindow.h"
#include <QMenuBar>
@@ -74,7 +75,7 @@ QString KeySequenceEditor::export_shortcut() {
if (ks != action->property("default")) {
return action->property("id").toString() + "\t" + keySequence().toString();
}
return 0;
return nullptr;
}
PreferencesDialog::PreferencesDialog(QWidget *parent) :
@@ -173,6 +174,7 @@ void PreferencesDialog::save() {
bool restart_after_saving = false;
bool reinit_audio = false;
bool reload_language = false;
bool reload_effects = false;
// Validate whether the specified CSS file exists
if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) {
@@ -184,9 +186,13 @@ void PreferencesDialog::save() {
return;
}
// Validate whether the effects panel should refresh itself
if (olive::CurrentConfig.effect_textbox_lines != effect_textbox_lines_field->value()) {
reload_effects = true;
}
// Check if any settings will require a restart of Olive
if (olive::CurrentConfig.effect_textbox_lines != effect_textbox_lines_field->value()
|| olive::CurrentConfig.use_software_fallback != use_software_fallbacks_checkbox->isChecked()
if (olive::CurrentConfig.use_software_fallback != use_software_fallbacks_checkbox->isChecked()
|| olive::CurrentConfig.thumbnail_resolution != thumbnail_res_spinbox->value()
|| olive::CurrentConfig.waveform_resolution != waveform_res_spinbox->value()) {
@@ -290,6 +296,10 @@ void PreferencesDialog::save() {
init_audio();
}
if (reload_effects) {
panel_effect_controls->Reload();
}
// reload language file if it changed
if (reload_language) {
olive::Global->load_translation_from_config();
+26
View File
@@ -1,5 +1,10 @@
#include "stringfield.h"
#include <QtMath>
#include "ui/texteditex.h"
#include "io/config.h"
StringField::StringField(EffectRow* parent, const QString& id) :
EffectField(parent, id, EFFECT_FIELD_STRING)
{
@@ -10,3 +15,24 @@ QString StringField::GetStringAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *StringField::CreateWidget()
{
TextEditEx* text_edit = new TextEditEx();
text_edit->setUndoRedoEnabled(true);
// the "2" looks like a magic number, but it's just one pixel on the top and the bottom
text_edit->setFixedHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::CurrentConfig.effect_textbox_lines
+ text_edit->document()->documentMargin()
+ text_edit->document()->documentMargin() + 2));
connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
return text_edit;
}
void StringField::UpdateFromWidget(const QString &s)
{
SetValueAt(Now(), s);
}
+4
View File
@@ -10,6 +10,10 @@ public:
StringField(EffectRow* parent, const QString& id);
QString GetStringAt(double timecode);
virtual QWidget *CreateWidget() override;
private slots:
void UpdateFromWidget(const QString& b);
};
#endif // STRINGFIELD_H
+7
View File
@@ -72,6 +72,8 @@ TextEditEx::TextEditEx(QWidget *parent) : QTextEdit(parent)
{
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(text_edit_menu()));
connect(this, SIGNAL(textChanged()), this, SLOT(queue_text_modified()));
}
void TextEditEx::text_edit_menu() {
@@ -90,3 +92,8 @@ void TextEditEx::open_text_edit() {
setHtml(result);
}
}
void TextEditEx::queue_text_modified()
{
emit textModified(toHtml());
}
+3 -18
View File
@@ -23,31 +23,16 @@
#include <QTextEdit>
/*
class TextEditEx : public QTextEdit {
Q_OBJECT
public:
TextEditEx(QWidget* parent = 0);
void setPlainTextEx(const QString &text);
const QString& getPreviousValue();
const QString& getPlainTextEx();
TextEditEx(QWidget* parent = nullptr);
signals:
void updateSelf();
private slots:
void updateInternals();
void updateText();
private:
QString previousText;
QString text;
};
*/
class TextEditEx : public QTextEdit {
public:
TextEditEx(QWidget* parent);
void textModified(const QString& s);
private slots:
void text_edit_menu();
void open_text_edit();
void queue_text_modified();
};
#endif // TEXTEDITEX_H