| 2334 | } |
| 2335 | |
| 2336 | void MainWindow::RegisterShortcut(const rdcstr &shortcut, QWidget *widget, ShortcutCallback callback) |
| 2337 | { |
| 2338 | QKeySequence ks = QKeySequence::fromString(shortcut); |
| 2339 | |
| 2340 | if(widget) |
| 2341 | { |
| 2342 | // we need to create a Qt shortcut for this widget. Even though we don't actually use the |
| 2343 | // callback, unless a shortcut exists Qt might not properly send the ShortcutOverride event to |
| 2344 | // our eventFilter - an example is on windows where Shift-F10 might go straight to a |
| 2345 | // ContextEvent. So we create a shortcut on this widget & key-sequence to force Qt to process it |
| 2346 | m_QtShortcuts.push_back(new QShortcut(ks, widget)); |
| 2347 | |
| 2348 | m_WidgetShortcutCallbacks[ks][widget] = callback; |
| 2349 | } |
| 2350 | else |
| 2351 | { |
| 2352 | if(m_GlobalShortcutCallbacks[ks]) |
| 2353 | { |
| 2354 | qCritical() << "Assigning duplicate global shortcut for" << ks; |
| 2355 | return; |
| 2356 | } |
| 2357 | |
| 2358 | m_GlobalShortcutCallbacks[ks] = callback; |
| 2359 | } |
| 2360 | } |
| 2361 | |
| 2362 | void MainWindow::UnregisterShortcut(const rdcstr &shortcut, QWidget *widget) |
| 2363 | { |