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 "annotationcommenttab.h"
|
||||||
#include "ui_annotationcommenttab.h"
|
#include "ui_annotationcommenttab.h"
|
||||||
|
|
||||||
|
#include "richtexteditor/richtexteditor.h"
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
AnnotationCommentTab::AnnotationCommentTab(QWidget *parent) :
|
AnnotationCommentTab::AnnotationCommentTab(QWidget *parent) :
|
||||||
@@ -34,6 +36,9 @@ AnnotationCommentTab::AnnotationCommentTab(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
m_editor = new RichTextEditor;
|
||||||
|
ui->formLayout->setWidget(3, QFormLayout::FieldRole, m_editor);
|
||||||
|
|
||||||
connect(ui->titleEdit, &QLineEdit::textEdited,
|
connect(ui->titleEdit, &QLineEdit::textEdited,
|
||||||
this, &AnnotationCommentTab::commentTitleChanged);
|
this, &AnnotationCommentTab::commentTitleChanged);
|
||||||
}
|
}
|
||||||
@@ -49,7 +54,7 @@ Comment AnnotationCommentTab::currentComment() const
|
|||||||
|
|
||||||
result.setTitle(ui->titleEdit->text().trimmed());
|
result.setTitle(ui->titleEdit->text().trimmed());
|
||||||
result.setAuthor(ui->authorEdit->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))
|
if (m_comment.sameContent(result))
|
||||||
result.setTimestamp(m_comment.timestamp());
|
result.setTimestamp(m_comment.timestamp());
|
||||||
@@ -74,7 +79,7 @@ void AnnotationCommentTab::resetUI()
|
|||||||
{
|
{
|
||||||
ui->titleEdit->setText(m_comment.title());
|
ui->titleEdit->setText(m_comment.title());
|
||||||
ui->authorEdit->setText(m_comment.author());
|
ui->authorEdit->setText(m_comment.author());
|
||||||
ui->textEdit->setText(m_comment.text());
|
m_editor->setRichText(m_comment.text());
|
||||||
|
|
||||||
if (m_comment.timestamp() > 0)
|
if (m_comment.timestamp() > 0)
|
||||||
ui->timeLabel->setText(m_comment.timestampStr());
|
ui->timeLabel->setText(m_comment.timestampStr());
|
||||||
|
@@ -35,6 +35,8 @@ namespace Ui {
|
|||||||
class AnnotationCommentTab;
|
class AnnotationCommentTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RichTextEditor;
|
||||||
|
|
||||||
class AnnotationCommentTab : public QWidget
|
class AnnotationCommentTab : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -59,6 +61,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AnnotationCommentTab *ui;
|
Ui::AnnotationCommentTab *ui;
|
||||||
|
RichTextEditor *m_editor;
|
||||||
|
|
||||||
Comment m_comment;
|
Comment m_comment;
|
||||||
};
|
};
|
||||||
|
@@ -33,13 +33,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="authorLabel">
|
<widget class="QLabel" name="authorLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -64,7 +57,6 @@
|
|||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>titleEdit</tabstop>
|
<tabstop>titleEdit</tabstop>
|
||||||
<tabstop>authorEdit</tabstop>
|
<tabstop>authorEdit</tabstop>
|
||||||
<tabstop>textEdit</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>700</width>
|
<width>1100</width>
|
||||||
<height>487</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@@ -339,7 +339,7 @@ QGraphicsItem *FormEditorAnnotationIcon::createCommentBubble(QRectF rect, const
|
|||||||
authorItem->update();
|
authorItem->update();
|
||||||
|
|
||||||
QGraphicsTextItem *textItem = new QGraphicsTextItem(frameItem);
|
QGraphicsTextItem *textItem = new QGraphicsTextItem(frameItem);
|
||||||
textItem->setPlainText(text);
|
textItem->setHtml(text);
|
||||||
textItem->setDefaultTextColor(textColor);
|
textItem->setDefaultTextColor(textColor);
|
||||||
textItem->setTextWidth(rect.width());
|
textItem->setTextWidth(rect.width());
|
||||||
textItem->setPos(authorItem->x(), authorItem->boundingRect().height() + authorItem->y() + 5);
|
textItem->setPos(authorItem->x(), authorItem->boundingRect().height() + authorItem->y() + 5);
|
||||||
|
Reference in New Issue
Block a user