Cute Chess  0.1
mainwindow.h
1 /*
2  This file is part of Cute Chess.
3 
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.
8 
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.
13 
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/>.
16 */
17 
18 #ifndef MAINWINDOW_H
19 #define MAINWINDOW_H
20 
21 #include <QMainWindow>
22 #include <QPointer>
23 
24 namespace Chess {
25  class Board;
26  class Move;
27 }
28 class QMenu;
29 class QAction;
30 class QCloseEvent;
31 class QTabBar;
32 class GameViewer;
33 class MoveList;
34 class PlainTextLog;
35 class PgnGame;
36 class ChessGame;
37 class ChessPlayer;
38 class PgnTagsModel;
39 class Tournament;
40 class GameTabBar;
41 class EvalHistory;
42 class EvalWidget;
43 
47 class MainWindow : public QMainWindow
48 {
49  Q_OBJECT
50 
51  public:
52  explicit MainWindow(ChessGame* game);
53  virtual ~MainWindow();
54  QString windowListTitle() const;
55 
56  public slots:
57  void addGame(ChessGame* game);
58 
59  protected:
60  virtual void closeEvent(QCloseEvent* event);
61  void closeCurrentGame();
62 
63  private slots:
64  void newGame();
65  void newTournament();
66  void onWindowMenuAboutToShow();
67  void showGameWindow();
68  void updateWindowTitle();
69  bool save();
70  bool saveAs();
71  void onTabChanged(int index);
72  void onTabCloseRequested(int index);
73  void closeTab(int index);
74  void destroyGame(ChessGame* game);
75  void onTournamentFinished();
76  void onGameManagerFinished();
77  void onGameStartFailed(ChessGame* game);
78  void onGameFinished(ChessGame* game);
79  void editMoveComment(int ply, const QString& comment);
80  void copyFen();
81  void showAboutDialog();
82  void closeAllGames();
83 
84  private:
85  struct TabData
86  {
87  explicit TabData(ChessGame* m_game,
88  Tournament* m_tournament = nullptr);
89 
90  ChessGame* m_id;
91  QPointer<ChessGame> m_game;
92  PgnGame* m_pgn;
93  Tournament* m_tournament;
94  bool m_finished;
95  };
96 
97  void createActions();
98  void createMenus();
99  void createToolBars();
100  void createDockWindows();
101  void readSettings();
102  void writeSettings();
103  QString genericTitle(const TabData& gameData) const;
104  void lockCurrentGame();
105  void unlockCurrentGame();
106  bool saveGame(const QString& fileName);
107  bool askToSave();
108  void setCurrentGame(const TabData& gameData);
109  void removeGame(int index);
110  int tabIndex(ChessGame* game) const;
111  int tabIndex(Tournament* tournament, bool freeTab = false) const;
112  void addDefaultWindowMenu();
113 
114  QMenu* m_gameMenu;
115  QMenu* m_tournamentMenu;
116  QMenu* m_toolsMenu;
117  QMenu* m_viewMenu;
118  QMenu* m_windowMenu;
119  QMenu* m_helpMenu;
120 
121  GameTabBar* m_tabBar;
122 
123  GameViewer* m_gameViewer;
124  MoveList* m_moveList;
125  PgnTagsModel* m_tagsModel;
126 
127  QAction* m_quitGameAct;
128  QAction* m_newGameAct;
129  QAction* m_closeGameAct;
130  QAction* m_saveGameAct;
131  QAction* m_saveGameAsAct;
132  QAction* m_copyFenAct;
133  QAction* m_flipBoardAct;
134  QAction* m_newTournamentAct;
135  QAction* m_stopTournamentAct;
136  QAction* m_showTournamentResultsAct;
137  QAction* m_minimizeAct;
138  QAction* m_showGameDatabaseWindowAct;
139  QAction* m_showGameWallAct;
140  QAction* m_showPreviousTabAct;
141  QAction* m_showNextTabAct;
142  QAction* m_aboutAct;
143  QAction* m_showSettingsAct;
144 
145  PlainTextLog* m_engineDebugLog;
146 
147  EvalHistory* m_evalHistory;
148  EvalWidget* m_evalWidgets[2];
149 
150  QPointer<ChessGame> m_game;
151  QPointer<ChessPlayer> m_players[2];
152  QList<TabData> m_tabs;
153 
154  QString m_currentFile;
155  bool m_closing;
156  bool m_readyToClose;
157 };
158 
159 #endif // MAINWINDOW_H
Widget that is used to display log messages in plain text.
Definition: plaintextlog.h:29
A chess player, human or AI.
Definition: chessplayer.h:37
A game of chess in PGN format.
Definition: pgngame.h:51
A widget that shows engines&#39; move evaluation history.
Definition: evalhistory.h:33
Definition: chessgame.h:38
Definition: boardscene.h:28
A widget that shows the engine&#39;s thinking in realtime.
Definition: evalwidget.h:31
Definition: gameviewer.h:38
Provides a game tab bar for game windows.
Definition: gametabbar.h:26
Definition: movelist.h:40
Base class for chess tournaments.
Definition: tournament.h:44
Supplies PGN tag information to views.
Definition: pgntagsmodel.h:28
Definition: mainwindow.h:47