Commit ac313623 authored by Hugo Pereira Da Costa's avatar Hugo Pereira Da Costa

Set a mask to shadow widget to make sure that it does not overlap with the mdi window.

BUG:379790
parent 84fdb60c
......@@ -38,25 +38,44 @@
namespace Oxygen
{
//____________________________________________________________________
MdiWindowShadow::MdiWindowShadow( QWidget* parent, TileSet tileSet ):
QWidget( parent ),
_widget( nullptr ),
_tileSet( tileSet )
{
setAttribute( Qt::WA_OpaquePaintEvent, false );
setAttribute( Qt::WA_TransparentForMouseEvents, true );
setFocusPolicy( Qt::NoFocus );
}
//____________________________________________________________________
void MdiWindowShadow::updateGeometry( void )
{
if( !_widget ) return;
// get tileSet rect
auto hole = _widget->frameGeometry().adjusted(1, 1, -1, -1 );;
_tileSetRect = _widget->frameGeometry().adjusted( -ShadowSize, -ShadowSize, ShadowSize, ShadowSize );
// get parent MDI area's viewport
QWidget *parent( parentWidget() );
if (parent && !qobject_cast<QMdiArea *>(parent) && qobject_cast<QMdiArea*>(parent->parentWidget()))
{ parent = parent->parentWidget(); }
if( qobject_cast<QAbstractScrollArea *>( parent ) )
{ parent = qobject_cast<QAbstractScrollArea *>( parent )->viewport(); }
// set geometry
QRect geometry( _tileSetRect );
if( parent ) geometry &= parent->rect();
if( parent )
{
geometry &= parent->rect();
hole &= parent->rect();
}
setGeometry( geometry );
setMask( QRegion( rect() ) - hole.translated( -geometry.topLeft() ) );
// translate rendering rect
_tileSetRect.translate( -geometry.topLeft() );
......@@ -174,7 +193,7 @@ namespace Oxygen
{
// check object,
if( !object->parent() ) return 0L;
if( !object->parent() ) return nullptr;
// find existing window shadows
const QList<QObject* > children = object->parent()->children();
......@@ -184,7 +203,7 @@ namespace Oxygen
{ if( shadow->widget() == object ) return shadow; }
}
return 0L;
return nullptr;
}
......
......@@ -44,7 +44,7 @@
namespace Oxygen
{
//! frame shadow
//* frame shadow
/*! this allows the shadow to be painted over the widgets viewport */
class MdiWindowShadow: public QWidget
{
......@@ -53,57 +53,45 @@ namespace Oxygen
public:
//! shadow size (hard coded)
//* shadow size (hard coded)
enum { ShadowSize = 10 };
//! constructor
explicit MdiWindowShadow( QWidget* parent, TileSet tileSet ):
QWidget( parent ),
_widget( 0L ),
_tileSet( tileSet )
{
setAttribute( Qt::WA_OpaquePaintEvent, false );
setAttribute( Qt::WA_TransparentForMouseEvents, true );
setFocusPolicy( Qt::NoFocus );
}
//! destructor
virtual ~MdiWindowShadow( void )
{}
//* constructor
explicit MdiWindowShadow( QWidget*, TileSet );
//! update geometry
//* update geometry
void updateGeometry( void );
//! update ZOrder
//* update ZOrder
void updateZOrder( void );
//! set associated window
//* set associated window
void setWidget( QWidget* value )
{ _widget = value; }
//! associated window
//* associated window
QWidget* widget( void ) const
{ return _widget; }
protected:
//! painting
//* painting
virtual void paintEvent(QPaintEvent *);
private:
//! associated widget
//* associated widget
QWidget* _widget;
//! tileset rect, used for painting
//* tileset rect, used for painting
QRect _tileSetRect;
//! tileset used to draw shadow
//* tileset used to draw shadow
TileSet _tileSet;
};
//! shadow manager
//* shadow manager
class MdiWindowShadowFactory: public QObject
{
......@@ -111,45 +99,45 @@ namespace Oxygen
public:
//! constructor
//* constructor
MdiWindowShadowFactory( QObject*, StyleHelper& );
//! destructor
//* destructor
virtual ~MdiWindowShadowFactory( void )
{}
//! register widget
//* register widget
bool registerWidget( QWidget* );
//! unregister
//* unregister
void unregisterWidget( QWidget* );
//! true if widget is registered
//* true if widget is registered
bool isRegistered( const QObject* widget ) const
{ return _registeredWidgets.contains( widget ); }
//! event filter
//* event filter
virtual bool eventFilter( QObject*, QEvent*);
protected:
//! find shadow matching a given object
//* find shadow matching a given object
MdiWindowShadow* findShadow( QObject* ) const;
//! install shadows on given widget
//* install shadows on given widget
void installShadow( QObject* );
//! remove shadows from widget
//* remove shadows from widget
void removeShadow( QObject* );
//! hide shadows
//* hide shadows
void hideShadows( QObject* object ) const
{
if( MdiWindowShadow* windowShadow = findShadow( object ) )
{ windowShadow->hide(); }
}
//! update ZOrder
//* update ZOrder
void updateShadowZOrder( QObject* object ) const
{
if( MdiWindowShadow* windowShadow = findShadow( object ) )
......@@ -159,14 +147,14 @@ namespace Oxygen
}
}
//! update shadows geometry
//* update shadows geometry
void updateShadowGeometry( QObject* object ) const
{
if( MdiWindowShadow* windowShadow = findShadow( object ) )
{ windowShadow->updateGeometry(); }
}
//! update shadows
//* update shadows
void update( QObject* object ) const
{
if( MdiWindowShadow* windowShadow = findShadow( object ) )
......@@ -175,15 +163,15 @@ namespace Oxygen
protected Q_SLOTS:
//! triggered by object destruction
//* triggered by object destruction
void widgetDestroyed( QObject* );
private:
//! set of registered widgets
//* set of registered widgets
QSet<const QObject*> _registeredWidgets;
//! tileset used to draw shadow
//* tileset used to draw shadow
TileSet _tileSet;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment