File indexing completed on 2024-05-19 04:04:49

0001 /*
0002     SPDX-FileCopyrightText: 2008 Sascha Peilicke <sasch.pe@gmx.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef KIGO_MAINWINDOW_H
0008 #define KIGO_MAINWINDOW_H
0009 
0010 #include <KXmlGuiWindow>
0011 
0012 #include <KNSWidgets/Action>
0013 
0014 class QAction;
0015 class KToggleAction;
0016 class QDockWidget;
0017 class QUndoView;
0018 
0019 namespace Kigo {
0020 
0021 class Game;
0022 class GameScene;
0023 class GameView;
0024 class Player;
0025 class SetupWidget;
0026 
0027 /**
0028  * The MainWindow class acts as the main window for the Kigo graphical
0029  * user interface.
0030  *
0031  * @author Sascha Peilicke <sasch.pe@gmx.de>
0032  * @since 0.1
0033  */
0034 class MainWindow : public KXmlGuiWindow
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039     explicit MainWindow(const QString &fileName = QLatin1String(""), QWidget *parent = nullptr);
0040 
0041 private Q_SLOTS:
0042     void newGame();                         ///< Configure new game
0043     void loadGame();                        ///< Configure loaded game
0044     bool loadGame(const QString &fileName);
0045     void backendError();                    ///<
0046     void saveGame();                        ///< Save current game state
0047     void startGame();                       ///< React on start button
0048     void finishGame();                      ///< Final screen, scores, ...
0049     void undo();                            ///< Undo last move
0050     void redo();                            ///< Redo last move
0051     void pass();                            ///< Pass current move
0052     void hint();                            ///< Show a playing hint
0053     void showPreferences();                 ///< Show configuration dialog
0054     void applyPreferences();                ///< React on changed config
0055     void showBusy(bool busy);               ///< Signal a busy app
0056     void showFinishGameAction();
0057     void playerChanged();
0058     void generateMove();
0059     void passMovePlayed(const Player &);
0060 
0061 private:
0062     void setupActions();
0063     void setupDockWindows();
0064 
0065     bool isBackendWorking();
0066 
0067     Game *m_game;                           ///< Handles complete game state
0068     GameScene *m_gameScene;                 ///< QGraphicsScene for Go board
0069     GameView *m_gameView;                   ///< QGraphicsView for Go board
0070 
0071     SetupWidget *m_setupWidget;             ///< Part of dock widget
0072     QUndoView *m_undoView;                  ///< Part of dock widget
0073 
0074     QDockWidget *m_setupDock;               ///< Game setup dock widget
0075     QDockWidget *m_gameDock;                ///< Game info dock widget
0076     QDockWidget *m_movesDock;               ///< Move history dock widget
0077     QDockWidget *m_errorDock;               ///< Dock shown when errors occur
0078 
0079     QAction *m_newGameAction;
0080     QAction *m_loadGameAction;
0081     KNSWidgets::Action *m_getMoreGamesAction;
0082     QAction *m_saveAction;                  ///< Action to save the current game
0083     QAction *m_undoMoveAction;              ///< Action to jump to the last move
0084     QAction *m_redoMoveAction;              ///< Action to jump to the next move
0085     QAction *m_passMoveAction;              ///< Action to pass current move
0086     QAction *m_hintAction;
0087     QAction *m_startGameAction;
0088     QAction *m_finishGameAction;
0089     KToggleAction *m_moveNumbersAction;
0090 };
0091 
0092 } // End of namespace Kigo
0093 
0094 #endif