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_NEW_GAME_DIALOG_H
8 #define TANGLET_NEW_GAME_DIALOG_H
9 
10 #include <QDialog>
11 class QAbstractButton;
12 class QCommandLinkButton;
13 class QComboBox;
14 class QDialogButtonBox;
15 class QScrollArea;
16 class QToolButton;
17 
18 /**
19  * @brief The NewGameDialog class allows the player to choose the new game settings.
20  */
21 class NewGameDialog : public QDialog
22 {
23 	Q_OBJECT
24 
25 public:
26 	/**
27 	 * Constructs a new game dialog.
28 	 * @param parent the QWidget that manages the dialog
29 	 */
30 	NewGameDialog(QWidget* parent = nullptr);
31 
32 	/**
33 	 * Fetch the description of an amount of words.
34 	 * @param density the word range
35 	 * @return the translated description of a word density range
36 	 */
37 	static QString densityString(int density);
38 
39 private slots:
40 	/**
41 	 * Tracks the length of the shortest allowed word.
42 	 * @param length the player selected word length
43 	 */
44 	void lengthChanged(int length);
45 
46 	/**
47 	 * Adjusts the range of minimum length words when the board size is changed.
48 	 */
49 	void sizeChanged();
50 
51 	/**
52 	 * The player has chosen a timer so the settings are stored.
53 	 * @param timer which timer mode the player has chosen
54 	 */
55 	void timerChosen(int timer);
56 
57 	/**
58 	 * Checks if the player has activated the restore button and resets if they have.
59 	 * @param button which dialog button the player activated
60 	 */
61 	void restoreDefaults(QAbstractButton* button);
62 
63 private:
64 	QToolButton* m_normal_size; /**< option for a normal board */
65 	QToolButton* m_large_size; /**< option for a large board */
66 	QComboBox* m_density; /**< option to select the amount of words on the board */
67 	QComboBox* m_length; /**< option to select minimum word length */
68 	int m_minimum; /**< length of the shortest word allowed */
69 	QScrollArea* m_timers_area; /**< scrollarea containing timer buttons */
70 	QList<QCommandLinkButton*> m_timers; /**< actions to choose timer mode and start game */
71 	QDialogButtonBox* m_buttons; /**< buttons to control dialog */
72 };
73 
74 #endif // TANGLET_NEW_GAME_DIALOG_H
75