File indexing completed on 2024-04-21 04:02:13
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Stefan Majewsky <majewsky@gmx.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "view.h" 0008 0009 #include <QWheelEvent> 0010 #include <KLocalizedString> 0011 0012 KDiamond::View::View(QWidget *parent) 0013 : QGraphicsView(parent) 0014 { 0015 setFrameStyle(QFrame::NoFrame); 0016 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 0017 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 0018 //optimize rendering 0019 setOptimizationFlags(QGraphicsView::DontSavePainterState | QGraphicsView::DontAdjustForAntialiasing); 0020 //"What's this?" context help 0021 setWhatsThis(i18n("<h3>Rules of Game</h3><p>Your goal is to assemble lines of at least three similar diamonds. Click on two adjacent diamonds to swap them.</p><p>Earn extra points by building cascades, and extra seconds by assembling big lines or multiple lines at one time.</p>")); 0022 } 0023 0024 void KDiamond::View::setScene(QGraphicsScene *scene) 0025 { 0026 QGraphicsView::setScene(scene); 0027 resizeEvent(nullptr); 0028 } 0029 0030 void KDiamond::View::resizeEvent(QResizeEvent *event) 0031 { 0032 Q_UNUSED(event) 0033 //make widget coordinates equal scene coordinates 0034 scene()->setSceneRect(rect()); 0035 setTransform(QTransform()); 0036 } 0037 0038 void KDiamond::View::wheelEvent(QWheelEvent *event) 0039 { 0040 //do not allow wheel events 0041 event->ignore(); 0042 }