X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fmultilineedit.cpp;h=4c5759f552680752f848e92c55e3d99c2b6c42d3;hp=114c61349a058ef1a97e22bc3337a70135840f81;hb=3ff1ec5b699a38e4a03deec4ea9576fade54cbbe;hpb=e1164aedd95d03553cc875e6501f8e1fe35c2d9e diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index 114c6134..4c5759f5 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -40,6 +40,7 @@ MultiLineEdit::MultiLineEdit(QWidget *parent) _maxHeight(5), _scrollBarsEnabled(true), _pasteProtectionEnabled(true), + _emacsMode(false), _lastDocumentHeight(-1) { #if QT_VERSION >= 0x040500 @@ -347,6 +348,9 @@ void MultiLineEdit::keyPressEvent(QKeyEvent *event) { moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); cut(); return; + + default: + break; } } else if(event->modifiers() & Qt::MetaModifier || @@ -394,6 +398,29 @@ void MultiLineEdit::keyPressEvent(QKeyEvent *event) { textCursor().insertText(text.left(1).toUpper() + text.mid(1).toLower()); return; } + + case Qt::Key_T: { // transpose words + moveCursor(QTextCursor::StartOfWord); + moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); + QString const word1 = textCursor().selectedText(); + textCursor().clearSelection(); + moveCursor(QTextCursor::WordRight); + moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); + QString const word2 = textCursor().selectedText(); + if(!word2.isEmpty() && !word1.isEmpty()) { + textCursor().insertText(word1); + moveCursor(QTextCursor::WordLeft); + moveCursor(QTextCursor::WordLeft); + moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); + textCursor().insertText(word2); + moveCursor(QTextCursor::WordRight); + moveCursor(QTextCursor::EndOfWord); + } + return; + } + + default: + break; } } } @@ -631,7 +658,7 @@ void MultiLineEdit::on_textChanged() { clear(); if(lines.count() >= 4) { - QString msg = tr("Do you really want to paste %n lines?", "", lines.count()); + QString msg = tr("Do you really want to paste %n line(s)?", "", lines.count()); msg += "

"; for(int i = 0; i < 4; i++) { msg += Qt::escape(lines[i].left(40));