1 | /* |
---|---|
2 | * Copyright 2007-2009 Parker Coates <coates@kde.org> |
3 | * |
4 | * This file is part of Killbots. |
5 | * |
6 | * Killbots is free software: you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation, either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * Killbots is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with Killbots. If not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | |
20 | #include "view.h" |
21 | |
22 | #include <QtGui/QResizeEvent> |
23 | |
24 | |
25 | Killbots::View::View( QGraphicsScene * scene, QWidget * parent ) |
26 | : QGraphicsView( scene, parent ) |
27 | { |
28 | setMinimumSize( QSize( 300, 200 ) ); |
29 | setFrameShape( QFrame::NoFrame ); |
30 | |
31 | // This makes the background of the widget transparent so that Oxygen's |
32 | // (or any other style's) window gradient is visible in unpainted areas of |
33 | // the scene. |
34 | QPalette p = palette(); |
35 | QColor c = p.color( QPalette::Base ); |
36 | c.setAlpha( 0 ); |
37 | p.setColor( QPalette::Base, c ); |
38 | setPalette( p ); |
39 | setBackgroundRole( QPalette::Base ); |
40 | |
41 | setCacheMode( QGraphicsView::CacheBackground ); |
42 | setViewportUpdateMode( QGraphicsView::SmartViewportUpdate ); |
43 | |
44 | // Including QGraphicsView::DontAdjustForAntialiasing here sometimes caused |
45 | // painting traces in certain situations like pushing junkheaps. |
46 | setOptimizationFlags( QGraphicsView::DontClipPainter | QGraphicsView::DontSavePainterState ); |
47 | } |
48 | |
49 | |
50 | Killbots::View::~View() |
51 | { |
52 | } |
53 | |
54 | |
55 | void Killbots::View::resizeEvent( QResizeEvent * event ) |
56 | { |
57 | QGraphicsView::resizeEvent( event ); |
58 | emit sizeChanged( event->size() ); |
59 | } |
60 | |
61 | #include "moc_view.cpp" |
62 |