forked from qt-creator/qt-creator
QmlDesigner: Rich Text Editor integration
Change-Id: I36403a596b1d4c8241663a4b0e5b1d0e2f9cb45e Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -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());
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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/>
|
||||
|
@@ -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">
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user