File indexing completed on 2024-04-21 04:02:11

0001 /*
0002     SPDX-FileCopyrightText: 2012 Viranch Mehta <viranch.mehta@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef CANVASWIDGET_H
0008 #define CANVASWIDGET_H
0009 
0010 // Qt
0011 #include <QQuickWidget>
0012 
0013 class KGameThemeProvider;
0014 
0015 class CanvasWidget : public QQuickWidget
0016 {
0017     Q_OBJECT
0018 public:
0019     explicit CanvasWidget(QWidget *parent = nullptr);
0020     ~CanvasWidget() override;
0021     KGameThemeProvider *getProvider()
0022     {
0023         return m_provider;
0024     }
0025 
0026 Q_SIGNALS:
0027     void levelComplete();
0028     void gameEnded(int score, int level, int elapsedTime);
0029     void focusLost();
0030     void mousePressed();
0031 
0032 public Q_SLOTS:
0033     void fire();
0034     void cheatSkipLevel();
0035     void cheatAddLife();
0036     void setGamePaused(bool paused);
0037     void updateFireShortcut();
0038 
0039 public Q_SLOTS:
0040     void newGame();
0041     void showLine(const QString &line, int lineNumber);
0042     void putGift(const QString &gift, int times, const QString &pos);
0043     void updateBarDirection();
0044     void startGame();
0045     void updateCursor();
0046     void resetMousePosition();
0047 
0048 protected:
0049     void focusOutEvent(QFocusEvent *event) override;
0050     void resizeEvent(QResizeEvent *event) override;
0051     bool event(QEvent *event) override;
0052 
0053 private:
0054     //used when moving the bar with the keys
0055     int m_barDirection;
0056 
0057     // used to track which direction keys are pressed between key events
0058     bool m_rightPressed;
0059     bool m_leftPressed;
0060     KGameThemeProvider *m_provider;
0061 };
0062 
0063 #endif //CANVASWIDGET_H