Add background and start detecting the close event from subwindows

This commit is contained in:
2015-01-22 00:34:43 +00:00
parent 26623822fb
commit bece510edd
10 changed files with 164 additions and 54 deletions
+1
View File
@@ -10,6 +10,7 @@ set(plaYUver_App_SRCS
main.cpp
plaYUVerApp.cpp
PlaYUVerSubWinManager.cpp
PlaYUVerMdiSubWindow.cpp
SubWindowHandle.cpp
Settings.cpp
# Module Video
+41
View File
@@ -0,0 +1,41 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file PlaYUVerMdiSubWindow.cpp
* \brief Re-implementation QMdiSubWindow
*/
#include "PlaYUVerMdiSubWindow.h"
namespace plaYUVer
{
PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget *parent ) :
QMdiSubWindow( parent )
{
}
Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent *event )
{
emit aboutToClose( this );
event->accept();
}
} // NAMESPACE
+57
View File
@@ -0,0 +1,57 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* \file PlaYUVerMdiSubWindow.h
* \brief Re-implementation QMdiSubWindow
*/
#ifndef __PLAYUVERMDISUBWINDOW_H__
#define __PLAYUVERMDISUBWINDOW_H__
#include "config.h"
#include "lib/PlaYUVerDefs.h"
#if( QT_VERSION_PLAYUVER == 5 )
#include <QtWidgets>
#elif( QT_VERSION_PLAYUVER == 4 )
#include <QtGui>
#endif
namespace plaYUVer
{
class PlaYUVerMdiSubWindow: public QMdiSubWindow
{
Q_OBJECT
public:
PlaYUVerMdiSubWindow( QWidget *parent = 0 );
Q_SIGNALS:
void aboutToClose( PlaYUVerMdiSubWindow* );
protected:
void closeEvent( QCloseEvent *event );
};
} // NAMESPACE
#endif // __PLAYUVERMDISUBWINDOW_H__
+46 -23
View File
@@ -23,18 +23,43 @@
*/
#include "PlaYUVerSubWinManager.h"
#include "PlaYUVerMdiSubWindow.h"
#include "SubWindowHandle.h"
namespace plaYUVer
{
class PlaYUVerMdiArea: public QMdiArea
{
public:
PlaYUVerMdiArea( QWidget *parent = 0 ) :
QMdiArea( parent ),
m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
{
}
protected:
void paintEvent( QPaintEvent *event )
{
QMdiArea::paintEvent( event );
QPainter painter( viewport() );
QPixmap pixFinalLogo = m_pixmapLogo.scaled( 2 * size() / 3, Qt::KeepAspectRatio );
// Calculate the logo position - the bottom right corner of the mdi area.
int x = width() / 2 - pixFinalLogo.width() / 2;
int y = height() / 2 - pixFinalLogo.height() / 2;
painter.drawPixmap( x, y, pixFinalLogo );
}
private:
QPixmap m_pixmapLogo;
};
PlaYUVerSubWinManager::PlaYUVerSubWinManager( QWidget *parent ) :
QWidget( parent ),
m_pixmapLogo( ":/images/playuver-backgroud-logo.png" )
QWidget( parent )
{
m_bMdiModeEnabled = true;
m_pcMdiArea = new QMdiArea( this );
m_pcMdiArea = new PlaYUVerMdiArea( this );
m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
QHBoxLayout* m_pcWindowManagerLayout = new QHBoxLayout( this );
@@ -48,27 +73,13 @@ PlaYUVerSubWinManager::PlaYUVerSubWinManager( QWidget *parent ) :
m_apcMdiSubWindowList.clear();
}
void PlaYUVerSubWinManager::paintEvent( QPaintEvent *event )
{
// QWidget::paintEvent( event );
// QPainter painter( m_pcMdiArea->viewport() );
// QSize logoSize = 2 * size() / 3;
//
// QPixmap pixFinalLogo = m_pixmapLogo.scaled( logoSize, Qt::KeepAspectRatio );
//
// // Calculate the logo position - the bottom right corner of the mdi area.
// int x = width() / 2 - pixFinalLogo.width() / 2;
// int y = height() / 2 - pixFinalLogo.height() / 2;
// painter.drawPixmap( x, y, pixFinalLogo );
}
Void PlaYUVerSubWinManager::updateActiveSubWindow()
{
if( m_bMdiModeEnabled )
{
m_pcActiveWindow = NULL;
QMdiSubWindow* mdiSubWindow = m_pcMdiArea->activeSubWindow();
if( mdiSubWindow)
if( mdiSubWindow )
{
QWidget* activeWidget = m_pcMdiArea->activeSubWindow()->widget();
Int windowIdx = m_apcSubWindowList.indexOf( qobject_cast<SubWindowHandle *>( activeWidget ) );
@@ -85,9 +96,12 @@ Void PlaYUVerSubWinManager::addSubWindow( SubWindowHandle *window, Qt::WindowFla
{
if( m_bMdiModeEnabled )
{
m_apcMdiSubWindowList.append( m_pcMdiArea->addSubWindow( window ) );
PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow( this );
mdiSubWindow->setWidget( window );
m_pcMdiArea->addSubWindow( mdiSubWindow );
m_apcMdiSubWindowList.append( mdiSubWindow );
connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) );
}
m_apcSubWindowList.append( window );
}
@@ -105,21 +119,30 @@ Void PlaYUVerSubWinManager::removeSubWindow( Int windowIdx )
}
}
Void PlaYUVerSubWinManager::removeSubWindow( SubWindowHandle* window )
{
removeSubWindow( m_apcSubWindowList.indexOf( window ) );
}
Void PlaYUVerSubWinManager::removeMdiSubWindow( PlaYUVerMdiSubWindow* window )
{
Int windowIdx = m_apcMdiSubWindowList.indexOf( window );
if( windowIdx >= 0 )
{
m_apcMdiSubWindowList.removeAt( windowIdx );
m_apcSubWindowList.removeAt( windowIdx );
}
}
Void PlaYUVerSubWinManager::removeAllSubWindow()
{
while( m_apcSubWindowList.size() > 0)
while( m_apcSubWindowList.size() > 0 )
{
removeSubWindow( 0 );
}
}
SubWindowHandle* PlaYUVerSubWinManager::activeSubWindow() const
{
return m_pcActiveWindow;
+7 -7
View File
@@ -37,6 +37,8 @@ namespace plaYUVer
{
class SubWindowHandle;
class PlaYUVerMdiArea;
class PlaYUVerMdiSubWindow;
class PlaYUVerSubWinManager : public QWidget
{
@@ -45,21 +47,20 @@ class PlaYUVerSubWinManager : public QWidget
private:
Bool m_bMdiModeEnabled;
QList<SubWindowHandle*> m_apcSubWindowList;
QList<QMdiSubWindow*> m_apcMdiSubWindowList;
QHBoxLayout* m_pcWindowManagerLayout;
QMdiArea* m_pcMdiArea;
PlaYUVerMdiArea* m_pcMdiArea;
QList<PlaYUVerMdiSubWindow*> m_apcMdiSubWindowList;
SubWindowHandle* m_pcActiveWindow;
QPixmap m_pixmapLogo;
public:
PlaYUVerSubWinManager(QWidget *parent = 0);
Void addSubWindow(SubWindowHandle *widget, Qt::WindowFlags flags = 0);
Void removeSubWindow( Int windowIdx );
Void removeSubWindow( SubWindowHandle *window);
Void removeSubWindow( SubWindowHandle *window);
Void removeAllSubWindow();
SubWindowHandle *activeSubWindow() const;
@@ -71,14 +72,13 @@ public:
public Q_SLOTS:
void updateActiveSubWindow();
void setActiveSubWindow(QWidget *window);
void removeMdiSubWindow( PlaYUVerMdiSubWindow* window );
void tileSubWindows();
void cascadeSubWindows();
Q_SIGNALS:
void windowActivated();
protected:
void paintEvent( QPaintEvent *event );
};
} // NAMESPACE
-13
View File
@@ -111,17 +111,4 @@ Void PlotSubWindow::scaleView( Double scale, QPoint center )
//
//}
Void PlotSubWindow::closeEvent( QCloseEvent *event )
{
Bool bAccept = true;
if( bAccept )
{
event->accept();
}
else
{
event->ignore();
}
}
} // NAMESPACE
-3
View File
@@ -64,9 +64,6 @@ public:
return 0;
}
//QSize sizeHint() const;
protected:
void closeEvent( QCloseEvent *event );
};
} // NAMESPACE
+6 -2
View File
@@ -55,7 +55,7 @@ SubWindowHandle::~SubWindowHandle()
QSize SubWindowHandle::getScrollSize()
{
return QSize( viewport()->size().width() - 5, viewport()->size().height() - 5 );
return QSize( viewport()->size().width() - 5, viewport()->size().height() - 5 );
}
Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset )
@@ -116,7 +116,6 @@ Void SubWindowHandle::updateLastScrollValue()
m_cLastScroll.setY( scrollBar->value() );
}
Void SubWindowHandle::setWindowName( QString name )
{
m_cWindowName = name;
@@ -133,4 +132,9 @@ Bool SubWindowHandle::mayClose()
return true;
}
Void SubWindowHandle::closeEvent( QCloseEvent *event )
{
event->accept();
}
} // NAMESPACE
+6 -5
View File
@@ -70,14 +70,13 @@ public:
/**
* Scale the image (zoomed in or out) to speficied absolute zoom value (1.0 = original size).
*/
virtual Void zoomToFactor( Double factor , QPoint center = QPoint() ) = 0;
virtual Void zoomToFactor( Double factor, QPoint center = QPoint() ) = 0;
/**
* Scale the image by a given factor
* @param factor factor of scale. Ex: 1.2 scale the image up by 20% and
* 0.8 scale the image down by 25%
*/
virtual Void scaleView( Double , QPoint center = QPoint() ) = 0;
virtual Void scaleView( Double, QPoint center = QPoint() ) = 0;
virtual Double getScaleFactor() = 0;
@@ -92,7 +91,7 @@ public:
}
protected:
virtual void closeEvent( QCloseEvent *event ) = 0;
virtual void closeEvent( QCloseEvent *event );
QSize getScrollSize();
Q_SIGNALS:
@@ -104,7 +103,9 @@ Q_SIGNALS:
* Notify that scrollbar position was changed by internal event (e.g. by mouse panning )
*/
void scrollBarMoved_SWindow( const QPoint );
/**
* Update stauts bars
*/
void updateStatusBar( const QString& );
public Q_SLOTS:
-1
View File
@@ -125,7 +125,6 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event )
for( Int i = 0; i < subWindowList.size(); i++ )
{
mayCloseAll &= subWindowList.at( i )->mayClose();
;
}
if( mayCloseAll )