diff options
| author | fschmid <fschmid@11d20701-8431-0410-a711-e3c959e3b870> | 2012-01-29 09:44:55 +0000 |
|---|---|---|
| committer | fschmid <fschmid@11d20701-8431-0410-a711-e3c959e3b870> | 2012-01-29 09:44:55 +0000 |
| commit | 2aa6551af9ad44d387cf7055c9b58c061575c15b (patch) | |
| tree | 3552285d402642ea84a89e189402ced3adee2ef2 /scribus/storyeditor.cpp | |
| parent | 80db955537db5b700231469e8b30e5ddede6374b (diff) | |
| download | scribus-2aa6551af9ad44d387cf7055c9b58c061575c15b.tar.gz scribus-2aa6551af9ad44d387cf7055c9b58c061575c15b.tar.xz scribus-2aa6551af9ad44d387cf7055c9b58c061575c15b.zip | |
Applied Patch from Bug 10550: "Story editor does not show pre-edit strings when a input method is active."
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17256 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/storyeditor.cpp')
| -rw-r--r-- | scribus/storyeditor.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/scribus/storyeditor.cpp b/scribus/storyeditor.cpp index d393205..4fb4b8b 100644 --- a/scribus/storyeditor.cpp +++ b/scribus/storyeditor.cpp @@ -267,6 +267,7 @@ SEditor::SEditor(QWidget* parent, ScribusDoc *docc, StoryEditor* parentSE) : QTe setAutoFillBackground(true); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipChange())); connect(this->document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(handleContentsChange(int, int, int))); + SuspendContentsChange = 0; } void SEditor::setCurrentDocument(ScribusDoc *docc) @@ -278,14 +279,48 @@ void SEditor::setCurrentDocument(ScribusDoc *docc) void SEditor::inputMethodEvent(QInputMethodEvent *event) { QString uc = event->commitString(); - if ((!uc.isEmpty()) && ((*doc->AllFonts)[CurrFont].canRender(uc[0]))) + SuspendContentsChange = 1; // prevent our handler from doing anything + bool changed = false; + int pos; + if(textCursor().hasSelection()) + { + pos = textCursor().selectionStart(); + StyledText.removeChars(pos, textCursor().selectionEnd() - pos); + changed = true; + } + pos = -1; + if(!uc.isEmpty()) + { + if ((*doc->AllFonts)[CurrFont].canRender(uc[0])) + { + pos = textCursor().hasSelection() ? textCursor().selectionStart() : textCursor().position(); + pos = qMin(pos, StyledText.length()); + } + else + { + event->setCommitString(""); + } + } + QTextEdit::inputMethodEvent(event); + SuspendContentsChange = 0; + if(pos >= 0) + { + handleContentsChange(pos, 0, uc.length()); + changed = true; + } + if(changed) + { + emit SideBarUp(true); + emit SideBarUpdate(); + } +/* if ((!uc.isEmpty()) && ((*doc->AllFonts)[CurrFont].canRender(uc[0]))) { // Should be processed by the handleContentsChange slot // insertCharsInternal(event->commitString()); QTextEdit::inputMethodEvent(event); emit SideBarUp(true); emit SideBarUpdate(); - } + } */ } void SEditor::keyPressEvent(QKeyEvent *k) @@ -445,6 +480,10 @@ void SEditor::keyPressEvent(QKeyEvent *k) void SEditor::handleContentsChange(int position, int charsRemoved, int charsAdded) { + // As of Qt 4.7.4, Cococa-QTextEdit output of input method is broken. + // We need a workaround to avoit the bug. + if(SuspendContentsChange != 0) + return; if (blockContentsChangeHook <= 0) { if (charsRemoved > 0 && StyledText.length() > 0) @@ -2009,6 +2048,7 @@ void StoryEditor::connectSignals() connect(Editor, SIGNAL(SideBarUp(bool )), EditorBar, SLOT(setRepaint(bool ))); connect(Editor, SIGNAL(SideBarUpdate( )), EditorBar, SLOT(doRepaint())); connect(Editor->document(), SIGNAL(contentsChange(int, int, int)), Editor, SLOT(handleContentsChange(int, int, int))); + Editor->SuspendContentsChange = 0; // 10/12/2004 - pv - #1203: wrong selection on double click // connect(Editor, SIGNAL(doubleClicked(int, int)), this, SLOT(doubleClick(int, int))); connect(EditorBar, SIGNAL(ChangeStyle(int, const QString& )), this, SLOT(changeStyleSB(int, const QString&))); |
