File indexing completed on 2024-04-28 04:04:47
0001 /*************************************************************************** 0002 * Copyright 2005-2007 Francesco Rossi <redsh@email.it> * 0003 * Copyright 2006-2007 Mick Kappenburg <ksudoku@kappendburg.net> * 0004 * Copyright 2006-2007 Johannes Bergmeier <johannes.bergmeier@gmx.net> * 0005 * Copyright 2012 Ian Wadham <iandw.au@gmail.com> * 0006 * Copyright 2015 Ian Wadham <iandw.au@gmail.com> * 0007 * * 0008 * This program is free software; you can redistribute it and/or modify * 0009 * it under the terms of the GNU General Public License as published by * 0010 * the Free Software Foundation; either version 2 of the License, or * 0011 * (at your option) any later version. * 0012 * * 0013 * This program is distributed in the hope that it will be useful, * 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0016 * GNU General Public License for more details. * 0017 * * 0018 * You should have received a copy of the GNU General Public License * 0019 * along with this program; if not, write to the * 0020 * Free Software Foundation, Inc., * 0021 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0022 ***************************************************************************/ 0023 0024 #ifndef _KSUDOKU_H_ 0025 #define _KSUDOKU_H_ 0026 0027 #include <QUrl> 0028 #include <QTime> 0029 #include <KXmlGuiWindow> 0030 #if 0 0031 #include <knewstuff/knewstuff.h> 0032 #endif 0033 0034 class KGameDifficultyLevel; 0035 0036 namespace ksudoku { 0037 class KsView; 0038 class GameActions; 0039 class GameVariantCollection; 0040 class ValueListWidget; 0041 class WelcomeScreen; 0042 class Game; 0043 class Puzzle; 0044 } 0045 0046 class PuzzlePrinter; 0047 0048 /** 0049 * This class serves as the main window for ksudoku. It handles the 0050 * menus, toolbars, and status bars. 0051 * 0052 * @short Main window class 0053 * @author Francesco Rossi <redsh@email.it> 0054 * @version 0.3 0055 */ 0056 0057 class KSudoku; 0058 0059 #if 0 0060 class KSudokuNewStuff : public KNewStuff 0061 { 0062 public: 0063 KSudoku* parent; 0064 public: 0065 KSudokuNewStuff(KSudoku* p); 0066 bool install( const QString &fileName ); 0067 bool createUploadFile( const QString &fileName ); 0068 }; 0069 #endif 0070 0071 class KSudoku : public KXmlGuiWindow 0072 { 0073 Q_OBJECT 0074 0075 public: 0076 /** 0077 * Default Constructor 0078 */ 0079 KSudoku(); 0080 0081 /** 0082 * Default Destructor 0083 */ 0084 ~KSudoku() override; 0085 0086 void loadGame(const QUrl& url); 0087 0088 public: 0089 void updateShapesList(); 0090 0091 ksudoku::Game currentGame() const; 0092 ksudoku::KsView* currentView() const; 0093 0094 protected: 0095 void dragEnterEvent(QDragEnterEvent *event) override; 0096 void dropEvent(QDropEvent *event) override; 0097 0098 public Q_SLOTS: 0099 void onCompleted(bool isCorrect, QTime required, bool withHelp = false); 0100 0101 void showWelcomeScreen(); 0102 0103 void startGame(const ::ksudoku::Game& game); 0104 void endCurrentGame(); 0105 0106 bool queryClose() override; 0107 0108 private Q_SLOTS: 0109 void handleCurrentDifficultyLevelChanged(const KGameDifficultyLevel *level); 0110 void symmetryChanged (int symmetry); 0111 0112 void gameNew(); 0113 void gameRestart(); 0114 void gameOpen(); 0115 void gameSave(); 0116 void gameSaveAs(); 0117 void gamePrint(); 0118 void gameExport(); 0119 0120 void undo(); 0121 void redo(); 0122 void push(); 0123 void pop(); 0124 0125 void giveHint(); 0126 void autoSolve(); 0127 void dubPuzzle(); 0128 void genMultiple(); 0129 0130 void optionsPreferences(); 0131 void updateSettings(); 0132 void changeCaption(const QString& text); 0133 // void updateStatusBar(); 0134 // void changeStatusbar(const QString& text); 0135 0136 void onModified(bool isModified); 0137 0138 void enableMessages(); 0139 0140 Q_SIGNALS: 0141 void settingsChanged(); 0142 0143 private: 0144 void setupActions(); 0145 void setupStatusBar(int difficulty, int symmetry); 0146 0147 void adaptActions2View(); 0148 0149 private: 0150 QWidget* wrapper; 0151 0152 QAction* m_gameSave; 0153 QAction* m_gameSaveAs; 0154 0155 ksudoku::GameVariantCollection* m_gameVariants; 0156 ksudoku::WelcomeScreen* m_welcomeScreen; 0157 0158 QWidget* m_gameWidget; 0159 ksudoku::ValueListWidget* m_valueListWidget; 0160 0161 ksudoku::KsView* m_gameUI; 0162 0163 ksudoku::GameActions* m_gameActions; 0164 0165 PuzzlePrinter * m_puzzlePrinter; 0166 }; 0167 0168 #endif // _KSUDOKU_H_ 0169