From 7303ca2760cd1d5cb609132c97814674691eda5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 22 May 2016 16:03:26 +0200 Subject: [PATCH 1/9] Viewer: start work on better handling of keys 0-9 on AZERTY keyboards --- Gui/ActionShortcuts.h | 29 +++++++++++++ Gui/Gui.cpp | 33 ++++++++++++--- Gui/Gui.h | 5 +++ Gui/Gui30.cpp | 9 ++++ Gui/Gui50.cpp | 73 ++++++++++++++++++++++++++++++++- Gui/GuiApplicationManager10.cpp | 37 ++++++++++++++++- Gui/GuiPrivate.h | 4 +- Gui/ViewerTab.h | 1 + Gui/ViewerTab10.cpp | 22 +++++++++- Gui/ViewerTab30.cpp | 9 ++++ 10 files changed, 212 insertions(+), 10 deletions(-) diff --git a/Gui/ActionShortcuts.h b/Gui/ActionShortcuts.h index 29d64b58e8..307ee4c884 100644 --- a/Gui/ActionShortcuts.h +++ b/Gui/ActionShortcuts.h @@ -163,6 +163,35 @@ CLANG_DIAG_ON(uninitialized) #define kShortcutIDActionConnectViewerToInput10 "connectViewerInput10" #define kShortcutDescActionConnectViewerToInput10 "Connect Viewer to Input 10" +#define kShortcutIDActionConnectViewerBToInput1 "connectViewerBInput1" +#define kShortcutDescActionConnectViewerBToInput1 "Connect Viewer B Side to Input 1" + +#define kShortcutIDActionConnectViewerBToInput2 "connectViewerBInput2" +#define kShortcutDescActionConnectViewerBToInput2 "Connect Viewer B Side to Input 2" + +#define kShortcutIDActionConnectViewerBToInput3 "connectViewerBInput3" +#define kShortcutDescActionConnectViewerBToInput3 "Connect Viewer B Side to Input 3" + +#define kShortcutIDActionConnectViewerBToInput4 "connectViewerBInput4" +#define kShortcutDescActionConnectViewerBToInput4 "Connect Viewer B Side to Input 4" + +#define kShortcutIDActionConnectViewerBToInput5 "connectViewerBInput5" +#define kShortcutDescActionConnectViewerBToInput5 "Connect Viewer B Side to Input 5" + +#define kShortcutIDActionConnectViewerBToInput6 "connectViewerBInput6" +#define kShortcutDescActionConnectViewerBToInput6 "Connect Viewer B Side to Input 6" + +#define kShortcutIDActionConnectViewerBToInput7 "connectViewerBInput7" +#define kShortcutDescActionConnectViewerBToInput7 "Connect Viewer B Side to Input 7" + +#define kShortcutIDActionConnectViewerBToInput8 "connectViewerBInput8" +#define kShortcutDescActionConnectViewerBToInput8 "Connect Viewer B Side to Input 8" + +#define kShortcutIDActionConnectViewerBToInput9 "connectViewerBInput9" +#define kShortcutDescActionConnectViewerBToInput9 "Connect Viewer B Side to Input 9" + +#define kShortcutIDActionConnectViewerBToInput10 "connectViewerBInput10" +#define kShortcutDescActionConnectViewerBToInput10 "Connect Viewer B Side to Input 10" #define kShortcutIDActionShowPaneFullScreen "showPaneFullScreen" #define kShortcutDescActionShowPaneFullScreen "Show Pane Full Screen" diff --git a/Gui/Gui.cpp b/Gui/Gui.cpp index df9f2f0e96..2d3ebeaa1c 100644 --- a/Gui/Gui.cpp +++ b/Gui/Gui.cpp @@ -514,7 +514,7 @@ Gui::createMenuActions() connect( _imp->actionsOpenRecentFile[c], SIGNAL(triggered()), this, SLOT(openRecentFile()) ); } - const char* descs[10] = { + const char* descs[NATRON_CONNECT_INPUT_NB] = { kShortcutDescActionConnectViewerToInput1, kShortcutDescActionConnectViewerToInput2, kShortcutDescActionConnectViewerToInput3, @@ -524,9 +524,19 @@ Gui::createMenuActions() kShortcutDescActionConnectViewerToInput7, kShortcutDescActionConnectViewerToInput8, kShortcutDescActionConnectViewerToInput9, - kShortcutDescActionConnectViewerToInput10 + kShortcutDescActionConnectViewerToInput10, + kShortcutDescActionConnectViewerBToInput1, + kShortcutDescActionConnectViewerBToInput2, + kShortcutDescActionConnectViewerBToInput3, + kShortcutDescActionConnectViewerBToInput4, + kShortcutDescActionConnectViewerBToInput5, + kShortcutDescActionConnectViewerBToInput6, + kShortcutDescActionConnectViewerBToInput7, + kShortcutDescActionConnectViewerBToInput8, + kShortcutDescActionConnectViewerBToInput9, + kShortcutDescActionConnectViewerBToInput10 }; - const char* ids[10] = { + const char* ids[NATRON_CONNECT_INPUT_NB] = { kShortcutIDActionConnectViewerToInput1, kShortcutIDActionConnectViewerToInput2, kShortcutIDActionConnectViewerToInput3, @@ -536,13 +546,24 @@ Gui::createMenuActions() kShortcutIDActionConnectViewerToInput7, kShortcutIDActionConnectViewerToInput8, kShortcutIDActionConnectViewerToInput9, - kShortcutIDActionConnectViewerToInput10 + kShortcutIDActionConnectViewerToInput10, + kShortcutIDActionConnectViewerBToInput1, + kShortcutIDActionConnectViewerBToInput2, + kShortcutIDActionConnectViewerBToInput3, + kShortcutIDActionConnectViewerBToInput4, + kShortcutIDActionConnectViewerBToInput5, + kShortcutIDActionConnectViewerBToInput6, + kShortcutIDActionConnectViewerBToInput7, + kShortcutIDActionConnectViewerBToInput8, + kShortcutIDActionConnectViewerBToInput9, + kShortcutIDActionConnectViewerBToInput10 }; - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < NATRON_CONNECT_INPUT_NB; ++i) { _imp->actionConnectInput[i] = new ActionWithShortcut(kShortcutGroupGlobal, ids[i], descs[i], this); - _imp->actionConnectInput[i]->setData(i); +#pragma message WARN("TODO: implement connectInput for B side") + _imp->actionConnectInput[i]->setData(i%10); // <-- will always connect A !!!!!!! _imp->actionConnectInput[i]->setShortcutContext(Qt::WidgetShortcut); QObject::connect( _imp->actionConnectInput[i], SIGNAL(triggered()), this, SLOT(connectInput()) ); } diff --git a/Gui/Gui.h b/Gui/Gui.h index 828113a5c9..7a6420cfd2 100644 --- a/Gui/Gui.h +++ b/Gui/Gui.h @@ -551,6 +551,10 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void setLastKeyPressVisitedClickFocus(bool visited); void setLastKeyUpVisitedClickFocus(bool visited); + /// Handle the viewer keys separately: use the nativeVirtualKey so that they work + /// on any keyboard, including French AZERTY (where numbers are shifted) + static int handleNativeKeys(int key, quint32 nativeVirtualKey) WARN_UNUSED_RETURN; + void setApplicationConsoleActionVisible(bool visible); bool saveProjectAs(const std::string& filename); @@ -613,6 +617,7 @@ public Q_SLOTS: void connectInput(); void connectInput(int inputNb); + void connectBInput(int inputNb); void showView0(); diff --git a/Gui/Gui30.cpp b/Gui/Gui30.cpp index 3b440b7a0c..75b84c4473 100644 --- a/Gui/Gui30.cpp +++ b/Gui/Gui30.cpp @@ -35,6 +35,7 @@ #include "Global/Macros.h" #include +#include #include #include // qApp @@ -497,6 +498,14 @@ Gui::connectInput(int inputNb) graph->connectCurrentViewerToSelection(inputNb); } +void +Gui::connectBInput(int inputNb) +{ +#pragma message WARN("TODO: Gui::connectBInput()") + qDebug() << "Gui::connectBInput" << inputNb; + return connectInput(inputNb); +} + void Gui::connectInput() { diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 5d08fa672d..ef71e95df6 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -384,6 +384,57 @@ Gui::setLastKeyUpVisitedClickFocus(bool visited) _imp->keyUpEventHasVisitedFocusWidget = visited; } +/// Handle the viewer keys separately: use the nativeVirtualKey so that they work +/// on any keyboard, including French AZERTY (where numbers are shifted) +int +Gui::handleNativeKeys(int key, quint32 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 + // kVK_ANSI_1 = 0x12, + // kVK_ANSI_2 = 0x13, + // kVK_ANSI_3 = 0x14, + // kVK_ANSI_4 = 0x15, + // kVK_ANSI_6 = 0x16, + // kVK_ANSI_5 = 0x17, + // kVK_ANSI_9 = 0x19, + // kVK_ANSI_7 = 0x1A, + // kVK_ANSI_8 = 0x1C, + // kVK_ANSI_0 = 0x1D, + + switch (nativeVirtualKey) { + case 0x12: + return Qt::Key_1; + case 0x13: + return Qt::Key_2; + case 0x14: + return Qt::Key_3; + case 0x15: + return Qt::Key_4; + case 0x16: + return Qt::Key_6; + case 0x17: + return Qt::Key_5; + case 0x18: + return Qt::Key_9; + case 0x1A: + return Qt::Key_7; + case 0x1C: + return Qt::Key_8; + case 0x1D: + return Qt::Key_0; + } +#endif +#ifdef Q_WS_WIN +#pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") +#endif +#ifdef Q_WS_X11 +#pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") +#endif + return key; +} + void Gui::keyPressEvent(QKeyEvent* e) { @@ -392,7 +443,7 @@ Gui::keyPressEvent(QKeyEvent* e) } QWidget* w = qApp->widgetAt( QCursor::pos() ); - Qt::Key key = (Qt::Key)e->key(); + Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeVirtualKey() ); Qt::KeyboardModifiers modifiers = e->modifiers(); if (key == Qt::Key_Escape) { @@ -489,6 +540,26 @@ Gui::keyPressEvent(QKeyEvent* e) connectInput(8); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput10, modifiers, key) ) { connectInput(9); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput1, modifiers, key) ) { + connectBInput(0); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput2, modifiers, key) ) { + connectBInput(1); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput3, modifiers, key) ) { + connectBInput(2); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput4, modifiers, key) ) { + connectBInput(3); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput5, modifiers, key) ) { + connectBInput(4); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput6, modifiers, key) ) { + connectBInput(5); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput7, modifiers, key) ) { + connectBInput(6); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput8, modifiers, key) ) { + connectBInput(7); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput9, modifiers, key) ) { + connectBInput(8); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput10, modifiers, key) ) { + connectBInput(9); } else { /* * Modifiers are always uncaught by child implementations so that we can forward them to 1 ViewerTab so that diff --git a/Gui/GuiApplicationManager10.cpp b/Gui/GuiApplicationManager10.cpp index 72a200271f..ca8fcd75d3 100644 --- a/Gui/GuiApplicationManager10.cpp +++ b/Gui/GuiApplicationManager10.cpp @@ -306,6 +306,16 @@ GuiApplicationManager::initializeQApp(int &argc, // (requires using Q_INIT_RESOURCES_EXTERN(GuiResources) before entering the namespace) ::qInitResources_GuiResources(); +#ifdef DEBUG + QLocale loc; +#if QT_VERSION < 0x050000 + loc = QApplication::keyboardInputLocale(); +#else + loc = QGuiApplication::inputMethod()->locale(); +#endif + qDebug() << "keyboard input locale:" << loc.bcp47Name(); +#endif + ///Register all the shortcuts. populateShortcuts(); } @@ -786,7 +796,30 @@ 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 + 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); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput4, kShortcutDescActionConnectViewerToInput4, Qt::NoModifier, Qt::Key_4); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput5, kShortcutDescActionConnectViewerToInput5, Qt::NoModifier, Qt::Key_5); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput6, kShortcutDescActionConnectViewerToInput6, Qt::NoModifier, Qt::Key_6); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput7, kShortcutDescActionConnectViewerToInput7, Qt::NoModifier, Qt::Key_7); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput8, kShortcutDescActionConnectViewerToInput8, Qt::NoModifier, Qt::Key_8); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput9, kShortcutDescActionConnectViewerToInput9, Qt::NoModifier, Qt::Key_9); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput10, kShortcutDescActionConnectViewerToInput10, Qt::NoModifier, Qt::Key_0); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput1, kShortcutDescActionConnectViewerToInput1, Qt::ShiftModifier, Qt::Key_1); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput2, kShortcutDescActionConnectViewerToInput2, Qt::ShiftModifier, Qt::Key_2); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput3, kShortcutDescActionConnectViewerToInput3, Qt::ShiftModifier, Qt::Key_3); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput4, kShortcutDescActionConnectViewerToInput4, Qt::ShiftModifier, Qt::Key_4); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput5, kShortcutDescActionConnectViewerToInput5, Qt::ShiftModifier, Qt::Key_5); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput6, kShortcutDescActionConnectViewerToInput6, Qt::ShiftModifier, Qt::Key_6); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput7, kShortcutDescActionConnectViewerToInput7, Qt::ShiftModifier, Qt::Key_7); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput8, kShortcutDescActionConnectViewerToInput8, Qt::ShiftModifier, Qt::Key_8); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput9, kShortcutDescActionConnectViewerToInput9, Qt::ShiftModifier, Qt::Key_9); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput10, kShortcutDescActionConnectViewerToInput10, Qt::ShiftModifier, Qt::Key_0); +#else +#pragma message WARN("TODO: Gui::handleNativeKeys() on X11 and Win") registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput1, kShortcutDescActionConnectViewerToInput1, Qt::NoModifier, Qt::Key_1, Qt::ShiftModifier); registerKeybindWithMask(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput2, kShortcutDescActionConnectViewerToInput2, Qt::NoModifier, Qt::Key_2, @@ -808,6 +841,8 @@ GuiApplicationManager::populateShortcuts() 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); registerKeybind(kShortcutGroupGlobal, kShortcutIDActionPrevTab, kShortcutDescActionPrevTab, Qt::ShiftModifier | Qt::ControlModifier, Qt::Key_T); diff --git a/Gui/GuiPrivate.h b/Gui/GuiPrivate.h index 69ee22453a..b7b1456739 100644 --- a/Gui/GuiPrivate.h +++ b/Gui/GuiPrivate.h @@ -52,6 +52,8 @@ CLANG_DIAG_ON(uninitialized) NATRON_NAMESPACE_ENTER; +#define NATRON_CONNECT_INPUT_NB (2*10) + struct GuiPrivate { Q_DECLARE_TR_FUNCTIONS(Gui) @@ -115,7 +117,7 @@ struct GuiPrivate ActionWithShortcut *renderAllWriters; ActionWithShortcut *renderSelectedNode; ActionWithShortcut *enableRenderStats; - ActionWithShortcut* actionConnectInput[10]; + ActionWithShortcut* actionConnectInput[NATRON_CONNECT_INPUT_NB]; ActionWithShortcut* actionImportLayout; ActionWithShortcut* actionExportLayout; ActionWithShortcut* actionRestoreDefaultLayout; diff --git a/Gui/ViewerTab.h b/Gui/ViewerTab.h index 17d9046898..ada0bbbb3f 100644 --- a/Gui/ViewerTab.h +++ b/Gui/ViewerTab.h @@ -268,6 +268,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON void refresh(bool enableRenderStats); void connectToInput(int inputNb); + void connectToBInput(int inputNb); bool isPickerEnabled() const; void setPickerEnabled(bool enabled); diff --git a/Gui/ViewerTab10.cpp b/Gui/ViewerTab10.cpp index 8694066cde..626c4198a7 100644 --- a/Gui/ViewerTab10.cpp +++ b/Gui/ViewerTab10.cpp @@ -550,7 +550,7 @@ ViewerTab::keyPressEvent(QKeyEvent* e) bool accept = true; Qt::KeyboardModifiers modifiers = e->modifiers(); - Qt::Key key = (Qt::Key)e->key(); + Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeVirtualKey() ); double scale = 1. / ( 1 << _imp->viewer->getCurrentRenderScale() ); if ( isKeybind(kShortcutGroupViewer, kShortcutIDActionLuminance, modifiers, key) ) { @@ -743,6 +743,26 @@ ViewerTab::keyPressEvent(QKeyEvent* e) connectToInput(8); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput10, modifiers, key) ) { connectToInput(9); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput1, modifiers, key) ) { + connectToBInput(0); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput2, modifiers, key) ) { + connectToBInput(1); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput3, modifiers, key) ) { + connectToBInput(2); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput4, modifiers, key) ) { + connectToBInput(3); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput5, modifiers, key) ) { + connectToBInput(4); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput6, modifiers, key) ) { + connectToBInput(5); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput7, modifiers, key) ) { + connectToBInput(6); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput8, modifiers, key) ) { + connectToBInput(7); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput9, modifiers, key) ) { + connectToBInput(8); + } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput10, modifiers, key) ) { + connectToBInput(9); } else if ( isKeybind(kShortcutGroupViewer, kShortcutIDActionHideOverlays, modifiers, key) ) { _imp->viewer->toggleOverlays(); } else if ( isKeybind(kShortcutGroupViewer, kShortcutIDToggleWipe, modifiers, key) ) { diff --git a/Gui/ViewerTab30.cpp b/Gui/ViewerTab30.cpp index c5209500d1..b1a9ae48f9 100644 --- a/Gui/ViewerTab30.cpp +++ b/Gui/ViewerTab30.cpp @@ -1113,6 +1113,15 @@ ViewerTab::connectToInput(int inputNb) } } + +void +ViewerTab::connectToBInput(int inputNb) +{ +#pragma message WARN("TODO: ViewerTab::connectToBInput()") + qDebug() << "ViewerTab::connectToBInput" << inputNb; + return connectToInput(inputNb); +} + void ViewerTab::onAvailableComponentsChanged() { From 9c406a13cc8708bd5e8dc15ad3b918a2d81f30be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 22 May 2016 18:47:37 +0200 Subject: [PATCH 2/9] print scancode and virtualkeys --- Gui/Gui.h | 2 +- Gui/Gui50.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Gui/Gui.h b/Gui/Gui.h index 7a6420cfd2..19a5dff1a1 100644 --- a/Gui/Gui.h +++ b/Gui/Gui.h @@ -553,7 +553,7 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON /// Handle the viewer keys separately: use the nativeVirtualKey so that they work /// on any keyboard, including French AZERTY (where numbers are shifted) - static int handleNativeKeys(int key, quint32 nativeVirtualKey) WARN_UNUSED_RETURN; + static int handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey) WARN_UNUSED_RETURN; void setApplicationConsoleActionVisible(bool visible); diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index ef71e95df6..2d04f1c14b 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -387,7 +387,7 @@ Gui::setLastKeyUpVisitedClickFocus(bool visited) /// Handle the viewer keys separately: use the nativeVirtualKey so that they work /// on any keyboard, including French AZERTY (where numbers are shifted) int -Gui::handleNativeKeys(int key, quint32 nativeVirtualKey) +Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey) { #ifdef Q_WS_MAC // OS X virtual key codes, from @@ -402,7 +402,7 @@ Gui::handleNativeKeys(int key, quint32 nativeVirtualKey) // kVK_ANSI_7 = 0x1A, // kVK_ANSI_8 = 0x1C, // kVK_ANSI_0 = 0x1D, - + Q_UNUSED(nativeScanCode); switch (nativeVirtualKey) { case 0x12: return Qt::Key_1; @@ -428,9 +428,14 @@ Gui::handleNativeKeys(int key, quint32 nativeVirtualKey) #endif #ifdef Q_WS_WIN #pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") + // https://msdn.microsoft.com/en-us/library/aa299374%28v=vs.60%29.aspx + qDebug << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; #endif #ifdef Q_WS_X11 #pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") + // probably only possible on Linux + // https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html + qDebug << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; #endif return key; } @@ -443,7 +448,7 @@ Gui::keyPressEvent(QKeyEvent* e) } QWidget* w = qApp->widgetAt( QCursor::pos() ); - Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeVirtualKey() ); + Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeScanCode(), e->nativeVirtualKey() ); Qt::KeyboardModifiers modifiers = e->modifiers(); if (key == Qt::Key_Escape) { From bf901de52a8f6e822fc00e7447e30f25bc10787c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 22 May 2016 18:52:46 +0200 Subject: [PATCH 3/9] oops --- Gui/ViewerTab10.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gui/ViewerTab10.cpp b/Gui/ViewerTab10.cpp index 626c4198a7..84cb03de82 100644 --- a/Gui/ViewerTab10.cpp +++ b/Gui/ViewerTab10.cpp @@ -550,7 +550,7 @@ ViewerTab::keyPressEvent(QKeyEvent* e) bool accept = true; Qt::KeyboardModifiers modifiers = e->modifiers(); - Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeVirtualKey() ); + Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeSCanCode(), e->nativeVirtualKey() ); double scale = 1. / ( 1 << _imp->viewer->getCurrentRenderScale() ); if ( isKeybind(kShortcutGroupViewer, kShortcutIDActionLuminance, modifiers, key) ) { From 054519af6b2f8b97b0c36d91d7ccb3fd131f8e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Sun, 22 May 2016 18:53:20 +0200 Subject: [PATCH 4/9] oops --- Gui/ViewerTab10.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gui/ViewerTab10.cpp b/Gui/ViewerTab10.cpp index 84cb03de82..6c77927c5d 100644 --- a/Gui/ViewerTab10.cpp +++ b/Gui/ViewerTab10.cpp @@ -550,7 +550,7 @@ ViewerTab::keyPressEvent(QKeyEvent* e) bool accept = true; Qt::KeyboardModifiers modifiers = e->modifiers(); - Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeSCanCode(), e->nativeVirtualKey() ); + Qt::Key key = (Qt::Key)Gui::handleNativeKeys( e->key(), e->nativeScanCode(), e->nativeVirtualKey() ); double scale = 1. / ( 1 << _imp->viewer->getCurrentRenderScale() ); if ( isKeybind(kShortcutGroupViewer, kShortcutIDActionLuminance, modifiers, key) ) { From 14758ae9db3f27c76e584619de03edf8691d7fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Mon, 23 May 2016 10:21:23 +0200 Subject: [PATCH 5/9] fix --- Gui/Gui50.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 2d04f1c14b..8aee1146c0 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -429,13 +429,13 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey) #ifdef Q_WS_WIN #pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") // https://msdn.microsoft.com/en-us/library/aa299374%28v=vs.60%29.aspx - qDebug << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; + qDebug() << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; #endif #ifdef Q_WS_X11 #pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") // probably only possible on Linux // https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html - qDebug << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; + qDebug() << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; #endif return key; } From 86faa0401da27afc6f809564d7129f31a53c8307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Mon, 23 May 2016 11:31:15 +0200 Subject: [PATCH 6/9] Viewer input: fix menus --- Gui/Gui.cpp | 24 ++++++++++++++++-------- Gui/Gui50.cpp | 4 ++-- Gui/GuiApplicationManager10.cpp | 22 +++++++++++----------- Gui/GuiPrivate.h | 1 + Gui/ViewerTab10.cpp | 1 + 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Gui/Gui.cpp b/Gui/Gui.cpp index 2d3ebeaa1c..d0c6e0b2eb 100644 --- a/Gui/Gui.cpp +++ b/Gui/Gui.cpp @@ -406,8 +406,9 @@ Gui::createMenuActions() _imp->menuDisplay = new Menu(tr("Display"), _imp->menubar); _imp->menuRender = new Menu(tr("Render"), _imp->menubar); _imp->viewersMenu = new Menu(tr("Viewer(s)"), _imp->menuDisplay); - _imp->viewerInputsMenu = new Menu(tr("Connect Current Viewer"), _imp->viewersMenu); - _imp->viewersViewMenu = new Menu(tr("Display View Number"), _imp->viewersMenu); + _imp->viewerInputsMenu = new Menu(tr("Connect to A Side"), _imp->viewersMenu); + _imp->viewerInputsBMenu = new Menu(tr("Connect to B Side"), _imp->viewersMenu); + _imp->viewersViewMenu = new Menu(tr("View"), _imp->viewersMenu); _imp->cacheMenu = new Menu(tr("Cache"), _imp->menubar); _imp->menuHelp = new Menu(tr("Help"), _imp->menubar); @@ -562,11 +563,13 @@ Gui::createMenuActions() for (int i = 0; i < NATRON_CONNECT_INPUT_NB; ++i) { _imp->actionConnectInput[i] = new ActionWithShortcut(kShortcutGroupGlobal, ids[i], descs[i], this); -#pragma message WARN("TODO: implement connectInput for B side") - _imp->actionConnectInput[i]->setData(i%10); // <-- will always connect A !!!!!!! + _imp->actionConnectInput[i]->setData( i % (NATRON_CONNECT_INPUT_NB / 2) ); _imp->actionConnectInput[i]->setShortcutContext(Qt::WidgetShortcut); - QObject::connect( _imp->actionConnectInput[i], SIGNAL(triggered()), this, SLOT(connectInput()) ); - } + if (i < NATRON_CONNECT_INPUT_NB/2) { + QObject::connect( _imp->actionConnectInput[i], SIGNAL(triggered()), this, SLOT(connectInput()) ); + } else { + QObject::connect( _imp->actionConnectInput[i], SIGNAL(triggered()), this, SLOT(connectBInput()) ); + } } _imp->actionImportLayout = new ActionWithShortcut(kShortcutGroupGlobal, kShortcutIDActionImportLayout, kShortcutDescActionImportLayout, this); QObject::connect( _imp->actionImportLayout, SIGNAL(triggered()), this, SLOT(importLayout()) ); @@ -626,9 +629,14 @@ Gui::createMenuActions() _imp->menuDisplay->addAction(_imp->actionNewViewer); _imp->menuDisplay->addAction( _imp->viewersMenu->menuAction() ); _imp->viewersMenu->addAction( _imp->viewerInputsMenu->menuAction() ); + _imp->viewersMenu->addAction( _imp->viewerInputsBMenu->menuAction() ); _imp->viewersMenu->addAction( _imp->viewersViewMenu->menuAction() ); - for (int i = 0; i < 10; ++i) { - _imp->viewerInputsMenu->addAction(_imp->actionConnectInput[i]); + for (int i = 0; i < NATRON_CONNECT_INPUT_NB; ++i) { + if ( i < (NATRON_CONNECT_INPUT_NB / 2) ) { + _imp->viewerInputsMenu->addAction(_imp->actionConnectInput[i]); + } else { + _imp->viewerInputsBMenu->addAction(_imp->actionConnectInput[i]); + } } _imp->menuDisplay->addAction(_imp->actionProject_settings); diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 8aee1146c0..5faab094c5 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -389,6 +389,7 @@ Gui::setLastKeyUpVisitedClickFocus(bool visited) int Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 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 @@ -429,13 +430,11 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey) #ifdef Q_WS_WIN #pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") // https://msdn.microsoft.com/en-us/library/aa299374%28v=vs.60%29.aspx - qDebug() << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; #endif #ifdef Q_WS_X11 #pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") // probably only possible on Linux // https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html - qDebug() << "scancode=" << nativeScanCode << "virtualkey=" << nativeVirtualKey; #endif return key; } @@ -443,6 +442,7 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey) void Gui::keyPressEvent(QKeyEvent* e) { + qDebug() << "Gui::keyPressed:" << e->text() << "modifiers:" << e->modifiers(); if (_imp->currentPanelFocusEventRecursion > 0) { return; } diff --git a/Gui/GuiApplicationManager10.cpp b/Gui/GuiApplicationManager10.cpp index ca8fcd75d3..700087300b 100644 --- a/Gui/GuiApplicationManager10.cpp +++ b/Gui/GuiApplicationManager10.cpp @@ -808,18 +808,18 @@ GuiApplicationManager::populateShortcuts() registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput8, kShortcutDescActionConnectViewerToInput8, Qt::NoModifier, Qt::Key_8); registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput9, kShortcutDescActionConnectViewerToInput9, Qt::NoModifier, Qt::Key_9); registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput10, kShortcutDescActionConnectViewerToInput10, Qt::NoModifier, Qt::Key_0); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput1, kShortcutDescActionConnectViewerToInput1, Qt::ShiftModifier, Qt::Key_1); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput2, kShortcutDescActionConnectViewerToInput2, Qt::ShiftModifier, Qt::Key_2); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput3, kShortcutDescActionConnectViewerToInput3, Qt::ShiftModifier, Qt::Key_3); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput4, kShortcutDescActionConnectViewerToInput4, Qt::ShiftModifier, Qt::Key_4); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput5, kShortcutDescActionConnectViewerToInput5, Qt::ShiftModifier, Qt::Key_5); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput6, kShortcutDescActionConnectViewerToInput6, Qt::ShiftModifier, Qt::Key_6); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput7, kShortcutDescActionConnectViewerToInput7, Qt::ShiftModifier, Qt::Key_7); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput8, kShortcutDescActionConnectViewerToInput8, Qt::ShiftModifier, Qt::Key_8); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput9, kShortcutDescActionConnectViewerToInput9, Qt::ShiftModifier, Qt::Key_9); - registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerToInput10, kShortcutDescActionConnectViewerToInput10, Qt::ShiftModifier, Qt::Key_0); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput1, kShortcutDescActionConnectViewerBToInput1, Qt::ShiftModifier, Qt::Key_1); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput2, kShortcutDescActionConnectViewerBToInput2, Qt::ShiftModifier, Qt::Key_2); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput3, kShortcutDescActionConnectViewerBToInput3, Qt::ShiftModifier, Qt::Key_3); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput4, kShortcutDescActionConnectViewerBToInput4, Qt::ShiftModifier, Qt::Key_4); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput5, kShortcutDescActionConnectViewerBToInput5, Qt::ShiftModifier, Qt::Key_5); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput6, kShortcutDescActionConnectViewerBToInput6, Qt::ShiftModifier, Qt::Key_6); + registerKeybind(kShortcutGroupGlobal, kShortcutIDActionConnectViewerBToInput7, kShortcutDescActionConnectViewerBToInput7, Qt::ShiftModifier, Qt::Key_7); + 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 and Win") +#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, diff --git a/Gui/GuiPrivate.h b/Gui/GuiPrivate.h index b7b1456739..2397ea6442 100644 --- a/Gui/GuiPrivate.h +++ b/Gui/GuiPrivate.h @@ -204,6 +204,7 @@ struct GuiPrivate Menu *menuRender; Menu *viewersMenu; Menu *viewerInputsMenu; + Menu *viewerInputsBMenu; Menu *viewersViewMenu; Menu *cacheMenu; Menu *menuHelp; diff --git a/Gui/ViewerTab10.cpp b/Gui/ViewerTab10.cpp index 6c77927c5d..7d687c0cf7 100644 --- a/Gui/ViewerTab10.cpp +++ b/Gui/ViewerTab10.cpp @@ -544,6 +544,7 @@ ViewerTab::leaveEvent(QEvent* e) void ViewerTab::keyPressEvent(QKeyEvent* e) { + qDebug() << "ViewerTab::keyPressed:" << e->text() << "modifiers:" << e->modifiers(); if ( getGui() ) { getGui()->setActiveViewer(this); } From c61a6c824964ed112ca35443e2c165c4afa14de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Mon, 23 May 2016 11:58:01 +0200 Subject: [PATCH 7/9] Viewer: add windows and linux 0-9 keys detection --- Gui/Gui50.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 5faab094c5..029668ad9f 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -430,11 +430,67 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey) #ifdef Q_WS_WIN #pragma message WARN("TODO: handle keys 0-9 on AZERTY keyboards") // https://msdn.microsoft.com/en-us/library/aa299374%28v=vs.60%29.aspx + // 48 0x30 (VK_0) | 0 key + // 49 0x31 (VK_1) | 1 key + // 50 0x32 (VK_2) | 2 key + // 51 0x33 (VK_3) | 3 key + // 52 0x34 (VK_4) | 4 key + // 53 0x35 (VK_5) | 5 key + // 54 0x36 (VK_6) | 6 key + // 55 0x37 (VK_7) | 7 key + // 56 0x38 (VK_8) | 8 key + // 57 0x39 (VK_9) | 9 key + Q_UNUSED(nativeScanCode); + switch (nativeVirtualKey) { + case 0x30: + return Qt::Key_0; + case 0x31: + return Qt::Key_1; + case 0x32: + return Qt::Key_2; + case 0x33: + return Qt::Key_3; + case 0x34: + return Qt::Key_4; + case 0x35: + return Qt::Key_5; + case 0x36: + return Qt::Key_6; + case 0x37: + return Qt::Key_7; + case 0x38: + return Qt::Key_8; + case 0x39: + return Qt::Key_9; + } #endif -#ifdef Q_WS_X11 +#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 // https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html + Q_UNUSED(nativeVirtualKey); + switch (nativeScanCode) { + case 0x02: + return Qt::Key_1; + case 0x03: + return Qt::Key_2; + case 0x04: + return Qt::Key_3; + case 0x05: + return Qt::Key_4; + case 0x06: + return Qt::Key_5; + case 0x07: + return Qt::Key_6; + case 0x08: + return Qt::Key_7; + case 0x09: + return Qt::Key_8; + case 0x0a: + return Qt::Key_9; + case 0x0b: + return Qt::Key_0; + } #endif return key; } From c743a6eed62b70d0835d34d019b19803c01b07ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Mon, 23 May 2016 12:36:35 +0200 Subject: [PATCH 8/9] fix linux scancodes --- Gui/Gui50.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 029668ad9f..8cc67226cd 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -470,25 +470,25 @@ Gui::handleNativeKeys(int key, quint32 nativeScanCode, quint32 nativeVirtualKey) // https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html Q_UNUSED(nativeVirtualKey); switch (nativeScanCode) { - case 0x02: + case 10: return Qt::Key_1; - case 0x03: + case 11: return Qt::Key_2; - case 0x04: + case 12: return Qt::Key_3; - case 0x05: + case 13: return Qt::Key_4; - case 0x06: + case 14: return Qt::Key_5; - case 0x07: + case 15: return Qt::Key_6; - case 0x08: + case 16: return Qt::Key_7; - case 0x09: + case 17: return Qt::Key_8; - case 0x0a: + case 18: return Qt::Key_9; - case 0x0b: + case 19: return Qt::Key_0; } #endif From 2961dc9ab4a7c483e7ea83919cb57065d331b8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Mon, 23 May 2016 12:53:06 +0200 Subject: [PATCH 9/9] Viewer: digits keys are correctly handled, now we have to fix the callbacks --- Gui/Gui50.cpp | 7 ++++--- Gui/GuiApplicationManager10.cpp | 27 +-------------------------- Gui/ViewerTab10.cpp | 2 +- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 8cc67226cd..5987d57fa2 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -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 @@ -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: @@ -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) { @@ -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; } diff --git a/Gui/GuiApplicationManager10.cpp b/Gui/GuiApplicationManager10.cpp index 700087300b..a2fd53705a 100644 --- a/Gui/GuiApplicationManager10.cpp +++ b/Gui/GuiApplicationManager10.cpp @@ -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); @@ -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); diff --git a/Gui/ViewerTab10.cpp b/Gui/ViewerTab10.cpp index 7d687c0cf7..92bb08bd8c 100644 --- a/Gui/ViewerTab10.cpp +++ b/Gui/ViewerTab10.cpp @@ -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); }