From: Marcus Eggenberger Date: Sat, 14 Feb 2009 01:51:31 +0000 (+0100) Subject: fixes 541 - preliminary paste protection X-Git-Tag: 0.4.0~59 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=d3f2be9223dc34e5bc52095de4ec59f734f5c820 fixes 541 - preliminary paste protection --- diff --git a/src/uisupport/inputline.cpp b/src/uisupport/inputline.cpp index 745a3e33..53bcdcac 100644 --- a/src/uisupport/inputline.cpp +++ b/src/uisupport/inputline.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include "bufferview.h" + #include "inputline.h" #include "tabcompleter.h" @@ -140,14 +141,39 @@ void InputLine::on_textChanged(QString newText) { if(lineSep.isEmpty()) return; - if(newText.contains(lineSep)) { + QStringList lines = newText.split(lineSep); + clear(); + + if(lines.count() > 4) { + QString msg = tr("Do you really want to paste %1 lines?").arg(lines.count()); + msg += "

"; + for(int i = 0; i < 3; i++) { + msg += lines[i].left(40); + if(lines[i].count() > 40) + msg += "..."; + msg += "
"; + } + msg += "...

"; + QMessageBox question(QMessageBox::NoIcon, tr("Paste Protection"), msg, QMessageBox::Yes|QMessageBox::No); + question.setDefaultButton(QMessageBox::No); + question.setWindowFlags(question.windowFlags() | Qt::Sheet); + if(question.exec() == QMessageBox::No) + return; + } + + foreach(QString line, lines) { clear(); - QString line = newText.section(lineSep, 0, 0); - QString remainder = newText.section(lineSep, 1); insert(line); emit returnPressed(); - insert(remainder); } +// if(newText.contains(lineSep)) { +// clear(); +// QString line = newText.section(lineSep, 0, 0); +// QString remainder = newText.section(lineSep, 1); +// insert(line); +// emit returnPressed(); +// insert(remainder); +// } } void InputLine::resetLine() {