Cute Chess 0.1
piecechooser.h
1/*
2 This file is part of Cute Chess.
3 Copyright (C) 2008-2018 Cute Chess authors
4
5 Cute Chess is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Cute Chess is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef PIECECHOOSER_H
20#define PIECECHOOSER_H
21
22#include <QGraphicsObject>
23#include <QList>
24class GraphicsPiece;
25class QAbstractAnimation;
26namespace Chess { class Piece; }
27
28
35class PieceChooser : public QGraphicsObject
36{
37 Q_OBJECT
38
39 public:
41 enum { Type = UserType + 2 };
42
56 qreal squareSize,
57 QGraphicsItem* parent = nullptr);
58
59 // Inherited from QGraphicsObject
60 virtual int type() const;
61 virtual QRectF boundingRect() const;
62 virtual void paint(QPainter* painter,
63 const QStyleOptionGraphicsItem* option,
64 QWidget* widget = nullptr);
65
67 void cancelChoice();
68
69 public slots:
71 void reveal();
73 void destroy();
74
75 signals:
84 void pieceChosen(const Chess::Piece& piece);
85
86 protected:
87 // Inherited from QGraphicsObject
88 virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
89
90 private:
91 qreal m_squareSize;
92 QRectF m_rect;
93 QList<GraphicsPiece*> m_pieces[2];
94 QAbstractAnimation* m_anim;
95};
96
97#endif // PIECECHOOSER_H
A chess piece.
Definition piece.h:41
A graphical representation of a chess piece.
Definition graphicspiece.h:38
PieceChooser(const QList< GraphicsPiece * > &pieces, qreal squareSize, QGraphicsItem *parent=nullptr)
Definition piecechooser.cpp:10
void cancelChoice()
Definition piecechooser.cpp:58
void destroy()
Definition piecechooser.cpp:109
void reveal()
Definition piecechooser.cpp:64
void pieceChosen(const Chess::Piece &piece)