MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / eventFilter

Method eventFilter

launcher/ui/pages/modplatform/ModPage.cpp:119–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119auto ModPage::eventFilter(QObject* watched, QEvent* event) -> bool
120{
121 if (watched == ui->searchEdit && event->type() == QEvent::KeyPress) {
122 auto* keyEvent = dynamic_cast<QKeyEvent*>(event);
123 if (keyEvent->key() == Qt::Key_Return) {
124 triggerSearch();
125 keyEvent->accept();
126 return true;
127 } else {
128 if (m_search_timer.isActive())
129 m_search_timer.stop();
130
131 m_search_timer.start(350);
132 }
133 } else if (watched == ui->packView && event->type() == QEvent::KeyPress) {
134 auto* keyEvent = dynamic_cast<QKeyEvent*>(event);
135 if (keyEvent->key() == Qt::Key_Return) {
136 onModSelected();
137
138 // To have the 'select mod' button outlined instead of the 'review and confirm' one
139 ui->modSelectionButton->setFocus(Qt::FocusReason::ShortcutFocusReason);
140 ui->packView->setFocus(Qt::FocusReason::NoFocusReason);
141
142 keyEvent->accept();
143 return true;
144 }
145 }
146 return QWidget::eventFilter(watched, event);
147}
148
149
150/******** Callbacks to events in the UI (set up in the derived classes) ********/

Callers

nothing calls this directly

Calls 5

stopMethod · 0.80
typeMethod · 0.45
acceptMethod · 0.45
isActiveMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected