-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgridsizescreen.cpp
More file actions
145 lines (125 loc) · 4.04 KB
/
gridsizescreen.cpp
File metadata and controls
145 lines (125 loc) · 4.04 KB
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
136
137
138
139
140
141
142
143
144
145
//AUTHORS: Matt Dumford
#include "gridsizescreen.h"
#include "playscreen.h"
#include <QFont>
#include <QDebug>
// The grid size screen is used to get a size for the singleplayer play grid
// it uses 8 qpushbuttons with the respective grid size
GridSizeScreen::GridSizeScreen(MainWindow *mainWindow, QWidget *parent) : QWidget(parent)
{
this->mainWindow = mainWindow;
}
GridSizeScreen::GridSizeScreen(QString path, MainWindow *mainWindow, QWidget *parent) : QWidget(parent)
{
this->mainWindow = mainWindow;
this->path = path;
}
void GridSizeScreen::display(int screenWidth, int screenHeight)
{
this->screenWidth = screenWidth;
this->screenHeight = screenHeight;
//make the layout and a label for instructions
this->resize(screenWidth, screenHeight);
QGridLayout *layout = new QGridLayout(this);
this->setLayout(layout);
QFont font("Helvetica", 13);
QLabel *label = new QLabel("Please choose a grid size.");
label->setFont(font);
layout->addWidget(label,0,0,1,2);
//make the buttons
QPushButton *b3 = new QPushButton("3X3");
QPushButton *b4 = new QPushButton("4X4");
QPushButton *b5 = new QPushButton("5X5");
QPushButton *b6 = new QPushButton("6X6");
QPushButton *b7 = new QPushButton("7X7");
QPushButton *b8 = new QPushButton("8X8");
QPushButton *b9 = new QPushButton("9X9");
QPushButton *b10 = new QPushButton("10X10");
//set the fonts for the buttons
b3->setFont(font);
b4->setFont(font);
b5->setFont(font);
b6->setFont(font);
b7->setFont(font);
b8->setFont(font);
b9->setFont(font);
b10->setFont(font);
//resize the buttons
b3->setFixedHeight(screenHeight/5);
b4->setFixedHeight(screenHeight/5);
b5->setFixedHeight(screenHeight/5);
b6->setFixedHeight(screenHeight/5);
b7->setFixedHeight(screenHeight/5);
b8->setFixedHeight(screenHeight/5);
b9->setFixedHeight(screenHeight/5);
b10->setFixedHeight(screenHeight/5);
//add the buttons to the layout
layout->addWidget(b3, 1,0);
layout->addWidget(b4, 1,1);
layout->addWidget(b5, 2,0);
layout->addWidget(b6, 2,1);
layout->addWidget(b7, 3,0);
layout->addWidget(b8, 3,1);
layout->addWidget(b9, 4,0);
layout->addWidget(b10, 4,1);
//connect the buttons to their slots
connect(b3, SIGNAL(clicked()), this, SLOT(b3Pushed()));
connect(b4, SIGNAL(clicked()), this, SLOT(b4Pushed()));
connect(b5, SIGNAL(clicked()), this, SLOT(b5Pushed()));
connect(b6, SIGNAL(clicked()), this, SLOT(b6Pushed()));
connect(b7, SIGNAL(clicked()), this, SLOT(b7Pushed()));
connect(b8, SIGNAL(clicked()), this, SLOT(b8Pushed()));
connect(b9, SIGNAL(clicked()), this, SLOT(b9Pushed()));
connect(b10, SIGNAL(clicked()), this, SLOT(b10Pushed()));
this->show();
this->raise();
qDebug() << "end of display.";
}
void GridSizeScreen::b3Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow, mainWindow);
ps->display(screenWidth, screenHeight, 3);
ps->raise();
}
void GridSizeScreen::b4Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow);
ps->display(screenWidth, screenHeight, 4);
ps->raise();
}
void GridSizeScreen::b5Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow);
ps->display(screenWidth, screenHeight, 5);
ps->raise();
}
void GridSizeScreen::b6Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow);
ps->display(screenWidth, screenHeight, 6);
ps->raise();
}
void GridSizeScreen::b7Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow);
ps->display(screenWidth, screenHeight, 7);
ps->raise();
}
void GridSizeScreen::b8Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow);
ps->display(screenWidth, screenHeight, 8);
ps->raise();
}
void GridSizeScreen::b9Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow);
ps->display(screenWidth, screenHeight, 9);
ps->raise();
}
void GridSizeScreen::b10Pushed()
{
PlayScreen *ps = new PlayScreen(path, mainWindow);
ps->display(screenWidth, screenHeight, 10);
ps->raise();
}