From 55744503d8e1522229e4211cad0d077603bbe5d4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 19 Oct 2014 20:30:39 +0100 Subject: [PATCH] Change code for tools. stop reading previous used tool --- source/app/PlaYUVerSettings.cpp | 2 +- source/app/ViewArea.h | 14 +++++++++++--- source/app/plaYUVerApp.cpp | 26 +++++++++++++------------- source/app/plaYUVerApp.h | 15 ++++++++++----- source/lib/PlaYUVerDefs.h | 5 ----- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/source/app/PlaYUVerSettings.cpp b/source/app/PlaYUVerSettings.cpp index f396a79..34a5ece 100644 --- a/source/app/PlaYUVerSettings.cpp +++ b/source/app/PlaYUVerSettings.cpp @@ -65,7 +65,7 @@ Void PlaYUVerSettings::setLastOpenPath( const QString & path ) Int PlaYUVerSettings::getSelectedTool() { - return m_settings.value( "MainWindow/SelectedTool", NavigationTool ).toInt(); + return m_settings.value( "MainWindow/SelectedTool", ViewArea::NavigationTool ).toInt(); } Void PlaYUVerSettings::setSelectedTool( Int tool ) diff --git a/source/app/ViewArea.h b/source/app/ViewArea.h index 4604589..1c0b0eb 100644 --- a/source/app/ViewArea.h +++ b/source/app/ViewArea.h @@ -53,6 +53,14 @@ public: { NormalMode, MaskMode, }; + typedef enum + { + NavigationTool, + NormalSelectionTool, + BlockSelectionTool, + MaskTool, + EraserTool + }eTool; ViewArea( QWidget *parent = 0 ); @@ -90,7 +98,7 @@ public: { return m_mode; } - enum eTool tool() const + eTool tool() const { return m_tool; } @@ -109,7 +117,7 @@ public: Void zoomChangeEvent(Double factor, QPoint center); - void setTool( enum eTool tool ); + void setTool( eTool tool ); // QSize sizeHint() const; @@ -161,7 +169,7 @@ private: QPoint m_lastWindowPos; GridManager m_grid; ViewMode m_mode; - enum eTool m_tool; + eTool m_tool; QColor m_maskColor; double m_zoomFactor; int m_xOffset; diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 1b49d55..2834add 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -983,15 +983,9 @@ SubWindowHandle* plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const SubW return 0; } -Void plaYUVerApp::setNavigationTool() +Void plaYUVerApp::setTool( Int idxTool ) { - m_appTool = NavigationTool; - setAllSubWindowTool(); -} - -Void plaYUVerApp::setSelectionTool() -{ - m_appTool = NormalSelectionTool; + m_appTool = (ViewArea::eTool ) idxTool; setAllSubWindowTool(); } @@ -1273,19 +1267,25 @@ Void plaYUVerApp::createActions() actionGroupTools = new QActionGroup( this ); actionGroupTools->setExclusive( true ); - m_appTool = NavigationTool; + m_mapperTools = new QSignalMapper( this ); + connect( m_mapperTools, SIGNAL( mapped(int) ), this, SLOT( setTool(int) ) ); + + m_appTool = ViewArea::NavigationTool; m_arrayActions[NAVIGATION_TOOL_ACT] = new QAction( tr( "&Navigation Tool" ), this ); m_arrayActions[NAVIGATION_TOOL_ACT]->setCheckable( true ); m_arrayActions[NAVIGATION_TOOL_ACT]->setChecked( true ); actionGroupTools->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] ); - connect( m_arrayActions[NAVIGATION_TOOL_ACT], SIGNAL( triggered() ), this, SLOT( setNavigationTool() ) ); + connect( m_arrayActions[NAVIGATION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); + m_mapperTools->setMapping( m_arrayActions[NAVIGATION_TOOL_ACT], ViewArea::NavigationTool ); m_arrayActions[SELECTION_TOOL_ACT] = new QAction( "&Selection Tool", this ); m_arrayActions[SELECTION_TOOL_ACT]->setCheckable( true ); m_arrayActions[SELECTION_TOOL_ACT]->setChecked( false ); actionGroupTools->addAction( m_arrayActions[SELECTION_TOOL_ACT] ); - connect( m_arrayActions[SELECTION_TOOL_ACT], SIGNAL( triggered() ), this, SLOT( setSelectionTool() ) ); + connect( m_arrayActions[SELECTION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); + m_mapperTools->setMapping( m_arrayActions[SELECTION_TOOL_ACT], ViewArea::NormalSelectionTool ); + // ------------ Window ------------ @@ -1495,8 +1495,8 @@ Void plaYUVerApp::readSettings() move( pos ); resize( size ); m_cLastOpenPath = settings.lastOpenPath(); - m_appTool = ( enum eTool )settings.getSelectedTool(); - setAllSubWindowTool(); + //m_appTool = ( ViewArea::eTool )settings.getSelectedTool(); + //setAllSubWindowTool(); m_arrayActions[VIDEO_LOOP_ACT]->setChecked( settings.getRepeat() ); m_arrayActions[VIDEO_LOCK_ACT]->setChecked( settings.getVideoLock() ); diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index bd2baa0..ec13b8f 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -113,8 +113,7 @@ private Q_SLOTS: void updateZoomFactorSBox(); void setAllSubWindowTool(); - void setNavigationTool(); - void setSelectionTool(); + void setTool( int idxTool ); private: @@ -295,9 +294,15 @@ private: // Tools Actions; QActionGroup *actionGroupTools; - QAction *actionNavigationTool; - QAction *actionSelectionTool; - enum eTool m_appTool; + enum APP_TOOLS_ACTION_LIST + { + NAVIGATION_TOOL, + SELECTION_TOOL, + TOTAL_TOOLS, + }; + QVector m_arrayTools; + QSignalMapper *m_mapperTools; + ViewArea::eTool m_appTool; PlaYUVerStreamInfoVector m_aRecentFileStreamInfo; diff --git a/source/lib/PlaYUVerDefs.h b/source/lib/PlaYUVerDefs.h index c5462e9..fb27988 100644 --- a/source/lib/PlaYUVerDefs.h +++ b/source/lib/PlaYUVerDefs.h @@ -146,11 +146,6 @@ typedef struct __pixel_definition }; }Pixel; -enum eTool -{ - NavigationTool, NormalSelectionTool, BlockSelectionTool, MaskTool, EraserTool -}; - } // NAMESPACE #endif // __TYPEDEF_H__