1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: QY2LayoutUtils.cc
15 Author: Stefan Hundhammer <sh@suse.de>
17 These are pure Qt functions - they can be used independently of YaST2.
22 #include <qapplication.h>
24 #include "QY2LayoutUtils.h"
27 QWidget * addVStretch( QWidget * parent )
29 QWidget * spacer = new QWidget( parent );
30 spacer->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); // hor/vert
36 QWidget * addHStretch( QWidget * parent )
38 QWidget * spacer = new QWidget( parent );
39 spacer->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // hor/vert
45 QWidget * addVSpacing( QWidget * parent, int height )
47 QWidget * spacer = new QWidget( parent );
49 spacer->setFixedHeight( height );
55 QWidget * addHSpacing( QWidget * parent, int width )
57 QWidget * spacer = new QWidget( parent );
59 spacer->setFixedWidth( width );
66 limitToScreenSize( const QWidget * widget, int width, int height )
68 return limitToScreenSize( widget, QSize( width, height ) );
73 limitToScreenSize( const QWidget * widget, const QSize & desiredSize )
75 QSize availableSize = qApp->desktop()->availableGeometry( const_cast<QWidget*> (widget) ).size();
77 // Subtract WM decorations. There seems to be no reliable way to tell if
78 // this is necessary at all (even fvwm2 claims it is a NETWM compliant
79 // window manager) or how large the WM decorations are.
80 // For the purpose of this function, let's assume we have to subtract the
81 // common fvwm2 decoration size. This is simplistic and should be improved.
82 availableSize -= QSize( 10, 35 );
84 return desiredSize.boundedTo( availableSize );