summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-02-20 14:13:20 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-20 15:15:34 +0100
commitfa04dd02866e39985d9e038a067abcee650a7069 (patch)
tree0f6fe82c0fd5bfe0834728f7a3f703306303e7bf
parentd3ec09c1c0b6079335136e25f7957ea75ec4e76c (diff)
downloadqttools-fa04dd02866e39985d9e038a067abcee650a7069.tar.gz
Rich text editor: Add support for Right-to-Left blocks.
Task-number: QTBUG-9502 Change-Id: Ic1b0e4abdf71022609a90fc00f29e493958d9feb Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
-rw-r--r--src/designer/src/components/formeditor/formeditor.qrc1
-rw-r--r--src/designer/src/components/formeditor/images/righttoleft.pngbin0 -> 197 bytes
-rw-r--r--src/designer/src/lib/shared/richtexteditor.cpp22
3 files changed, 23 insertions, 0 deletions
diff --git a/src/designer/src/components/formeditor/formeditor.qrc b/src/designer/src/components/formeditor/formeditor.qrc
index 492729040..38fbb6200 100644
--- a/src/designer/src/components/formeditor/formeditor.qrc
+++ b/src/designer/src/components/formeditor/formeditor.qrc
@@ -29,6 +29,7 @@
<file>images/downplus.png</file>
<file>images/leveldown.png</file>
<file>images/levelup.png</file>
+ <file>images/righttoleft.png</file>
<file>images/mac/adjustsize.png</file>
<file>images/mac/widgettool.png</file>
<file>images/mac/signalslottool.png</file>
diff --git a/src/designer/src/components/formeditor/images/righttoleft.png b/src/designer/src/components/formeditor/images/righttoleft.png
new file mode 100644
index 000000000..26a69d5ba
--- /dev/null
+++ b/src/designer/src/components/formeditor/images/righttoleft.png
Binary files differ
diff --git a/src/designer/src/lib/shared/richtexteditor.cpp b/src/designer/src/lib/shared/richtexteditor.cpp
index 0da3a1010..92cf34048 100644
--- a/src/designer/src/lib/shared/richtexteditor.cpp
+++ b/src/designer/src/lib/shared/richtexteditor.cpp
@@ -394,6 +394,7 @@ private slots:
void setVAlignSub(bool sub);
void insertLink();
void insertImage();
+ void layoutDirectionChanged();
private:
QAction *m_bold_action;
@@ -405,6 +406,7 @@ private:
QAction *m_align_center_action;
QAction *m_align_right_action;
QAction *m_align_justify_action;
+ QAction *m_layoutDirectionAction;
QAction *m_link_action;
QAction *m_image_action;
QAction *m_simplify_richtext_action;
@@ -500,6 +502,11 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core,
tr("Justify"), editor, 0, alignment_group);
addAction(m_align_justify_action);
+ m_layoutDirectionAction = createCheckableAction(
+ createIconSet(QStringLiteral("righttoleft.png")),
+ tr("Right to Left"), this, SLOT(layoutDirectionChanged()));
+ addAction(m_layoutDirectionAction);
+
addSeparator();
// Superscript and subscript buttons
@@ -626,6 +633,20 @@ void RichTextEditorToolBar::insertImage()
m_editor->insertHtml(QStringLiteral("<img src=\"") + path + QStringLiteral("\"/>"));
}
+void RichTextEditorToolBar::layoutDirectionChanged()
+{
+ QTextCursor cursor = m_editor->textCursor();
+ QTextBlock block = cursor.block();
+ if (block.isValid()) {
+ QTextBlockFormat format = block.blockFormat();
+ const Qt::LayoutDirection newDirection = m_layoutDirectionAction->isChecked() ? Qt::RightToLeft : Qt::LeftToRight;
+ if (format.layoutDirection() != newDirection) {
+ format.setLayoutDirection(newDirection);
+ cursor.setBlockFormat(format);
+ }
+ }
+}
+
void RichTextEditorToolBar::updateActions()
{
if (m_editor == 0) {
@@ -651,6 +672,7 @@ void RichTextEditorToolBar::updateActions()
} else {
m_align_justify_action->setChecked(true);
}
+ m_layoutDirectionAction->setChecked(cursor.blockFormat().layoutDirection() == Qt::RightToLeft);
m_bold_action->setChecked(font.bold());
m_italic_action->setChecked(font.italic());