1 /* 2 SPDX-FileCopyrightText: 2009-2014 Graeme Gott <graeme@gottcode.org> 3 4 SPDX-License-Identifier: GPL-3.0-or-later 5 */ 6 7 #ifndef TANGLET_LANGUAGE_DIALOG_H 8 #define TANGLET_LANGUAGE_DIALOG_H 9 10 #include <QDialog> 11 class QAbstractButton; 12 class QCheckBox; 13 class QComboBox; 14 class QDialogButtonBox; 15 class QLineEdit; 16 class QPushButton; 17 18 /** 19 * @brief The LanguageDialog class allows the player to choose the board language. 20 */ 21 class LanguageDialog : public QDialog 22 { 23 Q_OBJECT 24 25 public: 26 /** 27 * Constructs a language dialog. 28 * @param parent the QWidget that manages the dialog 29 */ 30 LanguageDialog(QWidget* parent = nullptr); 31 32 /** 33 * Migrates old board language settings to the new location. It also removes the settings if 34 * they are merely the defaults. 35 */ 36 static void restoreDefaults(); 37 38 public slots: 39 /** 40 * Saves the new language settings. 41 */ 42 void accept() override; 43 44 private slots: 45 /** 46 * Checks if the player has activated the clear button and resets if they have. 47 * @param button which dialog button the player activated 48 */ 49 void clicked(QAbstractButton* button); 50 51 /** 52 * Sets the default placeholder text of the dice, words, and dictionary to that of the language. 53 * @param index which language settings to load 54 */ 55 void chooseLanguage(int index); 56 57 /** 58 * Pops up a dialog for the player to browse the filesystem for a dice file. 59 */ 60 void browseDice(); 61 62 /** 63 * Sets the value of the custom dice file, or resets if they have chosen the default value for 64 * the dice by blanking the field. 65 * @param dice the file for the custom dice. 66 */ 67 void chooseDice(const QString& dice); 68 69 /** 70 * Pops up a dialog for the player to browse the filesystem for a word list. 71 */ 72 void browseWords(); 73 74 /** 75 * Sets the value of the custom word list, or resets if they have chosen the default value for 76 * the word list by blanking the field. 77 * @param words the file for the custom word list. 78 */ 79 void chooseWords(const QString& words); 80 81 private: 82 /** 83 * Sets the placeholder language by language ID instead of index in combobox. 84 * @param language the language to load the settings from 85 */ 86 void setLanguage(const QString& language); 87 88 private: 89 QComboBox* m_language; /**< the language selector */ 90 QString m_dice_path; /**< location of custom dice */ 91 QLineEdit* m_dice; /**< entry for custom dice */ 92 QString m_words_path; /**< location of custom word list */ 93 QLineEdit* m_words; /**< entry for custom word list */ 94 QLineEdit* m_dictionary; /**< entry for custom dictionary */ 95 96 QDialogButtonBox* m_buttons; /**< buttons to control dialog */ 97 }; 98 99 #endif // TANGLET_LANGUAGE_DIALOG_H 100