Skip to content

Commit

Permalink
Viewer: digits keys are correctly handled, now we have to fix the cal…
Browse files Browse the repository at this point in the history
…lbacks
  • Loading branch information
devernay committed May 23, 2016
1 parent c743a6e commit 2961dc9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
7 changes: 4 additions & 3 deletions Gui/Gui50.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ Gui::setLastKeyUpVisitedClickFocus(bool visited)
int
Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey)
{
qDebug() << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey;
//qDebug() << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey;
#ifdef Q_WS_MAC
// OS X virtual key codes, from
// MacOSX10.11.sdk/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/Events.h
Expand Down Expand Up @@ -440,6 +440,7 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey)
// 55 0x37 (VK_7) | 7 key
// 56 0x38 (VK_8) | 8 key
// 57 0x39 (VK_9) | 9 key
// Windows seems to always return the same virtual key for digits, whatever the modifi
Q_UNUSED(nativeScanCode);
switch (nativeVirtualKey) {
case 0x30:
Expand All @@ -466,7 +467,7 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey)
#endif
#if defined(Q_WS_X11) && defined(Q_OS_LINUX)
#pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards")
// probably only possible on Linux
// probably only possible on Linux, since scancodes are OS-dependent
// https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
Q_UNUSED(nativeVirtualKey);
switch (nativeScanCode) {
Expand Down Expand Up @@ -498,7 +499,7 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey)
void
Gui::keyPressEvent(QKeyEvent* e)
{
qDebug() << "Gui::keyPressed:" << e->text() << "modifiers:" << e->modifiers();
//qDebug() << "Gui::keyPressed:" << e->text() << "modifiers:" << e->modifiers();
if (_imp->currentPanelFocusEventRecursion > 0) {
return;
}
Expand Down
27 changes: 1 addition & 26 deletions Gui/GuiApplicationManager10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,7 @@ GuiApplicationManager::populateShortcuts()

registerKeybind(kShortcutGroupGlobal, kShortcutIDActionEnableRenderStats, kShortcutDescActionEnableRenderStats, Qt::NoModifier, Qt::Key_F2);

#ifdef Q_WS_MAC
// Note: keys 0-1 are handles by Gui::handleNativeKeys(), and should thus work even on international keyboards
// Note: keys 0-1 are handled by Gui::handleNativeKeys(), and should thus work even on international keyboards
registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput1, kShortcutDescActionConnectViewerToInput1, Qt::NoModifier, Qt::Key_1);
registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput2, kShortcutDescActionConnectViewerToInput2, Qt::NoModifier, Qt::Key_2);
registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput3, kShortcutDescActionConnectViewerToInput3, Qt::NoModifier, Qt::Key_3);
Expand All @@ -818,30 +817,6 @@ GuiApplicationManager::populateShortcuts()
registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput8, kShortcutDescActionConnectViewerBToInput8, Qt::ShiftModifier, Qt::Key_8);
registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput9, kShortcutDescActionConnectViewerBToInput9, Qt::ShiftModifier, Qt::Key_9);
registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput10, kShortcutDescActionConnectViewerBToInput10, Qt::ShiftModifier, Qt::Key_0);
#else
#pragma message WARN("TODO: Gui::handleNativeKeys() on X11/linux and Win")
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput1, kShortcutDescActionConnectViewerToInput1, Qt::NoModifier, Qt::Key_1,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput2, kShortcutDescActionConnectViewerToInput2, Qt::NoModifier, Qt::Key_2,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput3, kShortcutDescActionConnectViewerToInput3, Qt::NoModifier, Qt::Key_3,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput4, kShortcutDescActionConnectViewerToInput4, Qt::NoModifier, Qt::Key_4,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput5, kShortcutDescActionConnectViewerToInput5, Qt::NoModifier, Qt::Key_5,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput6, kShortcutDescActionConnectViewerToInput6, Qt::NoModifier, Qt::Key_6,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput7, kShortcutDescActionConnectViewerToInput7, Qt::NoModifier, Qt::Key_7,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput8, kShortcutDescActionConnectViewerToInput8, Qt::NoModifier, Qt::Key_8,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput9, kShortcutDescActionConnectViewerToInput9, Qt::NoModifier, Qt::Key_9,
Qt::ShiftModifier);
registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput10, kShortcutDescActionConnectViewerToInput10, Qt::NoModifier, Qt::Key_0,
Qt::ShiftModifier);

#endif

registerKeybind(kShortcutGroupGlobal, kShortcutIDActionShowPaneFullScreen, kShortcutDescActionShowPaneFullScreen, Qt::NoModifier, Qt::Key_Space);
registerKeybind(kShortcutGroupGlobal, kShortcutIDActionNextTab, kShortcutDescActionNextTab, Qt::ControlModifier, Qt::Key_T);
Expand Down
2 changes: 1 addition & 1 deletion Gui/ViewerTab10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ ViewerTab::leaveEvent(QEvent* e)
void
ViewerTab::keyPressEvent(QKeyEvent* e)
{
qDebug() << "ViewerTab::keyPressed:" << e->text() << "modifiers:" << e->modifiers();
//qDebug() << "ViewerTab::keyPressed:" << e->text() << "modifiers:" << e->modifiers();
if ( getGui() ) {
getGui()->setActiveViewer(this);
}
Expand Down

0 comments on commit 2961dc9

Please sign in to comment.