|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
#include "ILineEdit.h" |
|
|
|
|
#include "ConfigMgr.h" |
|
|
|
|
#include <QMessageBox> |
|
|
|
|
#include <IWin/IWin.h> |
|
|
|
|
|
|
|
|
|
ILineEdit::ILineEdit(ILineEdit::TabCompleteCb&& tabCompleteCb, QWidget* parent) |
|
|
|
|
: QLineEdit(parent) |
|
|
|
@ -9,7 +11,13 @@ ILineEdit::ILineEdit(ILineEdit::TabCompleteCb&& tabCompleteCb, QWidget* parent) |
|
|
|
|
connect(&conf, &ConfigMgr::saved, this, &ILineEdit::loadConfig); |
|
|
|
|
loadConfig(); |
|
|
|
|
|
|
|
|
|
installEventFilter(new KeyEventFilter(this)); |
|
|
|
|
auto* filter = new KeyEventFilter(this); |
|
|
|
|
connect(filter, &KeyEventFilter::newLine, |
|
|
|
|
[this](const QString& l) { |
|
|
|
|
emit newLine(l); |
|
|
|
|
clear(); |
|
|
|
|
}); |
|
|
|
|
installEventFilter(filter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ILineEdit::loadConfig() |
|
|
|
@ -125,8 +133,30 @@ bool KeyEventFilter::eventFilter(QObject* obj, QEvent* evt) |
|
|
|
|
input->keyDown(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
else if (kevt->key() == Qt::Key_Return || kevt->key() == Qt::Key_Enter) |
|
|
|
|
input->prevLines.push_front(input->text()); |
|
|
|
|
else if (kevt->key() == Qt::Key_Return || kevt->key() == Qt::Key_Enter) { |
|
|
|
|
auto ln = input->text(); |
|
|
|
|
ln.remove('\r'); |
|
|
|
|
auto linelist = ln.split('\n'); |
|
|
|
|
|
|
|
|
|
bool proceedPasting{ true }; |
|
|
|
|
|
|
|
|
|
const auto* parent = dynamic_cast<IWin*>(input->parentWidget()); |
|
|
|
|
|
|
|
|
|
if (linelist.count() > 3 && parent && |
|
|
|
|
(parent->getType() == IWin::Type::Channel || parent->getType() == IWin::Type::Private)) |
|
|
|
|
{ |
|
|
|
|
auto msg = tr("You are about to paste %1 lines.\nYou should consider using an external \"paste service\".\nContinue anyway?") |
|
|
|
|
.arg(linelist.count()); |
|
|
|
|
auto btn = QMessageBox::warning(input, tr("Flood warning"), msg, QMessageBox::Yes | QMessageBox::No); |
|
|
|
|
proceedPasting = btn == QMessageBox::Yes; |
|
|
|
|
} |
|
|
|
|
if (proceedPasting) { |
|
|
|
|
for (const auto& line : linelist) { |
|
|
|
|
input->prevLines.push_front(line); |
|
|
|
|
emit newLine(line); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
input->logidx = -1; |
|
|
|
|
} |
|
|
|
|