00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "overlay.h"
00021
00022 #include <Plasma/FrameSvg>
00023 #include <Plasma/ScrollWidget>
00024
00025 #include <QAbstractItemModel>
00026 #include <QPainter>
00027 #include <QGraphicsSceneEvent>
00028 #include <QGraphicsLinearLayout>
00029 #include <QGraphicsGridLayout>
00030
00031
00032 Overlay::Overlay( QGraphicsItem* parent, Qt::WindowFlags wFlags )
00033 : QGraphicsWidget( parent, wFlags )
00034 , m_contentLayout( new QGraphicsLinearLayout( Qt::Vertical ) )
00035 , m_contentWidget( new QGraphicsWidget( this ) )
00036 , m_background( new Plasma::FrameSvg( this ) )
00037 , m_scrollWidget( new Plasma::ScrollWidget( this ) )
00038 {
00039 m_background->setImagePath( "widgets/translucentbackground" );
00040 m_background->setEnabledBorders( Plasma::FrameSvg::AllBorders );
00041
00042 m_scrollWidget->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
00043 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout( Qt::Vertical );
00044 layout->addItem( m_scrollWidget );
00045 setLayout( layout );
00046 setContentsMargins( 10, 15, 10, 15 );
00047
00048 m_contentWidget->setLayout( m_contentLayout );
00049 m_scrollWidget->setWidget( m_contentWidget );
00050 }
00051
00052 void Overlay::keyPressEvent( QKeyEvent* event )
00053 {
00054 QGraphicsItem::keyPressEvent( event );
00055 }
00056
00057 void Overlay::wheelEvent( QGraphicsSceneWheelEvent* event )
00058 {
00059 QGraphicsItem::wheelEvent( event );
00060 }
00061
00062 void Overlay::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
00063 {
00064 Q_UNUSED( option );
00065 Q_UNUSED( widget );
00066 m_background->paintFrame( painter );
00067 }
00068
00069 void Overlay::resizeEvent( QGraphicsSceneResizeEvent* event )
00070 {
00071 m_background->resizeFrame( event->newSize() );
00072 }
00073
00074 #include "overlay.moc"