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 ***************************************************************************/
10
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"
21
22
23#include <QGraphicsView>
24#include <QResizeEvent>
25#include <QBoxLayout>
26
27MainWidget::MainWidget( QWidget* parent )
28 : QWidget( parent )
29{
30 QBoxLayout *mainLay = new QHBoxLayout( this );
31 mainLay->setMargin( 0 );
32
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);
39
40 klview->setOptimizationFlags( QGraphicsView::DontClipPainter |
41 QGraphicsView::DontSavePainterState |
42 QGraphicsView::DontAdjustForAntialiasing );
43
44 mainLay->addWidget( klview );
45
46 setMinimumSize( 250, 250 );
47}
48
49MainWidget::~MainWidget()
50{
51}
52
53void MainWidget::setShowNextColors(bool visible)
54{
55 // add bonus score points if playing w/o preview
56 m_scene->setBonusScorePoints( visible ? 0 : 1 );
57 m_scene->setPreviewZoneVisible( visible );
58}
59
60void MainWidget::resizeEvent( QResizeEvent* ev)
61{
62 m_scene->resizeScene( ev->size().width(), ev->size().height() );
63}
64
65#include "mwidget.moc"
66