diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 76d3c31..0d40fab 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -224,16 +224,15 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) m_pcWindowHandle->addSubWindow( videoSubWindow ); videoSubWindow->show(); - connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) ); - connect( subWindow, SIGNAL( aboutToClose( SubWindowAbstract* ) ), m_appModuleVideo, SLOT( closeSubWindow( SubWindowAbstract* ) ) ); connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo, SLOT( zoomToFactorAll( double, QPoint ) ) ); connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) ); videoSubWindow->zoomToFit(); - videoSubWindow->getViewArea()->setTool( m_uiViewTool ); updateZoomFactorSBox(); + m_appModuleVideo->openSubWindow( videoSubWindow ); + addStreamInfoToRecentList( videoSubWindow->getStreamInfo() ); printMessage( "File loaded", LOG_INFO ); @@ -405,17 +404,6 @@ Void PlaYUVerApp::loadAll() } } -Void PlaYUVerApp::setTool( Int idxTool ) -{ - m_uiViewTool = idxTool; - actionGroupTools->actions().at( m_uiViewTool )->setChecked( true ); - QList subWindowList = m_pcWindowHandle->findSubWindow(); - for( Int i = 0; i < subWindowList.size(); i++ ) - { - subWindowList.at( i )->setTool( m_uiViewTool ); - } -} - // ----------------------- Zoom Functions ----------------------- Void PlaYUVerApp::normalSize() @@ -595,9 +583,6 @@ Void PlaYUVerApp::updateMenus() m_arrayActions[ZOOM_FIT_ALL_ACT]->setEnabled( hasSubWindow ); m_pcZoomFactorSBox->setEnabled( hasSubWindow ); - m_arrayActions[NAVIGATION_TOOL_ACT]->setEnabled( hasSubWindow ); - m_arrayActions[SELECTION_TOOL_ACT]->setEnabled( hasSubWindow ); - m_appModuleVideo->updateMenus(); m_appModuleQuality->updateMenus(); m_appModuleExtensions->updateMenus(); @@ -700,39 +685,6 @@ Void PlaYUVerApp::createActions() m_arrayActions[ZOOM_FIT_ALL_ACT]->setStatusTip( tr( "Apply zoom to fit to all windows" ) ); connect( m_arrayActions[ZOOM_FIT_ALL_ACT], SIGNAL( triggered() ), this, SLOT( zoomToFitAll() ) ); - // ------------ Tools ------------ - actionGroupTools = new QActionGroup( this ); - actionGroupTools->setExclusive( true ); - - m_mapperTools = new QSignalMapper( this ); - connect( m_mapperTools, SIGNAL( mapped(int) ), this, SLOT( setTool(int) ) ); - - m_uiViewTool = ViewArea::NavigationView; - - 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 ); - m_arrayActions[NAVIGATION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_1 ); - actionGroupTools->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] ); - connect( m_arrayActions[NAVIGATION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); - m_mapperTools->setMapping( m_arrayActions[NAVIGATION_TOOL_ACT], ViewArea::NavigationView ); - - m_arrayActions[SELECTION_TOOL_ACT] = new QAction( "Selection Tool", this ); - m_arrayActions[SELECTION_TOOL_ACT]->setCheckable( true ); - m_arrayActions[SELECTION_TOOL_ACT]->setChecked( false ); - m_arrayActions[SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_2 ); - actionGroupTools->addAction( m_arrayActions[SELECTION_TOOL_ACT] ); - connect( m_arrayActions[SELECTION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); - m_mapperTools->setMapping( m_arrayActions[SELECTION_TOOL_ACT], ViewArea::NormalSelectionView ); - - m_arrayActions[BLOCK_SELECTION_TOOL_ACT] = new QAction( "Block Selection Tool", this ); - m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setCheckable( true ); - m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setChecked( false ); - m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_3 ); - actionGroupTools->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] ); - connect( m_arrayActions[BLOCK_SELECTION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); - m_mapperTools->setMapping( m_arrayActions[BLOCK_SELECTION_TOOL_ACT], ViewArea::BlockSelectionView ); - m_appModuleVideo->createActions(); m_appModuleQuality->createActions(); m_appModuleExtensions->createActions(); @@ -779,10 +731,6 @@ Void PlaYUVerApp::createMenus() m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[EXIT_ACT] ); m_arrayMenu[VIEW_MENU] = menuBar()->addMenu( tr( "&View" ) ); - m_arrayMenu[VIEW_MENU]->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] ); - m_arrayMenu[VIEW_MENU]->addAction( m_arrayActions[SELECTION_TOOL_ACT] ); - //m_arrayMenu[VIEW_MENU]->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] ); - m_arrayMenu[VIEW_MENU]->addSeparator(); m_arrayMenu[VIEW_MENU]->addAction( m_arrayActions[ZOOM_IN_ACT] ); m_arrayMenu[VIEW_MENU]->addAction( m_arrayActions[ZOOM_OUT_ACT] ); m_arrayMenu[VIEW_MENU]->addAction( m_arrayActions[ZOOM_NORMAL_ACT] ); @@ -800,12 +748,8 @@ Void PlaYUVerApp::createMenus() actionPopupMenu->setText( tr( "&Toolbars/Docks" ) ); } -// m_arrayMenu[TOOLS_MENU] = menuBar()->addMenu( tr( "Tools" ) ); -// m_arrayMenu[TOOLS_MENU]->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] ); -// m_arrayMenu[TOOLS_MENU]->addAction( m_arrayActions[SELECTION_TOOL_ACT] ); - - QMenu* VideoMenu = m_appModuleVideo->createMenu(); - menuBar()->addMenu( VideoMenu ); + menuBar()->addMenu( m_appModuleVideo->createVideoMenu() ); + menuBar()->addMenu( m_appModuleVideo->createImageMenu() ); QMenu* QualityMenu = m_appModuleQuality->createMenu(); menuBar()->addMenu( QualityMenu ); QMenu* ModuleMenu = m_appModuleExtensions->createMenu(); @@ -943,9 +887,6 @@ Void PlaYUVerApp::readSettings() m_cLastOpenPath = appSettings.value( "MainWindow/LastOpenPath", QDir::homePath() ).toString(); - m_uiViewTool = appSettings.value( "MainWindow/SelectedTool", ViewArea::NavigationView ).toUInt(); - setTool( m_uiViewTool ); - QVariant value = appSettings.value( "MainWindow/RecentFileList" ); m_aRecentFileStreamInfo = value.value(); checkRecentFileActions(); @@ -964,7 +905,6 @@ Void PlaYUVerApp::writeSettings() appSettings.setValue( "MainWindow/Position", pos() ); appSettings.setValue( "MainWindow/Size", size() ); appSettings.setValue( "MainWindow/LastOpenPath", m_cLastOpenPath ); - appSettings.setValue( "MainWindow/SelectedTool", m_uiViewTool ); QVariant var; var.setValue( m_aRecentFileStreamInfo ); diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index 770df20..7f26498 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -111,8 +111,6 @@ private Q_SLOTS: void zoomToFit(); void zoomToFitAll(); - void setTool( int idxTool ); - void dragEnterEvent( QDragEnterEvent *event ); void dropEvent( QDropEvent *event ); @@ -153,17 +151,6 @@ private: QSignalMapper *mapperZoom; QSignalMapper *mapperWindow; - // Tools Actions; - QActionGroup *actionGroupTools; - enum APP_TOOLS_ACTION_LIST - { - NAVIGATION_TOOL, - SELECTION_TOOL, - TOTAL_TOOLS, - }; - QSignalMapper *m_mapperTools; - UInt m_uiViewTool; - /** * App modules * Video @@ -236,9 +223,6 @@ private: ZOOM_NORMAL_ACT, ZOOM_FIT_ACT, ZOOM_FIT_ALL_ACT, - NAVIGATION_TOOL_ACT, - SELECTION_TOOL_ACT, - BLOCK_SELECTION_TOOL_ACT, UPDATE_ACT, ABOUT_ACT, ABOUTQT_ACT, diff --git a/app/SubWindowAbstract.h b/app/SubWindowAbstract.h index cd89aff..bb6a080 100644 --- a/app/SubWindowAbstract.h +++ b/app/SubWindowAbstract.h @@ -82,11 +82,6 @@ public: */ virtual Void refreshSubWindow() = 0; - /** - * Show the image at its original size - */ - virtual Void setTool( UInt uiTool ) = 0; - /** * Show the image at its original size */ diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 0109c17..d325b83 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -123,9 +123,47 @@ Void VideoHandle::createActions() m_pcFrameSlider->setEnabled( false ); m_pcFrameSlider->setTracking( false ); connect( m_pcFrameSlider, SIGNAL( valueChanged(int) ), this, SLOT( seekSliderEvent(int) ) ); + + // ------------ Tools ------------ + actionGroupTools = new QActionGroup( this ); + actionGroupTools->setExclusive( true ); + + m_mapperTools = new QSignalMapper( this ); + connect( m_mapperTools, SIGNAL( mapped(int) ), this, SLOT( setTool(int) ) ); + + m_uiViewTool = ViewArea::NavigationView; + + 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 ); + m_arrayActions[NAVIGATION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_1 ); + actionGroupTools->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] ); + connect( m_arrayActions[NAVIGATION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); + m_mapperTools->setMapping( m_arrayActions[NAVIGATION_TOOL_ACT], ViewArea::NavigationView ); + + m_arrayActions[SELECTION_TOOL_ACT] = new QAction( "Selection Tool", this ); + m_arrayActions[SELECTION_TOOL_ACT]->setCheckable( true ); + m_arrayActions[SELECTION_TOOL_ACT]->setChecked( false ); + m_arrayActions[SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_2 ); + actionGroupTools->addAction( m_arrayActions[SELECTION_TOOL_ACT] ); + connect( m_arrayActions[SELECTION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); + m_mapperTools->setMapping( m_arrayActions[SELECTION_TOOL_ACT], ViewArea::NormalSelectionView ); + + m_arrayActions[BLOCK_SELECTION_TOOL_ACT] = new QAction( "Block Selection Tool", this ); + m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setCheckable( true ); + m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setChecked( false ); + m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_3 ); + actionGroupTools->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] ); + connect( m_arrayActions[BLOCK_SELECTION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) ); + m_mapperTools->setMapping( m_arrayActions[BLOCK_SELECTION_TOOL_ACT], ViewArea::BlockSelectionView ); + + m_arrayActions[SHOW_GRID_ACT] = new QAction( "Show grid", this ); + m_arrayActions[SHOW_GRID_ACT]->setCheckable( true ); + m_arrayActions[SHOW_GRID_ACT]->setChecked( false ); + connect( m_arrayActions[SHOW_GRID_ACT], SIGNAL( triggered() ), this, SLOT( toogleGrid() ) ); } -QMenu* VideoHandle::createMenu() +QMenu* VideoHandle::createVideoMenu() { m_pcMenuVideo = new QMenu( "Video", this ); m_pcMenuVideo->addAction( m_arrayActions[PLAY_ACT] ); @@ -140,6 +178,17 @@ QMenu* VideoHandle::createMenu() return m_pcMenuVideo; } +QMenu* VideoHandle::createImageMenu() +{ + m_pcMenuImage = new QMenu( "Image", this ); + m_pcMenuImage->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] ); + m_pcMenuImage->addAction( m_arrayActions[SELECTION_TOOL_ACT] ); + //m_pcMenuImage->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] ); + //m_pcMenuImage->addSeparator(); + //m_pcMenuImage->addAction( m_arrayActions[SHOW_GRID_ACT] ); + return m_pcMenuImage; +} + QToolBar* VideoHandle::createToolBar() { m_toolbarVideo = new QToolBar( tr( "Video" ) ); @@ -216,6 +265,11 @@ Void VideoHandle::updateMenus() m_pcFrameSlider->setValue( 0 ); m_pcFrameNumInfo->clear(); } + + m_arrayActions[NAVIGATION_TOOL_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[SELECTION_TOOL_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[SHOW_GRID_ACT]->setEnabled( hasSubWindow ); } Void VideoHandle::readSettings() @@ -225,6 +279,9 @@ Void VideoHandle::readSettings() m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->setChecked( appSettings.value( "VideoHandle/VideoZoomLock", false ).toBool() ); if( !appSettings.value( "VideoHandle/FrameProperties", true ).toBool() ) m_pcFramePropertiesDock->close(); + + m_uiViewTool = appSettings.value( "VideoHandle/SelectedTool", ViewArea::NavigationView ).toUInt(); + setTool( m_uiViewTool ); } Void VideoHandle::writeSettings() @@ -233,6 +290,7 @@ Void VideoHandle::writeSettings() appSettings.setValue( "VideoHandle/Repeat", m_arrayActions[VIDEO_REPEAT_ACT]->isChecked() ); appSettings.setValue( "VideoHandle/VideoZoomLock", m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ); appSettings.setValue( "VideoHandle/FrameProperties", m_pcFramePropertiesSideBar->isVisible() ); + appSettings.setValue( "VideoHandle/SelectedTool", m_uiViewTool ); } Void VideoHandle::update() @@ -310,6 +368,12 @@ Void VideoHandle::updateSelectionArea( QRect area ) } } +Void VideoHandle::openSubWindow( VideoSubWindow* subWindow ) +{ + connect( subWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectionArea( QRect ) ) ); + subWindow->getViewArea()->setTool( m_uiViewTool ); +} + Void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow ) { VideoSubWindow* videoSubWindow = qobject_cast( subWindow ); @@ -691,5 +755,21 @@ Void VideoHandle::videoSelectionButtonEvent() } } +Void VideoHandle::setTool( Int tool ) +{ + m_uiViewTool = tool; + actionGroupTools->actions().at( m_uiViewTool )->setChecked( true ); + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); + for( Int i = 0; i < subWindowList.size(); i++ ) + { + qobject_cast( subWindowList.at( i ) )->setTool( m_uiViewTool ); + } +} + +Void VideoHandle::toggleGrid() +{ + +} + } // NAMESPACE diff --git a/app/VideoHandle.h b/app/VideoHandle.h index 23c703f..bf9c898 100644 --- a/app/VideoHandle.h +++ b/app/VideoHandle.h @@ -59,7 +59,8 @@ public: ~VideoHandle(); Void createActions(); - QMenu* createMenu(); + QMenu* createVideoMenu(); + QMenu* createImageMenu(); QToolBar* createToolBar(); QDockWidget* createDock(); QWidget* createStatusBarMessage(); @@ -70,6 +71,8 @@ public: Void update( VideoSubWindow* currSubWindow ); + Void openSubWindow( VideoSubWindow* subWindow ); + private: QWidget* m_pcParet; PlaYUVerSubWindowHandle* m_pcMainWindowManager; @@ -84,6 +87,10 @@ private: VIDEO_ZOOM_LOCK_ACT, VIDEO_LOCK_ACT, VIDEO_LOCK_SELECTION_ACT, + NAVIGATION_TOOL_ACT, + SELECTION_TOOL_ACT, + BLOCK_SELECTION_TOOL_ACT, + SHOW_GRID_ACT, TOTAL_ACT, }; QVector m_arrayActions; @@ -92,7 +99,13 @@ private: QSlider* m_pcFrameSlider; WidgetFrameNumber* m_pcFrameNumInfo; + // Tools Actions; + QActionGroup *actionGroupTools; + QSignalMapper *m_mapperTools; + UInt m_uiViewTool; + QMenu* m_pcMenuVideo; + QMenu* m_pcMenuImage; QToolBar* m_toolbarVideo; QDockWidget* m_pcFramePropertiesDock; @@ -132,6 +145,8 @@ private Q_SLOTS: void seekEvent( int direction ); void seekVideo(); void videoSelectionButtonEvent(); + void setTool( int tool ); + void toggleGrid(); }; diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index a7cc6fa..aca520c 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -71,11 +71,6 @@ ViewArea::ViewArea( QWidget *parent ) : connect( &m_zoomWinTimer, SIGNAL( timeout() ), this, SLOT( update() ) ); } -Void ViewArea::startZoomWinTimer() -{ - m_zoomWinTimer.start(); -} - Void ViewArea::setImage( PlaYUVerFrame* pcFrame ) { m_pcCurrFrame = pcFrame; @@ -139,6 +134,14 @@ Void ViewArea::clearMask() m_mask.clear(); } +/** + * Zoom related function + */ +Void ViewArea::startZoomWinTimer() +{ + m_zoomWinTimer.start(); +} + Void ViewArea::setZoomFactor( Double f ) { m_zoomFactor = f; diff --git a/app/ViewArea.h b/app/ViewArea.h index 506ef7f..5affd66 100644 --- a/app/ViewArea.h +++ b/app/ViewArea.h @@ -61,6 +61,7 @@ public: Void setImage( PlaYUVerFrame* pcFrame ); Void setImage( const QPixmap &pixmap ); + Void setMode( Int mode ); Void setMaskColor( const QColor &color = QColor() ); @@ -109,8 +110,6 @@ public: // Scale function. Return used scale value (it may change when it touches the min or max zoom value) Double scaleZoomFactor( Double scale, QPoint center, QSize minimumSize ); - - Q_SIGNALS: void selectionChanged( const QRect &rect ); void positionChanged( const QPoint &pos ); @@ -167,9 +166,10 @@ private: Void initZoomWinRect(); Void startZoomWinTimer(); + Void setZoomFactor( Double ); + Bool isPosValid( const QPoint &pos ) const; Void updateMask( const QRect &rect ); - Void setZoomFactor( double ); QPoint windowToView( const QPoint& pt ) const; QRect windowToView( const QRect& rc ) const;