Changeset View
Changeset View
Standalone View
Standalone View
krusader/Panel/krsearchbar.cpp
Show First 20 Lines • Show All 220 Lines • ▼ Show 20 Line(s) | 211 | { | |||
---|---|---|---|---|---|
221 | 221 | | |||
222 | if (event->type() != QEvent::KeyPress) { | 222 | if (event->type() != QEvent::KeyPress) { | ||
223 | return false; | 223 | return false; | ||
224 | } | 224 | } | ||
225 | 225 | | |||
226 | qDebug() << "key press event=" << event; | 226 | qDebug() << "key press event=" << event; | ||
227 | 227 | | |||
228 | QKeyEvent *ke = static_cast<QKeyEvent *>(event); | 228 | QKeyEvent *ke = static_cast<QKeyEvent *>(event); | ||
229 | auto modifiers = ke->modifiers(); | ||||
229 | if (watched == _view->widget()) { | 230 | if (watched == _view->widget()) { | ||
230 | KConfigGroup grpSv(krConfig, "Look&Feel"); | 231 | KConfigGroup grpSv(krConfig, "Look&Feel"); | ||
231 | const bool autoShow = grpSv.readEntry("New Style Quicksearch", _NewStyleQuicksearch); | 232 | const bool autoShow = grpSv.readEntry("New Style Quicksearch", _NewStyleQuicksearch); | ||
232 | 233 | | |||
233 | if (isHidden() && !autoShow) { | 234 | if (isHidden() && !autoShow) { | ||
234 | return false; | 235 | return false; | ||
235 | } | 236 | } | ||
236 | 237 | | |||
Show All 11 Lines | 248 | !((ke->key() == Qt::Key_Backspace && !_textBox->currentText().isEmpty()) || | |||
248 | // ...insert space in search bar (even if not focused) | 249 | // ...insert space in search bar (even if not focused) | ||
249 | (ke->key() == Qt::Key_Space && _currentMode == KrSearchBar::MODE_SEARCH))) { | 250 | (ke->key() == Qt::Key_Space && _currentMode == KrSearchBar::MODE_SEARCH))) { | ||
250 | const bool handled = _view->handleKeyEvent(ke); | 251 | const bool handled = _view->handleKeyEvent(ke); | ||
251 | if (handled) { | 252 | if (handled) { | ||
252 | return true; | 253 | return true; | ||
253 | } | 254 | } | ||
254 | } | 255 | } | ||
255 | 256 | | |||
256 | if (ke->text().isEmpty() || (ke->modifiers() != Qt::NoModifier && | 257 | if (ke->text().isEmpty() || (modifiers != Qt::NoModifier && | ||
257 | ke->modifiers() != Qt::ShiftModifier && | 258 | modifiers != Qt::ShiftModifier && | ||
258 | ke->modifiers() != Qt::KeypadModifier)) { | 259 | modifiers != Qt::KeypadModifier)) { | ||
259 | return false; | 260 | return false; | ||
260 | } | 261 | } | ||
261 | 262 | | |||
262 | // start searching if bar is hidden? | 263 | // start searching if bar is hidden? | ||
263 | if (isHidden()) { | 264 | if (isHidden()) { | ||
264 | if (autoShow) { | 265 | if (autoShow) { | ||
265 | showBar(); | 266 | showBar(); | ||
266 | } else { | 267 | } else { | ||
Show All 11 Lines | |||||
278 | return true; | 279 | return true; | ||
279 | } else if (watched == _textBox) { | 280 | } else if (watched == _textBox) { | ||
280 | const bool handled = handleKeyPressEvent(ke); | 281 | const bool handled = handleKeyPressEvent(ke); | ||
281 | if (handled) { | 282 | if (handled) { | ||
282 | _view->widget()->setFocus(); | 283 | _view->widget()->setFocus(); | ||
283 | return true; | 284 | return true; | ||
284 | } | 285 | } | ||
285 | // allow the view to handle (most) key events from the text box | 286 | // allow the view to handle (most) key events from the text box | ||
286 | if (ke->modifiers() == Qt::NoModifier && | 287 | if ((modifiers == Qt::NoModifier || modifiers == Qt::KeypadModifier) && | ||
287 | ke->key() != Qt::Key_Space && | 288 | ke->key() != Qt::Key_Space && | ||
288 | ke->key() != Qt::Key_Backspace && | 289 | ke->key() != Qt::Key_Backspace && | ||
289 | ke->key() != Qt::Key_Left && | 290 | ke->key() != Qt::Key_Left && | ||
290 | ke->key() != Qt::Key_Right) { | 291 | ke->key() != Qt::Key_Right) { | ||
291 | const bool handled = _view->handleKeyEvent(ke); | 292 | const bool handled = _view->handleKeyEvent(ke); | ||
292 | if (handled) { | 293 | if (handled) { | ||
293 | _view->widget()->setFocus(); | 294 | _view->widget()->setFocus(); | ||
294 | return true; | 295 | return true; | ||
295 | } | 296 | } | ||
296 | } | 297 | } | ||
297 | } | 298 | } | ||
298 | return false; | 299 | return false; | ||
299 | } | 300 | } | ||
300 | 301 | | |||
301 | // #### private | 302 | // #### private | ||
302 | 303 | | |||
303 | bool KrSearchBar::handleKeyPressEvent(QKeyEvent *ke) | 304 | bool KrSearchBar::handleKeyPressEvent(QKeyEvent *ke) | ||
304 | { | 305 | { | ||
305 | if (ke->modifiers() != Qt::NoModifier) { | 306 | auto modifiers = ke->modifiers(); | ||
307 | if (!(modifiers == Qt::NoModifier || modifiers == Qt::KeypadModifier)) { | ||||
306 | return false; | 308 | return false; | ||
307 | } | 309 | } | ||
308 | 310 | | |||
309 | switch (ke->key()) { | 311 | switch (ke->key()) { | ||
310 | case Qt::Key_Escape: { | 312 | case Qt::Key_Escape: { | ||
311 | hideBar(); | 313 | hideBar(); | ||
312 | return true; | 314 | return true; | ||
313 | } | 315 | } | ||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |