From ec39cdee48b2ae345b01327747397bc3ed409721 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 17 Jan 2015 03:29:57 +0000 Subject: [PATCH] Minor code arrangements --- app/ModulesHandle.cpp | 12 +++- app/ModulesHandle.h | 2 - app/VideoSubWindow.cpp | 12 ++-- app/plaYUVerApp.cpp | 130 +++++++++++++++++++++-------------------- app/plaYUVerApp.h | 31 +++++----- 5 files changed, 98 insertions(+), 89 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index dd61d6c..8f0a6f4 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -303,7 +303,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) { if( ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) { - pcModuleSubWindow = new VideoSubWindow( m_pcParent, true ); + pcModuleSubWindow = new VideoSubWindow( this , true ); pcModuleSubWindow->setWindowShortName( windowName ); pcModuleSubWindow->setWindowName( windowName ); @@ -312,7 +312,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) pcCurrModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow; pcCurrModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrModuleIf, true ); - m_pcMdiArea->addSubWindow( pcModuleSubWindow ); + //m_pcMdiArea->addSubWindow( pcModuleSubWindow ); } } else if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE ) @@ -342,7 +342,13 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) applyModuleIf( pcCurrModuleIf, false ); QCoreApplication::processEvents(); - //pcModuleSubWindow->show(); + + if( pcModuleSubWindow ) + { + QMdiSubWindow* window = m_pcMdiArea->addSubWindow( pcModuleSubWindow ); + window->show(); + } + return; } diff --git a/app/ModulesHandle.h b/app/ModulesHandle.h index 3c362b0..a07c0f8 100644 --- a/app/ModulesHandle.h +++ b/app/ModulesHandle.h @@ -60,8 +60,6 @@ public: Void readSettings(); Void writeSettings(); - SubWindowHandle* processModuleHandlingOpt(); - static Void destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf ); static Bool applyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf, Bool isPlaying = false, Bool disableThreads = false ); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 4825102..48c6dde 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -246,12 +246,12 @@ Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) { m_pcCurrFrame = pcCurrFrame; m_cViewArea->setImage( m_pcCurrFrame ); - if( !isVisible() ) - { - show(); - resize( sizeHint() ); - zoomToFit(); - } +// if( !isVisible() ) +// { +// show(); +// resize( sizeHint() ); +// zoomToFit(); +// } } Void VideoSubWindow::refreshFrame() diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 539d9c9..96d2795 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -45,7 +45,7 @@ plaYUVerApp::plaYUVerApp() m_pDBusAdaptor = new PlaYUVerAppAdaptor( this ); #endif - mdiArea = new PlaYUVerMdiArea; + mdiArea = new PlaYUVerMdiArea( this ); setCentralWidget( mdiArea ); //mdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder ); @@ -245,8 +245,8 @@ Void plaYUVerApp::open() QStringList filter; filter << supported - << formatsList - << tr( "All Files (*)" ); + << formatsList + << tr( "All Files (*)" ); QStringList fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) ); @@ -292,8 +292,8 @@ Void plaYUVerApp::save() QStringList filter; filter << supported - << formatsList - << tr( "All Files (*)" ); + << formatsList + << tr( "All Files (*)" ); QString fileName = QFileDialog::getSaveFileName( this, tr( "Open File" ), QString(), filter.join( ";;" ) ); @@ -310,8 +310,6 @@ Void plaYUVerApp::save() } } - - Void plaYUVerApp::format() { if( m_pcCurrentVideoSubWindow ) @@ -448,56 +446,6 @@ Void plaYUVerApp::updateZoomFactorSBox() } } -Void plaYUVerApp::update() -{ - SubWindowHandle *new_window = activeSubWindow(); - QCoreApplication::processEvents(); - //if( activeSubWindow() != m_pcCurrentSubWindow ) - { - m_pcCurrentSubWindow = NULL; - m_pcCurrentVideoSubWindow = NULL; - if( activeSubWindow() ) - { - m_pcCurrentSubWindow = new_window; - - switch( m_pcCurrentSubWindow->getCategory() ) - { - case SubWindowHandle::VIDEO_SUBWINDOW: - m_pcCurrentVideoSubWindow = qobject_cast( m_pcCurrentSubWindow ); - break; - } - - setWindowTitle( QApplication::applicationName() + " - " + m_pcCurrentSubWindow->getWindowName() ); - - if( m_pcCurrentVideoSubWindow ) - { - if( !plaYUVerApp::findSubWindow( mdiArea, m_pcCurrentVideoSubWindow->getRefSubWindow() ) ) - { - m_pcCurrentVideoSubWindow->setRefSubWindow( NULL ); - } - } - updateZoomFactorSBox(); - } - } - m_appModuleVideo->update( m_pcCurrentVideoSubWindow ); - m_appModuleQuality->update( m_pcCurrentVideoSubWindow ); - updateMenus(); -} - -// ----------------------- Status bar Functions ----------------------- - -Void plaYUVerApp::updateStatusBar( const QString& statusBarString ) -{ - if( !statusBarString.isEmpty() ) - { - statusBar()->showMessage( statusBarString, 5000 ); - } - else - { - statusBar()->showMessage( " " ); - } -} - // ----------------------- Drag and drop functions ---------------------- Void plaYUVerApp::dragEnterEvent( QDragEnterEvent *event ) @@ -519,7 +467,12 @@ Void plaYUVerApp::dropEvent( QDropEvent *event ) } } -// ----------------------- Gui Functions ----------------------- +// ----------------------- Sub Window Functions ----------------------- + +void plaYUVerApp::tileSubWindows() +{ + mdiArea->tileSubWindows(); +} SubWindowHandle *plaYUVerApp::activeSubWindow() { @@ -575,6 +528,56 @@ Void plaYUVerApp::setActiveSubWindow( QWidget *window ) mdiArea->setActiveSubWindow( qobject_cast( window ) ); } +// ----------------------- Update Functions ----------------------- + +Void plaYUVerApp::update() +{ + SubWindowHandle *new_window = activeSubWindow(); + QCoreApplication::processEvents(); + //if( activeSubWindow() != m_pcCurrentSubWindow ) + { + m_pcCurrentSubWindow = NULL; + m_pcCurrentVideoSubWindow = NULL; + if( activeSubWindow() ) + { + m_pcCurrentSubWindow = new_window; + + switch( m_pcCurrentSubWindow->getCategory() ) + { + case SubWindowHandle::VIDEO_SUBWINDOW: + m_pcCurrentVideoSubWindow = qobject_cast( m_pcCurrentSubWindow ); + break; + } + + setWindowTitle( QApplication::applicationName() + " - " + m_pcCurrentSubWindow->getWindowName() ); + + if( m_pcCurrentVideoSubWindow ) + { + if( !plaYUVerApp::findSubWindow( mdiArea, m_pcCurrentVideoSubWindow->getRefSubWindow() ) ) + { + m_pcCurrentVideoSubWindow->setRefSubWindow( NULL ); + } + } + updateZoomFactorSBox(); + } + } + m_appModuleVideo->update( m_pcCurrentVideoSubWindow ); + m_appModuleQuality->update( m_pcCurrentVideoSubWindow ); + updateMenus(); +} + +Void plaYUVerApp::updateStatusBar( const QString& statusBarString ) +{ + if( !statusBarString.isEmpty() ) + { + statusBar()->showMessage( statusBarString, 5000 ); + } + else + { + statusBar()->showMessage( " " ); + } +} + Void plaYUVerApp::updateMenus() { Bool hasSubWindow = ( activeSubWindow() != 0 ); @@ -658,7 +661,7 @@ Void plaYUVerApp::updateWindowMenu() } } - +// ----------------------- Create Functions ----------------------- Void plaYUVerApp::createActions() { @@ -787,7 +790,8 @@ Void plaYUVerApp::createActions() m_arrayActions[TILE_WINDOWS_ACT] = new QAction( tr( "Tile" ), this ); m_arrayActions[TILE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowstile.png" ) ); m_arrayActions[TILE_WINDOWS_ACT]->setStatusTip( tr( "Tile the windows" ) ); - connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) ); + //connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) ); + connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( tileSubWindows() ) ); m_arrayActions[CASCADE_WINDOWS_ACT] = new QAction( tr( "Cascade" ), this ); m_arrayActions[CASCADE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowscascade.png" ) ); @@ -942,7 +946,7 @@ Void plaYUVerApp::createDockWidgets() Void plaYUVerApp::createStatusBar() { - statusBar()->addPermanentWidget( m_appModuleVideo->createStatusBarMessage() ); + statusBar()->addPermanentWidget( m_appModuleVideo->createStatusBarMessage() ); statusBar()->showMessage( tr( "Ready" ) ); } @@ -994,7 +998,7 @@ Void plaYUVerApp::readSettings() m_appTool = ( ViewArea::eTool )appSettings.value( "MainWindow/SelectedTool", ViewArea::NavigationTool ).toInt(); setTool( m_appTool ); - QVariant value = appSettings.value("MainWindow/RecentFileList"); + QVariant value = appSettings.value( "MainWindow/RecentFileList" ); m_aRecentFileStreamInfo = value.value(); updateRecentFileActions(); @@ -1014,7 +1018,7 @@ Void plaYUVerApp::writeSettings() QVariant var; var.setValue( m_aRecentFileStreamInfo ); - appSettings.setValue("MainWindow/RecentFileList", var ); + appSettings.setValue( "MainWindow/RecentFileList", var ); m_appModuleVideo->writeSettings(); m_appModuleQuality->writeSettings(); diff --git a/app/plaYUVerApp.h b/app/plaYUVerApp.h index 3190271..9354cac 100644 --- a/app/plaYUVerApp.h +++ b/app/plaYUVerApp.h @@ -64,6 +64,8 @@ protected: private Q_SLOTS: + void about(); + /** * File functions slots */ @@ -90,18 +92,18 @@ private Q_SLOTS: void setTool( int idxTool ); + void dragEnterEvent( QDragEnterEvent *event ); + void dropEvent( QDropEvent *event ); + + void tileSubWindows(); + void setActiveSubWindow( QWidget *window ); + + void update(); void updateWindowMenu(); void updateZoomFactorSBox(); void updateStatusBar( const QString& ); - void about(); - - void dragEnterEvent( QDragEnterEvent *event ); - void dropEvent( QDropEvent *event ); - - void setActiveSubWindow( QWidget *window ); - private: class PlaYUVerMdiArea: public QMdiArea @@ -141,6 +143,13 @@ private: QString m_cLastOpenPath; + SubWindowHandle *activeSubWindow(); + template + T findSubWindow( const QMdiArea* mdiArea, const QString& name ); + template + T findSubWindow( const QMdiArea* mdiArea, const T subWindow ); + static VideoSubWindow* findVideoSubWindow( const QMdiArea* mdiArea, const QString& fileName ); + Void updateMenus(); Void createActions(); @@ -155,14 +164,6 @@ private: Void readSettings(); Void writeSettings(); - SubWindowHandle *activeSubWindow(); - - template - T findSubWindow( const QMdiArea* mdiArea, const QString& name ); - template - T findSubWindow( const QMdiArea* mdiArea, const T subWindow ); - - static VideoSubWindow* findVideoSubWindow( const QMdiArea* mdiArea, const QString& fileName ); QDoubleSpinBox *m_pcZoomFactorSBox;