| 609 | } |
| 610 | |
| 611 | bool RPCConsole::eventFilter(QObject* obj, QEvent *event) |
| 612 | { |
| 613 | if(event->type() == QEvent::KeyPress) // Special key handling |
| 614 | { |
| 615 | QKeyEvent *keyevt = static_cast<QKeyEvent*>(event); |
| 616 | int key = keyevt->key(); |
| 617 | Qt::KeyboardModifiers mod = keyevt->modifiers(); |
| 618 | switch(key) |
| 619 | { |
| 620 | case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } break; |
| 621 | case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } break; |
| 622 | case Qt::Key_PageUp: /* pass paging keys to messages widget */ |
| 623 | case Qt::Key_PageDown: |
| 624 | if(obj == ui->lineEdit) |
| 625 | { |
| 626 | QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt)); |
| 627 | return true; |
| 628 | } |
| 629 | break; |
| 630 | case Qt::Key_Return: |
| 631 | case Qt::Key_Enter: |
| 632 | // forward these events to lineEdit |
| 633 | if(obj == autoCompleter->popup()) { |
| 634 | QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt)); |
| 635 | autoCompleter->popup()->hide(); |
| 636 | return true; |
| 637 | } |
| 638 | break; |
| 639 | default: |
| 640 | // Typing in messages widget brings focus to line edit, and redirects key there |
| 641 | // Exclude most combinations and keys that emit no text, except paste shortcuts |
| 642 | if(obj == ui->messagesWidget && ( |
| 643 | (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) || |
| 644 | ((mod & Qt::ControlModifier) && key == Qt::Key_V) || |
| 645 | ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) |
| 646 | { |
| 647 | ui->lineEdit->setFocus(); |
| 648 | QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt)); |
| 649 | return true; |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | return QWidget::eventFilter(obj, event); |
| 654 | } |
| 655 | |
| 656 | void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_t bestblock_date, double verification_progress) |
| 657 | { |