X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fmultilineedit.cpp;h=ed0dbb60cc75840287c01c7cfdee72d5cc84c2dc;hp=a4d95b0dbebf7071e97d8cc9cccc25a0bfbd33cc;hb=71c1023224f3446ea610793cc47019e792359e77;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index a4d95b0d..ed0dbb60 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2012 by the Quassel Project * + * Copyright (C) 2005-2015 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include @@ -43,9 +43,7 @@ MultiLineEdit::MultiLineEdit(QWidget *parent) _emacsMode(false), _lastDocumentHeight(-1) { -#if QT_VERSION >= 0x040500 - document()->setDocumentMargin(0); // new in Qt 4.5 and we really don't want it here -#endif + document()->setDocumentMargin(0); setAcceptRichText(false); #ifdef HAVE_KDE @@ -53,7 +51,7 @@ MultiLineEdit::MultiLineEdit(QWidget *parent) #endif setMode(SingleLine); - setWordWrapEnabled(false); + setLineWrapEnabled(false); reset(); connect(this, SIGNAL(textChanged()), this, SLOT(on_textChanged())); @@ -98,6 +96,13 @@ void MultiLineEdit::setMode(Mode mode) } +void MultiLineEdit::setLineWrapEnabled(bool enable) +{ + setLineWrapMode(enable ? WidgetWidth : NoWrap); + updateSizeHint(); +} + + void MultiLineEdit::setMinHeight(int lines) { if (lines == _minHeight) @@ -207,13 +212,6 @@ void MultiLineEdit::setSpellCheckEnabled(bool enable) } -void MultiLineEdit::setWordWrapEnabled(bool enable) -{ - setLineWrapMode(enable ? WidgetWidth : NoWrap); - updateSizeHint(); -} - - void MultiLineEdit::setPasteProtectionEnabled(bool enable, QWidget *) { _pasteProtectionEnabled = enable; @@ -296,18 +294,7 @@ bool MultiLineEdit::event(QEvent *e) void MultiLineEdit::keyPressEvent(QKeyEvent *event) { - // Workaround the fact that Qt < 4.5 doesn't know InsertLineSeparator yet -#if QT_VERSION >= 0x040500 if (event == QKeySequence::InsertLineSeparator) { -#else - -# ifdef Q_WS_MAC - if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && event->modifiers() & Qt::META) { -# else - if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && event->modifiers() & Qt::SHIFT) { -# endif -#endif - if (_mode == SingleLine) { event->accept(); on_returnPressed(); @@ -564,22 +551,18 @@ QString MultiLineEdit::convertRichtextToMircCodes() cursor.clearSelection(); } - if (color) { - color = false; + + if (color) mircText.append('\x03'); - } - if (underline) { - underline = false; + + if (underline) mircText.append('\x1f'); - } - if (italic) { - italic = false; + + if (italic) mircText.append('\x1d'); - } - if (bold) { - bold = false; + + if (bold) mircText.append('\x02'); - } return mircText; } @@ -718,7 +701,11 @@ void MultiLineEdit::on_textChanged() QString msg = tr("Do you really want to paste %n line(s)?", "", lines.count()); msg += "

"; for (int i = 0; i < 4; i++) { +#if QT_VERSION < 0x050000 msg += Qt::escape(lines[i].left(40)); +#else + msg += lines[i].left(40).toHtmlEscaped(); +#endif if (lines[i].count() > 40) msg += "..."; msg += "
"; @@ -726,7 +713,7 @@ void MultiLineEdit::on_textChanged() msg += "...

"; QMessageBox question(QMessageBox::NoIcon, tr("Paste Protection"), msg, QMessageBox::Yes|QMessageBox::No); question.setDefaultButton(QMessageBox::No); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC question.setWindowFlags(question.windowFlags() | Qt::Sheet); #endif if (question.exec() != QMessageBox::Yes)