diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index b93e969..b54b66e 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -37,7 +37,7 @@ PlotSubWindow::PlotSubWindow( QWidget * parent ) : setVisible( false ); m_cPlotArea = new QCustomPlot( this ); - setMainWidget( m_cPlotArea ); + setWidget( m_cPlotArea ); Example(); diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index 05b22a5..75c1742 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -28,19 +28,20 @@ namespace plaYUVer { SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : - QMdiSubWindow( parent ) + QScrollArea( parent ) { setParent( parent ); setAttribute( Qt::WA_DeleteOnClose ); setBackgroundRole( QPalette::Light ); // Create a new scroll area inside the sub-window - m_cScrollArea = new QScrollArea( this ); - connect( m_cScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); - connect( m_cScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); + connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); + connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); - setWidget( m_cScrollArea ); - m_cScrollArea->setWidgetResizable( true ); + setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + + setWidgetResizable( true ); m_cLastScroll = QPoint(); @@ -50,25 +51,19 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : SubWindowHandle::~SubWindowHandle() { - delete m_cScrollArea; -} - -Void SubWindowHandle::setMainWidget( QWidget *widget ) -{ - m_cScrollArea->setWidget( widget ); } QSize SubWindowHandle::getScrollSize() { - return QSize( m_cScrollArea->viewport()->size().width() - 5, m_cScrollArea->viewport()->size().height() - 5 ); + return QSize( viewport()->size().width() - 5, viewport()->size().height() - 5 ); } Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) { - QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar(); + QScrollBar *scrollBar = horizontalScrollBar(); scrollBar->setValue( int( scrollBar->value() + Offset.x() ) ); m_cLastScroll.setX( scrollBar->value() ); - scrollBar = m_cScrollArea->verticalScrollBar(); + scrollBar = verticalScrollBar(); scrollBar->setValue( int( scrollBar->value() + Offset.y() ) ); m_cLastScroll.setY( scrollBar->value() ); updateLastScrollValue(); @@ -78,7 +73,7 @@ Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) // http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) { - QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar(); + QScrollBar *scrollBar = horizontalScrollBar(); if( center.isNull() ) { scrollBar->setValue( int( scale * scrollBar->value() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ) ); @@ -94,7 +89,7 @@ Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) scrollBar->setValue( value ); } - scrollBar = m_cScrollArea->verticalScrollBar(); + scrollBar = verticalScrollBar(); if( center.isNull() ) { scrollBar->setValue( int( scale * scrollBar->value() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ) ); @@ -115,9 +110,9 @@ Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) Void SubWindowHandle::updateLastScrollValue() { - QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar(); + QScrollBar *scrollBar = horizontalScrollBar(); m_cLastScroll.setX( scrollBar->value() ); - scrollBar = m_cScrollArea->verticalScrollBar(); + scrollBar = verticalScrollBar(); m_cLastScroll.setY( scrollBar->value() ); } diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 2c2c76d..cbe4e0e 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -36,12 +36,11 @@ namespace plaYUVer { -class SubWindowHandle: public QMdiSubWindow +class SubWindowHandle: public QScrollArea { Q_OBJECT private: - QScrollArea* m_cScrollArea; QPoint m_cLastScroll; UInt m_uiCategory; @@ -92,7 +91,6 @@ public: protected: virtual void closeEvent( QCloseEvent *event ) = 0; - virtual Void setMainWidget( QWidget *widget ); QSize getScrollSize(); Q_SIGNALS: diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 41e11bc..87d648f 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -93,7 +93,7 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) : connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) ); // Define the cViewArea as the widget inside the scroll area - setMainWidget( m_cViewArea ); + setWidget( m_cViewArea ); m_apcCurrentModule.clear(); diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index 7d81cf6..8eb145c 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -34,7 +34,6 @@ #include #include #include - #include "ViewArea.h" #include "GridManager.h" @@ -66,6 +65,7 @@ ViewArea::ViewArea( QWidget *parent ) : m_snapToGrid = false; m_blockTrackEnable = false; m_pStream = NULL; + } void ViewArea::setImage( PlaYUVerFrame* pcFrame ) @@ -346,6 +346,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) painter.restore(); + // Draw a border around the image. /* if( m_xOffset || m_yOffset ) { diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 3c080b8..094fe4e 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -72,6 +72,7 @@ plaYUVerApp::plaYUVerApp() setAcceptDrops( true ); mdiArea->setAcceptDrops( true ); + //mdiArea->hide(); connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( update() ) ); connect( m_appModuleVideo, SIGNAL( changed() ), this, SLOT( update() ) ); @@ -167,7 +168,7 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) VideoSubWindow *videoSubWindow = plaYUVerApp::findVideoSubWindow( mdiArea, fileName ); if( videoSubWindow ) { - mdiArea->setActiveSubWindow( videoSubWindow ); + //mdiArea->setActiveSubWindow( videoSubWindow ); return; } videoSubWindow = new VideoSubWindow( this ); //createSubWindow(); @@ -190,15 +191,16 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) if( opened ) { statusBar()->showMessage( tr( "Loading file..." ) ); - mdiArea->addSubWindow( videoSubWindow ); + //mdiArea->addSubWindow( videoSubWindow ); + videoSubWindow->setWindowFlags(Qt::Window); videoSubWindow->show(); connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) ); 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 ); @@ -510,7 +512,7 @@ void plaYUVerApp::tileSubWindows() SubWindowHandle *plaYUVerApp::activeSubWindow() { if( QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow() ) - return qobject_cast( activeSubWindow ); + return qobject_cast( activeSubWindow->widget() ); return 0; } @@ -675,7 +677,7 @@ Void plaYUVerApp::updateWindowMenu() for( Int i = 0; i < number_windows; ++i ) { - SubWindowHandle *child = qobject_cast( windows.at( i ) ); + SubWindowHandle *child = qobject_cast( windows.at(i)->widget()); QString text; if( i < 9 )