1 /* ColorCode, a free MasterMind clone with built in solver 2 * Copyright (C) 2009 Dirk Laebisch 3 * http://www.laebisch.com/ 4 * 5 * ColorCode 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 * ColorCode 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 ColorCode. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef SETTINGS_H 20 #define SETTINGS_H 21 22 #include <QSettings> 23 #include <iostream> 24 #include "ccgame.h" 25 26 class Settings : public QObject 27 { 28 Q_OBJECT 29 30 public: 31 Settings(); 32 ~Settings(); 33 34 static const int INDICATOR_LETTER; 35 static const int INDICATOR_NUMBER; 36 37 static const int DEF_COLOR_CNT; 38 static const int DEF_PEG_CNT; 39 static const int DEF_DOUBLES; 40 static const int DEF_LIST_MAX_CNT; 41 42 static const int HIGHSCORE_NO; 43 static const int HIGHSCORE_PROMPT; 44 static const int HIGHSCORE_AUTO; 45 46 static const int MAX_LENGTH_USERNAME; 47 48 void Init(); 49 void InitSettings(); 50 void ReadSettings(); 51 void Validate(); 52 void SaveLastSettings(); 53 void RestoreLastSettings(); 54 void RestoreDefSettings(); 55 void WriteSettings(); 56 57 QMap<QString, QVariant> GetDefaultsMap() const; 58 59 CCGame* GetCurSettingsGame() const; 60 QString GetActiveRowHFg() const; 61 QString GetActiveRowHBg() const; 62 63 QSettings mSettings; 64 65 bool mShowToolBar; 66 bool mShowMenuBar; 67 bool mShowStatusBar; 68 bool mShowTimer; 69 bool mShowTenth; 70 bool mShowGameNo; 71 bool mShowIndicators; 72 int mIndicatorType; 73 bool mHideColors; 74 bool mCustomRowHColor; 75 QString mRowHColorFg; 76 QString mRowHColorBg; 77 78 int mPegCnt; 79 int mColorCnt; 80 bool mDoubles; 81 int mGameMode; 82 bool mAutoClose; 83 bool mAutoHints; 84 int mSolverStrength; 85 int mHintsDelay; 86 QString mPrevGamesStr; 87 QString mSavedGamesStr; 88 QString mHighGamesStr; 89 90 int mGamesListMaxCnt; 91 int mHighScoreHandling; 92 QString mHighScoreUserName; 93 94 public slots: 95 96 signals: 97 void ReadSettingsGamesDone(); 98 99 private: 100 void RestoreSettingsMap(QMap<QString, QVariant> &map); 101 void SaveSettingsMap(QMap<QString, QVariant> &map); 102 QMap<QString, QVariant> mDefMap; 103 QMap<QString, QVariant> mLastMap; 104 }; 105 106 Settings* GetSettings(); 107 108 #endif // SETTINGS_H 109