diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-25 17:31:11 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-27 09:42:09 +0000 |
commit | 35684c6dd7dec1b902218e2b134e427305e234e4 (patch) | |
tree | 71ba71619329a84ac6e600d8ec3a645adeaaba97 | |
parent | b1a5c793e31aa68e5f33ed7b64e0b1563d5efc0a (diff) |
Fix edit menu items
- Show what is about to be deleted/duplicated
- Properly enable delete/duplicate items
- Action delete/copy/cut/paste is now fully contained in action view
- Every view and player window indicates when they are activated
(i.e. mouse is pressed on them) so we can track the context reliably
even when menu steals the focus. Required for slide duplicate/delete
enabling in edit menu.
Task-number: QT3DS-1911
Task-number: QT3DS-1958
Change-Id: Icf0bb173809740dd709b9e0525735de7aecba617
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
20 files changed, 164 insertions, 93 deletions
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp index 2a6f4053..e25a4bdb 100644 --- a/src/Authoring/Studio/Application/StudioApp.cpp +++ b/src/Authoring/Studio/Application/StudioApp.cpp @@ -39,6 +39,8 @@ #include "qtsingleapplication.h" #include "qtlocalpeer.h" #include "TimelineWidget.h" +#include "SlideView.h" +#include "IKeyframesManager.h" #include <QtGui/qsurfaceformat.h> #include <QtCore/qfileinfo.h> @@ -948,6 +950,52 @@ QString CStudioApp::GetCopyType() return theCopyType; } +QString CStudioApp::getDuplicateType() const +{ + const bool slide = qobject_cast<SlideView *>(m_lastActiveView) != nullptr; + CDoc *doc = m_core->GetDoc(); + if (slide) { + qt3dsdm::Qt3DSDMSlideHandle handle = doc->GetActiveSlide(); + if (handle != doc->GetStudioSystem()->GetSlideSystem()->GetMasterSlide(handle)) + return tr("Slide"); + } else { + qt3dsdm::Qt3DSDMInstanceHandle selectedInstance = doc->GetSelectedInstance(); + CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + if (bridge->IsDuplicateable(selectedInstance)) + return tr("Object"); + } + return {}; +} + +QString CStudioApp::getDeleteType() const +{ + // Delete priority: keyframes, slides, objects + const bool slide = qobject_cast<SlideView *>(m_lastActiveView) != nullptr; + CDoc *doc = m_core->GetDoc(); + if (doc->GetKeyframesManager()->HasSelectedKeyframes()) { + return tr("Keyframes"); + } else if (slide) { + // Check if the slide is the last one or the master + qt3dsdm::Qt3DSDMSlideHandle slideHandle = doc->GetActiveSlide(); + qt3dsdm::ISlideSystem *slideSys = doc->GetStudioSystem()->GetSlideSystem(); + qt3dsdm::Qt3DSDMSlideHandle masterSlideHandle = slideSys->GetMasterSlide(slideHandle); + size_t slideCount = slideSys->GetSlideCount(masterSlideHandle); + if (slideHandle != masterSlideHandle && slideCount > 2) + return tr("Slide"); + } else { + qt3dsdm::TInstanceHandleList selected = doc->GetSelectedValue().GetSelectedInstances(); + CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + int deletableCount = 0; + for (size_t idx = 0, end = selected.size(); idx < end; ++idx) { + if (bridge->CanDelete(selected[idx])) + deletableCount++; + } + if (deletableCount && deletableCount == selected.size()) + return tr("Object"); + } + return {}; +} + //============================================================================= /** * Cuts the selected object or keys @@ -1031,37 +1079,21 @@ void CStudioApp::DeleteSelectedKeys() /** * Deletes selected object or keyframes */ -void CStudioApp::DeleteSelectedObject(bool slide) +void CStudioApp::DeleteSelectedObject() { + const bool slide = qobject_cast<SlideView *>(m_lastActiveView) != nullptr; m_core->GetDoc()->DeleteSelectedItems(slide); } -//============================================================================= /** * Handles the duplicate object command */ -void CStudioApp::HandleDuplicateCommand(bool slide) +void CStudioApp::HandleDuplicateCommand() { + const bool slide = qobject_cast<SlideView *>(m_lastActiveView) != nullptr; m_core->GetDoc()->HandleDuplicateCommand(slide); } -//============================================================================= -/** - * return true if the selected object is duplicatable - */ -bool CStudioApp::CanDuplicateObject() -{ - // Get the currently selected object - qt3dsdm::Qt3DSDMInstanceHandle theSelectedInstance = m_core->GetDoc()->GetSelectedInstance(); - if (!theSelectedInstance.Valid()) - return false; - - // Check if the object can be duplicated - return m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge()->IsDuplicateable( - theSelectedInstance); -} - -//============================================================================== /** * Toggles the state of autoset keyframes. */ diff --git a/src/Authoring/Studio/Application/StudioApp.h b/src/Authoring/Studio/Application/StudioApp.h index b4fe932f..bc6a594b 100644 --- a/src/Authoring/Studio/Application/StudioApp.h +++ b/src/Authoring/Studio/Application/StudioApp.h @@ -145,6 +145,7 @@ private: public: CMainFrame* m_pMainWnd; + QWidget *m_lastActiveView = nullptr; CCore *GetCore(); CViews *GetViews(); @@ -162,6 +163,8 @@ public: void OnCopy(); bool CanCopy(); QString GetCopyType(); + QString getDuplicateType() const; + QString getDeleteType() const; void OnCut(); bool CanCut(); void OnPaste(); @@ -171,9 +174,8 @@ public: bool CanChangeTimebarColor(); void HandleSetChangedKeys(); void DeleteSelectedKeys(); - void DeleteSelectedObject(bool slide = false); - void HandleDuplicateCommand(bool slide = false); - bool CanDuplicateObject(); + void DeleteSelectedObject(); + void HandleDuplicateCommand(); void OnToggleAutosetKeyframes(); void SetAutosetKeyframes(bool inFlag); void PlaybackPlay(); @@ -243,6 +245,9 @@ public: void SaveUIAFile(bool subpresentations = true); Q3DStudio::CFilePath getMostRecentDirectory() const; + + void setLastActiveView(QWidget *widget) { m_lastActiveView = widget; } + QWidget *lastActiveView() const { return m_lastActiveView; } }; extern CStudioApp g_StudioApp; diff --git a/src/Authoring/Studio/MainFrm.cpp b/src/Authoring/Studio/MainFrm.cpp index bd9df0b5..48cd8842 100644 --- a/src/Authoring/Studio/MainFrm.cpp +++ b/src/Authoring/Studio/MainFrm.cpp @@ -132,6 +132,23 @@ CMainFrame::CMainFrame() this, &CMainFrame::OnEditApplicationPreferences); connect(m_ui->actionPresentation_Settings, &QAction::triggered, this, &CMainFrame::OnEditPresentationPreferences); + connect(m_ui->menu_Edit, &QMenu::aboutToShow, [this]() { + // Enable/disable delete and duplicate + QString type = g_StudioApp.getDuplicateType(); + QString label = tr("Duplicate %1").arg(type); + m_ui->action_Duplicate_Object->setText(label); + m_ui->action_Duplicate_Object->setEnabled(!type.isEmpty()); + + type = g_StudioApp.getDeleteType(); + label = tr("Delete %1").arg(type); + m_ui->actionDelete->setText(label); + m_ui->actionDelete->setEnabled(!type.isEmpty()); + }); + connect(m_ui->menu_Edit, &QMenu::aboutToHide, [this]() { + // Enable delete and duplicate so hotkeys will work + m_ui->action_Duplicate_Object->setEnabled(true); + m_ui->actionDelete->setEnabled(true); + }); // View Menu connect(m_ui->actionReset_layout, &QAction::triggered, this, &CMainFrame::onViewResetLayout); @@ -240,7 +257,6 @@ CMainFrame::CMainFrame() OnUpdateEditCut(); OnUpdateToolAutosetkeys(); OnUpdateEditPaste(); - OnUpdateEditDuplicate(); OnUpdateTimelineDeleteSelectedKeyframes(); OnUpdateTimelineSetInterpolation(); OnUpdateTimelineSetTimeBarColor(); @@ -497,7 +513,9 @@ void CMainFrame::OnEditCopy() */ void CMainFrame::OnUpdateEditCopy() { - if (g_StudioApp.CanCopy() && !m_actionActive) { + // TODO: Actions cannot currently be copied/cut/pasted via main edit menu + // ActionView handles action copy/cut/paste internally + if (g_StudioApp.CanCopy()) { QString theDescription = tr("Copy %1\tCtrl+C").arg(g_StudioApp.GetCopyType()); m_ui->action_Copy->setText(theDescription); @@ -529,7 +547,7 @@ void CMainFrame::OnEditCut() */ void CMainFrame::OnUpdateEditCut() { - if (g_StudioApp.CanCut() && !m_actionActive) { + if (g_StudioApp.CanCut()) { QString theDescription = tr("Cut %1\tCtrl+X").arg(g_StudioApp.GetCopyType()); m_ui->action_Cut->setText(theDescription); @@ -567,7 +585,7 @@ void CMainFrame::onEditPasteToMaster() */ void CMainFrame::OnUpdateEditPaste() { - if (g_StudioApp.CanPaste() && !m_actionActive) { + if (g_StudioApp.CanPaste()) { QString theUndoDescription = tr("Paste %1\tCtrl+V").arg(g_StudioApp.GetPasteType()); m_ui->action_Paste->setText(theUndoDescription); @@ -683,28 +701,14 @@ void CMainFrame::OnUpdateTimelineSetInterpolation() */ void CMainFrame::OnEditDuplicate() { - g_StudioApp.HandleDuplicateCommand(m_slideActive); + g_StudioApp.HandleDuplicateCommand(); } void CMainFrame::onEditDelete() { - g_StudioApp.DeleteSelectedObject(m_slideActive); + g_StudioApp.DeleteSelectedObject(); } -//============================================================================== -/** - * OnUpdateEditDuplicate: Handles the UPDATE COMMAND UI message for this menu item. - * - * If the currently selected object is not null, and it is not in the library, - * then the user can duplicate the object and the menu item is enabled. Otherwise, - * it is disabled. - */ -void CMainFrame::OnUpdateEditDuplicate() -{ - m_ui->action_Duplicate_Object->setEnabled(m_slideActive || g_StudioApp.CanDuplicateObject()); -} - -//============================================================================= /** * Command handler for the File Open menu and toolbar options. * This will save the file, if the file has not been saved before this will @@ -1966,15 +1970,6 @@ void CMainFrame::toggleSelectMode() m_sceneView->onToolItemSelection(); } -void CMainFrame::onActionActive(bool active) -{ - m_actionActive = active; - m_ui->actionDelete->setEnabled(!active); - m_ui->action_Copy->setEnabled(!active); - m_ui->action_Cut->setEnabled(!active); - m_ui->action_Paste->setEnabled(!active); -} - void CMainFrame::showScene() { if (!m_sceneView.data()->isVisible()) { @@ -1982,8 +1977,3 @@ void CMainFrame::showScene() m_sceneView.data()->setVisible(true); } } - -void CMainFrame::onSlideActive(bool active) -{ - m_slideActive = active; -} diff --git a/src/Authoring/Studio/MainFrm.h b/src/Authoring/Studio/MainFrm.h index bed7e105..bf71bf1b 100644 --- a/src/Authoring/Studio/MainFrm.h +++ b/src/Authoring/Studio/MainFrm.h @@ -126,7 +126,6 @@ public: void OnUpdateEditPaste(); void OnEditDuplicate(); void onEditDelete(); - void OnUpdateEditDuplicate(); void timerEvent(QTimerEvent *event) override; void showEvent(QShowEvent *event) override; @@ -241,9 +240,7 @@ public: void initializeGeometryAndState(); void toggleSelectMode(); - void onActionActive(bool active); void showScene(); - void onSlideActive(bool active); Q_SIGNALS: void playStateChanged(bool started); @@ -263,8 +260,6 @@ protected: QScopedPointer<CStudioPreferencesPropSheet> m_propSheet; bool m_playbackFlag = false; - bool m_actionActive = false; - bool m_slideActive = false; bool m_resettingLayout = false; }; diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.cpp b/src/Authoring/Studio/Palettes/Action/ActionView.cpp index 2ec9728e..a0d03267 100644 --- a/src/Authoring/Studio/Palettes/Action/ActionView.cpp +++ b/src/Authoring/Studio/Palettes/Action/ActionView.cpp @@ -112,26 +112,18 @@ ActionView::ActionView(const QSize &preferredSize, QWidget *parent) QQuickWidget::addAction(action); m_actionCopy = new QAction(tr("Copy Action\t%1C").arg(ctrlKey)); - m_actionCopy->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C)); - m_actionCopy->setShortcutContext(Qt::WidgetShortcut); connect(m_actionCopy, &QAction::triggered, this, &ActionView::copyAction); QQuickWidget::addAction(m_actionCopy); m_actionPaste = new QAction(tr("Paste Action\t%1V").arg(ctrlKey)); - m_actionPaste->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V)); - m_actionPaste->setShortcutContext(Qt::WidgetShortcut); connect(m_actionPaste, &QAction::triggered, this, &ActionView::pasteAction); QQuickWidget::addAction(m_actionPaste); m_actionCut = new QAction(tr("Cut Action\t%1X").arg(ctrlKey)); - m_actionCut->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X)); - m_actionCut->setShortcutContext(Qt::WidgetShortcut); connect(m_actionCut, &QAction::triggered, this, &ActionView::cutAction); QQuickWidget::addAction(m_actionCut); m_actionDel = new QAction(tr("Delete Action\tDel")); - m_actionDel->setShortcut(QKeySequence(Qt::Key_Delete)); - m_actionDel->setShortcutContext(Qt::WidgetShortcut); connect(m_actionDel, &QAction::triggered, [=](){ deleteAction(m_currentActionIndex); }); QQuickWidget::addAction(m_actionDel); } @@ -148,15 +140,48 @@ QSize ActionView::sizeHint() const void ActionView::focusInEvent(QFocusEvent *event) { - Q_UNUSED(event) updateActionStates(); - Q_EMIT actionFocused(true); + QQuickWidget::focusInEvent(event); } -void ActionView::focusOutEvent(QFocusEvent *event) +void ActionView::mousePressEvent(QMouseEvent *event) { - Q_UNUSED(event) - Q_EMIT actionFocused(false); + g_StudioApp.setLastActiveView(this); + QQuickWidget::mousePressEvent(event); +} + +bool ActionView::event(QEvent *event) +{ + if (event->type() == QEvent::ShortcutOverride) { + QKeyEvent *ke = static_cast<QKeyEvent *>(event); + if (m_currentActionIndex >= 0 && (ke->key() == Qt::Key_Delete + || (ke->modifiers() == Qt::ControlModifier + && (ke->key() == Qt::Key_C || ke->key() == Qt::Key_V + || ke->key() == Qt::Key_X)))) { + auto focusItem = quickWindow()->activeFocusItem(); + if (focusItem && (focusItem->objectName() == QStringLiteral("actionListDelegate") + || focusItem->objectName() == QStringLiteral("focusEater"))) { + if (ke->key() == Qt::Key_Delete) { + if (m_actionDel->isEnabled()) + deleteAction(m_currentActionIndex); + } else if (ke->modifiers() == Qt::ControlModifier) { + if (ke->key() == Qt::Key_C) { + if (m_actionCopy->isEnabled()) + copyAction(); + } else if (ke->key() == Qt::Key_V) { + if (m_actionPaste->isEnabled()) + pasteAction(); + } else if (ke->key() == Qt::Key_X) { + if (m_actionCut->isEnabled()) + cutAction(); + } + } + event->accept(); + return true; + } + } + } + return QQuickWidget::event(event); } void ActionView::setItem(const qt3dsdm::Qt3DSDMInstanceHandle &handle) diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.h b/src/Authoring/Studio/Palettes/Action/ActionView.h index 02ab05f9..fdb92917 100644 --- a/src/Authoring/Studio/Palettes/Action/ActionView.h +++ b/src/Authoring/Studio/Palettes/Action/ActionView.h @@ -152,7 +152,8 @@ public: protected: void focusInEvent(QFocusEvent *event) override; - void focusOutEvent(QFocusEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + bool event(QEvent *event) override; Q_SIGNALS: void itemChanged(); @@ -162,7 +163,6 @@ Q_SIGNALS: void propertyChanged(); void firedEventChanged(); void hasItemChanged(); - void actionFocused(bool); void propertyValueInvalidChanged(); private Q_SLOTS: diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.qml b/src/Authoring/Studio/Palettes/Action/ActionView.qml index 151cb177..a5b905b3 100644 --- a/src/Authoring/Studio/Palettes/Action/ActionView.qml +++ b/src/Authoring/Studio/Palettes/Action/ActionView.qml @@ -39,6 +39,7 @@ Rectangle { Item { id: focusEater + objectName: "focusEater" // Used to eat keyboard focus when user clicks outside any property control } @@ -143,6 +144,7 @@ Rectangle { delegate: Rectangle { id: delegateItem + objectName: "actionListDelegate" width: actionsList.width height: _controlBaseHeight diff --git a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp index d86db72d..5a7e9948 100644 --- a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp +++ b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp @@ -32,6 +32,7 @@ #include "Literals.h" #include "StudioPreferences.h" #include "StudioUtils.h" +#include "StudioApp.h" #include <QtCore/qcoreapplication.h> #include <QtCore/qtimer.h> @@ -64,6 +65,12 @@ void BasicObjectsView::startDrag(QQuickItem *item, int row) QTimer::singleShot(0, item, &QQuickItem::ungrabMouse); } +void BasicObjectsView::mousePressEvent(QMouseEvent *event) +{ + g_StudioApp.setLastActiveView(this); + QQuickWidget::mousePressEvent(event); +} + void BasicObjectsView::initialize() { CStudioPreferences::setQmlContextProperties(rootContext()); diff --git a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.h b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.h index 86549cb0..19e8ddc3 100644 --- a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.h +++ b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.h @@ -43,6 +43,10 @@ public: QSize sizeHint() const override; Q_INVOKABLE void startDrag(QQuickItem *item, int row); + +protected: + void mousePressEvent(QMouseEvent *event) override; + private: void initialize(); diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 54ebf193..bffbf82f 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -177,6 +177,12 @@ QSize InspectorControlView::sizeHint() const return m_preferredSize; } +void InspectorControlView::mousePressEvent(QMouseEvent *event) +{ + g_StudioApp.setLastActiveView(this); + QQuickWidget::mousePressEvent(event); +} + void InspectorControlView::initialize() { CStudioPreferences::setQmlContextProperties(rootContext()); diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h index 2ea02c2e..a5269319 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.h @@ -96,6 +96,7 @@ public Q_SLOTS: protected: QSize sizeHint() const override; + void mousePressEvent(QMouseEvent *event) override; private: void setInspectable(CInspectableBase *inInspectable); diff --git a/src/Authoring/Studio/Palettes/PaletteManager.cpp b/src/Authoring/Studio/Palettes/PaletteManager.cpp index 02ec8324..04bd4fd7 100644 --- a/src/Authoring/Studio/Palettes/PaletteManager.cpp +++ b/src/Authoring/Studio/Palettes/PaletteManager.cpp @@ -92,8 +92,6 @@ CPaletteManager::CPaletteManager(CMainFrame *inMainFrame) auto slideView = new SlideView(m_slideDock); slideView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); m_slideDock->setWidget(slideView); - QObject::connect(slideView, &SlideView::slideFocused, - m_MainFrame, &CMainFrame::onSlideActive); inMainFrame->addDockWidget(Qt::LeftDockWidgetArea, m_slideDock); m_ControlList.insert(std::make_pair(CONTROLTYPE_SLIDE, m_slideDock)); @@ -143,8 +141,6 @@ CPaletteManager::CPaletteManager(CMainFrame *inMainFrame) m_actionDock); actionView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); m_actionDock->setWidget(actionView); - QObject::connect(actionView, &ActionView::actionFocused, - m_MainFrame, &CMainFrame::onActionActive); inMainFrame->addDockWidget(Qt::BottomDockWidgetArea, m_actionDock); m_ControlList.insert(std::make_pair(CONTROLTYPE_ACTION, m_actionDock)); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp index 9a82463b..7ef3b6aa 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp @@ -217,6 +217,12 @@ void ProjectView::OnImmediateRefreshInstanceMultiple(qt3dsdm::Qt3DSDMInstanceHan Q_UNUSED(inInstanceCount); } +void ProjectView::mousePressEvent(QMouseEvent *event) +{ + g_StudioApp.setLastActiveView(this); + QQuickWidget::mousePressEvent(event); +} + void ProjectView::startDrag(QQuickItem *item, int row) { const auto index = m_ProjectModel->index(row); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.h b/src/Authoring/Studio/Palettes/Project/ProjectView.h index b60eea52..f0da7a0b 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.h +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.h @@ -90,6 +90,9 @@ public: Q_SIGNALS: void projectChanged(); +protected: + void mousePressEvent(QMouseEvent *event) override; + private: void initialize(); void rebuild(); diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp index 431282d7..cd56029e 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp @@ -214,16 +214,10 @@ void SlideView::OnClosingPresentation() clearSlideList(); } -void SlideView::focusInEvent(QFocusEvent *event) +void SlideView::mousePressEvent(QMouseEvent *event) { - Q_UNUSED(event) - Q_EMIT slideFocused(true); -} - -void SlideView::focusOutEvent(QFocusEvent *event) -{ - Q_UNUSED(event) - Q_EMIT slideFocused(false); + g_StudioApp.setLastActiveView(this); + QQuickWidget::mousePressEvent(event); } void SlideView::OnActiveSlide(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inIndex, diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.h b/src/Authoring/Studio/Palettes/Slide/SlideView.h index 5034c035..e5f04eb5 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.h +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.h @@ -91,11 +91,9 @@ Q_SIGNALS: void currentModelChanged(); void showMasterSlideChanged(); void controlledChanged(); - void slideFocused(bool); protected: - void focusInEvent(QFocusEvent *event) override; - void focusOutEvent(QFocusEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; // DataModel callbacks virtual void OnActiveSlide(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inIndex, diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp index a1efdb72..315c7cd7 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp @@ -436,6 +436,8 @@ void TimelineGraphicsScene::resetMouseCursor() void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) { + g_StudioApp.setLastActiveView(m_widgetTimeline); + // Ignore non-left presses if dragging if (event->button() != Qt::LeftButton && (m_dragging || m_startRowMoverOnNextDrag)) { event->accept(); diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp index 8088d170..33102d5e 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp @@ -1025,6 +1025,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { if (childAt(event->pos()) == m_splitter) m_splitterPressed = true; + g_StudioApp.setLastActiveView(this); } void TimelineWidget::mouseMoveEvent(QMouseEvent *event) diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbarLabel.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbarLabel.cpp index 8abd4297..69c8843d 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbarLabel.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbarLabel.cpp @@ -28,6 +28,7 @@ #include "TimelineToolbarLabel.h" #include "StudioPreferences.h" +#include "StudioApp.h" TimelineToolbarLabel::TimelineToolbarLabel(QWidget *parent) : QLabel(parent) @@ -52,6 +53,7 @@ void TimelineToolbarLabel::leaveEvent(QEvent *event) void TimelineToolbarLabel::mousePressEvent(QMouseEvent *event) { + g_StudioApp.setLastActiveView(parentWidget()->parentWidget()); emit clicked(event); } diff --git a/src/Authoring/Studio/UI/PlayerWnd.cpp b/src/Authoring/Studio/UI/PlayerWnd.cpp index dfa174fe..5e1f0c51 100644 --- a/src/Authoring/Studio/UI/PlayerWnd.cpp +++ b/src/Authoring/Studio/UI/PlayerWnd.cpp @@ -106,6 +106,8 @@ void CPlayerWnd::mouseMoveEvent(QMouseEvent *event) void CPlayerWnd::mousePressEvent(QMouseEvent *event) { + g_StudioApp.setLastActiveView(this); + long toolMode = g_StudioApp.GetToolMode(); const Qt::MouseButton btn = event->button(); bool toolChanged = false; |