|
|
|
@ -3,6 +3,15 @@ |
|
|
|
|
#include <QMessageBox> |
|
|
|
|
#include <IWin/IWin.h> |
|
|
|
|
|
|
|
|
|
enum CtrlModifierCode : uint16_t { |
|
|
|
|
CMC_Invert = 0x25E9, |
|
|
|
|
CMC_Bold = 0x25A0, |
|
|
|
|
CMC_Underline = 0x25BD, |
|
|
|
|
CMC_Color = 0x25A9, |
|
|
|
|
CMC_Strikethrough = 0x25BB, |
|
|
|
|
CMC_Reset = 0x25A1 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
ILineEdit::ILineEdit(ILineEdit::TabCompleteCb&& tabCompleteCb, QWidget* parent) |
|
|
|
|
: QLineEdit(parent) |
|
|
|
|
, tabCb(std::move(tabCompleteCb)) |
|
|
|
@ -112,11 +121,13 @@ void ILineEdit::keyPressEvent(QKeyEvent* evt) |
|
|
|
|
|
|
|
|
|
bool KeyEventFilter::eventFilter(QObject* obj, QEvent* evt) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
auto* input = qobject_cast<ILineEdit*>(obj); |
|
|
|
|
if (!input) |
|
|
|
|
qWarning() << "Expected parent for KeyEventFilter is not an ILineEdit!"; |
|
|
|
|
else if (evt->type() == QEvent::KeyPress) { |
|
|
|
|
auto kevt = dynamic_cast<QKeyEvent*>(evt); |
|
|
|
|
const bool Ctrl = kevt->modifiers() & Qt::ControlModifier; |
|
|
|
|
|
|
|
|
|
if (kevt->key() != Qt::Key_Tab) |
|
|
|
|
input->resetCompletePattern(); |
|
|
|
@ -151,12 +162,44 @@ bool KeyEventFilter::eventFilter(QObject* obj, QEvent* evt) |
|
|
|
|
proceedPasting = btn == QMessageBox::Yes; |
|
|
|
|
} |
|
|
|
|
if (proceedPasting) { |
|
|
|
|
for (const auto& line : linelist) { |
|
|
|
|
for (auto line : linelist) { |
|
|
|
|
input->prevLines.push_front(line); |
|
|
|
|
if (!Ctrl) { |
|
|
|
|
line.replace(QChar(CMC_Invert), QChar(CtrlReverse)); |
|
|
|
|
line.replace(QChar(CMC_Bold), QChar(CtrlBold)); |
|
|
|
|
line.replace(QChar(CMC_Underline), QChar(CtrlUnderline)); |
|
|
|
|
line.replace(QChar(CMC_Color), QChar(CtrlColor)); |
|
|
|
|
line.replace(QChar(CMC_Strikethrough), QChar(CtrlStriketrhough)); |
|
|
|
|
line.replace(QChar(CMC_Reset), QChar(CtrlReset)); |
|
|
|
|
} |
|
|
|
|
emit newLine(line); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (Ctrl && kevt->key() == Qt::Key_I) { |
|
|
|
|
input->insert(QChar(CMC_Invert)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
else if (Ctrl && kevt->key() == Qt::Key_B) { |
|
|
|
|
input->insert(QChar(CMC_Bold)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
else if (Ctrl && kevt->key() == Qt::Key_U) { |
|
|
|
|
input->insert(QChar(CMC_Underline)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
else if (Ctrl && kevt->key() == Qt::Key_K) { |
|
|
|
|
input->insert(QChar(CMC_Color)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
else if (Ctrl && kevt->key() == Qt::Key_S) { |
|
|
|
|
input->insert(QChar(CMC_Strikethrough)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
else if (Ctrl && kevt->key() == Qt::Key_R) { |
|
|
|
|
input->insert(QChar(CMC_Reset)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
input->logidx = -1; |
|
|
|
|
} |
|
|
|
|