File indexing completed on 2024-04-21 04:02:01
0001 /* 0002 KBlackBox - A simple game inspired by an emacs module 0003 0004 SPDX-FileCopyrightText: 2007 Nicolas Roffet <nicolas-kde@roffet.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 0010 0011 #ifndef KBBBALLSGRAPHICWIDGET_H 0012 #define KBBBALLSGRAPHICWIDGET_H 0013 0014 0015 class QGraphicsScene; 0016 #include <QGraphicsView> 0017 #include <QList> 0018 0019 0020 class KBBGraphicsItem; 0021 class KBBThemeManager; 0022 0023 0024 0025 /** 0026 * @brief Widget displaying the number of balls to place on the black box 0027 * 0028 * This is always the number of balls remaining to be placed. If this number is negative because the player placed too many balls, the widget displays how many balls the player should remove from the black box. 0029 */ 0030 class KBBBallsGraphicWidget : public QGraphicsView 0031 { 0032 public: 0033 /** 0034 * @brief Constructor 0035 * 0036 * @param themeManager Pointer to the theme manager to display the right graphic items. 0037 */ 0038 explicit KBBBallsGraphicWidget(KBBThemeManager* themeManager); 0039 0040 /** 0041 * @brief Destructor 0042 * Remove all items displayed on the scene. 0043 */ 0044 ~KBBBallsGraphicWidget(); 0045 0046 0047 /** 0048 * @brief Event: widget has been resized 0049 * This happens for instance when the main window has been resized. 0050 */ 0051 void resizeEvent(QResizeEvent*) override; 0052 0053 /** 0054 * @brief Define the number of balls to place on the black box 0055 * 0056 * This defines also the maximum number of balls (or items) to display on this widget. 0057 * @param ballsToPlace Number of balls to place 0058 */ 0059 void setBallsToPlace(const int ballsToPlace); 0060 0061 /** 0062 * @brief Define the number of balls the player already placed on the board 0063 * 0064 * So the number of balls to display on this widget is "Number of balls to place" - this. (if >=0). 0065 * @param placedBalls Number of balls placed on the black box. 0066 */ 0067 void setPlacedBalls(const int placedBalls); 0068 0069 0070 private: 0071 int m_ballsToPlace; 0072 QList<KBBGraphicsItem*> m_playerBalls; 0073 QGraphicsScene* m_scene; 0074 KBBThemeManager* m_themeManager; 0075 QList<KBBGraphicsItem*> m_wrongPlayerBalls; 0076 }; 0077 0078 #endif // KBBBALLSGRAPHICWIDGET_H