1 /*****************************************************************************
2 * LibreMines *
3 * Copyright (C) 2020-2021 Bruno Bollos Correa *
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
21 #ifndef LIBREMINESPREFERENCESDIALOG_H
22 #define LIBREMINESPREFERENCESDIALOG_H
23
24 #include <QDialog>
25 #include <QtCore>
26
27 namespace Ui {
28 class LibreMinesPreferencesDialog;
29 }
30
31 namespace LibreMines
32 {
33 enum WhenCtrlIsPressedOptions : uchar
34 {
35 GoToTheEdge = 0,
36 Jump3Cells = 1,
37 Jump5Cells = 2,
38 Jump10Cells = 3
39 };
40
41 enum MinefieldGenerationAnimation : uchar
42 {
43 AnimationOn = 0,
44 AnimationLimited = 1,
45 AnimationOff = 2
46 };
47
48 enum AskToSaveMatchScore : uchar
49 {
50 SaveNever = 0x00,
51 SaveWhenNewHighScore = 0x01,
52 SaveWhenGameCompleted = 0x02,
53 SaveAlways = 0x04
54 };
55
56 }
Q_DECLARE_FLAGS(AskToSaveMatchScore,LibreMines::AskToSaveMatchScore)57 Q_DECLARE_FLAGS(AskToSaveMatchScore, LibreMines::AskToSaveMatchScore)
58 Q_DECLARE_OPERATORS_FOR_FLAGS(AskToSaveMatchScore)
59
60 class LibreMinesPreferencesDialog : public QDialog
61 {
62 Q_OBJECT
63
64 public:
65 explicit LibreMinesPreferencesDialog(QWidget *parent = nullptr);
66 ~LibreMinesPreferencesDialog();
67
68 bool optionFirstCellClean()const;
69 bool optionCleanNeighborCellsWhenClickedOnShowedCell()const;
70 bool optionProgressBar()const;
71 QString optionApplicationStyle()const;
72 QString optionMinefieldTheme()const;
73 QString optionFacesReaction()const;
74 QString optionUsername()const;
75 uchar optionWhenCtrlIsPressed()const;
76 int optionMinimumCellLength()const;
77 int optionMaximumCellLength()const;
78 QString optionsLanguage()const;
79 uchar optionMinefieldGenerationAnimation()const;
80 QString optionMinefieldGenerationAnimationString()const;
81 AskToSaveMatchScore optionAskToSaveMatchScoreBehaviour()const;
82
83 void setOptionFirstCellClean(const QString& option);
84 void setOptionCleanNeighborCellsWhenClickedOnShowedCell(const QString& option);
85 void setOptionProgressBar(const QString& option);
86 void setOptionApplicationStyle(const QString& option);
87 void setOptionMinefieldTheme(const QString& option);
88 void setOptionFacesReaction(const QString& option);
89 void setOptionUsername(const QString& username);
90 void setOptionWhenCtrlIsPressed(const uchar option);
91 void setOptionMinimumCellLength(const int option);
92 void setOptionMaximumCellLength(const int option);
93 void setOptionLanguage(const QString& option);
94 void setOptionMinefieldGenerationAnimation(const uchar option);
95 void setOptionMinefieldGenerationAnimation(const QString& option);
96 void setOptionAskToSaveMatchScoreBehaviour(const uchar option);
97
98 QList<int> optionKeyboardControllerKeys()const;
99 QString optionKeyboardControllerKeysString()const;
100 void setOptionKeyboardControllerKeys(const QList<int>& keys);
101
102 protected:
103 void closeEvent(QCloseEvent* e);
104 void hideEvent(QHideEvent* e);
105 void showEvent(QShowEvent* e);
106
107 private:
108 Ui::LibreMinesPreferencesDialog *ui;
109 bool updateLanguageDialog;
110
111 private Q_SLOTS:
112 void SLOT_updateCellLengthParameters();
113 void SLOT_updateLanguage();
114
115 Q_SIGNALS:
116 void SIGNAL_optionChanged(const QString& name, const QString& value);
117 void SIGNAL_visibilityChanged(const bool visible);
118 };
119
120 #endif // LIBREMINESPREFERENCESDIALOG_H
121