diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-03-18 16:16:48 +0200 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-03-19 11:01:31 +0000 |
commit | a4655e1c580114bbad0b761eb79ed06985c16ec0 (patch) | |
tree | 357f482f106a1690904154baa7c95567332648fa | |
parent | 4ea8d5e92901b25000efbc37b1ecae1561832966 (diff) |
Fix the clutter delay when clicking a move, rotate, or scale button
Also some clean ups in the MainFrm class
Change-Id: Ic795a6adcdfb7c728a4058d7cb4ca887e1c4eea9
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r-- | src/Authoring/Studio/MainFrm.cpp | 193 | ||||
-rw-r--r-- | src/Authoring/Studio/MainFrm.h | 35 |
2 files changed, 30 insertions, 198 deletions
diff --git a/src/Authoring/Studio/MainFrm.cpp b/src/Authoring/Studio/MainFrm.cpp index b14b54ae..a2bb82b7 100644 --- a/src/Authoring/Studio/MainFrm.cpp +++ b/src/Authoring/Studio/MainFrm.cpp @@ -27,19 +27,9 @@ ** ****************************************************************************/ -//============================================================================== -// Prefix -//============================================================================== #include "MainFrm.h" #include "ui_MainFrm.h" - #include "StudioConst.h" - -//============================================================================== -// Includes -//============================================================================== -#include "Bindings/TimelineTranslationManager.h" -#include "Bindings/Qt3DSDMTimelineItemBinding.h" #include "SceneView.h" #include "StudioApp.h" #include "IKeyframesManager.h" @@ -62,24 +52,18 @@ #include "WidgetControl.h" #include "SlideView.h" #include "FilterVariantsDlg.h" +#include "PreviewHelper.h" #include <QtGui/qevent.h> #include <QtGui/qdesktopservices.h> -#include <QtWidgets/qdockwidget.h> #include <QtCore/qsettings.h> -#include <QtCore/qtimer.h> #include <QtCore/qurl.h> -#include <QtCore/qdir.h> #include <QtCore/qprocess.h> #include <QtGui/qfontdatabase.h> // Constants -const long PLAYBACK_TIMER_TIMEOUT = 10; // 10 milliseconds +const long PLAYBACK_TIMER_TIMEOUT = 10; // milliseconds -//============================================================================== -/** - * Constructor - */ CMainFrame::CMainFrame() : m_ui(new Ui::MainFrame) , m_remoteDeploymentSender(new RemoteDeploymentSender(this)) @@ -227,9 +211,12 @@ CMainFrame::CMainFrame() this, &CMainFrame::OnPlaybackPreviewRemote); // Tool mode toolbar - connect(m_ui->actionPosition_Tool, &QAction::triggered, this, &CMainFrame::OnToolMove); - connect(m_ui->actionRotation_Tool, &QAction::triggered, this, &CMainFrame::OnToolRotate); - connect(m_ui->actionScale_Tool, &QAction::triggered, this, &CMainFrame::OnToolScale); + connect(m_ui->actionPosition_Tool, &QAction::triggered, this, + std::bind(&CMainFrame::onTransformToolChanged, this, STUDIO_TOOLMODE_MOVE)); + connect(m_ui->actionRotation_Tool, &QAction::triggered, this, + std::bind(&CMainFrame::onTransformToolChanged, this, STUDIO_TOOLMODE_ROTATE)); + connect(m_ui->actionScale_Tool, &QAction::triggered, this, + std::bind(&CMainFrame::onTransformToolChanged, this, STUDIO_TOOLMODE_SCALE)); connect(m_ui->actionLocal_Global_Manipulators, &QAction::triggered, this, &CMainFrame::OnToolGlobalManipulators); @@ -285,12 +272,7 @@ CMainFrame::CMainFrame() OnUpdateViewSlide(); OnUpdateHelpIndex(); OnUpdatePlaybackPlay(); - OnUpdatePlaybackRewind(); - OnUpdatePlaybackStop(); OnUpdatePlaybackPreview(); - OnUpdateToolMove(); - OnUpdateToolRotate(); - OnUpdateToolScale(); OnUpdateToolGlobalManipulators(); OnUpdateToolGroupSelection(); OnUpdateToolItemSelection(); @@ -311,10 +293,6 @@ CMainFrame::CMainFrame() qApp->installEventFilter(this); } -//============================================================================== -/** - * Destructor - */ CMainFrame::~CMainFrame() { qApp->removeEventFilter(this); @@ -322,10 +300,7 @@ CMainFrame::~CMainFrame() m_updateUITimer->stop(); } -//============================================================================== -/** - * Timer callback - */ +// Timer callback void CMainFrame::onPlaybackTimeout() { // Timer callback that drives playback @@ -333,7 +308,6 @@ void CMainFrame::onPlaybackTimeout() g_StudioApp.GetCore()->GetDoc()->ClientStep(); } -//============================================================================== /** * Called when the main frame is actually created. Sets up tool bars and default * views. @@ -404,7 +378,6 @@ void CMainFrame::OnCreate() setCentralWidget(m_ui->infoText); } -//============================================================================== /** * Called when a new presenation is created. We have to wait to associate the * scene object with the scene view until this point, because the scene object @@ -438,7 +411,6 @@ void CMainFrame::OnNewPresentation() g_StudioApp.m_dataInputDialogItems.clear(); } -//============================================================================== /** * Called when the current presentation is being closed. * This will close all the editor windows that are open. @@ -447,7 +419,6 @@ void CMainFrame::OnClosingPresentation() { } -//============================================================================== /** * Handles the Timeline | Set Interpolation menu item * This is a temporary method that will display the Set Interpolation dialog. @@ -457,27 +428,22 @@ void CMainFrame::OnTimelineSetInterpolation() g_StudioApp.GetCore()->GetDoc()->SetKeyframeInterpolation(); } -//============================================================================== /** * OnEditRedo: calls handleRedoOperation */ -//============================================================================== void CMainFrame::OnEditRedo() { g_StudioApp.GetCore()->GetCmdStack()->Redo(); } -//============================================================================== /** * OnEditUndo: calls HandleUndoOperation */ -//============================================================================== void CMainFrame::OnEditUndo() { g_StudioApp.GetCore()->GetCmdStack()->Undo(); } -//============================================================================== /** * OnUpdateEditUndo: Handler for ID_EDIT_UNDO message * @@ -491,7 +457,6 @@ void CMainFrame::OnUpdateEditUndo() m_ui->action_Undo->setText(undoDescription); } -//============================================================================== /** * OnUpdateEditRedo: handles the message ID_EDIT_REDO * @@ -505,7 +470,6 @@ void CMainFrame::OnUpdateEditRedo() m_ui->action_Redo->setText(redoDescription); } -//============================================================================== /** * OnEditCopy: Handles the Copy message * @@ -516,7 +480,6 @@ void CMainFrame::OnEditCopy() g_StudioApp.OnCopy(); } -//============================================================================== /** * OnUpdateEditCopy: Handle the update UI command for the copy button and menu item * @@ -539,7 +502,6 @@ void CMainFrame::OnUpdateEditCopy() } } -//============================================================================== /** * OnEditCut: Handles the Cut message * @@ -550,7 +512,6 @@ void CMainFrame::OnEditCut() g_StudioApp.OnCut(); } -//============================================================================== /** * OnUpdateEditCut: Handle the update UI command for the cut button and menu item * @@ -571,7 +532,6 @@ void CMainFrame::OnUpdateEditCut() } } -//============================================================================== /** * OnEditPaste: Handles the Paste command * @@ -588,7 +548,6 @@ void CMainFrame::onEditPasteToMaster() g_StudioApp.GetCore()->GetDoc()->HandleMasterPaste(); } -//============================================================================== /** * OnUpdateEditPaste: Handle the update UI command for the paste button and menu item * @@ -612,7 +571,6 @@ void CMainFrame::OnUpdateEditPaste() } } -//============================================================================= /** * Called when a tool mode changes from a modifier key */ @@ -637,7 +595,6 @@ void CMainFrame::OnUpdateToolChange() #endif } -//============================================================================== /** * OnTimelineSettimebarcolor: Handles the ID_TIMELINE_SETTIMEBARCOLOR message. * @@ -649,7 +606,6 @@ void CMainFrame::OnTimelineSetTimeBarColor() getTimelineWidget()->openBarColorDialog(); } -//============================================================================== /** * OnUpdateTimelineSetTimeBarColor: Handles the update UI message for the * "Change Time Bar Color" menu item. @@ -664,7 +620,6 @@ void CMainFrame::OnUpdateTimelineSetTimeBarColor() m_ui->actionChange_Time_Bar_Color->setEnabled(g_StudioApp.CanChangeTimebarColor()); } -//============================================================================== /** * OnTimelineSetChangedKeyframe: Handles the ID_TIMELINE_SETCHANGEDKEYFRAME message. * @@ -676,7 +631,6 @@ void CMainFrame::OnTimelineSetChangedKeyframe() g_StudioApp.HandleSetChangedKeys(); } -//============================================================================== /** * OnUpdateTimelineDeleteSelectedKeyframes: Handles the update UI message for * the "Delete Selected Keyframe(s)" message. @@ -691,7 +645,6 @@ void CMainFrame::OnUpdateTimelineDeleteSelectedKeyframes() m_ui->actionDelete_Selected_Keyframe_s->setEnabled(getTimelineWidget()->hasSelectedKeyframes()); } -//============================================================================== /** * OnUpdateTimelineSetInterpolation: Handles the update UI message for * the "Set Interpolation" message. @@ -707,7 +660,6 @@ void CMainFrame::OnUpdateTimelineSetInterpolation() g_StudioApp.GetCore()->GetDoc()->GetKeyframesManager()->HasSelectedKeyframes()); } -//============================================================================== /** * OnEditDuplicate: Handles the ID_EDIT_DUPLICATE message. * @@ -739,7 +691,6 @@ void CMainFrame::OnFileOpen() g_StudioApp.OnFileOpen(); } -//============================================================================= /** * Command handler for the File Save menu and toolbar options. * This will save the file, if the file has not been saved before this will @@ -809,7 +760,6 @@ void CMainFrame::onCtrlNPressed() } } -//============================================================================== /** * Overrides the close method to prompt if the document is modified. */ @@ -835,7 +785,6 @@ void CMainFrame::closeEvent(QCloseEvent *event) QTimer::singleShot(0, &g_StudioApp, &CStudioApp::performShutdown); } -//============================================================================== /** * Displays the preferences dialog and can change program settings. */ @@ -844,7 +793,6 @@ void CMainFrame::OnEditApplicationPreferences() EditPreferences(PAGE_STUDIOAPPPREFERENCES); } -//============================================================================== /** * Displays the preferences dialog and can change program settings. */ @@ -853,7 +801,6 @@ void CMainFrame::OnEditPresentationPreferences() EditPreferences(PAGE_STUDIOPROJECTSETTINGS); } -//============================================================================== /** * Displays the data input dialog. */ @@ -866,7 +813,6 @@ void CMainFrame::OnFileDataInputs() g_StudioApp.saveDataInputsToProjectFile(); } -//============================================================================== /** * EditPreferences: Displays the presentation settings property sheet with * the specified active page. @@ -930,7 +876,6 @@ void CMainFrame::EditPreferences(short inPageIndex) } } -//============================================================================== /** * OnToolAutosetkeys: Called when the Autoset Keyframe button is pressed. * Calls the doc to turn off or on the Autoset Keyframe preference. @@ -944,7 +889,6 @@ void CMainFrame::OnToolAutosetkeys() m_ui->actionAutoset_Keyframes->setChecked(CStudioPreferences::IsAutosetKeyframesOn()); } -//============================================================================== /** * OnUpdateToolAutosetkeys: Updates the UI associated with this button. * Checks or unchecks this button on the toolbar, depending on the current @@ -957,7 +901,6 @@ void CMainFrame::OnUpdateToolAutosetkeys() m_ui->actionAutoset_Keyframes->setChecked(CStudioPreferences::IsAutosetKeyframesOn()); } -//========================================================================== /** * Called when the presentation is being played in Studio. Updates the play * button on the main frame. @@ -973,7 +916,6 @@ void CMainFrame::OnPlayStart() } } -//========================================================================== /** * Called when the presentation stops being played in Studio. Updates the play * button on the main frame. @@ -1120,26 +1062,6 @@ void CMainFrame::OnPlaybackRewind() //============================================================================== /** - * Handles the update ui message for the rewind button. Does nothing because - * no additional ui handling is necessary for this button. - * @param inCmdUI Pointer to the UI element that needs updating - */ -void CMainFrame::OnUpdatePlaybackRewind() -{ -} - -//============================================================================== -/** - * Handles the update ui message for the stop button. Doesn't do anything - * because no special ui handling is necessary for the stop button. - * @param inCmdUI Pointer to the UI element that needs updating - */ -void CMainFrame::OnUpdatePlaybackStop() -{ -} - -//============================================================================== -/** * Registers all the keys it will need for shortcuts, also telsl children to register theirs * @param inHotKeys the hotkeys to with which to register */ @@ -1164,64 +1086,6 @@ void CMainFrame::RegisterGlobalKeyboardShortcuts(CHotKeys *inHotKeys, QWidget *a //============================================================================== /** - * OnUpdateToolMove: Updates the UI associated with this button. - * - * Checks or unchecks this button on the toolbar, depending on the current - * tool mode, and whether or not the button is enabled. - * - * @param pCmdUI Pointer to the button that generated the message. - */ -//============================================================================== -void CMainFrame::OnUpdateToolMove() -{ - long theCurrentToolSettings = g_StudioApp.GetToolMode(); - - // If the current tool mode matches this button - // If the button is currently enabled - m_ui->actionPosition_Tool->setChecked(theCurrentToolSettings == STUDIO_TOOLMODE_MOVE - && m_ui->actionPosition_Tool->isEnabled()); -} - -//============================================================================== -/** - * OnUpdateToolRotate: Updates the UI associated with this button. - * - * Checks or unchecks this button on the toolbar, depending on the current - * tool mode, and whether or not the button is enabled. - * - * @param pCmdUI Pointer to the button that generated the message. - */ -void CMainFrame::OnUpdateToolRotate() -{ - long theCurrentToolSettings = g_StudioApp.GetToolMode(); - - // If the current tool mode matches this button - // If the button is currently enabled - m_ui->actionRotation_Tool->setChecked(theCurrentToolSettings == STUDIO_TOOLMODE_ROTATE - && m_ui->actionRotation_Tool->isEnabled()); -} - -//============================================================================== -/** - * OnUpdateToolScale: Updates the UI associated with this button. - * - * Checks or unchecks this button on the toolbar, depending on the current - * tool mode, and whether or not the button is enabled. - * - * @param pCmdUI Pointer to the button that generated the message. - */ -void CMainFrame::OnUpdateToolScale() -{ - long theCurrentToolSettings = g_StudioApp.GetToolMode(); - - // If the current tool mode matches this button - // If the button is currently enabled - m_ui->actionScale_Tool->setChecked(theCurrentToolSettings == STUDIO_TOOLMODE_SCALE - && m_ui->actionScale_Tool->isEnabled()); -} - -//============================================================================== -/** * OnUpdateToolScale: Updates the UI associated with this button. * * Checks or unchecks this button on the toolbar, depending on the current @@ -1242,35 +1106,18 @@ void CMainFrame::OnUpdateToolGlobalManipulators() //============================================================================== /** - * OnToolMove: Called when the Move button is pressed. - * Sets the current tool mode and changes the cursor. - */ -void CMainFrame::OnToolMove() -{ - g_StudioApp.SetToolMode(STUDIO_TOOLMODE_MOVE); - m_sceneView->setToolMode(STUDIO_TOOLMODE_MOVE); -} - -//============================================================================== -/** - * OnToolRotate: Called when the Rotate button is pressed. - * Sets the current tool mode and changes the cursor. + * Move, Rotate, or Scale button clicked. Sets the current tool mode and changes the cursor. + * + * @param toolMode the selected tool (move, rotate, or scale) */ -void CMainFrame::OnToolRotate() +void CMainFrame::onTransformToolChanged(long toolMode) { - g_StudioApp.SetToolMode(STUDIO_TOOLMODE_ROTATE); - m_sceneView->setToolMode(STUDIO_TOOLMODE_ROTATE); -} + g_StudioApp.SetToolMode(toolMode); + m_sceneView->setToolMode(toolMode); -//============================================================================== -/** - * OnToolScale: Called when the Scale button is pressed. - * Sets the current tool mode and changes the cursor. - */ -void CMainFrame::OnToolScale() -{ - g_StudioApp.SetToolMode(STUDIO_TOOLMODE_SCALE); - m_sceneView->setToolMode(STUDIO_TOOLMODE_SCALE); + m_ui->actionPosition_Tool->setChecked(toolMode == STUDIO_TOOLMODE_MOVE); + m_ui->actionRotation_Tool->setChecked(toolMode == STUDIO_TOOLMODE_ROTATE); + m_ui->actionScale_Tool->setChecked(toolMode == STUDIO_TOOLMODE_SCALE); } void CMainFrame::OnToolGlobalManipulators() @@ -1977,12 +1824,12 @@ InspectorControlView *CMainFrame::getInspectorView() const ->widget()); } -CRecentItems *CMainFrame::GetRecentItems() +CRecentItems *CMainFrame::GetRecentItems() const { return m_recentItems.data(); } -QWidget *CMainFrame::GetActiveView() +QWidget *CMainFrame::GetActiveView() const { return centralWidget(); } diff --git a/src/Authoring/Studio/MainFrm.h b/src/Authoring/Studio/MainFrm.h index 6eebd0fb..a8d3e5cd 100644 --- a/src/Authoring/Studio/MainFrm.h +++ b/src/Authoring/Studio/MainFrm.h @@ -27,26 +27,14 @@ ** ****************************************************************************/ -//============================================================================== -// Prefix -//============================================================================== #ifndef INCLUDED_MAIN_FRAME -#define INCLUDED_MAIN_FRAME 1 +#define INCLUDED_MAIN_FRAME -#pragma once - -//============================================================================== -// Includes -//============================================================================== -#include "PreviewHelper.h" #include "DispatchListeners.h" #include <QtWidgets/qmainwindow.h> #include <QtCore/qtimer.h> -//============================================================================== -// Forwards -//============================================================================== class CHotKeys; class CPaletteManager; class CRecentItems; @@ -59,6 +47,7 @@ class CStudioPreferencesPropSheet; class SlideView; class InspectorControlView; class FilterVariantsDlg; +class CPlayerWnd; #ifdef QT_NAMESPACE using namespace QT_NAMESPACE; @@ -71,17 +60,17 @@ namespace Ui } QT_END_NAMESPACE -class CPlayerWnd; class CMainFrame : public QMainWindow, - public CPresentationChangeListener, - public CFileOpenListener, - public CClientPlayChangeListener + public CPresentationChangeListener, + public CFileOpenListener, + public CClientPlayChangeListener { Q_OBJECT + public: CMainFrame(); - virtual ~CMainFrame(); + virtual ~CMainFrame() override; void OnNewPresentation() override; void OnClosingPresentation() override; @@ -99,7 +88,7 @@ public: void OnPlayStop() override; void OnTimeChanged(long inTime) override; - CRecentItems *GetRecentItems(); + CRecentItems *GetRecentItems() const; void OnCreate(); @@ -151,9 +140,7 @@ public: void OnPlaybackPlay(); void OnUpdatePlaybackPlay(); void OnPlaybackRewind(); - void OnUpdatePlaybackRewind(); void OnPlaybackStop(); - void OnUpdatePlaybackStop(); void OnPlaybackPreview(const QString &viewerExeName, bool remote = false); void OnPlaybackPreviewRuntime1(); void OnPlaybackPreviewRuntime2(); @@ -164,9 +151,7 @@ public: void OnUpdateToolRotate(); void OnUpdateToolScale(); void OnUpdateToolGlobalManipulators(); - void OnToolMove(); - void OnToolRotate(); - void OnToolScale(); + void onTransformToolChanged(long toolMode); void OnToolGlobalManipulators(); void OnUpdateToolChange(); void OnUpdateToolGroupSelection(); @@ -245,7 +230,7 @@ public: void HandleEditViewFillModeKey(); void HandleEditCameraZoomExtent(); - QWidget *GetActiveView(); + QWidget *GetActiveView() const; CPlayerWnd *GetPlayerWnd() const; void initializeGeometryAndState(); |