You can now switch this off to get a single line with paste protection as it used to be.
This makes mostly sense for people using a Qt style with buggy layouting, screwing up dynamic
resize.
   ui.inputEdit->setMinHeight(1);
   ui.inputEdit->setMaxHeight(5);
   ui.inputEdit->setMode(MultiLineEdit::MultiLine);
+  ui.inputEdit->setPasteProtectionEnabled(true);
 
   new TabCompleter(ui.inputEdit);
 
   s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant)));
   setMaxLines(s.value("MaxNumLines", 5));
 
-  s.notify("EnableScrollBars", this, SLOT(setEnableScrollBars(QVariant)));
-  setEnableScrollBars(s.value("EnableScrollBars", true));
+  s.notify("EnableScrollBars", this, SLOT(setScrollBarsEnabled(QVariant)));
+  setScrollBarsEnabled(s.value("EnableScrollBars", true));
+
+  s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant)));
+  setMultiLineEnabled(s.value("EnableMultiLine", true));
 
   ActionCollection *coll = QtUi::actionCollection();
 
   ui.inputEdit->setMaxHeight(v.toInt());
 }
 
-void InputWidget::setEnableScrollBars(const QVariant &v) {
+void InputWidget::setScrollBarsEnabled(const QVariant &v) {
   ui.inputEdit->setScrollBarsEnabled(v.toBool());
 }
 
+void InputWidget::setMultiLineEnabled(const QVariant &v) {
+  ui.inputEdit->setMode(v.toBool()? MultiLineEdit::MultiLine : MultiLineEdit::SingleLine);
+}
+
 bool InputWidget::eventFilter(QObject *watched, QEvent *event) {
   if(event->type() != QEvent::KeyPress)
     return false;
 
   void setEnableSpellCheck(const QVariant &);
   void setShowNickSelector(const QVariant &);
   void setMaxLines(const QVariant &);
-  void setEnableScrollBars(const QVariant &);
+  void setMultiLineEnabled(const QVariant &);
+  void setScrollBarsEnabled(const QVariant &);
 
   void sendText(const QString &text) const;
   void changeNick(const QString &newNick) const;
 
      <property name="title">
       <string>Multi-Line Editing</string>
      </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+     <property name="settingsKey" stdset="0">
+      <string>EnableMultiLine</string>
+     </property>
+     <property name="defaultValue" stdset="0">
+      <bool>true</bool>
+     </property>
      <layout class="QVBoxLayout" name="verticalLayout">
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_2">
 
   updateSizeHint();
 }
 
+void MultiLineEdit::setPasteProtectionEnabled(bool enable, QWidget *) {
+  _pasteProtectionEnabled = enable;
+}
+
 void MultiLineEdit::historyMoveBack() {
   addToHistory(text(), true);
 
 }
 
 void MultiLineEdit::on_returnPressed() {
-  if(!text().isEmpty()) {
-    foreach(const QString &line, text().split('\n', QString::SkipEmptyParts)) {
+  on_returnPressed(text());
+}
+
+void MultiLineEdit::on_returnPressed(const QString & text) {
+  if(!text.isEmpty()) {
+    foreach(const QString &line, text.split('\n', QString::SkipEmptyParts)) {
       if(line.isEmpty())
         continue;
       addToHistory(line);
   QString newText = text();
   newText.replace("\r\n", "\n");
   newText.replace('\r', '\n');
-  if(_mode == SingleLine)
-    newText.replace('\n', ' ');
+  if(_mode == SingleLine) {
+    if(!pasteProtectionEnabled())
+      newText.replace('\n', ' ');
+    else if(newText.contains('\n')) {
+      QStringList lines = newText.split('\n', QString::SkipEmptyParts);
+      clear();
+
+      if(lines.count() >= 4) {
+        QString msg = tr("Do you really want to paste %n lines?", "", lines.count());
+        msg += "<p>";
+        for(int i = 0; i < 4; i++) {
+          msg += Qt::escape(lines[i].left(40));
+          if(lines[i].count() > 40)
+            msg += "...";
+          msg += "<br />";
+        }
+        msg += "...</p>";
+        QMessageBox question(QMessageBox::NoIcon, tr("Paste Protection"), msg, QMessageBox::Yes|QMessageBox::No);
+        question.setDefaultButton(QMessageBox::No);
+#ifdef Q_WS_MAC
+        question.setWindowFlags(question.windowFlags() | Qt::Sheet);
+#endif
+        if(question.exec() != QMessageBox::Yes)
+          return;
+      }
+
+      foreach(QString line, lines) {
+        clear();
+        insert(line);
+        on_returnPressed();
+      }
+    }
+  }
 
   _singleLine = (newText.indexOf('\n') < 0);
 
 
   inline void insert(const QString &newText) { insertPlainText(newText); }
   inline void backspace() { keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier)); }
   inline bool hasSelectedText() { return textCursor().hasSelection(); }
+
   inline bool isSingleLine() const { return _singleLine; }
+  inline bool pasteProtectionEnabled() const { return _pasteProtectionEnabled; }
 
   virtual QSize sizeHint() const;
   virtual QSize minimumSizeHint() const;
   void setMaxHeight(int numLines);
   void setScrollBarsEnabled(bool enable = true);
   void setSpellCheckEnabled(bool enable = true);
+  void setPasteProtectionEnabled(bool enable = true, QWidget *msgBoxParent = 0);
 
   // Note: Enabling wrap will make isSingleLine() not work correctly, so only use this if minHeight() > 1!
   void setWordWrapEnabled(bool enable = true);
 
 private slots:
   void on_returnPressed();
+  void on_returnPressed(const QString &text);
   void on_textChanged();
   void on_documentHeightChanged(qreal height);
 
   int _minHeight;
   int _maxHeight;
   bool _scrollBarsEnabled;
+  bool _pasteProtectionEnabled;
 
   QSize _sizeHint;
   qreal _lastDocumentHeight;