SVN_SILENT made messages (.desktop file)
[kdegames.git] / klines / mwidget.cpp
blob53f178f6eda4af7bef772cd0a29db9fef1ff27c8
1 /***************************************************************************
2 begin : Fri May 19 2000
3 copyright : (C) 2000 by Roman Merzlyakov
4 email : roman@sbrf.barrt.ru
5 copyright : (C) 2000 by Roman Razilov
6 email : Roman.Razilov@gmx.de
7 copyright : (C) 2006-2007 by Dmitry Suzdalev
8 email : dimsuz@gmail.com
9 ***************************************************************************/
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19 #include "mwidget.h"
20 #include "scene.h"
23 #include <QGraphicsView>
24 #include <QResizeEvent>
25 #include <QBoxLayout>
27 MainWidget::MainWidget( QWidget* parent )
28 : QWidget( parent )
30 QBoxLayout *mainLay = new QHBoxLayout( this );
31 mainLay->setMargin( 0 );
33 m_scene = new KLinesScene(this);
34 QGraphicsView* klview = new QGraphicsView( m_scene, this );
35 klview->setCacheMode( QGraphicsView::CacheBackground );
36 klview->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
37 klview->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
38 klview->setFrameStyle(QFrame::NoFrame);
40 klview->setOptimizationFlags( QGraphicsView::DontClipPainter |
41 QGraphicsView::DontSavePainterState |
42 QGraphicsView::DontAdjustForAntialiasing );
44 mainLay->addWidget( klview );
46 setMinimumSize( 250, 250 );
49 MainWidget::~MainWidget()
53 void MainWidget::setShowNextColors(bool visible)
55 // add bonus score points if playing w/o preview
56 m_scene->setBonusScorePoints( visible ? 0 : 1 );
57 m_scene->setPreviewZoneVisible( visible );
60 void MainWidget::resizeEvent( QResizeEvent* ev)
62 // if this flag is set it means that resizeEvent is called
63 // while widget is hidden.
64 // so we'll wait with resize until it will be unset to not
65 // waste time resizing invisible scene
66 if ( !testAttribute( Qt::WA_PendingResizeEvent ) )
67 m_scene->resizeScene( ev->size().width(), ev->size().height() );
70 #include "mwidget.moc"