diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a08e4f..18e2cca 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,11 +100,11 @@ IF( NOT USE_QT4) QT5_USE_MODULES( ${PROJECT_NAME} ${CURR_QT_MODULES} ) ENDIF() -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin ) -INSTALL(FILES resources/playuver.desktop DESTINATION share/applications ) -INSTALL(FILES resources/playuver.png DESTINATION share/icons ) - +INCLUDE(cmake/Install.cmake) +###################################################################################### +# Final information dump +###################################################################################### status("Configuration:") status(" Build type:" ${CMAKE_BUILD_TYPE} ) status(" Warnings as errors:" USE_WERROR THEN YES ELSE NO) diff --git a/cmake/Install.cmake b/cmake/Install.cmake new file mode 100644 index 0000000..323de4e --- /dev/null +++ b/cmake/Install.cmake @@ -0,0 +1,27 @@ +###################################################################################### +# Install +###################################################################################### + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin ) +INSTALL(FILES resources/playuver.desktop DESTINATION share/applications ) +INSTALL(FILES resources/playuver.png DESTINATION share/icons ) +INSTALL(FILES resources/x-raw.xml DESTINATION share/mime/video ) + +# # try to set up the menu system +# find_program(XDG-MIME_EXECUTABLE xdg-mime) +# # find_program(XDG-DESKTOP-MENU_EXECUTABLE xdg-desktop-menu) +# INSTALL(CODE "execute_process(COMMAND ${XDG-MIME_EXECUTABLE} install --novendor resources/)" ) + +###################################################################################### +# Create deb package +###################################################################################### +SET(CPACK_GENERATOR "DEB") +SET(CPACK_PACKAGE_VERSION_MAJOR "0") +SET(CPACK_PACKAGE_VERSION_MINOR "1") +SET(CPACK_PACKAGE_VERSION_PATCH "0") +SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-core,libqt4-gui,libavformat53,libcodec53,libavutil51") +SET(CPACK_PACKAGE_DESCRIPTION "plaYUVer is an open-source QT based raw video player") +SET(CPACK_PACKAGE_CONTACT "Joao Carreira (jfmcarreira@gmail.com)") +# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst") + +INCLUDE(CPack) \ No newline at end of file diff --git a/resources/playuver.desktop b/resources/playuver.desktop index 9872f8e..28f9ed7 100755 --- a/resources/playuver.desktop +++ b/resources/playuver.desktop @@ -5,6 +5,6 @@ Name=plaYUVer Exec=playuver Icon=playuver.png Terminal=false -#MimeType=text/x-pgf +MimeType=video/x-raw Categories=AudioVideo;Video;Player; GenericName=raw video player diff --git a/resources/x-raw.xml b/resources/x-raw.xml new file mode 100644 index 0000000..6d06cd7 --- /dev/null +++ b/resources/x-raw.xml @@ -0,0 +1,7 @@ + + + Raw YUV file + + + + diff --git a/source/app/TypeDef.h b/source/app/TypeDef.h index a121cef..1a2ed00 100644 --- a/source/app/TypeDef.h +++ b/source/app/TypeDef.h @@ -146,6 +146,11 @@ typedef struct __pixel_definition }; }Pixel; +enum eTool +{ + NavigationTool, NormalSelectionTool, BlockSelectionTool, MaskTool, EraserTool +}; + } // NAMESPACE #endif // __TYPEDEF_H__ diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 50df77d..4b0b00d 100755 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -165,7 +165,7 @@ void ViewArea::setMaskColor( const QColor &color ) update(); } -void ViewArea::setTool( Tool tool ) +void ViewArea::setTool( eTool tool ) { m_tool = tool; } @@ -874,5 +874,4 @@ InputStream* ViewArea::getInputStream() return m_pStream; } - } // NameSpace plaYUVer diff --git a/source/app/ViewArea.h b/source/app/ViewArea.h index b708280..8a48d9a 100755 --- a/source/app/ViewArea.h +++ b/source/app/ViewArea.h @@ -53,16 +53,10 @@ public: NormalMode, MaskMode, }; - enum Tool - { - NavigationTool, NormalSelectionTool, BlockSelectionTool, MaskTool, EraserTool - }; - ViewArea( QWidget *parent = 0 ); void setImage( const QPixmap &pixmap ); void setMode( ViewMode mode ); - void setTool( Tool tool ); void setMaskColor( const QColor &color = QColor() ); /** @@ -94,7 +88,7 @@ public: { return m_mode; } - Tool tool() const + enum eTool tool() const { return m_tool; } @@ -108,6 +102,7 @@ public: Void zoomChangeEvent(Double factor, QPoint center); Double getZoomFactor(); + void setTool( enum eTool tool ); // QSize sizeHint() const; @@ -158,7 +153,7 @@ private: QPoint m_lastWindowPos; GridManager m_grid; ViewMode m_mode; - Tool m_tool; + enum eTool m_tool; QColor m_maskColor; double m_zoomFactor; int m_xOffset; diff --git a/source/app/main.cpp b/source/app/main.cpp index 293eff3..36114d2 100755 --- a/source/app/main.cpp +++ b/source/app/main.cpp @@ -31,8 +31,7 @@ int main( int argc, char *argv[] ) { QApplication a( argc, argv ); plaYUVerApp w; - w.show(); - + w.parseArgs( argc, argv ); return a.exec(); } diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 8a0a010..b97b11e 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -82,6 +82,14 @@ plaYUVerApp::plaYUVerApp() m_pcCurrentSubWindow = NULL; } +Void plaYUVerApp::parseArgs( Int argc, Char *argv[] ) +{ + if( argc == 2 ) + { + loadFile( argv[1] ); + } +} + Void plaYUVerApp::closeEvent( QCloseEvent *event ) { Int mayCloseAll = true; @@ -124,6 +132,33 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event ) } } +Void plaYUVerApp::loadFile( QString fileName ) +{ + QMdiSubWindow *existing = findSubWindow( fileName ); + if( existing ) + { + mdiArea->setActiveSubWindow( existing ); + return; + } + + SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow(); + if( interfaceChild->loadFile( fileName ) ) + { + mdiArea->addSubWindow( interfaceChild ); + statusBar()->showMessage( tr( "File loaded" ), 2000 ); + interfaceChild->show(); + connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, InputStream *) ), this, + SLOT( updatePixelValueStatusBar(const QPoint &, InputStream *) ) ); + interfaceChild->zoomToFit(); + interfaceChild->getViewArea()->setTool( m_appTool ); + } + else + { + interfaceChild->close(); + } +} + + // ----------------------- File Functions ----------------------- void plaYUVerApp::open() @@ -144,28 +179,7 @@ void plaYUVerApp::open() if( !fileName.isEmpty() ) { m_cLastOpenPath = QFileInfo( fileName ).path(); - - QMdiSubWindow *existing = findSubWindow( fileName ); - if( existing ) - { - mdiArea->setActiveSubWindow( existing ); - return; - } - - SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow(); - if( interfaceChild->loadFile( fileName ) ) - { - mdiArea->addSubWindow( interfaceChild ); - statusBar()->showMessage( tr( "File loaded" ), 2000 ); - interfaceChild->show(); - connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, InputStream *) ), this, - SLOT( updatePixelValueStatusBar(const QPoint &, InputStream *) ) ); - interfaceChild->zoomToFit(); - } - else - { - interfaceChild->close(); - } + loadFile( fileName ); } } @@ -529,24 +543,8 @@ void plaYUVerApp::dropEvent( QDropEvent *event ) if( urlList.size() == 1 ) { QString fileName = urlList.at( 0 ).toLocalFile(); - m_cLastOpenPath = QFileInfo( fileName ).path(); - - QMdiSubWindow *existing = findSubWindow( fileName ); - if( !existing ) - { - SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow(); - if( interfaceChild->loadFile( fileName ) ) - { - mdiArea->addSubWindow( interfaceChild ); - statusBar()->showMessage( tr( "File loaded" ), 2000 ); - interfaceChild->show(); - } - else - { - interfaceChild->close(); - } - } + loadFile( fileName ); } } @@ -564,13 +562,33 @@ QMdiSubWindow *plaYUVerApp::findSubWindow( const QString &fileName ) QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath(); foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ - SubWindowHandle *mdiChild = qobject_cast( window); - if( mdiChild->currentFile() == canonicalFilePath ) - return window; -} + SubWindowHandle *mdiChild = qobject_cast( window); + if( mdiChild->currentFile() == canonicalFilePath ) + return window; + } return 0; } +void plaYUVerApp::setNavigationTool( ) +{ + m_appTool = NavigationTool; + setAllSubWindowTool( ); +} + +void plaYUVerApp::setSelectionTool( ) +{ + m_appTool = NormalSelectionTool; + setAllSubWindowTool( ); +} + +void plaYUVerApp::setAllSubWindowTool( ) +{ + foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ + SubWindowHandle *mdiChild = qobject_cast( window); + mdiChild->getViewArea()->setTool( m_appTool ); + } +} + void plaYUVerApp::setActiveSubWindow( QWidget *window ) { if( !window ) @@ -606,6 +624,9 @@ Void plaYUVerApp::updateMenus() m_pcFrameSlider->setValue( 0 ); } + actionNavigationTool->setEnabled( hasSubWindow ); + actionSelectionTool->setEnabled( hasSubWindow ); + m_pcModulesHandle->updateMenus( hasSubWindow ); } @@ -770,6 +791,24 @@ Void plaYUVerApp::createActions() m_pcFrameSlider->setEnabled( false ); connect( m_pcFrameSlider, SIGNAL( sliderMoved(int) ), this, SLOT( seekSliderEvent(int) ) ); + // ------------ Tools ------------ + actionGroupTools = new QActionGroup( this ); + actionGroupTools->setExclusive(true); + + m_appTool = NavigationTool; + + actionNavigationTool = new QAction( tr( "&Navigation Tool" ), this ); + actionNavigationTool->setCheckable( true ); + actionNavigationTool->setChecked( true ); + actionGroupTools->addAction( actionNavigationTool ); + connect( actionNavigationTool, SIGNAL( triggered() ), this, SLOT( setNavigationTool() ) ); + + actionSelectionTool = new QAction( "&Selection Tool", this ); + actionSelectionTool->setCheckable( true ); + actionSelectionTool->setChecked( false ); + actionGroupTools->addAction( actionSelectionTool ); + connect( actionSelectionTool, SIGNAL( triggered() ), this, SLOT( setSelectionTool() ) ); + // ------------ Window ------------ actionTile = new QAction( tr( "&Tile" ), this ); @@ -846,6 +885,10 @@ Void plaYUVerApp::createMenus() QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() ); connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( selectModule(QAction *) ) ); + m_arrayMenu[TOOLS_MENU] = menuBar()->addMenu( tr( "Tools" ) ); + m_arrayMenu[TOOLS_MENU]->addAction( actionNavigationTool ); + m_arrayMenu[TOOLS_MENU]->addAction( actionSelectionTool ); + m_arrayMenu[WINDOW_MENU] = menuBar()->addMenu( tr( "&Window" ) ); updateWindowMenu(); connect( m_arrayMenu[WINDOW_MENU], SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) ); diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index f3c0c79..2fd311c 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -50,6 +50,7 @@ Q_OBJECT public: plaYUVerApp(); + Void parseArgs( Int argc, Char *argv[] ); protected: Void closeEvent( QCloseEvent *event ); @@ -98,6 +99,10 @@ private Q_SLOTS: void updatePixelValueStatusBar(const QPoint & pos, InputStream* stream); + void setAllSubWindowTool( ); + void setNavigationTool( ); + void setSelectionTool( ); + private: QMdiArea *mdiArea; SubWindowHandle *m_pcCurrentSubWindow; @@ -108,6 +113,7 @@ private: QTime m_cTimer; UInt m_uiAveragePlayInterval; + Void loadFile( QString fileName ); //! Playing functions Void setTimerStatus(); @@ -138,16 +144,16 @@ private: /** * Array of menus for the main app * @param position description: - * 0 - Window - * 1 - File - * 2 - View - * 3 - Help + * 0 - File + * 1 - View + * 2 - ... */ enum MAIN_APP_MENU_LIST { FILE_MENU = 0, VIEW_MENU, VIDEO_MENU, + TOOLS_MENU, WINDOW_MENU, ABOUT_MENU, TOTAL_MENUS, @@ -213,6 +219,12 @@ private: QAction *actionAbout; QAction *actionAboutQt; + // Tools Actions; + QActionGroup *actionGroupTools; + QAction *actionNavigationTool; + QAction *actionSelectionTool; + enum eTool m_appTool; + }; } // NAMESPACE