Cute Chess 0.1
mainwindow.h
1/*
2 This file is part of Cute Chess.
3 Copyright (C) 2008-2018 Cute Chess authors
4
5 Cute Chess is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Cute Chess is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef MAINWINDOW_H
20#define MAINWINDOW_H
21
22#include <QMainWindow>
23#include <QPointer>
24#include <board/side.h>
25
26namespace Chess {
27 class Board;
28 class Move;
29}
30class QMenu;
31class QAction;
32class QCloseEvent;
33class QTabBar;
34class GameViewer;
35class MoveList;
36class PlainTextLog;
37class PgnGame;
38class ChessGame;
39class ChessPlayer;
40class PgnTagsModel;
41class Tournament;
42class GameTabBar;
43class EvalHistory;
44class EvalWidget;
45
49class MainWindow : public QMainWindow
50{
51 Q_OBJECT
52
53 public:
54 explicit MainWindow(ChessGame* game);
55 virtual ~MainWindow();
56 QString windowListTitle() const;
57
58 public slots:
59 void addGame(ChessGame* game);
60
61 protected:
62 virtual void closeEvent(QCloseEvent* event);
63 void closeCurrentGame();
64
65 private slots:
66 void newGame();
67 void newTournament();
68 void onWindowMenuAboutToShow();
69 void showGameWindow();
70 void updateWindowTitle();
71 void updateMenus();
72 bool save();
73 bool saveAs();
74 void onTabChanged(int index);
75 void onTabCloseRequested(int index);
76 void closeTab(int index);
77 void destroyGame(ChessGame* game);
78 void onTournamentFinished();
79 void onGameManagerFinished();
80 void onGameStartFailed(ChessGame* game);
81 void onGameFinished(ChessGame* game);
82 void editMoveComment(int ply, const QString& comment);
83 void copyFen();
84 void pasteFen();
85 void copyPgn();
86 void showAboutDialog();
87 void closeAllGames();
88 void adjudicateDraw();
89 void adjudicateWhiteWin();
90 void adjudicateBlackWin();
91 void resignGame();
92
93 private:
94 struct TabData
95 {
96 explicit TabData(ChessGame* m_game,
97 Tournament* m_tournament = nullptr);
98
99 ChessGame* m_id;
100 QPointer<ChessGame> m_game;
101 PgnGame* m_pgn;
102 Tournament* m_tournament;
103 bool m_finished;
104 };
105
106 void createActions();
107 void createMenus();
108 void createToolBars();
109 void createDockWindows();
110 void readSettings();
111 void writeSettings();
112 QString genericTitle(const TabData& gameData) const;
113 QString nameOnClock(const QString& name, Chess::Side side) const;
114 void lockCurrentGame();
115 void unlockCurrentGame();
116 bool saveGame(const QString& fileName);
117 bool askToSave();
118 void setCurrentGame(const TabData& gameData);
119 void removeGame(int index);
120 int tabIndex(ChessGame* game) const;
121 int tabIndex(Tournament* tournament, bool freeTab = false) const;
122 void addDefaultWindowMenu();
123 void adjudicateGame(Chess::Side winner);
124
125 QMenu* m_gameMenu;
126 QMenu* m_tournamentMenu;
127 QMenu* m_toolsMenu;
128 QMenu* m_viewMenu;
129 QMenu* m_windowMenu;
130 QMenu* m_helpMenu;
131
132 GameTabBar* m_tabBar;
133
134 GameViewer* m_gameViewer;
135 MoveList* m_moveList;
136 PgnTagsModel* m_tagsModel;
137
138 QAction* m_quitGameAct;
139 QAction* m_newGameAct;
140 QAction* m_adjudicateBlackWinAct;
141 QAction* m_adjudicateWhiteWinAct;
142 QAction* m_adjudicateDrawAct;
143 QAction* m_resignGameAct;
144 QAction* m_closeGameAct;
145 QAction* m_saveGameAct;
146 QAction* m_saveGameAsAct;
147 QAction* m_copyFenAct;
148 QAction* m_pasteFenAct;
149 QAction* m_copyPgnAct;
150 QAction* m_flipBoardAct;
151 QAction* m_newTournamentAct;
152 QAction* m_stopTournamentAct;
153 QAction* m_showTournamentResultsAct;
154 QAction* m_minimizeAct;
155 QAction* m_showGameDatabaseWindowAct;
156 QAction* m_showGameWallAct;
157 QAction* m_showPreviousTabAct;
158 QAction* m_showNextTabAct;
159 QAction* m_aboutAct;
160 QAction* m_showSettingsAct;
161
162 PlainTextLog* m_engineDebugLog;
163
164 EvalHistory* m_evalHistory;
165 EvalWidget* m_evalWidgets[2];
166
167 QPointer<ChessGame> m_game;
168 QPointer<ChessPlayer> m_players[2];
169 QList<TabData> m_tabs;
170
171 QString m_currentFile;
172 bool m_closing;
173 bool m_readyToClose;
174
175 bool m_firstTabAutoCloseEnabled;
176};
177
178#endif // MAINWINDOW_H
Definition chessgame.h:39
A chess player, human or AI.
Definition chessplayer.h:39
An internal chessboard class.
Definition board.h:58
A small and efficient chessmove class.
Definition move.h:43
The side or color of a chess player.
Definition side.h:36
A widget that shows engines' move evaluation history.
Definition evalhistory.h:36
A widget that shows the engine's thinking in realtime.
Definition evalwidget.h:33
Provides a game tab bar for game windows.
Definition gametabbar.h:28
Definition gameviewer.h:40
Definition movelist.h:42
A game of chess in PGN format.
Definition pgngame.h:52
Supplies PGN tag information to views.
Definition pgntagsmodel.h:30
Widget that is used to display log messages in plain text.
Definition plaintextlog.h:31
Base class for chess tournaments.
Definition tournament.h:45