Officially at GitHub
[sloppygui.git] / projects / gui / src / mainwindow.h
blob592524704db9cff89e728ef6316f489878366744
1 /*
2 This file is part of Cute Chess.
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.
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.
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/>.
18 #ifndef MAINWINDOW_H
19 #define MAINWINDOW_H
21 #include <QMainWindow>
22 #include <QPointer>
24 namespace Chess { class Board; class Move; }
25 class QMenu;
26 class QAction;
27 class QTextEdit;
28 class QCloseEvent;
29 class QGraphicsView;
30 class QTabBar;
31 class BoardScene;
32 class MoveListModel;
33 class EngineConfigurationModel;
34 class ChessClock;
35 class PlainTextLog;
36 class ChessGame;
38 /**
39 * MainWindow
41 class MainWindow : public QMainWindow
43 Q_OBJECT
45 public:
46 explicit MainWindow(ChessGame* game);
47 virtual ~MainWindow();
48 QString windowListTitle() const;
50 public slots:
51 void addGame(ChessGame* game);
53 protected:
54 virtual void closeEvent(QCloseEvent* event);
56 private slots:
57 void newGame();
58 void gameProperties();
59 void manageEngines();
60 void saveLogToFile();
61 void onWindowMenuAboutToShow();
62 void showGameWindow();
63 void updateWindowTitle();
64 bool save();
65 bool saveAs();
66 void import();
67 void onTabChanged(int index);
68 void onTabCloseRequested(int index);
69 void removeGame(ChessGame* game);
70 void destroyGame(ChessGame* game);
72 private:
73 void createActions();
74 void createMenus();
75 void createToolBars();
76 void createDockWindows();
77 void readSettings();
78 QString genericTitle(ChessGame* game) const;
79 bool saveGame(const QString& fileName);
80 bool askToSave();
81 void setCurrentGame(ChessGame* game);
83 QMenu* m_gameMenu;
84 QMenu* m_viewMenu;
85 QMenu* m_enginesMenu;
86 QMenu* m_windowMenu;
87 QMenu* m_helpMenu;
89 QTabBar* m_tabs;
91 BoardScene* m_boardScene;
92 QGraphicsView* m_boardView;
93 MoveListModel* m_moveListModel;
94 ChessClock* m_chessClock[2];
96 QAction* m_quitGameAct;
97 QAction* m_gamePropertiesAct;
98 QAction* m_newGameAct;
99 QAction* m_closeGameAct;
100 QAction* m_saveGameAct;
101 QAction* m_saveGameAsAct;
102 QAction* m_importGameAct;
103 QAction* m_manageEnginesAct;
104 QAction* m_showGameDatabaseWindowAct;
105 QAction* m_showGameWallAct;
107 PlainTextLog* m_engineDebugLog;
109 QPointer<ChessGame> m_game;
110 QList<ChessGame*> m_games;
112 QString m_currentFile;
113 bool m_closing;
116 #endif // MAINWINDOW_H