richtextdialog: show html tags rather than wysiwyg
While good in theory, a WYSIWYG rich text editor for large video frames was unwieldy (and in many cases unhelpful). Instead the titler will show plain text/HTML tags so the user can still write rich text but without the unwieldy UI. For a true WYSIWYG experience, we would probably need to write a true graphical editor (a la Premiere's titler), but that's a later goal. This titler will be sufficient in a good majority of cases and there are plenty of dedicated graphics packages if more complex titling is required for the timebeing.
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
RichTextDialog::RichTextDialog(const QString &start, QWidget* parent) :
|
||||
RichTextDialog::RichTextDialog(QString start, QWidget* parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
@@ -70,8 +70,9 @@ RichTextDialog::RichTextDialog(const QString &start, QWidget* parent) :
|
||||
// Create text edit widget
|
||||
text_edit_ = new QTextEdit();
|
||||
text_edit_->setWordWrapMode(QTextOption::NoWrap);
|
||||
connect(text_edit_, &QTextEdit::cursorPositionChanged, this, &RichTextDialog::UpdateButtons);
|
||||
text_edit_->document()->setHtml(start);
|
||||
//connect(text_edit_, &QTextEdit::cursorPositionChanged, this, &RichTextDialog::UpdateButtons);
|
||||
start.replace(QStringLiteral("<br>"), QStringLiteral("\n"));
|
||||
text_edit_->document()->setPlainText(start);
|
||||
layout->addWidget(text_edit_);
|
||||
|
||||
// Create buttons
|
||||
@@ -81,6 +82,7 @@ RichTextDialog::RichTextDialog(const QString &start, QWidget* parent) :
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &RichTextDialog::reject);
|
||||
|
||||
// Connect font buttons
|
||||
/*
|
||||
connect(bold_btn_, &QPushButton::clicked, this, [this](bool e){
|
||||
text_edit_->setFontWeight(e ? QFont::Bold : QFont::Normal);
|
||||
});
|
||||
@@ -113,6 +115,7 @@ RichTextDialog::RichTextDialog(const QString &start, QWidget* parent) :
|
||||
connect(font_combo_, &QFontComboBox::currentTextChanged, this, [this](const QString& s){
|
||||
text_edit_->setFontFamily(s);
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
QPushButton *RichTextDialog::CreateToolbarButton(const QString& label, const QString& tooltip)
|
||||
@@ -126,6 +129,7 @@ QPushButton *RichTextDialog::CreateToolbarButton(const QString& label, const QSt
|
||||
|
||||
void RichTextDialog::UpdateButtons()
|
||||
{
|
||||
/*
|
||||
bold_btn_->setChecked(text_edit_->fontWeight() > QFont::Normal);
|
||||
italic_btn_->setChecked(text_edit_->fontItalic());
|
||||
underline_btn_->setChecked(text_edit_->fontUnderline());
|
||||
@@ -142,6 +146,7 @@ void RichTextDialog::UpdateButtons()
|
||||
center_align_btn_->setChecked(text_edit_->alignment() == Qt::AlignCenter);
|
||||
right_align_btn_->setChecked(text_edit_->alignment() == Qt::AlignRight);
|
||||
justify_align_btn_->setChecked(text_edit_->alignment() == Qt::AlignJustify);
|
||||
*/
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -34,11 +34,16 @@ class RichTextDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RichTextDialog(const QString& start, QWidget* parent = nullptr);
|
||||
RichTextDialog(QString start, QWidget* parent = nullptr);
|
||||
|
||||
QString text() const
|
||||
{
|
||||
return text_edit_->document()->toHtml("utf-8");
|
||||
QString s = text_edit_->document()->toPlainText();
|
||||
|
||||
// Convert linebreaks
|
||||
s.replace('\n', QStringLiteral("<br>"));
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -48,8 +48,10 @@ void NodeParamViewRichText::ShowRichTextDialog()
|
||||
{
|
||||
RichTextDialog d(line_edit_->text(), this);
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
line_edit_->setText(d.text());
|
||||
emit textEdited(d.text());
|
||||
QString s = d.text();
|
||||
|
||||
line_edit_->setText(s);
|
||||
emit textEdited(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user