1 /***********************************************************************
2  *
3  * Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2017 Graeme Gott <graeme@gottcode.org>
4  *
5  * This program 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  * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  ***********************************************************************/
19 
20 #ifndef PREFERENCES_H
21 #define PREFERENCES_H
22 
23 #include "ranged_int.h"
24 #include "ranged_string.h"
25 #include "settings_file.h"
26 
27 #include <QStringList>
28 
29 class Preferences : public SettingsFile
30 {
31 public:
32 	~Preferences();
33 
instance()34 	static Preferences& instance()
35 	{
36 		static Preferences preferences;
37 		return preferences;
38 	}
39 
40 	RangedInt goalType() const;
41 	RangedInt goalMinutes() const;
42 	RangedInt goalWords() const;
43 	bool goalHistory() const;
44 	bool goalStreaks() const;
45 	RangedInt goalStreakMinimum() const;
46 	void setGoalType(int goal);
47 	void setGoalMinutes(int goal);
48 	void setGoalWords(int goal);
49 	void setGoalHistory(bool enable);
50 	void setGoalStreaks(bool enable);
51 	void setGoalStreakMinimum(int percent);
52 
53 	bool showCharacters() const;
54 	bool showPages() const;
55 	bool showParagraphs() const;
56 	bool showWords() const;
57 	void setShowCharacters(bool show);
58 	void setShowPages(bool show);
59 	void setShowParagraphs(bool show);
60 	void setShowWords(bool show);
61 
62 	RangedInt pageType() const;
63 	RangedInt pageCharacters() const;
64 	RangedInt pageParagraphs() const;
65 	RangedInt pageWords() const;
66 	void setPageType(int type);
67 	void setPageCharacters(int characters);
68 	void setPageParagraphs(int paragraphs);
69 	void setPageWords(int words);
70 
71 	RangedInt wordcountType() const;
72 	void setWordcountType(int type);
73 
74 	bool alwaysCenter() const;
75 	bool blockCursor() const;
76 	bool smoothFonts() const;
77 	bool smartQuotes() const;
78 	int doubleQuotes() const;
79 	int singleQuotes() const;
80 	bool typewriterSounds() const;
81 	void setAlwaysCenter(bool center);
82 	void setBlockCursor(bool block);
83 	void setSmoothFonts(bool smooth);
84 	void setSmartQuotes(bool quotes);
85 	void setDoubleQuotes(int quotes);
86 	void setSingleQuotes(int quotes);
87 	void setTypewriterSounds(bool sounds);
88 
89 	QString sceneDivider() const;
90 	void setSceneDivider(const QString& divider);
91 
92 	bool savePositions() const;
93 	bool writeByteOrderMark() const;
94 	RangedString saveFormat() const;
95 	void setSavePositions(bool save);
96 	void setWriteByteOrderMark(bool write_bom);
97 	void setSaveFormat(const QString& format);
98 
99 	bool alwaysShowScrollBar() const;
100 	void setAlwaysShowScrollbar(bool show_scrollbar);
101 	bool alwaysShowHeader() const;
102 	void setAlwaysShowHeader(bool show_header);
103 	bool alwaysShowFooter() const;
104 	void setAlwaysShowFooter(bool show_footer);
105 
106 	int toolbarStyle() const;
107 	QStringList toolbarActions() const;
108 	void setToolbarStyle(int style);
109 	void setToolbarActions(const QStringList& actions);
110 
111 	bool highlightMisspelled() const;
112 	bool ignoredWordsWithNumbers() const;
113 	bool ignoredUppercaseWords() const;
114 	QString language() const;
115 	void setHighlightMisspelled(bool highlight);
116 	void setIgnoreWordsWithNumbers(bool ignore);
117 	void setIgnoreUppercaseWords(bool ignore);
118 	void setLanguage(const QString& language);
119 
120 private:
121 	Preferences();
122 
123 	void reload();
124 	void write();
125 
126 private:
127 	RangedInt m_goal_type;
128 	RangedInt m_goal_minutes;
129 	RangedInt m_goal_words;
130 	bool m_goal_history;
131 	bool m_goal_streaks;
132 	RangedInt m_goal_streak_minimum;
133 
134 	bool m_show_characters;
135 	bool m_show_pages;
136 	bool m_show_paragraphs;
137 	bool m_show_words;
138 
139 	RangedInt m_page_type;
140 	RangedInt m_page_characters;
141 	RangedInt m_page_paragraphs;
142 	RangedInt m_page_words;
143 
144 	RangedInt m_wordcount_type;
145 
146 	bool m_always_center;
147 	bool m_block_cursor;
148 	bool m_smooth_fonts;
149 	bool m_smart_quotes;
150 	int m_double_quotes;
151 	int m_single_quotes;
152 	bool m_typewriter_sounds;
153 
154 	QString m_scene_divider;
155 
156 	bool m_save_positions;
157 	RangedString m_save_format;
158 	bool m_write_bom;
159 
160 	int m_toolbar_style;
161 	QStringList m_toolbar_actions;
162 
163 	bool m_highlight_misspelled;
164 	bool m_ignore_uppercase;
165 	bool m_ignore_numbers;
166 	QString m_language;
167 
168 	bool m_always_show_scrollbar;
169 	bool m_always_show_header;
170 	bool m_always_show_footer;
171 };
172 
173 #endif
174