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