File indexing completed on 2023-05-30 10:40:03
0001 /* 0002 SPDX-FileCopyrightText: 2005-2006 Albert Astals Cid <aacid@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef BLINKEN_H 0008 #define BLINKEN_H 0009 0010 #include <QMap> 0011 #include <KMainWindow> 0012 0013 #include "blinkengame.h" 0014 0015 class QSvgRenderer; 0016 class QTimer; 0017 0018 class KHelpMenu; 0019 0020 class button; 0021 0022 class blinken : public KMainWindow 0023 { 0024 Q_OBJECT 0025 public: 0026 blinken(); 0027 ~blinken() override; 0028 0029 QSize sizeHint() const override; 0030 0031 protected: 0032 void paintEvent(QPaintEvent *) override; 0033 void mouseMoveEvent(QMouseEvent *e) override; 0034 void mousePressEvent(QMouseEvent *e) override; 0035 void keyPressEvent(QKeyEvent *e) override; 0036 void keyReleaseEvent(QKeyEvent *e) override; 0037 0038 private Q_SLOTS: 0039 void checkHS(); 0040 void highlight(blinkenGame::color c, bool unhighlight); 0041 void unhighlight(); 0042 0043 void pressedColor(blinkenGame::color c); 0044 0045 private: 0046 void startGamePressed(); 0047 void startGameAtLevel(int level); 0048 void selectButton(int button); 0049 bool insideGreen(const QPointF &p) const; 0050 bool insideYellow(const QPointF &p) const; 0051 bool insideRed(const QPointF &p) const; 0052 bool insideBlue(const QPointF &p) const; 0053 bool insideButtonsArea(const QPointF &p) const; 0054 void updateCursor(const QPoint &p); 0055 0056 void drawMenuQuit(QPainter &p); 0057 void drawScoreAndCounter(QPainter &p); 0058 void drawStatusText(QPainter &p); 0059 void drawLevel(QPainter &p); 0060 void drawText(QPainter &p, const QString &text, const QPointF ¢er, bool withMargin, double xMargin, double yMargin, QRectF *rect, bool highlight, bool bold); 0061 void updateButtonHighlighting(const QPoint &p); 0062 QPixmap getPixmap(const QString &element, const QSize &imageSize); 0063 0064 void togglePreferences(); 0065 0066 0067 button *m_buttons[4]; 0068 QSvgRenderer *m_renderer; 0069 bool m_overHighscore, m_overQuit, m_overCentralText, m_overMenu, m_overAboutKDE, m_overAboutBlinken, m_overSettings, m_overManual, m_overLevels[3], m_overCentralLetters, m_overCounter, m_overFont, m_overSound; 0070 // i obviously suck but m_levelsRect[0] is 2, m_levelsRect[1] is 1 and m_levelsRect[3] is ? 0071 QRect m_highscoreRect, m_quitRect, m_menuRect, m_aboutKDERect, m_aboutBlinkenRect, m_settingsRect, m_manualRect, m_soundRect, m_fontRect; 0072 QRectF m_centralTextRect, m_levelsRect[3], m_centralLettersRect, m_counterRect; 0073 QColor m_fillColor, m_fontColor, m_fontHighlightColor, m_countDownColor; 0074 0075 // Preferences setting handling 0076 bool m_showPreferences; 0077 0078 // if should update the highlighting after the next repaint 0079 bool m_updateButtonHighlighting; 0080 0081 // use always the non-cool font? 0082 bool m_alwaysUseNonCoolFont; 0083 0084 blinkenGame::color m_highlighted; 0085 QTimer *m_unhighlighter; 0086 0087 QString m_lastName; 0088 0089 blinkenGame m_game; 0090 0091 KHelpMenu *m_helpMenu; 0092 0093 QSize m_lastSize; 0094 QMap<QString, QPixmap> m_pixmapCache; 0095 }; 0096 0097 #endif