nodes: revised text node
Clarifies text node's ability to parse HTML with Qt. Removes janky incomplete "rich text editing" functionality. I don't think this is the right approach.
This commit is contained in:
@@ -28,8 +28,8 @@ set(OLIVE_SOURCES
|
||||
widget/nodeparamview/nodeparamviewitem.cpp
|
||||
widget/nodeparamview/nodeparamviewkeyframecontrol.h
|
||||
widget/nodeparamview/nodeparamviewkeyframecontrol.cpp
|
||||
widget/nodeparamview/nodeparamviewrichtext.h
|
||||
widget/nodeparamview/nodeparamviewrichtext.cpp
|
||||
widget/nodeparamview/nodeparamviewtextedit.h
|
||||
widget/nodeparamview/nodeparamviewtextedit.cpp
|
||||
widget/nodeparamview/nodeparamviewundo.h
|
||||
widget/nodeparamview/nodeparamviewundo.cpp
|
||||
widget/nodeparamview/nodeparamviewwidgetbridge.h
|
||||
|
||||
+10
-10
@@ -18,46 +18,46 @@
|
||||
|
||||
***/
|
||||
|
||||
#include "nodeparamviewrichtext.h"
|
||||
#include "nodeparamviewtextedit.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "dialog/richtext/richtext.h"
|
||||
#include "dialog/text/text.h"
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
NodeParamViewRichText::NodeParamViewRichText(QWidget *parent) :
|
||||
NodeParamViewTextEdit::NodeParamViewTextEdit(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
|
||||
line_edit_ = new QTextEdit();
|
||||
line_edit_ = new QPlainTextEdit();
|
||||
line_edit_->setUndoRedoEnabled(true);
|
||||
connect(line_edit_, &QTextEdit::textChanged, this, &NodeParamViewRichText::InnerWidgetTextChanged);
|
||||
connect(line_edit_, &QPlainTextEdit::textChanged, this, &NodeParamViewTextEdit::InnerWidgetTextChanged);
|
||||
layout->addWidget(line_edit_);
|
||||
|
||||
QPushButton* edit_btn = new QPushButton();
|
||||
edit_btn->setIcon(icon::ToolEdit);
|
||||
edit_btn->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
layout->addWidget(edit_btn);
|
||||
connect(edit_btn, &QPushButton::clicked, this, &NodeParamViewRichText::ShowRichTextDialog);
|
||||
connect(edit_btn, &QPushButton::clicked, this, &NodeParamViewTextEdit::ShowTextDialog);
|
||||
}
|
||||
|
||||
void NodeParamViewRichText::ShowRichTextDialog()
|
||||
void NodeParamViewTextEdit::ShowTextDialog()
|
||||
{
|
||||
RichTextDialog d(this->text(), this);
|
||||
TextDialog d(this->text(), this);
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
QString s = d.text();
|
||||
|
||||
line_edit_->setText(s);
|
||||
line_edit_->setPlainText(s);
|
||||
emit textEdited(s);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewRichText::InnerWidgetTextChanged()
|
||||
void NodeParamViewTextEdit::InnerWidgetTextChanged()
|
||||
{
|
||||
emit textEdited(this->text());
|
||||
}
|
||||
+11
-11
@@ -18,32 +18,32 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWRICHTEXT_H
|
||||
#define NODEPARAMVIEWRICHTEXT_H
|
||||
#ifndef NODEPARAMVIEWTEXTEDIT_H
|
||||
#define NODEPARAMVIEWTEXTEDIT_H
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QWidget>
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class NodeParamViewRichText : public QWidget
|
||||
class NodeParamViewTextEdit : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NodeParamViewRichText(QWidget* parent = nullptr);
|
||||
NodeParamViewTextEdit(QWidget* parent = nullptr);
|
||||
|
||||
QString text() const
|
||||
{
|
||||
return line_edit_->toPlainText().replace('\n', QStringLiteral("<br>"));
|
||||
return line_edit_->toPlainText();
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setText(QString s)
|
||||
void setText(const QString &s)
|
||||
{
|
||||
line_edit_->blockSignals(true);
|
||||
line_edit_->setPlainText(s.replace(QStringLiteral("<br>"), QStringLiteral("\n")));
|
||||
line_edit_->setPlainText(s);
|
||||
line_edit_->blockSignals(false);
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@ signals:
|
||||
void textEdited(const QString &);
|
||||
|
||||
private:
|
||||
QTextEdit* line_edit_;
|
||||
QPlainTextEdit* line_edit_;
|
||||
|
||||
private slots:
|
||||
void ShowRichTextDialog();
|
||||
void ShowTextDialog();
|
||||
|
||||
void InnerWidgetTextChanged();
|
||||
|
||||
@@ -76,4 +76,4 @@ private slots:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWRICHTEXT_H
|
||||
#endif // NODEPARAMVIEWTEXTEDIT_H
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "node/node.h"
|
||||
#include "node/project/sequence/sequence.h"
|
||||
#include "nodeparamviewarraywidget.h"
|
||||
#include "nodeparamviewrichtext.h"
|
||||
#include "nodeparamviewtextedit.h"
|
||||
#include "nodeparamviewundo.h"
|
||||
#include "undo/undostack.h"
|
||||
#include "widget/colorbutton/colorbutton.h"
|
||||
@@ -143,9 +143,9 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
}
|
||||
case NodeValue::kText:
|
||||
{
|
||||
NodeParamViewRichText* line_edit = new NodeParamViewRichText();
|
||||
NodeParamViewTextEdit* line_edit = new NodeParamViewTextEdit();
|
||||
widgets_.append(line_edit);
|
||||
connect(line_edit, &NodeParamViewRichText::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
connect(line_edit, &NodeParamViewTextEdit::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kBoolean:
|
||||
@@ -358,7 +358,7 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
case NodeValue::kText:
|
||||
{
|
||||
// Sender is a NodeParamViewRichText
|
||||
SetInputValue(static_cast<NodeParamViewRichText*>(sender())->text(), 0);
|
||||
SetInputValue(static_cast<NodeParamViewTextEdit*>(sender())->text(), 0);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kBoolean:
|
||||
@@ -498,7 +498,7 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
|
||||
}
|
||||
case NodeValue::kText:
|
||||
{
|
||||
NodeParamViewRichText* e = static_cast<NodeParamViewRichText*>(widgets_.first());
|
||||
NodeParamViewTextEdit* e = static_cast<NodeParamViewTextEdit*>(widgets_.first());
|
||||
e->setTextPreservingCursor(input_.GetValueAtTime(node_time).toString());
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user