QmlDesigner: Rich Text Editor integration

Change-Id: I36403a596b1d4c8241663a4b0e5b1d0e2f9cb45e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Aleksei German
2020-04-08 18:21:57 +02:00
parent fd62e36332
commit c2de17b280
5 changed files with 13 additions and 13 deletions

View File

@@ -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());

View File

@@ -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;
};

View File

@@ -33,13 +33,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTextEdit" name="textEdit">
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="authorLabel">
<property name="text">
@@ -64,7 +57,6 @@
<tabstops>
<tabstop>titleEdit</tabstop>
<tabstop>authorEdit</tabstop>
<tabstop>textEdit</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>487</height>
<width>1100</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">

View File

@@ -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);