File indexing completed on 2024-05-19 07:51:59

0001 /*
0002     This file is part of Killbots.
0003 
0004     SPDX-FileCopyrightText: 2007-2009 Parker Coates <coates@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #include "view.h"
0010 
0011 #include <QResizeEvent>
0012 
0013 Killbots::View::View(QGraphicsScene *scene, QWidget *parent)
0014     : QGraphicsView(scene, parent)
0015 {
0016     setMinimumSize(QSize(300, 200));
0017     setFrameShape(QFrame::NoFrame);
0018 
0019     // This makes the background of the widget transparent so that Oxygen's
0020     // (or any other style's) window gradient is visible in unpainted areas of
0021     // the scene.
0022     QPalette p = palette();
0023     QColor c = p.color(QPalette::Base);
0024     c.setAlpha(0);
0025     p.setColor(QPalette::Base, c);
0026     setPalette(p);
0027     setBackgroundRole(QPalette::Base);
0028 
0029     setCacheMode(QGraphicsView::CacheBackground);
0030     setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
0031 
0032     // Including QGraphicsView::DontAdjustForAntialiasing here sometimes caused
0033     // painting traces in certain situations like pushing junkheaps.
0034     setOptimizationFlags( QGraphicsView::DontSavePainterState);
0035 }
0036 
0037 Killbots::View::~View()
0038 {
0039 }
0040 
0041 void Killbots::View::resizeEvent(QResizeEvent *event)
0042 {
0043     QGraphicsView::resizeEvent(event);
0044     Q_EMIT sizeChanged(event->size());
0045 }
0046 
0047 #include "moc_view.cpp"