/** * @brief Receives a key press event. * * This overrides the implementation of QPlainTextEdit to block the built-in * undo/redo actions and use our own ones instead, to pass through the * QUndoStack. * * @param event The event to handle. */ void TextEditorWidget::keyPressEvent(QKeyEvent* event) { if (event == QKeySequence::Undo) { undo_stack.undo(); event->accept(); return; } if (event == QKeySequence::Redo) { undo_stack.redo(); event->accept(); return; } if (event->key() == Qt::Key_Tab) { insert_tab(); event->accept(); return; } if (event->key() == Qt::Key_Backtab) { remove_tab(); event->accept(); return; } QPlainTextEdit::keyPressEvent(event); }
void TabWidget::add_widget(Widget *widget, const String &title) { insert_tab(widget, title, tabs.length()); }