From 281b2b91365e9ab9b7c1c87d5a5dcbc250833be1 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 22 Mar 2018 17:46:21 +0900 Subject: Assign Ctrl+1 to Ctrl+9 to switch camera MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QT3DS-691 Task-number: QT3DS-692 Change-Id: Iec00f065e85403dbf854a73787e53ab4e202091e Reviewed-by: Tomi Korpipää --- src/Authoring/Studio/MainFrm.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/Authoring/Studio/MainFrm.cpp') diff --git a/src/Authoring/Studio/MainFrm.cpp b/src/Authoring/Studio/MainFrm.cpp index 7a6ef638..3cc34da4 100644 --- a/src/Authoring/Studio/MainFrm.cpp +++ b/src/Authoring/Studio/MainFrm.cpp @@ -749,6 +749,29 @@ void CMainFrame::OnFileNew() g_StudioApp.OnFileNew(); } +void CMainFrame::onCtrlNPressed() +{ + static QMap key2index { + {1, 9}, // Scene Camera View + {2, 0}, {3, 1}, // Perspective & Orthographic + {4, 2}, {5, 3}, // Top & Bottom + {6, 4}, {7, 5}, // Left & Right + {8, 6}, {9, 7}, // Front & Back + }; + + QAction *action = qobject_cast(sender()); + Q_ASSERT(action); + QKeySequence shortcut = action->shortcut(); + QMapIterator i(key2index); + while (i.hasNext()) { + i.next(); + QKeySequence keySequence(Qt::CTRL | static_cast(Qt::Key_0 + i.key())); + if (shortcut.matches(keySequence) == QKeySequence::ExactMatch) { + m_ui->m_EditCamerasBar->setCameraIndex(i.value()); + break; + } + } +} //============================================================================== /** @@ -1082,6 +1105,12 @@ void CMainFrame::RegisterGlobalKeyboardShortcuts(CHotKeys *inHotKeys, QWidget *a QKeySequence(Qt::Key_Q), CMainFrame::toggleSelectMode); + for (int keyN = Qt::Key_1; keyN <= Qt::Key_9; keyN++) { + ADD_GLOBAL_SHORTCUT(actionParent, + QKeySequence(Qt::CTRL | static_cast(keyN)), + CMainFrame::onCtrlNPressed); + } + CTimelineControl *theTimelineControl = GetTimelineControl(); if (theTimelineControl) theTimelineControl->RegisterGlobalKeyboardShortcuts(inHotKeys, actionParent); -- cgit v1.2.3