Changeset View
Changeset View
Standalone View
Standalone View
krusader/KViewer/krviewer.cpp
Show First 20 Lines • Show All 236 Lines • ▼ Show 20 Line(s) | |||||
237 | } | 237 | } | ||
238 | 238 | | |||
239 | bool KrViewer::eventFilter(QObject * /* watched */, QEvent * e) | 239 | bool KrViewer::eventFilter(QObject * /* watched */, QEvent * e) | ||
240 | { | 240 | { | ||
241 | // TODO: after porting to Qt5/KF5 we never catch *ANY* KeyPress or ShortcutOverride events here anymore. | 241 | // TODO: after porting to Qt5/KF5 we never catch *ANY* KeyPress or ShortcutOverride events here anymore. | ||
242 | // Should look into if there is any way to fix it. Currently if a KPart has same shortcut as KrViewer then | 242 | // Should look into if there is any way to fix it. Currently if a KPart has same shortcut as KrViewer then | ||
243 | // it causes a conflict, messagebox shown to user and no action triggered. | 243 | // it causes a conflict, messagebox shown to user and no action triggered. | ||
244 | if (e->type() == QEvent::ShortcutOverride) { | 244 | if (e->type() == QEvent::ShortcutOverride) { | ||
245 | auto* ke = (QKeyEvent*) e; | 245 | auto* ke = dynamic_cast<QKeyEvent*>( e); | ||
246 | if (reservedKeys.contains(ke->key())) { | 246 | if (reservedKeys.contains(ke->key())) { | ||
247 | ke->accept(); | 247 | ke->accept(); | ||
248 | 248 | | |||
249 | QAction *act = reservedKeyActions[ reservedKeys.indexOf(ke->key())]; | 249 | QAction *act = reservedKeyActions[ reservedKeys.indexOf(ke->key())]; | ||
250 | if (act != nullptr) { | 250 | if (act != nullptr) { | ||
251 | // don't activate the close functions immediately! | 251 | // don't activate the close functions immediately! | ||
252 | // it can cause crash | 252 | // it can cause crash | ||
253 | if (act == tabCloseAction || act == quitAction) { | 253 | if (act == tabCloseAction || act == quitAction) { | ||
254 | QTimer::singleShot(0, act, &QAction::trigger); | 254 | QTimer::singleShot(0, act, &QAction::trigger); | ||
255 | } else { | 255 | } else { | ||
256 | act->activate(QAction::Trigger); | 256 | act->activate(QAction::Trigger); | ||
257 | } | 257 | } | ||
258 | } | 258 | } | ||
259 | return true; | 259 | return true; | ||
260 | } | 260 | } | ||
261 | } else if (e->type() == QEvent::KeyPress) { | 261 | } else if (e->type() == QEvent::KeyPress) { | ||
262 | auto* ke = (QKeyEvent*) e; | 262 | auto* ke = dynamic_cast<QKeyEvent*>( e); | ||
263 | if (reservedKeys.contains(ke->key())) { | 263 | if (reservedKeys.contains(ke->key())) { | ||
264 | ke->accept(); | 264 | ke->accept(); | ||
265 | return true; | 265 | return true; | ||
266 | } | 266 | } | ||
267 | } | 267 | } | ||
268 | return false; | 268 | return false; | ||
269 | } | 269 | } | ||
270 | 270 | | |||
▲ Show 20 Lines • Show All 442 Lines • Show Last 20 Lines |