From c2de17b2800b4a8b89686774f99e4fbcf7a80f4e Mon Sep 17 00:00:00 2001 From: Aleksei German Date: Wed, 8 Apr 2020 18:21:57 +0200 Subject: [PATCH] QmlDesigner: Rich Text Editor integration Change-Id: I36403a596b1d4c8241663a4b0e5b1d0e2f9cb45e Reviewed-by: Tim Jenssen --- .../components/annotationeditor/annotationcommenttab.cpp | 9 +++++++-- .../components/annotationeditor/annotationcommenttab.h | 3 +++ .../components/annotationeditor/annotationcommenttab.ui | 8 -------- .../annotationeditor/annotationeditordialog.ui | 4 ++-- .../components/formeditor/formeditorannotationicon.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp index bd7aed67d02..bfe18e952b8 100644 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp +++ b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.cpp @@ -26,6 +26,8 @@ #include "annotationcommenttab.h" #include "ui_annotationcommenttab.h" +#include "richtexteditor/richtexteditor.h" + namespace QmlDesigner { AnnotationCommentTab::AnnotationCommentTab(QWidget *parent) : @@ -34,6 +36,9 @@ AnnotationCommentTab::AnnotationCommentTab(QWidget *parent) : { ui->setupUi(this); + m_editor = new RichTextEditor; + ui->formLayout->setWidget(3, QFormLayout::FieldRole, m_editor); + connect(ui->titleEdit, &QLineEdit::textEdited, this, &AnnotationCommentTab::commentTitleChanged); } @@ -49,7 +54,7 @@ Comment AnnotationCommentTab::currentComment() const result.setTitle(ui->titleEdit->text().trimmed()); result.setAuthor(ui->authorEdit->text().trimmed()); - result.setText(ui->textEdit->toPlainText().trimmed()); + result.setText(m_editor->richText().trimmed()); if (m_comment.sameContent(result)) result.setTimestamp(m_comment.timestamp()); @@ -74,7 +79,7 @@ void AnnotationCommentTab::resetUI() { ui->titleEdit->setText(m_comment.title()); ui->authorEdit->setText(m_comment.author()); - ui->textEdit->setText(m_comment.text()); + m_editor->setRichText(m_comment.text()); if (m_comment.timestamp() > 0) ui->timeLabel->setText(m_comment.timestampStr()); diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h index cc8d4c3d769..55fcf6ff1ed 100644 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h +++ b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.h @@ -35,6 +35,8 @@ namespace Ui { class AnnotationCommentTab; } +class RichTextEditor; + class AnnotationCommentTab : public QWidget { Q_OBJECT @@ -59,6 +61,7 @@ private slots: private: Ui::AnnotationCommentTab *ui; + RichTextEditor *m_editor; Comment m_comment; }; diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.ui b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.ui index f6bf277eb7c..4a69703d57d 100644 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.ui +++ b/src/plugins/qmldesigner/components/annotationeditor/annotationcommenttab.ui @@ -33,13 +33,6 @@ - - - - true - - - @@ -64,7 +57,6 @@ titleEdit authorEdit - textEdit diff --git a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui index 8ca9b75136c..93ce92b0450 100644 --- a/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui +++ b/src/plugins/qmldesigner/components/annotationeditor/annotationeditordialog.ui @@ -6,8 +6,8 @@ 0 0 - 700 - 487 + 1100 + 600 diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorannotationicon.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorannotationicon.cpp index 5fa24f1a5c0..81072179f36 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorannotationicon.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorannotationicon.cpp @@ -339,7 +339,7 @@ QGraphicsItem *FormEditorAnnotationIcon::createCommentBubble(QRectF rect, const authorItem->update(); QGraphicsTextItem *textItem = new QGraphicsTextItem(frameItem); - textItem->setPlainText(text); + textItem->setHtml(text); textItem->setDefaultTextColor(textColor); textItem->setTextWidth(rect.width()); textItem->setPos(authorItem->x(), authorItem->boundingRect().height() + authorItem->y() + 5);