-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathttkapplication.cpp
61 lines (50 loc) · 1.86 KB
/
ttkapplication.cpp
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
#include "ttkapplication.h"
#include "ttkpaintarea.h"
#include <QMenuBar>
#include <QBoxLayout>
TTKApplication::TTKApplication(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle("TTKApplication");
m_mainWidget = new QWidget(this);
m_area = new TTKPaintArea(m_mainWidget);
QHBoxLayout *hLayout = new QHBoxLayout(m_mainWidget);
hLayout->setSpacing(20);
hLayout->addWidget(m_area);
m_mainWidget->setLayout(hLayout);
QPalette p = palette();
p.setColor(QPalette::Window, Qt::white);
setPalette(p);
setCentralWidget(m_mainWidget);
initialize();
}
TTKApplication::~TTKApplication()
{
delete m_area;
}
void TTKApplication::initialize()
{
// exit Action
QAction *exitAction = new QAction(QIcon(":/data/images/openfile.png"), tr("Exit"), this);
exitAction->setShortcut(tr("Ctrl+X"));
exitAction->setStatusTip(tr("Exit"));
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
//newgame Action
QAction *newAction = new QAction(QIcon(":/data/images/openfile.png"), tr("New"), this);
newAction->setShortcut(tr("Ctrl+N"));
newAction->setStatusTip(tr("New"));
connect(newAction, SIGNAL(triggered()), m_area, SLOT(newGame()));
//nextpair Action
QAction *nextAction = new QAction(QIcon(":/data/images/openfile.png"), tr("Next"), this);
nextAction->setShortcut(tr("Ctrl+D"));
connect(nextAction, SIGNAL(triggered()), m_area, SLOT(nextPair()));
//reset Action
QAction *resetAction = new QAction(QIcon(":/data/images/openfile.png"), tr("Reset"), this);
connect(resetAction, SIGNAL(triggered()), m_area, SLOT(reset()));
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
QMenu *toolMenu = menuBar()->addMenu(tr("Tool"));
fileMenu->addAction(newAction);
fileMenu->addAction(exitAction);
toolMenu->addAction(nextAction);
toolMenu->addAction(resetAction);
}