Fix size hint of video subwindows
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PlaYUVerMdiSubWindow.h"
|
#include "PlaYUVerMdiSubWindow.h"
|
||||||
|
#include "SubWindowHandle.h"
|
||||||
|
|
||||||
namespace plaYUVer
|
namespace plaYUVer
|
||||||
{
|
{
|
||||||
@@ -34,11 +35,13 @@ PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget *parent ) :
|
|||||||
|
|
||||||
QSize PlaYUVerMdiSubWindow::sizeHint() const
|
QSize PlaYUVerMdiSubWindow::sizeHint() const
|
||||||
{
|
{
|
||||||
QSize sizeHint = widget()->sizeHint();
|
QSize maxSize;
|
||||||
|
if( parent() )
|
||||||
|
maxSize = parentWidget()->size();
|
||||||
|
QSize sizeHint = qobject_cast<SubWindowHandle*>( widget() )->sizeHint( maxSize );
|
||||||
return sizeHint;
|
return sizeHint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent *event )
|
Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent *event )
|
||||||
{
|
{
|
||||||
emit aboutToClose( this );
|
emit aboutToClose( this );
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace plaYUVer
|
|||||||
class PlaYUVerMdiArea: public QMdiArea
|
class PlaYUVerMdiArea: public QMdiArea
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlaYUVerMdiArea( QWidget *parent = 0 ) :
|
PlaYUVerMdiArea( QWidget *parent ) :
|
||||||
QMdiArea( parent ),
|
QMdiArea( parent ),
|
||||||
m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
|
m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
|
||||||
{
|
{
|
||||||
@@ -138,7 +138,7 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowHandle *window, Qt::WindowF
|
|||||||
}
|
}
|
||||||
if( m_uiWindowMode == MdiWSubWindows )
|
if( m_uiWindowMode == MdiWSubWindows )
|
||||||
{
|
{
|
||||||
PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow( this );
|
PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow;
|
||||||
mdiSubWindow->setWidget( window );
|
mdiSubWindow->setWidget( window );
|
||||||
m_pcMdiArea->addSubWindow( mdiSubWindow );
|
m_pcMdiArea->addSubWindow( mdiSubWindow );
|
||||||
m_apcMdiSubWindowList.append( mdiSubWindow );
|
m_apcMdiSubWindowList.append( mdiSubWindow );
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class PlaYUVerSubWindowHandle: public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlaYUVerSubWindowHandle( QWidget *parent = 0 );
|
PlaYUVerSubWindowHandle( QWidget *parent );
|
||||||
|
|
||||||
Void addSubWindow( SubWindowHandle *widget, Qt::WindowFlags flags = 0 );
|
Void addSubWindow( SubWindowHandle *widget, Qt::WindowFlags flags = 0 );
|
||||||
|
|
||||||
|
|||||||
@@ -110,5 +110,11 @@ Void PlotSubWindow::scaleView( Double scale, QPoint center )
|
|||||||
//{
|
//{
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//QSize PlotSubWindow::sizeHint( const QSize & maxSize ) const
|
||||||
|
//{
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
} // NAMESPACE
|
} // NAMESPACE
|
||||||
|
|||||||
+7
-1
@@ -63,7 +63,13 @@ public:
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//QSize sizeHint() const;
|
|
||||||
|
/**
|
||||||
|
* Size related functions
|
||||||
|
*/
|
||||||
|
// QSize sizeHint() const;
|
||||||
|
// QSize sizeHint( const QSize & ) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // NAMESPACE
|
} // NAMESPACE
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ Bool SubWindowHandle::mayClose()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize SubWindowHandle::sizeHint( const QSize & ) const
|
||||||
|
{
|
||||||
|
return QSize();
|
||||||
|
}
|
||||||
|
|
||||||
Void SubWindowHandle::focusInEvent( QFocusEvent * event )
|
Void SubWindowHandle::focusInEvent( QFocusEvent * event )
|
||||||
{
|
{
|
||||||
emit aboutToActivate( this );
|
emit aboutToActivate( this );
|
||||||
|
|||||||
+12
-2
@@ -80,6 +80,16 @@ public:
|
|||||||
|
|
||||||
virtual Double getScaleFactor() = 0;
|
virtual Double getScaleFactor() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size related functions
|
||||||
|
*/
|
||||||
|
//virtual QSize sizeHint() const;
|
||||||
|
virtual QSize sizeHint( const QSize & ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Window name
|
||||||
|
*/
|
||||||
|
|
||||||
Void setWindowName( QString );
|
Void setWindowName( QString );
|
||||||
QString getWindowName();
|
QString getWindowName();
|
||||||
|
|
||||||
@@ -91,8 +101,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void focusInEvent( QFocusEvent * event );
|
void focusInEvent( QFocusEvent * event );
|
||||||
virtual void closeEvent( QCloseEvent *event );
|
void closeEvent( QCloseEvent *event );
|
||||||
QSize getScrollSize();
|
QSize getScrollSize();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|||||||
+12
-9
@@ -93,6 +93,7 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) :
|
|||||||
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) );
|
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) );
|
||||||
|
|
||||||
// Define the cViewArea as the widget inside the scroll area
|
// Define the cViewArea as the widget inside the scroll area
|
||||||
|
m_cViewArea->setMinimumSize( size() );
|
||||||
setWidget( m_cViewArea );
|
setWidget( m_cViewArea );
|
||||||
|
|
||||||
m_apcCurrentModule.clear();
|
m_apcCurrentModule.clear();
|
||||||
@@ -454,8 +455,7 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
|
|||||||
|
|
||||||
QSize VideoSubWindow::sizeHint() const
|
QSize VideoSubWindow::sizeHint() const
|
||||||
{
|
{
|
||||||
QSize maxSize; // The size of the parent (viewport widget
|
QSize maxSize;
|
||||||
// of the QMdiArea).
|
|
||||||
|
|
||||||
QWidget *p = parentWidget();
|
QWidget *p = parentWidget();
|
||||||
if( p )
|
if( p )
|
||||||
@@ -466,7 +466,11 @@ QSize VideoSubWindow::sizeHint() const
|
|||||||
{
|
{
|
||||||
maxSize = QApplication::desktop()->availableGeometry().size();
|
maxSize = QApplication::desktop()->availableGeometry().size();
|
||||||
}
|
}
|
||||||
|
return sizeHint( maxSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const
|
||||||
|
{
|
||||||
QSize isize;
|
QSize isize;
|
||||||
if( m_pcCurrFrame )
|
if( m_pcCurrFrame )
|
||||||
isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 );
|
isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 );
|
||||||
@@ -475,17 +479,16 @@ QSize VideoSubWindow::sizeHint() const
|
|||||||
|
|
||||||
// If the VideoSubWindow needs more space that the avaiable, we'll give
|
// If the VideoSubWindow needs more space that the avaiable, we'll give
|
||||||
// to the subwindow a reasonable size preserving the image aspect ratio.
|
// to the subwindow a reasonable size preserving the image aspect ratio.
|
||||||
if( isize.width() < maxSize.width() && isize.height() < maxSize.height() )
|
if( !( isize.width() < maxSize.width() && isize.height() < maxSize.height() ) )
|
||||||
{
|
|
||||||
return isize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
isize.scale( maxSize, Qt::KeepAspectRatio );
|
isize.scale( maxSize, Qt::KeepAspectRatio );
|
||||||
maxSize = isize;
|
|
||||||
}
|
}
|
||||||
|
return isize;
|
||||||
|
}
|
||||||
|
|
||||||
return maxSize;
|
Void VideoSubWindow::resizeEvent( QResizeEvent * event )
|
||||||
|
{
|
||||||
|
m_cViewArea->setMinimumSize( size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Void VideoSubWindow::closeEvent( QCloseEvent *event )
|
Void VideoSubWindow::closeEvent( QCloseEvent *event )
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ public:
|
|||||||
return m_cViewArea->getZoomFactor();
|
return m_cViewArea->getZoomFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize sizeHint() const;
|
/**
|
||||||
|
* Size related functions
|
||||||
|
*/
|
||||||
|
QSize sizeHint() const ;
|
||||||
|
QSize sizeHint( const QSize & ) const ;
|
||||||
|
|
||||||
|
|
||||||
Void setWindowShortName( const QString& name)
|
Void setWindowShortName( const QString& name)
|
||||||
{
|
{
|
||||||
@@ -193,6 +198,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent * event);
|
||||||
void closeEvent( QCloseEvent *event );
|
void closeEvent( QCloseEvent *event );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|||||||
+2
-2
@@ -87,8 +87,8 @@ Void plaYUVerApp::parseArgs( Int argc, Char *argv[] )
|
|||||||
{
|
{
|
||||||
loadFile( argv[i] );
|
loadFile( argv[i] );
|
||||||
}
|
}
|
||||||
m_pcWindowHandle->tileSubWindows();
|
// m_pcWindowHandle->tileSubWindows();
|
||||||
zoomToFitAll();
|
// zoomToFitAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user