SVN_SILENT: minor refactoring
[kdegames.git] / knetwalk / src / mainwindow.h
blobd95e24112cdd2fd132e339e09b264231cb08d8bd
1 /*
2 Copyright 2004-2005 Andi Peredri <andi@ukr.net>
3 Copyright 2007 Simon Hürlimann <simon.huerlimann@huerlisi.ch>
4 Copyright 2007-2008 Fela Winkelmolen <fela.kde@gmail.com>
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef MAINWINDOW_H
21 #define MAINWINDOW_H
23 #include <KXmlGuiWindow>
24 #include <KSvgRenderer>
26 #include <QList>
28 class Cell;
29 class QAction;
30 class QSound;
31 class QLCDNumber;
32 class QCloseEvent;
33 class QResizeEvent;
34 class QPixmap;
35 class QGridLayout;
37 class MainWindow : public KXmlGuiWindow
39 Q_OBJECT
40 public:
41 explicit MainWindow(QWidget *parent=0);
42 virtual ~MainWindow();
44 static int boardSize();
46 protected:
47 void setupActions();
48 void createBoard();
49 virtual void closeEvent(QCloseEvent*);
50 virtual void paintEvent(QPaintEvent*);
51 virtual void resizeEvent(QResizeEvent*);
53 private:
54 enum BoardSize {
55 NoviceBoardSize = 5,
56 NormalBoardSize = 7,
57 ExpertBoardSize = 9,
58 MasterBoardSize = 9
61 enum {
62 NumHighscores = 10,
63 MinimumNumCells = 20
65 typedef QList<Cell*> CellList;
67 private slots:
68 void startNewGame();
70 void lClicked(int index);
71 void rClicked(int index);
72 void mClicked(int index);
74 void showHighscores();
75 void configureNotifications();
76 void updateConnections();
78 private:
79 Cell* uCell(Cell* cell) const;
80 Cell* dCell(Cell* cell) const;
81 Cell* lCell(Cell* cell) const;
82 Cell* rCell(Cell* cell) const;
83 void checkIfGameEnded();
84 bool startBrowser(const QString& url);
85 void blink(int index);
86 void rotate(int index, bool clockWise);
87 void dialog(const QString& caption, const QString& text);
88 void setBoardSize(int size);
90 private:
91 bool wrapped;
92 bool gameEnded;
93 Cell* root;
94 Cell* board[MasterBoardSize * MasterBoardSize];
95 QGridLayout* gridLayout;
97 QSound* clicksound;
98 QSound* connectsound;
99 QSound* startsound;
100 QSound* turnsound;
101 QSound* winsound;
103 QString username;
104 QString soundpath;
105 QAction* soundaction;
106 QStringList highscores;
107 QLCDNumber* lcd;
109 int m_clickcount;
111 QPixmap *pixmapCache;
112 bool m_invalidCache;
115 #endif // MAINWINDOW_H