File indexing completed on 2024-05-12 08:00:35

0001 /*
0002  * Copyright (C) 1995 Paul Olav Tvete <paul@troll.no>
0003  * Copyright (C) 1997 Mario Weilguni <mweilguni@sime.com>
0004  * Copyright (C) 2000-2009 Stephan Kulow <coolo@kde.org>
0005  * Copyright (C) 2009 Parker Coates <coates@kde.org>
0006  *
0007  * License of original code:
0008  * -------------------------------------------------------------------------
0009  *   Permission to use, copy, modify, and distribute this software and its
0010  *   documentation for any purpose and without fee is hereby granted,
0011  *   provided that the above copyright notice appear in all copies and that
0012  *   both that copyright notice and this permission notice appear in
0013  *   supporting documentation.
0014  *
0015  *   This file is provided AS IS with no warranties of any kind.  The author
0016  *   shall have no liability with respect to the infringement of copyrights,
0017  *   trade secrets or any patents by this file or any part thereof.  In no
0018  *   event will the author be liable for any lost revenue or profits or
0019  *   other special, indirect and consequential damages.
0020  * -------------------------------------------------------------------------
0021  *
0022  * License of modifications/additions made after 2009-01-01:
0023  * -------------------------------------------------------------------------
0024  *   This program is free software; you can redistribute it and/or
0025  *   modify it under the terms of the GNU General Public License as
0026  *   published by the Free Software Foundation; either version 2 of
0027  *   the License, or (at your option) any later version.
0028  *
0029  *   This program is distributed in the hope that it will be useful,
0030  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0031  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0032  *   GNU General Public License for more details.
0033  *
0034  *   You should have received a copy of the GNU General Public License
0035  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
0036  * -------------------------------------------------------------------------
0037  */
0038 
0039 #ifndef MAINWINDOW_H
0040 #define MAINWINDOW_H
0041 
0042 // KF
0043 #include <KXmlGuiWindow>
0044 // Qt
0045 #include <QMap>
0046 
0047 class DealerInfo;
0048 class DealerScene;
0049 class GameSelectionScene;
0050 class NumberedDealDialog;
0051 class PatienceView;
0052 class SoundEngine;
0053 
0054 class KCardDeck;
0055 
0056 class QAction;
0057 class KRecentFilesAction;
0058 class KToggleAction;
0059 class QUrl;
0060 
0061 class QLabel;
0062 
0063 #define saved_state_file "savedstate.xml"
0064 
0065 class MainWindow : public KXmlGuiWindow
0066 {
0067     Q_OBJECT
0068 
0069 public:
0070     MainWindow();
0071     ~MainWindow();
0072 
0073 public Q_SLOTS:
0074     bool loadGame(const QUrl &url, bool addToRecentFiles);
0075     void slotShowGameSelectionScreen();
0076     void slotGameSelected(int id);
0077 
0078 protected Q_SLOTS:
0079     void newGame();
0080     void startRandom();
0081     void loadGame();
0082     void loadGame(const QUrl &url);
0083     void restart();
0084     void newNumberedDeal();
0085     void startNumbered(int gameId, int dealNumber);
0086     void nextDeal();
0087     void previousDeal();
0088     void saveGame();
0089     void showStats();
0090 
0091     void undoMove();
0092     void redoMove();
0093 
0094     void toggleDrop();
0095     void toggleHints();
0096     void toggleDemo();
0097     void toggleDemoAction(bool active);
0098     void toggleMenubar();
0099     void toggleFullscreen(bool fullScreen);
0100 
0101     void setAutoDropEnabled(bool enabled);
0102     void enableSolver(bool enable);
0103     void enableSounds(bool enable);
0104     void enableRememberState(bool enable);
0105     void slotPickRandom();
0106     void configureAppearance();
0107     void appearanceChanged();
0108 
0109     void helpGame();
0110 
0111     void updateSolverDescription(const QString &text);
0112     void slotUpdateMoves(int moves);
0113 
0114 protected:
0115     void closeEvent(QCloseEvent *e) override;
0116     void saveNewToolbarConfig() override;
0117 
0118 private Q_SLOTS:
0119     void slotSnapshot();
0120     void slotSnapshot2();
0121     void generateThemePreview();
0122 
0123 private:
0124     void setupActions();
0125     void setGameType(int id);
0126     void setGameCaption();
0127     void startNew(int gameNumber);
0128     void updateActions();
0129     void updateGameActionList();
0130     void updateSoundEngine();
0131 
0132     // Members
0133     QAction *m_leftAction;
0134     QAction *m_rightAction;
0135     QAction *m_upAction;
0136     QAction *m_downAction;
0137     QAction *m_cancelAction;
0138     QAction *m_pickUpSetDownAction;
0139 
0140     KRecentFilesAction *m_recentFilesAction;
0141     QAction *m_saveAction;
0142     QAction *m_undoAction;
0143     QAction *m_redoAction;
0144     QAction *m_demoAction;
0145     QAction *m_hintAction;
0146     QAction *m_drawAction;
0147     QAction *m_dealAction;
0148     QAction *m_redealAction;
0149     QAction *m_dropAction;
0150     KToggleAction *m_autoDropEnabledAction;
0151     KToggleAction *m_solverEnabledAction;
0152     KToggleAction *m_rememberStateAction;
0153     KToggleAction *m_playSoundsAction;
0154     KToggleAction *m_showMenubarAction;
0155     QAction *m_gameHelpAction;
0156 
0157     QMap<int, const DealerInfo *> m_dealer_map;
0158     QMap<int, const DealerInfo *>::const_iterator m_dealer_it;
0159 
0160     PatienceView *m_view;
0161     DealerScene *m_dealer;
0162     GameSelectionScene *m_selector;
0163     KCardDeck *m_cardDeck;
0164     SoundEngine *m_soundEngine;
0165 
0166     NumberedDealDialog *m_dealDialog;
0167 
0168     QLabel *m_solverStatusLabel;
0169     QLabel *m_moveCountStatusLabel;
0170 };
0171 
0172 #endif