Merge with master

This commit is contained in:
Luis Lucas committed 2014-02-08 17:58:57 +00:00
commit a515b56527
12 files changed
+541 -457

No files matched your search

+5 -150
View File
@@ -8,6 +8,8 @@
cmake_minimum_required( VERSION 2.8.9 )
INCLUDE( cmake/CMakeMacros.cmake )
PROJECT( playuver )
SET( PROJECT_NAME playuver )
@@ -33,103 +35,6 @@ FILE( GLOB HEADERS_FILES ${INC_DIR}/*.h )
FILE( GLOB FORMS_FILES ${UI_DIR}/*.ui )
FILE( GLOB RESOURCES_FILES ${RSC_DIR}/*.qrc )
######################################################################################
# Macros
######################################################################################
macro(ADD_OPTION variable description value)
set(__value ${value})
set(__condition "")
set(__varname "__value")
foreach(arg ${ARGN})
if(arg STREQUAL "IF" OR arg STREQUAL "if")
set(__varname "__condition")
else()
list(APPEND ${__varname} ${arg})
endif()
endforeach()
unset(__varname)
if("${__condition}" STREQUAL "")
set(__condition 2 GREATER 1)
endif()
if(${__condition})
if("${__value}" MATCHES ";")
if(${__value})
option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
endif()
elseif(DEFINED ${__value})
if(${__value})
option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
endif()
else()
option(${variable} "${description}" ${__value})
endif()
else()
unset(${variable} CACHE)
endif()
unset(__condition)
unset(__value)
endmacro()
# Status report function.
# Automatically align right column and selects text based on condition.
# Usage:
# status(<text>)
# status(<heading> <value1> [<value2> ...])
# status(<heading> <condition> THEN <text for TRUE> ELSE <text for FALSE> )
function(status text)
set(status_cond)
set(status_then)
set(status_else)
set(status_current_name "cond")
foreach(arg ${ARGN})
if(arg STREQUAL "THEN")
set(status_current_name "then")
elseif(arg STREQUAL "ELSE")
set(status_current_name "else")
else()
list(APPEND status_${status_current_name} ${arg})
endif()
endforeach()
if(DEFINED status_cond)
set(status_placeholder_length 32)
string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
string(LENGTH "${text}" status_text_length)
if(status_text_length LESS status_placeholder_length)
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
elseif(DEFINED status_then OR DEFINED status_else)
message(STATUS ${text})
set(status_text "${status_placeholder}")
else()
set(status_text "${text}")
endif()
if(DEFINED status_then OR DEFINED status_else)
if(${status_cond})
string(REPLACE ";" " " status_then "${status_then}")
string(REGEX REPLACE "^[ \t]+" "" status_then "${status_then}")
message(STATUS "${status_text} ${status_then}")
else()
string(REPLACE ";" " " status_else "${status_else}")
string(REGEX REPLACE "^[ \t]+" "" status_else "${status_else}")
message(STATUS "${status_text} ${status_else}")
endif()
else()
string(REPLACE ";" " " status_cond "${status_cond}")
string(REGEX REPLACE "^[ \t]+" "" status_cond "${status_cond}")
message(STATUS "${status_text} ${status_cond}")
endif()
else()
message(STATUS "${text}")
endif()
endfunction()
######################################################################################
# Variables
@@ -139,45 +44,12 @@ ADD_OPTION(USE_QT4 "Build with QT4" OFF )
ADD_OPTION(USE_OPENCV "Add OpenCV support" OFF )
ADD_OPTION(USE_FFMPEG "Add FFMPEG support" OFF )
#####################################################################################
# Qt library
######################################################################################
IF( USE_QT4 )
FIND_PACKAGE( Qt4 REQUIRED QtCore QtGui )
IF( NOT QT4_FOUND)
SET(USE_QT4 FALSE)
ENDIF()
INCLUDE( ${QT_USE_FILE} )
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
QT4_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} )
QT4_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} )
SET( LINKER_LIBS ${LINKER_LIBS} ${QT_LIBRARIES} )
ENDIF()
IF( NOT USE_QT4 )
FIND_PACKAGE( Qt5Core REQUIRED )
FIND_PACKAGE( Qt5Gui REQUIRED )
FIND_PACKAGE( Qt5Widgets REQUIRED )
INCLUDE_DIRECTORIES( ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} )
# QT5_WRAP_CPP( HEADERS_MOC_FILES ${HEADERS_FILES} )
QT5_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} )
QT5_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} )
# Add compiler flags for building executables (-fPIE)
SET( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} )
SET( LINKER_LIBS ${LINKER_LIBS} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
SET( CURR_QT_MODULES Core Gui Widgets )
ENDIF()
######################################################################################
# Dependencies
######################################################################################
INCLUDE( cmake/LibQT.cmake )
INCLUDE_DIRECTORIES( ${EXTERNAL_SRC}/scode )
ADD_LIBRARY( Scode ${EXTERNAL_SRC}/scode/viewarea.cpp ${EXTERNAL_SRC}/scode/gridmanager.cpp ${EXTERNAL_SRC}/scode/scosettings.cpp )
SET( LINKER_LIBS ${LINKER_LIBS} Scode )
@@ -192,24 +64,7 @@ IF( USE_OPENCV )
ENDIF()
ENDIF()
IF( USE_FFMPEG )
IF( NOT WIN32 )
FIND_PACKAGE( FFmpeg )
IF( NOT FFMPEG_FOUND )
SET( USE_FFMPEG FALSE )
ELSE()
INCLUDE_DIRECTORIES( ${LIB_DIR}/ffmpeg )
#SET( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS )
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
ADD_LIBRARY( FFmpeg ${LIB_DIR}/ffmpeg/LibAvContextHandle.cpp )
TARGET_LINK_LIBRARIES( FFmpeg ${FFMPEG_LIBRARIES} )
SET( LINKER_LIBS ${LINKER_LIBS} FFmpeg )
ENDIF()
ELSE()
SET( USE_FFMPEG FALSE )
ENDIF()
ENDIF()
INCLUDE( cmake/LibFFmpeg.cmake )
######################################################################################
# Create config.h
+97
View File
@@ -0,0 +1,97 @@
######################################################################################
# Macros definition
######################################################################################
macro(ADD_OPTION variable description value)
set(__value ${value})
set(__condition "")
set(__varname "__value")
foreach(arg ${ARGN})
if(arg STREQUAL "IF" OR arg STREQUAL "if")
set(__varname "__condition")
else()
list(APPEND ${__varname} ${arg})
endif()
endforeach()
unset(__varname)
if("${__condition}" STREQUAL "")
set(__condition 2 GREATER 1)
endif()
if(${__condition})
if("${__value}" MATCHES ";")
if(${__value})
option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
endif()
elseif(DEFINED ${__value})
if(${__value})
option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
endif()
else()
option(${variable} "${description}" ${__value})
endif()
else()
unset(${variable} CACHE)
endif()
unset(__condition)
unset(__value)
endmacro()
# Status report function.
# Automatically align right column and selects text based on condition.
# Usage:
# status(<text>)
# status(<heading> <value1> [<value2> ...])
# status(<heading> <condition> THEN <text for TRUE> ELSE <text for FALSE> )
function(status text)
set(status_cond)
set(status_then)
set(status_else)
set(status_current_name "cond")
foreach(arg ${ARGN})
if(arg STREQUAL "THEN")
set(status_current_name "then")
elseif(arg STREQUAL "ELSE")
set(status_current_name "else")
else()
list(APPEND status_${status_current_name} ${arg})
endif()
endforeach()
if(DEFINED status_cond)
set(status_placeholder_length 32)
string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
string(LENGTH "${text}" status_text_length)
if(status_text_length LESS status_placeholder_length)
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
elseif(DEFINED status_then OR DEFINED status_else)
message(STATUS ${text})
set(status_text "${status_placeholder}")
else()
set(status_text "${text}")
endif()
if(DEFINED status_then OR DEFINED status_else)
if(${status_cond})
string(REPLACE ";" " " status_then "${status_then}")
string(REGEX REPLACE "^[ \t]+" "" status_then "${status_then}")
message(STATUS "${status_text} ${status_then}")
else()
string(REPLACE ";" " " status_else "${status_else}")
string(REGEX REPLACE "^[ \t]+" "" status_else "${status_else}")
message(STATUS "${status_text} ${status_else}")
endif()
else()
string(REPLACE ";" " " status_cond "${status_cond}")
string(REGEX REPLACE "^[ \t]+" "" status_cond "${status_cond}")
message(STATUS "${status_text} ${status_cond}")
endif()
else()
message(STATUS "${text}")
endif()
endfunction()
@@ -96,3 +96,22 @@ IF ( ${INC_SUCCESS} EQUAL ${LIST_SIZE_} )
SET( FFMPEG_FOUND TRUE )
SET( FFMPEG_SWSCALE_FOUND ${SWSCALE_FOUND} )
ENDIF ( ${INC_SUCCESS} EQUAL ${LIST_SIZE_} )
IF( USE_FFMPEG )
IF( NOT WIN32 )
IF( NOT FFMPEG_FOUND )
SET( USE_FFMPEG FALSE )
ELSE()
INCLUDE_DIRECTORIES( ${LIB_DIR}/ffmpeg )
#SET( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS )
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
ADD_LIBRARY( FFmpeg ${LIB_DIR}/ffmpeg/LibAvContextHandle.cpp )
TARGET_LINK_LIBRARIES( FFmpeg ${FFMPEG_LIBRARIES} )
SET( LINKER_LIBS ${LINKER_LIBS} FFmpeg )
ENDIF()
ELSE()
SET( USE_FFMPEG FALSE )
ENDIF()
ENDIF()
+35
View File
@@ -0,0 +1,35 @@
#####################################################################################
# Qt library cmake file
######################################################################################
IF( USE_QT4 )
FIND_PACKAGE( Qt4 REQUIRED QtCore QtGui )
IF( NOT QT4_FOUND)
SET(USE_QT4 FALSE)
ENDIF()
INCLUDE( ${QT_USE_FILE} )
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
QT4_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} )
QT4_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} )
SET( LINKER_LIBS ${LINKER_LIBS} ${QT_LIBRARIES} )
ENDIF()
IF( NOT USE_QT4 )
FIND_PACKAGE( Qt5Core REQUIRED )
FIND_PACKAGE( Qt5Gui REQUIRED )
FIND_PACKAGE( Qt5Widgets REQUIRED )
INCLUDE_DIRECTORIES( ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} )
# QT5_WRAP_CPP( HEADERS_MOC_FILES ${HEADERS_FILES} )
QT5_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} )
QT5_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} )
# Add compiler flags for building executables (-fPIE)
SET( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} )
SET( LINKER_LIBS ${LINKER_LIBS} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} )
SET( CURR_QT_MODULES Core Gui Widgets )
ENDIF()
+18 -19
View File
@@ -39,7 +39,7 @@ InputStream::InputStream()
m_uiWidth = 0;
m_uiHeight = 0;
m_uiTotalFrameNum = 0;
m_uiCurrFrameNum = 0;
m_iCurrFrameNum = -1;
m_iErrorStatus = 0;
m_iPixelFormat = -1;
@@ -137,9 +137,12 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
m_cStreamInformationString = QString( "[" );
#ifdef USE_FFMPEG
avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate );
m_cStreamInformationString.append( QString::fromUtf8( m_cLibAvContext.getStreamInformation() ) );
m_uiTotalFrameNum = 100;
if( QFileInfo( filename ).completeSuffix().compare( QString( "yuv" ) ) )
{
avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate );
m_cStreamInformationString.append( QString::fromUtf8( m_cLibAvContext.getStreamInformation() ) );
m_uiTotalFrameNum = 100;
}
#endif
if( m_uiWidth <= 0 || m_uiHeight <= 0 )
@@ -181,7 +184,7 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
m_cStreamInformationString.append( QFileInfo( m_cFilename ).fileName() );
m_uiCurrFrameNum = 0;
m_iCurrFrameNum = -1;
m_iStatus = 1;
return;
@@ -208,15 +211,12 @@ Void InputStream::readFrame()
return;
}
if( m_uiCurrFrameNum < m_uiTotalFrameNum )
{
m_uiCurrFrameNum++;
}
else
m_iCurrFrameNum++;
if( m_iCurrFrameNum >= m_uiTotalFrameNum )
{
m_iErrorStatus = END_OF_SEQ;
m_uiCurrFrameNum = 0;
seekInput( m_uiCurrFrameNum );
m_iCurrFrameNum = 0;
seekInput( m_iCurrFrameNum );
}
#ifdef USE_FFMPEG
@@ -243,14 +243,14 @@ Void InputStream::readFrame()
Bool InputStream::writeFrame( const QString& filename )
{
getFrameQImage().save( filename );
QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 );
getFrame( &img );
img.save( filename );
return true;
}
QImage InputStream::getFrameQImage()
Void InputStream::getFrame( QImage *qimage )
{
// Create QImage
QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 );
Pel*** bufferRGB = m_cCurrFrame->getPelBufferRGB();
if( sizeof(Pel) == sizeof(unsigned char) )
@@ -259,7 +259,7 @@ QImage InputStream::getFrameQImage()
{
for( Int x = 0; x < m_uiWidth; x++ )
{
img.setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) );
qimage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) );
}
}
}
@@ -267,7 +267,6 @@ QImage InputStream::getFrameQImage()
{
Q_ASSERT( 0 );
}
return img;
}
#ifdef USE_OPENCV
@@ -292,7 +291,7 @@ Void InputStream::seekInput( Int new_frame_num )
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
UInt64 nbytes_seek = frame_bytes_input * new_frame_num;
fseek( m_pFile, nbytes_seek, SEEK_SET );
m_uiCurrFrameNum = new_frame_num;
m_iCurrFrameNum = new_frame_num - 1;
}
}
+4 -4
View File
@@ -78,7 +78,7 @@ private:
UInt m_uiHeight;
UInt m_uiFrameRate;
UInt m_uiTotalFrameNum;
UInt m_uiCurrFrameNum;
Int m_iCurrFrameNum;
public:
InputStream();
@@ -103,7 +103,7 @@ public:
Bool writeFrame( const QString& filename );
QImage getFrameQImage();
Void getFrame( QImage *qimage );
#ifdef USE_OPENCV
cv::Mat getFrameCvMat();
#endif
@@ -136,9 +136,9 @@ public:
{
return m_uiHeight;
}
UInt getCurrFrameNum()
Int getCurrFrameNum()
{
return m_uiCurrFrameNum;
return m_iCurrFrameNum;
}
UInt getFrameRate()
{
+3
View File
@@ -201,7 +201,10 @@ UInt64 PlaYUVerFrame::getBytesPerFrame()
case RGB:
return m_uiWidth * m_uiHeight * 3;
break;
default:
return 0;
}
return 0;
}
} // NAMESPACE
+53 -25
View File
@@ -68,6 +68,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
connect( m_pcFrameSlider, SIGNAL( valueChanged(int) ), this, SLOT( seekSliderEvent() ) );
m_cWindowName = QString( " " );
m_bIsPlaying = true;
m_dScaleFactor = 1;
}
@@ -81,28 +82,32 @@ bool SubWindowHandle::loadFile( const QString &fileName )
{
ConfigureFormatDialog formatDialog( this );
if( m_currStream.needFormatDialog( fileName ) )
m_pCurrStream = new InputStream;
if( m_pCurrStream->needFormatDialog( fileName ) )
{
if( formatDialog.exec() == QDialog::Rejected )
{
return false;
}
m_currStream.init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height(), formatDialog.getPixelFormat(),
m_pCurrStream->init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height(), formatDialog.getPixelFormat(),
formatDialog.getFrameRate() );
}
else
{
m_currStream.init( fileName, 0, 0, 0, 0 );
m_pCurrStream->init( fileName, 0, 0, 0, 0 );
}
QApplication::setOverrideCursor( Qt::WaitCursor );
QApplication::restoreOverrideCursor();
if( m_currStream.getStatus() == 0 )
if( m_pCurrStream->getStatus() == 0 )
{
return false;
}
m_currStream.readFrame();
if( m_currStream.checkErrors( READING ) )
m_pCurrFrameQImage = new QImage( m_pCurrStream->getWidth(), m_pCurrStream->getHeight(), QImage::Format_RGB888 );
m_pCurrStream->readFrame();
if( m_pCurrStream->checkErrors( READING ) )
{
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( fileName ) );
return false;
@@ -110,12 +115,13 @@ bool SubWindowHandle::loadFile( const QString &fileName )
QApplication::restoreOverrideCursor();
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
m_pCurrStream->getFrame( m_pCurrFrameQImage );
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
normalSize();
m_pcFrameSlider->setRange( 0, m_currStream.getFrameNum() );
m_cWindowName = m_currStream.getStreamInformationString();
m_cWindowName = QString( " " );
m_cWindowName = m_pCurrStream->getStreamInformationString();
m_cCurrFileName = fileName;
setWindowTitle( m_cWindowName );
@@ -141,7 +147,7 @@ bool SubWindowHandle::save()
QApplication::setOverrideCursor( Qt::WaitCursor );
if( !m_currStream.writeFrame( fileName ) )
if( !m_pCurrStream->writeFrame( fileName ) )
{
QApplication::restoreOverrideCursor();
QMessageBox::warning( this, tr( "SCode" ), tr( "Cannot save file %1" ).arg( fileName ) );
@@ -162,22 +168,44 @@ void SubWindowHandle::seekSliderEvent()
bool SubWindowHandle::playEvent()
{
m_currStream.readFrame();
if( m_currStream.checkErrors( READING ) )
bool iRet = true;
if( m_bIsPlaying )
{
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) );
return false;
m_pCurrStream->readFrame();
if( m_pCurrStream->checkErrors( READING ) )
{
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) );
return false;
}
else if( m_pCurrStream->checkErrors( END_OF_SEQ ) )
{
iRet = false;
}
m_pCurrStream->getFrame( m_pCurrFrameQImage );
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
return iRet;
}
else if( m_currStream.checkErrors( END_OF_SEQ ) )
{
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
return false;
}
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
m_pcFrameSlider->setSliderPosition( m_currStream.getCurrFrameNum() );
return true;
return false;
}
Void SubWindowHandle::seekEvent( UInt new_frame_num )
{
m_pCurrStream->seekInput( new_frame_num );
m_pCurrStream->readFrame();
m_pCurrStream->getFrame( m_pCurrFrameQImage );
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
}
Void SubWindowHandle::stopEvent()
{
m_pCurrStream->seekInput( 0 );
m_pCurrStream->readFrame();
m_pCurrStream->getFrame( m_pCurrFrameQImage );
m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) );
return;
}
Void SubWindowHandle::normalSize()
{
m_dScaleFactor = 1.0;
@@ -188,7 +216,7 @@ Void SubWindowHandle::zoomToFit()
{
// Scale to a smaller size that the real to a nicer look
QSize niceFit( m_cScrollArea->viewport()->size().width() - 10, m_cScrollArea->viewport()->size().height() - 10 );
if( m_currStream.getWidth() <= niceFit.width() && m_currStream.getHeight() <= niceFit.height() )
if( m_pCurrStream->getWidth() <= niceFit.width() && m_pCurrStream->getHeight() <= niceFit.height() )
{
normalSize();
return;
@@ -211,7 +239,7 @@ Void SubWindowHandle::scaleView( Int width, Int height )
Void SubWindowHandle::scaleView( const QSize & size )
{
QSize imgViewSize( m_currStream.getWidth(), m_currStream.getHeight() );
QSize imgViewSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
QSize newSize = imgViewSize;
newSize.scale( size, Qt::KeepAspectRatio );
@@ -248,7 +276,7 @@ QSize SubWindowHandle::sizeHint() const
maxSize = p->size();
}
QSize isize = QSize( m_currStream.getWidth() + 500, m_currStream.getHeight() + 500 );
QSize isize = QSize( m_pCurrStream->getWidth() + 500, m_pCurrStream->getHeight() + 500 );
// If the SubWindowHandle needs more space that the avaiable, we'll give
// to the subwindow a reasonable size preserving the image aspect ratio.
+9 -7
View File
@@ -50,15 +50,16 @@ private:
QScrollArea* m_cScrollArea;
ViewArea* m_cViewArea;
QSlider* m_pcFrameSlider;
InputStream m_currStream;
InputStream* m_pCurrStream;
QImage* m_pCurrFrameQImage;
QString m_cWindowName;
QString m_cCurrFileName;
Double m_dScaleFactor;
Bool m_bIsPlaying;
public:
SubWindowHandle( QWidget * parent = 0 );
~SubWindowHandle();
@@ -66,11 +67,12 @@ public:
bool loadFile( const QString &fileName );
bool save();
bool playEvent();
Void stopEvent();
Void seekEvent( UInt new_frame_num );
InputStream* getInputStream()
{
return &m_currStream;
return m_pCurrStream;
}
/**
@@ -126,8 +128,8 @@ public:
protected:
Void closeEvent( QCloseEvent *event );
private slots:
void seekSliderEvent();
public Q_SLOTS:
bool playEvent();
};
} // NAMESPACE
+4 -2
View File
@@ -43,8 +43,6 @@ extern "C"
#include <libavformat/avformat.h>
}
#include "TypeDef.h"
namespace plaYUVer
@@ -53,6 +51,10 @@ namespace plaYUVer
class LibAvContextHandle
{
public:
LibAvContextHandle() :
m_bHasStream( false )
{
}
Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate );
Void closeAvFormat();
Bool decodeAvFormat();
+240 -201
View File
@@ -21,6 +21,10 @@
* \brief Main definition of the plaYUVerApp app
*/
#include "plaYUVerApp.h"
#include "SubWindowHandle.h"
#include "InputStream.h"
#if( QT_VERSION_PLAYUVER == 5 )
#include <QtWidgets>
#elif( QT_VERSION_PLAYUVER == 4 )
@@ -28,11 +32,6 @@
#endif
#include <QtDebug>
#include "TypeDef.h"
#include "plaYUVerApp.h"
#include "SubWindowHandle.h"
#include "InputStream.h"
namespace plaYUVer
{
@@ -46,9 +45,11 @@ plaYUVerApp::plaYUVerApp()
//mdiArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
//mdiArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateMenus() ) );
windowMapper = new QSignalMapper( this );
connect( windowMapper, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveImageInterface(QWidget*) ) );
connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( chageSubWindowSelection() ) );
//connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateMenus() ) );
mapperWindow = new QSignalMapper( this );
connect( mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) );
createActions();
createMenus();
@@ -62,13 +63,12 @@ plaYUVerApp::plaYUVerApp()
setWindowIcon( QIcon( ":/images/playuver.png" ) );
setUnifiedTitleAndToolBarOnMac( true );
playingTimer = new QTimer( this );
playingTimer = new QTimer;
playingTimer->setTimerType( Qt::CoarseTimer );
connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
setAcceptDrops( true );
mdiArea->setAcceptDrops( true );
connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
}
Void plaYUVerApp::closeEvent( QCloseEvent *event )
@@ -104,17 +104,17 @@ void plaYUVerApp::open()
{
m_cLastOpenPath = QFileInfo( fileName ).path();
QMdiSubWindow *existing = findImageInterface( fileName );
QMdiSubWindow *existing = findSubWindow( fileName );
if( existing )
{
mdiArea->setActiveSubWindow( existing );
return;
}
SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createImageInterface();
SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow();
if( interfaceChild->loadFile( fileName ) )
{
addImageInterface( interfaceChild );
addSubWindow( interfaceChild );
statusBar()->showMessage( tr( "File loaded" ), 2000 );
interfaceChild->show();
}
@@ -127,22 +127,21 @@ void plaYUVerApp::open()
void plaYUVerApp::save()
{
if( activeImageInterface() )
activeImageInterface()->save();
if( activeSubWindow() )
activeSubWindow()->save();
}
// ----------------------- Playing Functions --------------------
void plaYUVerApp::play()
{
UInt frameRate;
UInt timeInterval;
frameRate = activeImageInterface()->getInputStream()->getFrameRate();
timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
playingTimer->start( timeInterval );
playingTimer->stop();
if( activeSubWindow() )
{
UInt frameRate = activeSubWindow()->getInputStream()->getFrameRate();
UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
playingTimer->start( timeInterval );
}
}
void plaYUVerApp::pause()
@@ -152,55 +151,53 @@ void plaYUVerApp::pause()
void plaYUVerApp::stop()
{
activeSubWindow()->stopEvent();
m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() );
playingTimer->stop();
//disconnect( playingTimer, SIGNAL( timeout() ), 0, 0 );
}
void plaYUVerApp::playEvent()
{
if( activeImageInterface() )
if( activeSubWindow() )
{
if( !activeImageInterface()->playEvent() )
if( !activeSubWindow()->playEvent() )
{
playingTimer->stop();
stop();
}
m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() );
}
}
void plaYUVerApp::seekSliderEvent( int new_frame_num )
{
if( activeSubWindow() )
{
activeSubWindow()->seekEvent( new_frame_num );
}
}
// ----------------------- Zoom Functions -----------------------
void plaYUVerApp::zoomIn()
{
scaleImage( 1.25 );
}
void plaYUVerApp::zoomOut()
{
scaleImage( 0.8 );
}
void plaYUVerApp::normalSize()
{
if( activeImageInterface() )
activeImageInterface()->normalSize();
if( activeSubWindow() )
activeSubWindow()->normalSize();
}
void plaYUVerApp::zoomToFit()
{
if( activeImageInterface() )
activeImageInterface()->zoomToFit();
if( activeSubWindow() )
activeSubWindow()->zoomToFit();
}
Void plaYUVerApp::scaleImage( Double factor )
void plaYUVerApp::scaleFrame( int ratio )
{
if( activeImageInterface() )
if( activeSubWindow() )
{
activeImageInterface()->scaleView( factor );
activeSubWindow()->scaleView( ( Double )( ratio ) / 100.0 );
zoomInAct->setEnabled( activeImageInterface()->getScaleFactor() < 3.0 );
zoomOutAct->setEnabled( activeImageInterface()->getScaleFactor() > 0.333 );
actionZoomIn->setEnabled( activeSubWindow()->getScaleFactor() < 3.0 );
actionZoomOut->setEnabled( activeSubWindow()->getScaleFactor() > 0.333 );
}
}
@@ -211,49 +208,72 @@ void plaYUVerApp::about()
QMessageBox::about( this, tr( "About plaYUVerApp" ), tr( "The <b>plaYUVerApp</b> is an open-source raw video player " ) );
}
void plaYUVerApp::updateMenus()
void plaYUVerApp::chageSubWindowSelection()
{
Bool hasImageInterface = ( activeImageInterface() != 0 );
saveAct->setEnabled( hasImageInterface );
closeAct->setEnabled( hasImageInterface );
closeAllAct->setEnabled( hasImageInterface );
tileAct->setEnabled( hasImageInterface );
cascadeAct->setEnabled( hasImageInterface );
nextAct->setEnabled( hasImageInterface );
previousAct->setEnabled( hasImageInterface );
separatorAct->setVisible( hasImageInterface );
playingTimer->stop();
if( activeSubWindow() )
{
m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 );
m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() );
}
updateMenus();
//updateWindowMenu();
}
zoomInAct->setEnabled( hasImageInterface );
zoomOutAct->setEnabled( hasImageInterface );
normalSizeAct->setEnabled( hasImageInterface );
zoomToFitAct->setEnabled( hasImageInterface );
Void plaYUVerApp::updateMenus()
{
Bool hasSubWindow = ( activeSubWindow() != 0 );
actionSave->setEnabled( hasSubWindow );
actionClose->setEnabled( hasSubWindow );
actionCloseAll->setEnabled( hasSubWindow );
actionTile->setEnabled( hasSubWindow );
actionCascade->setEnabled( hasSubWindow );
actionSeparator->setVisible( hasSubWindow );
actionVideoPlay->setEnabled( hasImageInterface );
actionVideoPause->setEnabled( hasImageInterface );
actionVideoStop->setEnabled( hasImageInterface );
actionVideoBackward->setEnabled( hasImageInterface );
actionVideoForward->setEnabled( hasImageInterface );
actionZoomIn->setEnabled( hasSubWindow );
actionZoomOut->setEnabled( hasSubWindow );
actionNormalSize->setEnabled( hasSubWindow );
actionZoomToFit->setEnabled( hasSubWindow );
actionVideoPlay->setEnabled( hasSubWindow );
actionVideoPause->setEnabled( hasSubWindow );
actionVideoStop->setEnabled( hasSubWindow );
actionVideoBackward->setEnabled( hasSubWindow );
actionVideoForward->setEnabled( hasSubWindow );
m_pcFrameSlider->setEnabled( hasSubWindow );
}
void plaYUVerApp::updateWindowMenu()
{
windowMenu->clear();
windowMenu->addAction( closeAct );
windowMenu->addAction( closeAllAct );
windowMenu->addSeparator();
windowMenu->addAction( tileAct );
windowMenu->addAction( cascadeAct );
windowMenu->addSeparator();
windowMenu->addAction( nextAct );
windowMenu->addAction( previousAct );
windowMenu->addAction( separatorAct );
menuWindow->clear();
menuWindow->addAction( actionClose );
menuWindow->addAction( actionCloseAll );
menuWindow->addSeparator();
menuWindow->addAction( actionTile );
menuWindow->addAction( actionCascade );
menuWindow->addSeparator();
menuWindow->addAction( actionNext );
menuWindow->addAction( actionPrevious );
menuWindow->addAction( actionSeparator );
updateMenus();
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
separatorAct->setVisible( !windows.isEmpty() );
actionSeparator->setVisible( !windows.isEmpty() );
Int number_windows = windows.size();
for( Int i = 0; i < windows.size(); ++i )
if( number_windows > 1 )
{
actionNext->setEnabled( true );
actionPrevious->setEnabled( true );
}
else
{
actionNext->setEnabled( false );
actionPrevious->setEnabled( false );
}
for( Int i = 0; i < number_windows; ++i )
{
SubWindowHandle *child = qobject_cast<SubWindowHandle *>( windows.at( i ) );
@@ -266,15 +286,15 @@ void plaYUVerApp::updateWindowMenu()
{
text = tr( "%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() );
}
QAction *action = windowMenu->addAction( text );
QAction *action = menuWindow->addAction( text );
action->setCheckable( true );
action->setChecked( child == activeImageInterface() );
connect( action, SIGNAL( triggered() ), windowMapper, SLOT( map() ) );
windowMapper->setMapping( action, windows.at( i ) );
action->setChecked( child == activeSubWindow() );
connect( action, SIGNAL( triggered() ), mapperWindow, SLOT( map() ) );
mapperWindow->setMapping( action, windows.at( i ) );
}
}
SubWindowHandle *plaYUVerApp::createImageInterface()
SubWindowHandle *plaYUVerApp::createSubWindow()
{
SubWindowHandle *child = new SubWindowHandle;
mdiArea->addSubWindow( child );
@@ -282,7 +302,7 @@ SubWindowHandle *plaYUVerApp::createImageInterface()
return child;
}
void plaYUVerApp::addImageInterface( SubWindowHandle *child )
void plaYUVerApp::addSubWindow( SubWindowHandle *child )
{
//connect( child, SIGNAL( areaSelected( QRect ) ), this, SLOT( setSelection( QRect ) ) );
@@ -295,73 +315,84 @@ Void plaYUVerApp::createActions()
{
// ------------ File ------------
openAct = new QAction( QIcon( ":/images/open.png" ), tr( "&Open..." ), this );
openAct->setShortcuts( QKeySequence::Open );
openAct->setStatusTip( tr( "Open an existing file" ) );
connect( openAct, SIGNAL( triggered() ), this, SLOT( open() ) );
actionOpen = new QAction( QIcon( ":/images/open.png" ), tr( "&Open..." ), this );
actionOpen->setShortcuts( QKeySequence::Open );
actionOpen->setStatusTip( tr( "Open an existing file" ) );
connect( actionOpen, SIGNAL( triggered() ), this, SLOT( open() ) );
saveAct = new QAction( QIcon( ":/images/save.png" ), tr( "&Save..." ), this );
saveAct->setShortcuts( QKeySequence::SaveAs );
saveAct->setStatusTip( tr( "Save the document under a new name" ) );
connect( saveAct, SIGNAL( triggered() ), this, SLOT( save() ) );
actionSave = new QAction( QIcon( ":/images/save.png" ), tr( "&Save..." ), this );
actionSave->setShortcuts( QKeySequence::SaveAs );
actionSave->setStatusTip( tr( "Save the document under a new name" ) );
connect( actionSave, SIGNAL( triggered() ), this, SLOT( save() ) );
exitAct = new QAction( tr( "E&xit" ), this );
exitAct->setShortcuts( QKeySequence::Quit );
exitAct->setStatusTip( tr( "Exit the application" ) );
connect( exitAct, SIGNAL( triggered() ), qApp, SLOT( closeAllWindows() ) );
actionExit = new QAction( tr( "E&xit" ), this );
actionExit->setShortcuts( QKeySequence::Quit );
actionExit->setStatusTip( tr( "Exit the application" ) );
connect( actionExit, SIGNAL( triggered() ), qApp, SLOT( closeAllWindows() ) );
closeAct = new QAction( tr( "Cl&ose" ), this );
closeAct->setIcon( QIcon( ":/images/close.png" ) );
closeAct->setStatusTip( tr( "Close the active window" ) );
connect( closeAct, SIGNAL( triggered() ), mdiArea, SLOT( closeActiveSubWindow() ) );
actionClose = new QAction( tr( "Cl&ose" ), this );
actionClose->setIcon( QIcon( ":/images/close.png" ) );
actionClose->setStatusTip( tr( "Close the active window" ) );
connect( actionClose, SIGNAL( triggered() ), mdiArea, SLOT( closeActiveSubWindow() ) );
closeAllAct = new QAction( tr( "Close &All" ), this );
closeAllAct->setStatusTip( tr( "Close all the windows" ) );
connect( closeAllAct, SIGNAL( triggered() ), mdiArea, SLOT( closeAllSubWindows() ) );
actionCloseAll = new QAction( tr( "Close &All" ), this );
actionCloseAll->setStatusTip( tr( "Close all the windows" ) );
connect( actionCloseAll, SIGNAL( triggered() ), mdiArea, SLOT( closeAllSubWindows() ) );
// ------------ View ------------
zoomInAct = new QAction( tr( "Zoom &In (25%)" ), this );
zoomInAct->setIcon( QIcon( ":/images/zoomin.png" ) );
zoomInAct->setShortcut( tr( "Ctrl++" ) );
zoomInAct->setStatusTip( tr( "Scale the image up by 25%" ) );
connect( zoomInAct, SIGNAL( triggered() ), this, SLOT( zoomIn() ) );
mapperZoom = new QSignalMapper( this );
connect( mapperZoom, SIGNAL( mapped(int) ), this, SLOT( scaleFrame(int) ) );
zoomOutAct = new QAction( tr( "Zoom &Out (25%)" ), this );
zoomOutAct->setIcon( QIcon( ":/images/zoomout.png" ) );
zoomOutAct->setShortcut( tr( "Ctrl+-" ) );
zoomOutAct->setStatusTip( tr( "Scale the image down by 25%" ) );
connect( zoomOutAct, SIGNAL( triggered() ), this, SLOT( zoomOut() ) );
actionZoomIn = new QAction( tr( "Zoom &In (25%)" ), this );
actionZoomIn->setIcon( QIcon( ":/images/zoomin.png" ) );
actionZoomIn->setShortcut( tr( "Ctrl++" ) );
actionZoomIn->setStatusTip( tr( "Scale the image up by 25%" ) );
connect( actionZoomIn, SIGNAL( triggered() ), mapperZoom, SLOT( map() ) );
mapperZoom->setMapping( actionZoomIn, 125 );
normalSizeAct = new QAction( tr( "&Normal Size" ), this );
normalSizeAct->setIcon( QIcon( ":/images/zoomtonormal.png" ) );
normalSizeAct->setShortcut( tr( "Ctrl+N" ) );
normalSizeAct->setStatusTip( tr( "Show the image at its original size" ) );
connect( normalSizeAct, SIGNAL( triggered() ), this, SLOT( normalSize() ) );
actionZoomOut = new QAction( tr( "Zoom &Out (25%)" ), this );
actionZoomOut->setIcon( QIcon( ":/images/zoomout.png" ) );
actionZoomOut->setShortcut( tr( "Ctrl+-" ) );
actionZoomOut->setStatusTip( tr( "Scale the image down by 25%" ) );
connect( actionZoomOut, SIGNAL( triggered() ), mapperZoom, SLOT( map() ) );
mapperZoom->setMapping( actionZoomOut, 80 );
zoomToFitAct = new QAction( tr( "Zoom to &Fit" ), this );
zoomToFitAct->setIcon( QIcon( ":/images/fittowindow.png" ) );
zoomToFitAct->setStatusTip( tr( "Zoom in or out to fit on the window." ) );
zoomToFitAct->setShortcut( tr( "Ctrl+F" ) );
connect( zoomToFitAct, SIGNAL( triggered() ), this, SLOT( zoomToFit() ) );
actionNormalSize = new QAction( tr( "&Normal Size" ), this );
actionNormalSize->setIcon( QIcon( ":/images/zoomtonormal.png" ) );
actionNormalSize->setShortcut( tr( "Ctrl+N" ) );
actionNormalSize->setStatusTip( tr( "Show the image at its original size" ) );
connect( actionNormalSize, SIGNAL( triggered() ), this, SLOT( normalSize() ) );
actionZoomToFit = new QAction( tr( "Zoom to &Fit" ), this );
actionZoomToFit->setIcon( QIcon( ":/images/fittowindow.png" ) );
actionZoomToFit->setStatusTip( tr( "Zoom in or out to fit on the window." ) );
actionZoomToFit->setShortcut( tr( "Ctrl+F" ) );
connect( actionZoomToFit, SIGNAL( triggered() ), this, SLOT( zoomToFit() ) );
// ------------ Playing ------------
actionVideoPlay = new QAction( "VideoPlay", this );
actionVideoPlay->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) );
connect( actionVideoPlay, SIGNAL( triggered() ), this, SLOT( play() ) );
actionVideoPause = new QAction( "VideoPause", this );
actionVideoPause->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) );
connect( actionVideoPause, SIGNAL( triggered() ), this, SLOT( pause() ) );
actionVideoStop = new QAction( "VideoStop", this );
actionVideoStop->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) );
connect( actionVideoStop, SIGNAL( triggered() ), this, SLOT( stop() ) );
actionVideoBackward = new QAction( "VideoBackward", this );
actionVideoBackward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
actionVideoForward = new QAction( "VideoForward", this );
actionVideoForward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
actionVideoLoop = new QAction( "VideoLoop", this );
actionVideoLock = new QAction( "VideoLock", this );
actionVideoInterlace = new QAction( "VideoInterlace", this );
actionVideoCenter = new QAction( "VideoCenter", this );
actionVideoPlay->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) );
actionVideoPause->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) );
actionVideoStop->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) );
actionVideoBackward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
actionVideoForward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
/*
actionVideoLoop ->setIcon( QIcon( ":/images/videoloop.png" ) );
actionVideoLock ->setIcon( QIcon( ":/images/lock.png" ) );
@@ -369,95 +400,103 @@ Void plaYUVerApp::createActions()
actionVideoCenter ->setIcon( QIcon( ":/images/center.png" ) );
*/
connect( actionVideoPlay, SIGNAL( triggered() ), this, SLOT( play() ) );
connect( actionVideoPause, SIGNAL( triggered() ), this, SLOT( pause() ) );
connect( actionVideoStop, SIGNAL( triggered() ), this, SLOT( stop() ) );
m_pcFrameSlider = new QSlider;
m_pcFrameSlider->setOrientation( Qt::Horizontal );
m_pcFrameSlider->setMaximumWidth( 100 );
m_pcFrameSlider->setMaximumWidth( 300 );
m_pcFrameSlider->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
m_pcFrameSlider->setEnabled( false );
connect( m_pcFrameSlider, SIGNAL( valueChanged(int) ), this, SLOT( seekSliderEvent(int) ) );
// ------------ Window ------------
tileAct = new QAction( tr( "&Tile" ), this );
tileAct->setStatusTip( tr( "Tile the windows" ) );
connect( tileAct, SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
actionTile = new QAction( tr( "&Tile" ), this );
actionTile->setStatusTip( tr( "Tile the windows" ) );
connect( actionTile, SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) );
cascadeAct = new QAction( tr( "&Cascade" ), this );
cascadeAct->setStatusTip( tr( "Cascade the windows" ) );
connect( cascadeAct, SIGNAL( triggered() ), mdiArea, SLOT( cascadeSubWindows() ) );
actionCascade = new QAction( tr( "&Cascade" ), this );
actionCascade->setStatusTip( tr( "Cascade the windows" ) );
connect( actionCascade, SIGNAL( triggered() ), mdiArea, SLOT( cascadeSubWindows() ) );
nextAct = new QAction( tr( "Ne&xt" ), this );
nextAct->setShortcuts( QKeySequence::NextChild );
nextAct->setStatusTip( tr( "Move the focus to the next window" ) );
connect( nextAct, SIGNAL( triggered() ), mdiArea, SLOT( activateNextSubWindow() ) );
actionNext = new QAction( tr( "Ne&xt" ), this );
actionNext->setShortcuts( QKeySequence::NextChild );
actionNext->setStatusTip( tr( "Move the focus to the next window" ) );
connect( actionNext, SIGNAL( triggered() ), mdiArea, SLOT( activateNextSubWindow() ) );
previousAct = new QAction( tr( "Pre&vious" ), this );
previousAct->setShortcuts( QKeySequence::PreviousChild );
previousAct->setStatusTip( tr( "Move the focus to the previous window" ) );
connect( previousAct, SIGNAL( triggered() ), mdiArea, SLOT( activatePreviousSubWindow() ) );
actionPrevious = new QAction( tr( "Pre&vious" ), this );
actionPrevious->setShortcuts( QKeySequence::PreviousChild );
actionPrevious->setStatusTip( tr( "Move the focus to the previous window" ) );
connect( actionPrevious, SIGNAL( triggered() ), mdiArea, SLOT( activatePreviousSubWindow() ) );
separatorAct = new QAction( this );
separatorAct->setSeparator( true );
actionSeparator = new QAction( this );
actionSeparator->setSeparator( true );
// ------------ About ------------
aboutAct = new QAction( tr( "&About" ), this );
aboutAct->setStatusTip( tr( "Show the application's About box" ) );
connect( aboutAct, SIGNAL( triggered() ), this, SLOT( about() ) );
actionAbout = new QAction( tr( "&About" ), this );
actionAbout->setStatusTip( tr( "Show the application's About box" ) );
connect( actionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
aboutQtAct = new QAction( tr( "About &Qt" ), this );
aboutQtAct->setIcon( QIcon( ":images/qt.png" ) );
aboutQtAct->setStatusTip( tr( "Show the Qt library's About box" ) );
connect( aboutQtAct, SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) );
actionAboutQt = new QAction( tr( "About &Qt" ), this );
actionAboutQt->setIcon( QIcon( ":images/qt.png" ) );
actionAboutQt->setStatusTip( tr( "Show the Qt library's About box" ) );
connect( actionAboutQt, SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) );
}
Void plaYUVerApp::createMenus()
{
fileMenu = menuBar()->addMenu( tr( "&File" ) );
fileMenu->addAction( openAct );
fileMenu->addSeparator();
fileMenu->addAction( saveAct );
fileMenu->addSeparator();
fileMenu->addAction( closeAct );
fileMenu->addAction( exitAct );
menuFile = menuBar()->addMenu( tr( "&File" ) );
menuFile->addAction( actionOpen );
menuFile->addSeparator();
menuFile->addAction( actionSave );
menuFile->addSeparator();
menuFile->addAction( actionClose );
menuFile->addAction( actionExit );
viewMenu = new QMenu( tr( "&View" ), this );
viewMenu->addAction( zoomInAct );
viewMenu->addAction( zoomOutAct );
viewMenu->addAction( normalSizeAct );
viewMenu->addAction( zoomToFitAct );
menuView = new QMenu( tr( "&View" ), this );
menuView->addAction( actionZoomIn );
menuView->addAction( actionZoomOut );
menuView->addAction( actionNormalSize );
menuView->addAction( actionZoomToFit );
windowMenu = menuBar()->addMenu( tr( "&Window" ) );
menuWindow = menuBar()->addMenu( tr( "&Window" ) );
updateWindowMenu();
connect( windowMenu, SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) );
connect( menuWindow, SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) );
menuBar()->addSeparator();
helpMenu = menuBar()->addMenu( tr( "&Help" ) );
helpMenu->addAction( aboutAct );
helpMenu->addAction( aboutQtAct );
menuHelp = menuBar()->addMenu( tr( "&Help" ) );
menuHelp->addAction( actionAbout );
menuHelp->addAction( actionAboutQt );
}
Void plaYUVerApp::createToolBars()
{
fileToolBar = addToolBar( tr( "File" ) );
fileToolBar->addAction( openAct );
fileToolBar->addAction( saveAct );
fileToolBar->addAction( closeAct );
toolbarFile = addToolBar( tr( "File" ) );
toolbarFile->addAction( actionOpen );
toolbarFile->addAction( actionSave );
toolbarFile->addAction( actionClose );
viewToolBar = addToolBar( tr( "Zoom" ) );
viewToolBar->addAction( zoomInAct );
viewToolBar->addAction( zoomOutAct );
viewToolBar->addAction( normalSizeAct );
viewToolBar->addAction( zoomToFitAct );
toolbarView = addToolBar( tr( "Zoom" ) );
toolbarView->addAction( actionZoomIn );
toolbarView->addAction( actionZoomOut );
toolbarView->addAction( actionNormalSize );
toolbarView->addAction( actionZoomToFit );
toolbarVideo = addToolBar( tr( "Video" ) );
toolbarVideo->addAction( actionVideoPlay );
toolbarVideo->addAction( actionVideoPause );
toolbarVideo->addAction( actionVideoStop );
/*
toolbarVideo->addAction( actionVideoBackward );
toolbarVideo->addAction( actionVideoForward );
toolbarVideo->addAction( actionVideoLoop );
toolbarVideo->addAction( actionVideoLock );
toolbarVideo->addAction( actionVideoInterlace );
toolbarVideo->addAction( actionVideoCenter );
*/
toolbarVideo->addWidget( m_pcFrameSlider );
videoToolBar = addToolBar( tr( "Video" ) );
videoToolBar->addAction( actionVideoPlay );
videoToolBar->addAction( actionVideoPause );
videoToolBar->addAction( actionVideoStop );
videoToolBar->addAction( actionVideoBackward );
videoToolBar->addAction( actionVideoForward );
videoToolBar->addAction( actionVideoLoop );
videoToolBar->addAction( actionVideoLock );
videoToolBar->addAction( actionVideoInterlace );
videoToolBar->addAction( actionVideoCenter );
}
Void plaYUVerApp::createStatusBar()
@@ -489,13 +528,13 @@ void plaYUVerApp::dropEvent( QDropEvent *event )
m_cLastOpenPath = QFileInfo( fileName ).path();
QMdiSubWindow *existing = findImageInterface( fileName );
QMdiSubWindow *existing = findSubWindow( fileName );
if( !existing )
{
SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createImageInterface();
SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow();
if( interfaceChild->loadFile( fileName ) )
{
addImageInterface( interfaceChild );
addSubWindow( interfaceChild );
statusBar()->showMessage( tr( "File loaded" ), 2000 );
interfaceChild->show();
}
@@ -523,14 +562,14 @@ Void plaYUVerApp::writeSettings()
settings.setValue( "size", size() );
}
SubWindowHandle *plaYUVerApp::activeImageInterface()
SubWindowHandle *plaYUVerApp::activeSubWindow()
{
if( QMdiSubWindow *activeImageInterface = mdiArea->activeSubWindow() )
return qobject_cast<SubWindowHandle *>( activeImageInterface );
if( QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow() )
return qobject_cast<SubWindowHandle *>( activeSubWindow );
return 0;
}
QMdiSubWindow *plaYUVerApp::findImageInterface( const QString &fileName )
QMdiSubWindow *plaYUVerApp::findSubWindow( const QString &fileName )
{
QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath();
@@ -542,7 +581,7 @@ QMdiSubWindow *plaYUVerApp::findImageInterface( const QString &fileName )
return 0;
}
void plaYUVerApp::setActiveImageInterface( QWidget *window )
void plaYUVerApp::setActiveSubWindow( QWidget *window )
{
if( !window )
return;
+54 -49
View File
@@ -26,15 +26,14 @@
#include "config.h"
#if( QT_VERSION_PLAYUVER == 5 )
#include <QtWidgets>
#elif( QT_VERSION_PLAYUVER == 4 )
#include <QtGui>
#endif
#include <QMainWindow>
#include "TypeDef.h"
class QAction;
class QMenu;
class QMdiArea;
class QMdiSubWindow;
class QSignalMapper;
namespace plaYUVer
{
@@ -50,7 +49,7 @@ public:
protected:
Void closeEvent( QCloseEvent *event );
private slots:
private Q_SLOTS:
//! File functions
void open();
@@ -61,17 +60,21 @@ private slots:
void pause();
void stop();
void playEvent();
void seekSliderEvent(int new_frame_num );
/**
* Scale the image by a given factor
* @param factor factor of scale. Ex: 120 scale the image up by 20% and
* 80 scale the image down by 25%
*/
void scaleFrame( int ratio = 100 );
//! View functions
void zoomIn();
void zoomOut();
void normalSize();
void zoomToFit();
//! Show a message box with some information about the plaYUVerApp App
void about();
void updateMenus();
void chageSubWindowSelection();
void updateWindowMenu();
/*
@@ -80,57 +83,59 @@ private slots:
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
SubWindowHandle *createImageInterface();
void addImageInterface( SubWindowHandle *child );
void setActiveImageInterface( QWidget *window );
void setActiveSubWindow( QWidget *window );
private:
QMdiArea *mdiArea;
QString m_cLastOpenPath;
QTimer *playingTimer;
Void updateMenus();
Void createActions();
Void createMenus();
Void createToolBars();
Void createStatusBar();
Void readSettings();
Void writeSettings();
SubWindowHandle *activeImageInterface();
QMdiSubWindow *findImageInterface( const QString &fileName );
/**
* Scale the image by a given factor
* @param factor factor of scale. Ex: 1.2 scale the image up by 20% and
* 0.8 scale the image down by 25%
*/
Void scaleImage( Double factor );
Void addSubWindow( SubWindowHandle *child );
SubWindowHandle *createSubWindow();
SubWindowHandle *activeSubWindow();
QMdiSubWindow *findSubWindow( const QString &fileName );
QString m_cLastOpenPath;
QSlider *m_pcFrameSlider;
QTimer *playingTimer;
QMdiArea *mdiArea;
QSignalMapper *windowMapper;
QSignalMapper *mapperZoom;
QSignalMapper *mapperWindow;
QMenu *fileMenu;
QMenu *viewMenu;
QMenu *windowMenu;
QMenu *helpMenu;
QToolBar *fileToolBar;
QToolBar *viewToolBar;
QToolBar *videoToolBar;
QMenu *menuFile;
QMenu *menuView;
QMenu *menuWindow;
QMenu *menuHelp;
QAction *openAct;
QAction *saveAct;
QAction *exitAct;
QAction *closeAct;
QAction *closeAllAct;
QToolBar *toolbarFile;
QToolBar *toolbarView;
QToolBar *toolbarVideo;
QAction *zoomInAct;
QAction *zoomOutAct;
QAction *normalSizeAct;
QAction *zoomToFitAct;
QAction *actionOpen;
QAction *actionSave;
QAction *actionExit;
QAction *actionClose;
QAction *actionCloseAll;
QAction *tileAct;
QAction *cascadeAct;
QAction *nextAct;
QAction *previousAct;
QAction *separatorAct;
QAction *actionZoomIn;
QAction *actionZoomOut;
QAction *actionNormalSize;
QAction *actionZoomToFit;
QAction *actionTile;
QAction *actionCascade;
QAction *actionNext;
QAction *actionPrevious;
QAction *actionSeparator;
// Video actions.
QAction *actionVideoPlay;
@@ -143,8 +148,8 @@ private:
QAction *actionVideoInterlace;
QAction *actionVideoCenter;
QAction *aboutAct;
QAction *aboutQtAct;
QAction *actionAbout;
QAction *actionAboutQt;
};