-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsudoku.h
112 lines (97 loc) · 1.99 KB
/
sudoku.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
#pragma once
#include <QWidget>
#include <QPushButton>
#include <QLineEdit>
#include <QMainWindow>
#include <QStackedWidget>
#include <QGridLayout>
#include <QDebug>
#include <QPainter>
#include <QPaintEvent>
#include <QSpacerItem>
#include <QIntValidator>
#include <QTimer>
#include <QLabel>
#include <QFile>
class CellBtn : public QPushButton
{
Q_OBJECT
public:
CellBtn(QWidget* parent);
int GetDigit() const;
bool IsLocked() const;
void SetDigit(int digit);
void Lock();
void Open();
private slots:
void ChangeDigit();
private:
void mousePressEvent(QMouseEvent*) override;
void resizeEvent(QResizeEvent*) override;
void UpdateColor();
int _digit;
bool _is_open;
};
class Sudoku : public QWidget
{
Q_OBJECT
public:
Sudoku(QWidget* parent);
static bool IsSandboxMode();
public slots:
void Generate(int open_slots_count);
private slots:
void Solve();
void Help();
void ClickedReturnBtn();
void Check();
void Update();
signals:
void ReturnToMenu();
private:
std::pair<int,int> FindError();
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *) override;
QPushButton* _check;
QPushButton* _solve;
QPushButton* _return;
QPushButton* _help;
CellBtn* _cells[9][9];
QTimer* _timer;
uint16_t _seconds;
QLabel* _timer_lbl;
static inline bool _sandbox_mode = false;
int _open_slots_count;
};
class Menu : public QWidget
{
Q_OBJECT
public:
Menu(QWidget* parent);
private:
QPushButton* _play;
QPushButton* _exit;
QLineEdit* _setting;
private slots:
void ClickedPlayBtn();
void ClickedExitBtn();
signals:
void Play(int setting);
void Close();
};
class SdkWindow : public QMainWindow
{
Q_OBJECT
public:
SdkWindow();
private:
Menu* _m;
Sudoku* _sdk;
QStackedWidget* _main_widget;
private slots:
void gotoMenu();
void gotoSudoku(int setting);
void ClickedExitBtn();
signals:
void Close();
};