4425
|
1 |
#include "mainwindow.h"
|
|
2 |
#include "ui_mainwindow.h"
|
|
3 |
#include "drawmapscene.h"
|
|
4 |
|
|
5 |
MainWindow::MainWindow(QWidget *parent) :
|
|
6 |
QMainWindow(parent),
|
|
7 |
ui(new Ui::MainWindow)
|
|
8 |
{
|
|
9 |
ui->setupUi(this);
|
|
10 |
|
4427
|
11 |
scene = new DrawMapScene(this);
|
4425
|
12 |
ui->graphicsView->setScene(scene);
|
4426
|
13 |
|
|
14 |
connect(ui->pbUndo, SIGNAL(clicked()), scene, SLOT(undo()));
|
4427
|
15 |
connect(scene, SIGNAL(pathChanged()), this, SLOT(scene_pathChanged()));
|
4425
|
16 |
}
|
|
17 |
|
|
18 |
MainWindow::~MainWindow()
|
|
19 |
{
|
|
20 |
delete ui;
|
|
21 |
}
|
|
22 |
|
|
23 |
void MainWindow::changeEvent(QEvent *e)
|
|
24 |
{
|
|
25 |
QMainWindow::changeEvent(e);
|
|
26 |
switch (e->type()) {
|
|
27 |
case QEvent::LanguageChange:
|
|
28 |
ui->retranslateUi(this);
|
|
29 |
break;
|
|
30 |
default:
|
|
31 |
break;
|
|
32 |
}
|
|
33 |
}
|
|
34 |
|
|
35 |
void MainWindow::resizeEvent(QResizeEvent * event)
|
|
36 |
{
|
|
37 |
Q_UNUSED(event);
|
|
38 |
|
|
39 |
if(ui->graphicsView)
|
|
40 |
ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
|
|
41 |
}
|
4427
|
42 |
|
|
43 |
void MainWindow::scene_pathChanged()
|
|
44 |
{
|
4439
|
45 |
QString str = scene->encode().toBase64();
|
|
46 |
ui->plainTextEdit->setPlainText(str);
|
|
47 |
ui->sbBytes->setValue(str.size());
|
4427
|
48 |
}
|
4434
|
49 |
|
|
50 |
void MainWindow::on_pbSimplify_clicked()
|
|
51 |
{
|
4439
|
52 |
scene->simplifyLast();
|
4434
|
53 |
}
|