1/*
2 * Copyright (C) 1995 Paul Olav Tvete <paul@troll.no>
3 * Copyright (C) 1997 Mario Weilguni <mweilguni@sime.com>
4 * Copyright (C) 2000-2009 Stephan Kulow <coolo@kde.org>
5 * Copyright (C) 2009 Parker Coates <coates@kde.org>
6 *
7 * License of original code:
8 * -------------------------------------------------------------------------
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation for any purpose and without fee is hereby granted,
11 * provided that the above copyright notice appear in all copies and that
12 * both that copyright notice and this permission notice appear in
13 * supporting documentation.
14 *
15 * This file is provided AS IS with no warranties of any kind. The author
16 * shall have no liability with respect to the infringement of copyrights,
17 * trade secrets or any patents by this file or any part thereof. In no
18 * event will the author be liable for any lost revenue or profits or
19 * other special, indirect and consequential damages.
20 * -------------------------------------------------------------------------
21 *
22 * License of modifications/additions made after 2009-01-01:
23 * -------------------------------------------------------------------------
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License as
26 * published by the Free Software Foundation; either version 2 of
27 * the License, or (at your option) any later version.
28 *
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 * -------------------------------------------------------------------------
37 */
38
39#ifndef MAINWINDOW_H
40#define MAINWINDOW_H
41
42class DealerInfo;
43class DealerScene;
44class GameSelectionScene;
45class NumberedDealDialog;
46class PatienceView;
47class SoundEngine;
48
49class KCardDeck;
50
51class KAction;
52class KRecentFilesAction;
53class KToggleAction;
54class KUrl;
55#include <KXmlGuiWindow>
56
57class QLabel;
58
59
60class MainWindow: public KXmlGuiWindow {
61 Q_OBJECT
62
63public:
64 MainWindow();
65 ~MainWindow();
66
67public slots:
68 bool loadGame( const KUrl & url, bool addToRecentFiles = true );
69 void slotShowGameSelectionScreen();
70 void slotGameSelected(int id);
71
72protected slots:
73 void newGame();
74 void startRandom();
75 void loadGame();
76 void restart();
77 void newNumberedDeal();
78 void startNumbered( int gameId, int dealNumber );
79 void nextDeal();
80 void previousDeal();
81 void saveGame();
82 void showStats();
83
84 void undoMove();
85 void redoMove();
86
87 void toggleDrop();
88 void toggleHints();
89 void toggleDemo();
90 void toggleDemoAction(bool active);
91 void toggleMenubar();
92
93 void setAutoDropEnabled( bool enabled );
94 void enableSolver(bool enable);
95 void enableSounds(bool enable);
96 void enableRememberState(bool enable);
97 void slotPickRandom();
98 void configureAppearance();
99 void appearanceChanged();
100
101 void helpGame();
102
103 void updateSolverDescription(const QString & text);
104 void slotUpdateMoves(int moves);
105
106protected:
107 virtual void closeEvent(QCloseEvent * e);
108 virtual void saveNewToolbarConfig();
109
110private slots:
111 void slotSnapshot();
112 void slotSnapshot2();
113 void generateThemePreview();
114
115private:
116 void setupActions();
117 void setGameType( int id );
118 void setGameCaption();
119 void startNew(int gameNumber);
120 void updateActions();
121 void updateGameActionList();
122 void updateSoundEngine();
123
124 // Members
125 KAction * m_leftAction;
126 KAction * m_rightAction;
127 KAction * m_upAction;
128 KAction * m_downAction;
129 KAction * m_cancelAction;
130 KAction * m_pickUpSetDownAction;
131
132 KRecentFilesAction * m_recentFilesAction;
133 KAction * m_saveAction;
134 KAction * m_undoAction;
135 KAction * m_redoAction;
136 KAction * m_demoAction;
137 KAction * m_hintAction;
138 KAction * m_drawAction;
139 KAction * m_dealAction;
140 KAction * m_redealAction;
141 KAction * m_dropAction;
142 KToggleAction * m_autoDropEnabledAction;
143 KToggleAction * m_solverEnabledAction;
144 KToggleAction * m_rememberStateAction;
145 KToggleAction * m_playSoundsAction;
146 KToggleAction * m_showMenubarAction;
147 KAction * m_gameHelpAction;
148
149 QMap<int, const DealerInfo*> m_dealer_map;
150 QMap<int, const DealerInfo*>::const_iterator m_dealer_it;
151
152 PatienceView * m_view;
153 DealerScene * m_dealer;
154 GameSelectionScene * m_selector;
155 KCardDeck * m_cardDeck;
156 SoundEngine * m_soundEngine;
157
158 NumberedDealDialog * m_dealDialog;
159
160 QLabel * m_solverStatusLabel;
161 QLabel * m_moveCountStatusLabel;
162};
163
164#endif
165