19 #include <QGridLayout> |
19 #include <QGridLayout> |
20 #include <QPushButton> |
20 #include <QPushButton> |
21 #include <QFileDialog> |
21 #include <QFileDialog> |
22 #include <QCheckBox> |
22 #include <QCheckBox> |
23 #include <QRadioButton> |
23 #include <QRadioButton> |
|
24 #include <QSpinBox> |
|
25 #include <QDir> |
24 |
26 |
25 #include "pagedrawmap.h" |
27 #include "pagedrawmap.h" |
26 #include "drawmapwidget.h" |
28 #include "drawmapwidget.h" |
|
29 #include "hwconsts.h" |
27 |
30 |
28 |
31 |
29 QLayout * PageDrawMap::bodyLayoutDefinition() |
32 QLayout * PageDrawMap::bodyLayoutDefinition() |
30 { |
33 { |
31 QGridLayout * pageLayout = new QGridLayout(); |
34 QGridLayout * pageLayout = new QGridLayout(); |
32 |
35 |
33 cbEraser = new QCheckBox(tr("Eraser"), this); |
36 cbEraser = new QCheckBox(tr("Eraser"), this); |
34 pageLayout->addWidget(cbEraser, 0, 0); |
37 pageLayout->addWidget(cbEraser, 0, 0); |
35 pbUndo = addButton(tr("Undo"), pageLayout, 1, 0); |
|
36 |
38 |
37 rbPolyline = new QRadioButton(tr("Polyline"), this); |
39 rbPolyline = new QRadioButton(tr("Polyline"), this); |
38 pageLayout->addWidget(rbPolyline, 2, 0); |
40 pageLayout->addWidget(rbPolyline, 1, 0); |
39 rbRectangle = new QRadioButton(tr("Rectangle"), this); |
41 rbRectangle = new QRadioButton(tr("Rectangle"), this); |
40 pageLayout->addWidget(rbRectangle, 3, 0); |
42 pageLayout->addWidget(rbRectangle, 2, 0); |
41 rbEllipse = new QRadioButton(tr("Ellipse"), this); |
43 rbEllipse = new QRadioButton(tr("Ellipse"), this); |
42 pageLayout->addWidget(rbEllipse, 4, 0); |
44 pageLayout->addWidget(rbEllipse, 3, 0); |
43 |
45 |
44 rbPolyline->setChecked(true); |
46 rbPolyline->setChecked(true); |
45 |
47 |
46 pbClear = addButton(tr("Clear"), pageLayout, 5, 0); |
48 sbBrushSize = new QSpinBox(this); |
47 pbOptimize = addButton(tr("Optimize"), pageLayout, 6, 0); |
49 sbBrushSize->setWhatsThis(tr("Brush size")); |
|
50 sbBrushSize->setRange(DRAWN_MAP_BRUSH_SIZE_MIN, DRAWN_MAP_BRUSH_SIZE_MAX); |
|
51 sbBrushSize->setValue(DRAWN_MAP_BRUSH_SIZE_START); |
|
52 sbBrushSize->setSingleStep(DRAWN_MAP_BRUSH_SIZE_STEP); |
|
53 pageLayout->addWidget(sbBrushSize, 4, 0); |
|
54 |
|
55 pbUndo = addButton(tr("Undo"), pageLayout, 5, 0); |
|
56 pbClear = addButton(tr("Clear"), pageLayout, 6, 0); |
|
57 |
|
58 pbOptimize = addButton(tr("Optimize"), pageLayout, 7, 0); |
|
59 // The optimize button is quite buggy, so we disable it for now. |
|
60 // TODO: Re-enable optimize button when it's finished. |
48 pbOptimize->setVisible(false); |
61 pbOptimize->setVisible(false); |
49 pbLoad = addButton(tr("Load"), pageLayout, 7, 0); |
|
50 pbSave = addButton(tr("Save"), pageLayout, 8, 0); |
|
51 |
62 |
52 drawMapWidget = new DrawMapWidget(this); |
63 drawMapWidget = new DrawMapWidget(this); |
53 pageLayout->addWidget(drawMapWidget, 0, 1, 10, 1); |
64 pageLayout->addWidget(drawMapWidget, 0, 1, 10, 1); |
54 |
65 |
55 return pageLayout; |
66 return pageLayout; |
|
67 } |
|
68 |
|
69 QLayout * PageDrawMap::footerLayoutDefinition() |
|
70 { |
|
71 QHBoxLayout * bottomLayout = new QHBoxLayout(); |
|
72 |
|
73 bottomLayout->addStretch(); |
|
74 |
|
75 pbLoad = addButton(":/res/Load.png", bottomLayout, 0, true, Qt::AlignBottom); |
|
76 pbLoad ->setWhatsThis(tr("Load")); |
|
77 pbLoad->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); |
|
78 |
|
79 pbSave = addButton(":/res/Save.png", bottomLayout, 0, true, Qt::AlignBottom); |
|
80 pbSave ->setWhatsThis(tr("Save")); |
|
81 pbSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); |
|
82 |
|
83 return bottomLayout; |
56 } |
84 } |
57 |
85 |
58 void PageDrawMap::connectSignals() |
86 void PageDrawMap::connectSignals() |
59 { |
87 { |
60 connect(cbEraser, SIGNAL(toggled(bool)), drawMapWidget, SLOT(setErasing(bool))); |
88 connect(cbEraser, SIGNAL(toggled(bool)), drawMapWidget, SLOT(setErasing(bool))); |
61 connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo())); |
89 connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo())); |
62 connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear())); |
90 connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear())); |
63 connect(pbOptimize, SIGNAL(clicked()), drawMapWidget, SLOT(optimize())); |
91 connect(pbOptimize, SIGNAL(clicked()), drawMapWidget, SLOT(optimize())); |
|
92 connect(sbBrushSize, SIGNAL(valueChanged(int)), drawMapWidget, SLOT(setBrushSize(int))); |
|
93 |
|
94 connect(drawMapWidget, SIGNAL(brushSizeChanged(int)), this, SLOT(brushSizeChanged(int))); |
|
95 |
64 connect(pbLoad, SIGNAL(clicked()), this, SLOT(load())); |
96 connect(pbLoad, SIGNAL(clicked()), this, SLOT(load())); |
65 connect(pbSave, SIGNAL(clicked()), this, SLOT(save())); |
97 connect(pbSave, SIGNAL(clicked()), this, SLOT(save())); |
66 |
98 |
67 connect(rbPolyline, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool))); |
99 connect(rbPolyline, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool))); |
68 connect(rbRectangle, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool))); |
100 connect(rbRectangle, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool))); |