-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
executable file
·72 lines (56 loc) · 1.68 KB
/
Copy pathmainwindow.cpp
File metadata and controls
executable file
·72 lines (56 loc) · 1.68 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
#include "mainwindow.h"
#include "QGraphicsView"
#include "sweepscene.h"
#include <QMenu>
#include <QMenuBar>
#include "data.h"
#include "sweepview.h"
#include <QDebug>
#include <QMouseEvent>
#include <QInputDialog>
#include <QLineEdit>
#include <QDateTime>
#include <QGraphicsSimpleTextItem>
MainWindow::MainWindow(QWidget *parent)
:QMainWindow(parent)
{
initMenu();
initGraphics();
}
void MainWindow::initMenu()
{
QMenu *gameMenu = this->menuBar()->addMenu("游戏(&G)");
gameMenu->addAction("开始(&S)",this,SLOT(startSlot())\
,QKeySequence("Ctrl+b"));
QMenu *difficultyMenu = gameMenu->addMenu("难度");
QAction* common = difficultyMenu->addAction("普通");
common->setCheckable(true);
common->setChecked(true);
QAction* mid = difficultyMenu->addAction("中等");
mid->setCheckable(true);
QAction* hard = difficultyMenu->addAction("难");
hard->setCheckable(true);
gameMenu->addAction("退出(&E)",this,SLOT(close()));
QActionGroup *group = new QActionGroup(this);
group->addAction(common);
group->addAction(mid);
group->addAction(hard);
}
void MainWindow::startSlot()
{
Data::dis()->setStatus(G_runnig);
initGraphics();
}
void MainWindow::initGraphics()
{
SweepView * view = new SweepView(this);
SweepScene * _scene = new SweepScene(view);
view->setScene(_scene);
view->setSizeIncrement(Data::dis()->getRow()*Data::dis()->getCellWidth()\
,Data::dis()->getColumn()*Data::dis()->getCellWidth());
this->setCentralWidget(view);
}
MainWindow::~MainWindow()
{
Data::realease();
}