1 /*
2 	SPDX-FileCopyrightText: 2010-2021 Graeme Gott <graeme@gottcode.org>
3 
4 	SPDX-License-Identifier: GPL-3.0-or-later
5 */
6 
7 #ifndef TANGLET_LANGUAGE_SETTINGS_H
8 #define TANGLET_LANGUAGE_SETTINGS_H
9 
10 class QSettings;
11 
12 #include <QString>
13 
14 /**
15  * @brief The LanguageSettings class defines the set of language settings for game play.
16  */
17 class LanguageSettings
18 {
19 public:
20 	/**
21 	 * Constructs a language instance. Uses system locale to load defaults.
22 	 */
23 	explicit LanguageSettings();
24 
25 	/**
26 	 * Constructs a language instance.
27 	 * @param language what language to load defaults for
28 	 */
29 	explicit LanguageSettings(const QString& language);
30 
31 	/**
32 	 * Constructs a language instance.
33 	 * @param group where to load the language settings
34 	 */
35 	explicit LanguageSettings(const QSettings& group);
36 
37 	/**
38 	 * @return name of QLocale
39 	 */
language()40 	QString language() const
41 	{
42 		return m_language;
43 	}
44 
45 	/**
46 	 * @return path to load dice
47 	 */
dice()48 	QString dice() const
49 	{
50 		return m_dice;
51 	}
52 
53 	/**
54 	 * @return path to load words
55 	 */
words()56 	QString words() const
57 	{
58 		return m_words;
59 	}
60 
61 	/**
62 	 * @return URL to define words
63 	 */
dictionary()64 	QString dictionary() const
65 	{
66 		return m_dictionary;
67 	}
68 
69 private:
70 	/**
71 	 * Load the default values based on m_language as fallbacks.
72 	 */
73 	void loadDefaults();
74 
75 	/**
76 	 * Load the values from the Board group of the settings as fallbacks.
77 	 */
78 	void loadValues();
79 
80 private:
81 	QString m_language; /**< name of QLocale */
82 	QString m_dice; /**< where to load dice */
83 	QString m_words; /**< where to load words */
84 	QString m_dictionary; /**< where to define words */
85 };
86 
87 #endif // TANGLET_LANGUAGE_SETTINGS_H
88