-
Notifications
You must be signed in to change notification settings - Fork 19
/
iqpuzzle.h
135 lines (120 loc) · 3.55 KB
/
iqpuzzle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/**
* \file iqpuzzle.h
*
* \section LICENSE
*
* Copyright (C) 2012-present Thorsten Roth
*
* This file is part of iQPuzzle.
*
* iQPuzzle is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iQPuzzle is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with iQPuzzle. If not, see <https://www.gnu.org/licenses/>.
*
* \section DESCRIPTION
* Class definition main application.
*/
#ifndef IQPUZZLE_H_
#define IQPUZZLE_H_
#include <QDir>
#include <QMainWindow>
#include <QTime>
#include <QTranslator>
class QLabel;
class QGraphicsScene;
class QGraphicsTextItem;
class QGraphicsView;
class QTimer;
class Board;
class BoardSelection;
class Highscore;
class Settings;
namespace Ui {
class IQPuzzle;
}
/**
* \class IQPuzzle
* \brief Main application definition (GUI, objects, etc.)
*/
class IQPuzzle : public QMainWindow {
Q_OBJECT
public:
explicit IQPuzzle(const QDir &userDataDir, const QDir &sharePath,
QWidget *pParent = nullptr);
~IQPuzzle();
protected:
void changeEvent(QEvent *pEvent) override;
void resizeEvent(QResizeEvent *pEvent) override;
public slots:
void setMinWindowSize(const QSize size = QSize(),
const bool bFreestyle = false);
signals:
void updateUiLang();
void checkHighscore(const QString &sBoard, const quint32 nMoves,
const QTime tTime);
private slots:
void loadLanguage(const QString &sLang);
void startNewGame(QString sBoardFile = QLatin1String(""),
const QString &sSavedGame = QLatin1String(""),
const QString &sTime = QLatin1String(""),
const QString &sMoves = QLatin1String(""));
void randomGame(const int nChoice);
void restartGame();
void loadGame(QString sSaveFile = QLatin1String(""));
void saveGame();
void pauseGame(const bool bPaused);
void solvedPuzzle();
void showStatistics();
void showInfoBox();
private:
void createBoard();
auto chooseBoard() -> QString;
static auto switchTranslator(QTranslator *translator, const QString &sFile,
const QString &sPath = QLatin1String(""))
-> bool;
void setupMenu();
void setGameTitle();
void generateFileLists();
Ui::IQPuzzle *m_pUi;
QTranslator m_translator; // App translations
QTranslator m_translatorQt; // Qt translations
QString m_sCurrLang;
QGraphicsView *m_pGraphView;
QGraphicsScene *m_pScenePaused;
BoardSelection *m_pBoardSelection;
Board *m_pBoard;
QString m_sBoardFile;
QString m_sSavedGame;
const QDir m_userDataDir;
const QString m_sSharePath;
QLabel *m_pStatusLabelTime;
QLabel *m_pStatusLabelMoves;
quint32 m_nMoves;
QString m_sSavedTime;
QString m_sSavedMoves;
QTime m_Time;
QTimer *m_pTimer;
QGraphicsTextItem *m_pTextPaused;
bool m_bSolved;
Highscore *m_pHighscore;
Settings *m_pSettings;
QList<QStringList *> m_sListFiles;
QStringList m_sListAll;
QStringList m_sListAllUnsolved;
QStringList m_sListEasy;
QStringList m_sListEasyUnsolved;
QStringList m_sListMedium;
QStringList m_sListMediumUnsolved;
QStringList m_sListHard;
QStringList m_sListHardUnsolved;
};
#endif // IQPUZZLE_H_