From 3575cefb44fb0d8d3ee959d8389d60417bf026a4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 26 Mar 2014 06:16:37 +0000 Subject: [PATCH] Change code order --- source/app/SubWindowHandle.cpp | 13 +- source/app/SubWindowHandle.h | 22 ++-- source/app/plaYUVerApp.cpp | 223 +++++++++++++++++---------------- source/app/plaYUVerApp.h | 5 +- 4 files changed, 127 insertions(+), 136 deletions(-) diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index 8df8f29..48c53f3 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -72,7 +72,7 @@ SubWindowHandle::~SubWindowHandle() } } -bool SubWindowHandle::loadFile( const QString &fileName ) +Bool SubWindowHandle::loadFile( const QString &fileName ) { ConfigureFormatDialog formatDialog( this ); @@ -168,7 +168,7 @@ Void SubWindowHandle::refreshFrame() m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); } -bool SubWindowHandle::save() +Bool SubWindowHandle::save() { QString supported = tr( "Supported Files" ); QString formats = InputStream::supportedWriteFormats(); @@ -186,10 +186,10 @@ bool SubWindowHandle::save() QApplication::setOverrideCursor( Qt::WaitCursor ); - if( !m_pCurrStream->writeFrame( fileName ) ) + if( m_pCurrFrameQImage->save( fileName ) ) { QApplication::restoreOverrideCursor(); - QMessageBox::warning( this, tr( "SCode" ), tr( "Cannot save file %1" ).arg( fileName ) ); + QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot save file %1" ).arg( fileName ) ); return false; } @@ -321,9 +321,4 @@ void SubWindowHandle::closeEvent( QCloseEvent *event ) event->accept(); } -QString SubWindowHandle::userFriendlyCurrentFile() -{ - return m_cWindowName; -} - } // NAMESPACE diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 577204b..32c7ce7 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -59,15 +59,12 @@ private: Bool m_bIsPlaying; -private slots: - void adjustScrollBar( double factor ); - public: SubWindowHandle( QWidget * parent = 0 ); ~SubWindowHandle(); - bool loadFile( const QString &fileName ); - bool save(); + Bool loadFile( const QString &fileName ); + Bool save(); Void stopEvent(); Void seekEvent( UInt new_frame_num ); @@ -128,14 +125,11 @@ public: QSize sizeHint() const; - /** - * Arranges all the listed widgets (normaly QMdiImageInterface) in a cascade - * pattern. - * @Note This function implementation is taken from the Qt source. The - * QMdiArea only have a function that arranges @b all the child windows. - */ - //static void cascader( QList &widgets, const QRect &domain ); - QString userFriendlyCurrentFile(); + QString userFriendlyCurrentFile() + { + return m_cWindowName; + } + QString currentFile() { return m_cCurrFileName; @@ -146,7 +140,7 @@ protected: public Q_SLOTS: bool playEvent(); - + void adjustScrollBar( double factor ); }; } // NAMESPACE diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 6a1a01b..12795cb 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -271,6 +271,119 @@ void plaYUVerApp::chageSubWindowSelection() //updateWindowMenu(); } +// ----------------------- Status bar Functions ----------------------- + +void plaYUVerApp::updatePixelValueStatusBar(const QPoint & pos, InputStream* stream) +{ + Pixel sPixelValue; + Int iWidth, iHeight; + Int posX = pos.x(), posY = pos.y(); + QString strPixel; + QString strStatus = QString("(%1,%2) ").arg(posX).arg(posY); + PlaYUVerFrame *curFrame = stream->getCurrFrame(); + + iWidth = stream->getWidth(); + iHeight = stream->getHeight(); + + if( (posX=0) && (posY=0) ) + { + sPixelValue = curFrame->getPixelValue(pos,COLOR_YUV); + strPixel = QString("Y: %1 U: %2 V: %3").arg(sPixelValue.Luma).arg(sPixelValue.ChromaU).arg(sPixelValue.ChromaV); + } + else + { + strPixel = QString("Y: U: V: "); + } + strStatus.append(strPixel); + statusBar()->showMessage( strStatus , 0 ); +} + +// ----------------------- Drag and drop functions ---------------------- + +void plaYUVerApp::dragEnterEvent( QDragEnterEvent *event ) +{ + //setText(tr("")); + setBackgroundRole( QPalette::Highlight ); + + event->acceptProposedAction(); +} + +void plaYUVerApp::dropEvent( QDropEvent *event ) +{ + + const QMimeData *mimeData = event->mimeData(); + + QList urlList = mimeData->urls(); + + 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 ) ) + { + addSubWindow( interfaceChild ); + statusBar()->showMessage( tr( "File loaded" ), 2000 ); + interfaceChild->show(); + } + else + { + interfaceChild->close(); + } + } + } +} + +// ----------------------- Gui Functions ----------------------- + +SubWindowHandle *plaYUVerApp::createSubWindow() +{ + SubWindowHandle *child = new SubWindowHandle; + mdiArea->addSubWindow( child ); + + return child; +} + +void plaYUVerApp::addSubWindow( SubWindowHandle *child ) +{ + //connect( child, SIGNAL( areaSelected( QRect ) ), this, SLOT( setSelection( QRect ) ) ); + + // Add the interface to the mdiArea + mdiArea->addSubWindow( child ); + return; +} + +SubWindowHandle *plaYUVerApp::activeSubWindow() +{ + if( QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow() ) + return qobject_cast( activeSubWindow ); + return 0; +} + +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; + } + return 0; +} + +void plaYUVerApp::setActiveSubWindow( QWidget *window ) +{ + if( !window ) + return; + mdiArea->setActiveSubWindow( qobject_cast( window ) ); +} + Void plaYUVerApp::updateMenus() { Bool hasSubWindow = ( activeSubWindow() != 0 ); @@ -347,23 +460,6 @@ void plaYUVerApp::updateWindowMenu() } } -SubWindowHandle *plaYUVerApp::createSubWindow() -{ - SubWindowHandle *child = new SubWindowHandle; - mdiArea->addSubWindow( child ); - - return child; -} - -void plaYUVerApp::addSubWindow( SubWindowHandle *child ) -{ - //connect( child, SIGNAL( areaSelected( QRect ) ), this, SLOT( setSelection( QRect ) ) ); - - // Add the interface to the mdiArea - mdiArea->addSubWindow( child ); - return; -} - Void plaYUVerApp::createActions() { // ------------ File ------------ @@ -562,48 +658,6 @@ Void plaYUVerApp::createStatusBar() statusBar()->showMessage( tr( "Ready" ) ); } -/* - * Drag and drop functions - */ -void plaYUVerApp::dragEnterEvent( QDragEnterEvent *event ) -{ - //setText(tr("")); - setBackgroundRole( QPalette::Highlight ); - - event->acceptProposedAction(); -} - -void plaYUVerApp::dropEvent( QDropEvent *event ) -{ - - const QMimeData *mimeData = event->mimeData(); - - QList urlList = mimeData->urls(); - - 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 ) ) - { - addSubWindow( interfaceChild ); - statusBar()->showMessage( tr( "File loaded" ), 2000 ); - interfaceChild->show(); - } - else - { - interfaceChild->close(); - } - } - } -} - Void plaYUVerApp::readSettings() { PlaYUVerSettings settings; @@ -622,55 +676,4 @@ Void plaYUVerApp::writeSettings() settings.setLastOpenPath( m_cLastOpenPath ); } -SubWindowHandle *plaYUVerApp::activeSubWindow() -{ - if( QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow() ) - return qobject_cast( activeSubWindow ); - return 0; -} - -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; - } - return 0; -} - -void plaYUVerApp::setActiveSubWindow( QWidget *window ) -{ - if( !window ) - return; - mdiArea->setActiveSubWindow( qobject_cast( window ) ); -} - -void plaYUVerApp::updatePixelValueStatusBar(const QPoint & pos, InputStream* stream) -{ - Pixel sPixelValue; - Int iWidth, iHeight; - Int posX = pos.x(), posY = pos.y(); - QString strPixel; - QString strStatus = QString("(%1,%2) ").arg(posX).arg(posY); - PlaYUVerFrame *curFrame = stream->getCurrFrame(); - - iWidth = stream->getWidth(); - iHeight = stream->getHeight(); - - if( (posX=0) && (posY=0) ) - { - sPixelValue = curFrame->getPixelValue(pos,COLOR_YUV); - strPixel = QString("Y: %1 U: %2 V: %3").arg(sPixelValue.Luma).arg(sPixelValue.ChromaU).arg(sPixelValue.ChromaV); - } - else - { - strPixel = QString("Y: U: V: "); - } - strStatus.append(strPixel); - statusBar()->showMessage( strStatus , 0 ); -} - } // NAMESPACE diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 1fdf557..dcea3f3 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -83,13 +83,12 @@ private Q_SLOTS: void chageSubWindowSelection(); void updateWindowMenu(); - /* - * Drag and drop functions - */ + //! Drag and drop functions void dragEnterEvent( QDragEnterEvent *event ); void dropEvent( QDropEvent *event ); void setActiveSubWindow( QWidget *window ); + void updatePixelValueStatusBar(const QPoint & pos, InputStream* stream); private: