diff --git a/app/PlaYUVerMdiSubWindow.cpp b/app/PlaYUVerMdiSubWindow.cpp index faeaa7b..2a2e7a0 100644 --- a/app/PlaYUVerMdiSubWindow.cpp +++ b/app/PlaYUVerMdiSubWindow.cpp @@ -32,6 +32,13 @@ PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget *parent ) : { } +QSize PlaYUVerMdiSubWindow::sizeHint() const +{ + QSize sizeHint = widget()->sizeHint(); + return sizeHint; +} + + Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent *event ) { emit aboutToClose( this ); diff --git a/app/PlaYUVerMdiSubWindow.h b/app/PlaYUVerMdiSubWindow.h index c88a5fe..dc0f3c9 100644 --- a/app/PlaYUVerMdiSubWindow.h +++ b/app/PlaYUVerMdiSubWindow.h @@ -47,6 +47,7 @@ Q_SIGNALS: void aboutToClose( PlaYUVerMdiSubWindow* ); protected: + QSize sizeHint() const; void closeEvent( QCloseEvent *event ); }; diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 8a682e0..82b679d 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -57,25 +57,62 @@ private: PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : QWidget( parent ) { - m_bMdiModeEnabled = true; + m_uiWindowMode = 0; - m_pcMdiArea = new PlaYUVerMdiArea( this ); - m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder ); - - QHBoxLayout* m_pcWindowManagerLayout = new QHBoxLayout( this ); - m_pcWindowManagerLayout->addWidget( m_pcMdiArea ); - setLayout( m_pcWindowManagerLayout ); - - connect( m_pcMdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateActiveSubWindow() ) ); + setWindowMode( MdiWSubWindows ); m_pcActiveWindow = NULL; m_apcSubWindowList.clear(); m_apcMdiSubWindowList.clear(); } -Void PlaYUVerSubWindowHandle::updateActiveSubWindow() +Void PlaYUVerSubWindowHandle::resetWindowMode() { - if( m_bMdiModeEnabled ) + if( m_uiWindowMode == MdiWSubWindows ) + { + removeAllSubWindow(); + m_apcMdiSubWindowList.clear(); + if( m_pcMdiArea ) + delete m_pcMdiArea; + if( m_pcWindowManagerLayout ) + delete m_pcWindowManagerLayout; + } +} + +Void PlaYUVerSubWindowHandle::setWindowMode( UInt uiWindowMode ) +{ + if( m_uiWindowMode == uiWindowMode ) + return; + + resetWindowMode(); + + if( uiWindowMode == NormalSubWindows ) + { + + } + + if( uiWindowMode == MdiWSubWindows ) + { + m_pcMdiArea = new PlaYUVerMdiArea( this ); + m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder ); + connect( m_pcMdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateActiveSubWindow() ) ); + m_pcWindowManagerLayout = new QHBoxLayout( this ); + m_pcWindowManagerLayout->addWidget( m_pcMdiArea ); + setLayout( m_pcWindowManagerLayout ); + } + + m_uiWindowMode = uiWindowMode; +} + +Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) +{ + if( m_uiWindowMode == NormalSubWindows ) + { + if( window ) + m_pcActiveWindow = window; + } + + if( m_uiWindowMode == MdiWSubWindows ) { m_pcActiveWindow = NULL; QMdiSubWindow* mdiSubWindow = m_pcMdiArea->activeSubWindow(); @@ -94,7 +131,12 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow() Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowHandle *window, Qt::WindowFlags flags ) { - if( m_bMdiModeEnabled ) + if( m_uiWindowMode == NormalSubWindows ) + { + connect( window, SIGNAL( aboutToActivate( SubWindowHandle* ) ), this, SLOT( aboutToActivate( SubWindowHandle* ) ) ); + connect( window, SIGNAL( aboutToClose( SubWindowHandle* ) ), this, SLOT( removeMdiSubWindow( SubWindowHandle* ) ) ); + } + if( m_uiWindowMode == MdiWSubWindows ) { PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow( this ); mdiSubWindow->setWidget( window ); @@ -109,16 +151,24 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) { if( windowIdx >= 0 ) { - if( m_bMdiModeEnabled ) + if( m_uiWindowMode == NormalSubWindows ) + { + SubWindowHandle* subWindow = m_apcSubWindowList.at( windowIdx ); + m_apcSubWindowList.removeAt( windowIdx ); + subWindow->close(); + } + if( m_uiWindowMode == MdiWSubWindows ) { PlaYUVerMdiSubWindow* mdiSubWindow = m_apcMdiSubWindowList.at( windowIdx ); m_apcMdiSubWindowList.removeAt( windowIdx ); m_pcMdiArea->removeSubWindow( m_apcSubWindowList.at( windowIdx ) ); mdiSubWindow->close(); + m_apcSubWindowList.removeAt( windowIdx ); } - m_apcSubWindowList.removeAt( windowIdx ); + + if( !m_apcSubWindowList.isEmpty() ) + m_apcSubWindowList.front()->setFocus(); } - m_apcSubWindowList.front()->activateWindow(); } Void PlaYUVerSubWindowHandle::removeSubWindow( SubWindowHandle* window ) @@ -179,7 +229,7 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCat return apcSubWindowList; } -SubWindowHandle* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowHandle* subWindow ) +SubWindowHandle* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowHandle* subWindow ) const { QList subWindowList = findSubWindow(); for( Int i = 0; i < subWindowList.size(); i++ ) @@ -201,7 +251,7 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window ) Void PlaYUVerSubWindowHandle::tileSubWindows() { - if( m_bMdiModeEnabled ) + if( m_uiWindowMode == MdiWSubWindows ) { m_pcMdiArea->tileSubWindows(); } @@ -209,7 +259,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() Void PlaYUVerSubWindowHandle::cascadeSubWindows() { - if( m_bMdiModeEnabled ) + if( m_uiWindowMode == MdiWSubWindows ) { m_pcMdiArea->cascadeSubWindows(); } @@ -225,7 +275,7 @@ Void PlaYUVerSubWindowHandle::createActions() m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this ); m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) ); m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) ); - connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( closeActiveWindow() ) ); + connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( removeActiveSubWindow() ) ); m_arrayActions[CLOSE_ALL_ACT] = new QAction( tr( "Close &All" ), this ); m_arrayActions[CLOSE_ALL_ACT]->setStatusTip( tr( "Close all the windows" ) ); diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index 59e2f83..7a827fa 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -48,13 +48,12 @@ public: PlaYUVerSubWindowHandle( QWidget *parent = 0 ); Void addSubWindow( SubWindowHandle *widget, Qt::WindowFlags flags = 0 ); - Void removeSubWindow( SubWindowHandle *window ); SubWindowHandle *activeSubWindow() const; QList findSubWindow( const QString &aName = QString() ) const; QList findSubWindow( const UInt uiCategory ) const; - SubWindowHandle* findSubWindow( const SubWindowHandle* subWindow ); + SubWindowHandle* findSubWindow( const SubWindowHandle* subWindow ) const; Void createActions(); QMenu* createMenu(); @@ -62,8 +61,14 @@ public: Void readSettings(); Void writeSettings(); + enum WindowMode + { + NormalSubWindows = 0, + MdiWSubWindows = 1, + }; + private: - Bool m_bMdiModeEnabled; + UInt m_uiWindowMode; QList m_apcSubWindowList; QHBoxLayout* m_pcWindowManagerLayout; @@ -90,11 +95,14 @@ private: /** * Internal functions */ + Void resetWindowMode(); + Void setWindowMode( UInt uiWindowMode ); Void removeSubWindow( Int windowIdx ); public Q_SLOTS: - void updateActiveSubWindow(); + void updateActiveSubWindow( SubWindowHandle *window = 0 ); void setActiveSubWindow( QWidget *window ); + void removeSubWindow( SubWindowHandle *window ); void removeMdiSubWindow( PlaYUVerMdiSubWindow* window ); void removeActiveSubWindow(); void removeAllSubWindow(); diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index 98543ee..aeaf7f7 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -31,6 +31,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : QScrollArea( parent ) { setParent( parent ); + setFocusPolicy( Qt::StrongFocus ); setAttribute( Qt::WA_DeleteOnClose ); setBackgroundRole( QPalette::Light ); @@ -43,9 +44,8 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : setWidgetResizable( true ); - m_cLastScroll = QPoint(); - m_uiCategory = category; + m_cLastScroll = QPoint(); m_cWindowName = QString( " " ); } @@ -132,8 +132,14 @@ Bool SubWindowHandle::mayClose() return true; } +Void SubWindowHandle::focusInEvent( QFocusEvent * event ) +{ + emit aboutToActivate( this ); +} + Void SubWindowHandle::closeEvent( QCloseEvent *event ) { + emit aboutToClose( this ); event->accept(); } diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 694e30d..e9fc5af 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -91,6 +91,7 @@ public: } protected: + virtual void focusInEvent( QFocusEvent * event ); virtual void closeEvent( QCloseEvent *event ); QSize getScrollSize(); @@ -108,6 +109,9 @@ Q_SIGNALS: */ void updateStatusBar( const QString& ); + void aboutToActivate( SubWindowHandle* ); + void aboutToClose( SubWindowHandle* ); + public Q_SLOTS: void adjustScrollBarByScale( double scale, QPoint center ); void adjustScrollBarByOffset( QPoint Offset ); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 87d648f..1441d65 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -38,9 +38,9 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array { d = array.at( i ); out << d.m_cFilename << d.m_uiWidth - << d.m_uiHeight - << d.m_iPelFormat - << d.m_uiFrameRate; + << d.m_uiHeight + << d.m_iPelFormat + << d.m_uiFrameRate; } return out; @@ -72,12 +72,12 @@ Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename ) } VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) : - SubWindowHandle( parent, SubWindowHandle::VIDEO_SUBWINDOW ), - m_pCurrStream( NULL ), - m_pcCurrFrame( NULL ), - m_pcReferenceSubWindow( NULL ), - m_bIsPlaying( false ), - m_bIsModule( isModule ) + SubWindowHandle( parent, SubWindowHandle::VIDEO_SUBWINDOW ), + m_pCurrStream( NULL ), + m_pcCurrFrame( NULL ), + m_pcReferenceSubWindow( NULL ), + m_bIsPlaying( false ), + m_bIsModule( isModule ) { setVisible( false ); @@ -343,11 +343,11 @@ Void VideoSubWindow::stop() Void VideoSubWindow::normalSize() { Double factor = 1.0; - Double curFactor = getScaleFactor() ; + Double curFactor = getScaleFactor(); if( factor != curFactor ) { Double usedScale; - usedScale = m_cViewArea->scaleZoomFactor( factor/curFactor, QPoint() ); + usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, QPoint() ); adjustScrollBarByScale( usedScale, QPoint() ); } } @@ -358,22 +358,22 @@ Void VideoSubWindow::zoomToFit() scaleView( getScrollSize() ); } -Void VideoSubWindow::zoomToFactor( Double factor , QPoint center ) +Void VideoSubWindow::zoomToFactor( Double factor, QPoint center ) { Double curFactor; - curFactor = getScaleFactor() ; + curFactor = getScaleFactor(); if( factor != curFactor ) { Double usedScale; - usedScale = m_cViewArea->scaleZoomFactor( factor/curFactor, center ); + usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center ); adjustScrollBarByScale( usedScale, center ); } } -Void VideoSubWindow::scaleView( Double scale , QPoint center ) +Void VideoSubWindow::scaleView( Double scale, QPoint center ) { Q_ASSERT( m_cViewArea->image() ); - if(scale!=1.0) + if( scale != 1.0 ) { Double usedScale; usedScale = m_cViewArea->scaleZoomFactor( scale, center ); @@ -404,11 +404,11 @@ Void VideoSubWindow::scaleView( const QSize & size, QPoint center ) else factor = hfactor; - Double curFactor = getScaleFactor() ; + Double curFactor = getScaleFactor(); if( factor != curFactor ) { Double usedScale; - usedScale = m_cViewArea->scaleZoomFactor( factor/curFactor, center ); + usedScale = m_cViewArea->scaleZoomFactor( factor / curFactor, center ); adjustScrollBarByScale( usedScale, center ); } } @@ -452,7 +452,6 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos ) } } - QSize VideoSubWindow::sizeHint() const { QSize maxSize; // The size of the parent (viewport widget @@ -463,6 +462,10 @@ QSize VideoSubWindow::sizeHint() const { maxSize = p->size(); } + else + { + maxSize = QApplication::desktop()->availableGeometry().size(); + } QSize isize; if( m_pcCurrFrame ) diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index cd89fcf..f5a638a 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -39,6 +39,7 @@ plaYUVerApp::plaYUVerApp() { setWindowModality( Qt::ApplicationModal ); + setWindowModality( Qt::NonModal ); // DBus #ifdef USE_QTDBUS @@ -138,13 +139,6 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event ) } } -Void plaYUVerApp::closeActiveWindow() -{ - SubWindowHandle *currSubWindow = activeSubWindow(); - m_appModuleVideo->closeSubWindow( qobject_cast( currSubWindow ) ); - m_pcWindowHandle->removeSubWindow( currSubWindow ); -} - Void plaYUVerApp::closeAll() { m_pcWindowHandle->removeAllSubWindow(); @@ -163,7 +157,7 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) m_pcWindowHandle->setActiveSubWindow( videoSubWindow ); return; } - videoSubWindow = new VideoSubWindow( this ); //createSubWindow(); + videoSubWindow = new VideoSubWindow; //createSubWindow(); SubWindowHandle *subWindow = videoSubWindow; if( !pStreamInfo ) { @@ -190,8 +184,8 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) connect( subWindow, SIGNAL( updateStatusBar( const QString& ) ), this, SLOT( updateStatusBar( const QString& ) ) ); connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( updateZoomFactorSBox() ) ); - connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( zoomToFactorAll( double, QPoint ) ) ); - connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), this, SLOT( moveAllScrollBars( const QPoint ) ) ); + //connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( zoomToFactorAll( double, QPoint ) ) ); + //connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), this, SLOT( moveAllScrollBars( const QPoint ) ) ); videoSubWindow->zoomToFit(); videoSubWindow->getViewArea()->setTool( ( ViewArea::eTool )m_uiViewTool ); @@ -447,10 +441,11 @@ Void plaYUVerApp::scaleFrame( int ratio ) Void plaYUVerApp::zoomFromSBox( double zoom ) { + SubWindowHandle *activeSubWindow = m_pcWindowHandle->activeSubWindow(); Double factor = zoom / 100; - if( activeSubWindow() ) + if( activeSubWindow ) { - activeSubWindow()->zoomToFactor( factor ); + activeSubWindow->zoomToFactor( factor ); } } @@ -499,13 +494,6 @@ Void plaYUVerApp::dropEvent( QDropEvent *event ) // ----------------------- Sub Window Functions ----------------------- -SubWindowHandle *plaYUVerApp::activeSubWindow() -{ - if( SubWindowHandle *activeSubWindow = m_pcWindowHandle->activeSubWindow() ) - return activeSubWindow; - return NULL; -} - VideoSubWindow* plaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName ) { QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath(); @@ -524,15 +512,15 @@ VideoSubWindow* plaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHa Void plaYUVerApp::update() { - SubWindowHandle *new_window = activeSubWindow(); + SubWindowHandle *activeSubWindow = m_pcWindowHandle->activeSubWindow(); QCoreApplication::processEvents(); //if( activeSubWindow() != m_pcCurrentSubWindow ) { m_pcCurrentSubWindow = NULL; m_pcCurrentVideoSubWindow = NULL; - if( activeSubWindow() ) + if( activeSubWindow ) { - m_pcCurrentSubWindow = new_window; + m_pcCurrentSubWindow = activeSubWindow; switch( m_pcCurrentSubWindow->getCategory() ) { @@ -572,7 +560,7 @@ Void plaYUVerApp::updateStatusBar( const QString& statusBarString ) Void plaYUVerApp::updateMenus() { - Bool hasSubWindow = ( activeSubWindow() != 0 ); + Bool hasSubWindow = ( m_pcWindowHandle->activeSubWindow() != 0 ); m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false ); @@ -650,7 +638,7 @@ Void plaYUVerApp::createActions() m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this ); m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) ); m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) ); - connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( closeActiveWindow() ) ); + connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), m_pcWindowHandle, SLOT( removeActiveSubWindow() ) ); m_arrayActions[CLOSEALL_ACT] = new QAction( tr( "Close &All" ), this ); m_arrayActions[CLOSEALL_ACT]->setStatusTip( tr( "Close all the windows" ) ); diff --git a/app/plaYUVerApp.h b/app/plaYUVerApp.h index 9decc68..f29fc9e 100644 --- a/app/plaYUVerApp.h +++ b/app/plaYUVerApp.h @@ -76,7 +76,6 @@ private Q_SLOTS: void reload(); void reloadAll(); void loadAll(); - void closeActiveWindow(); void closeAll(); /** @@ -114,7 +113,6 @@ private: QString m_cLastOpenPath; - SubWindowHandle *activeSubWindow(); static VideoSubWindow* findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName ); Void updateMenus();