QTfrontend/ui/page/pagedrawmap.cpp
changeset 13209 f5d36be88c61
parent 13205 c681492df36d
child 13212 e9e4cc867b6e
equal deleted inserted replaced
13207:d948d39e5da8 13209:f5d36be88c61
    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>
    24 
    25 
    25 #include "pagedrawmap.h"
    26 #include "pagedrawmap.h"
    26 #include "drawmapwidget.h"
    27 #include "drawmapwidget.h"
    27 
    28 
    28 
    29 
    40     rbEllipse = new QRadioButton(tr("Ellipse"), this);
    41     rbEllipse = new QRadioButton(tr("Ellipse"), this);
    41     pageLayout->addWidget(rbEllipse, 3, 0);
    42     pageLayout->addWidget(rbEllipse, 3, 0);
    42 
    43 
    43     rbPolyline->setChecked(true);
    44     rbPolyline->setChecked(true);
    44 
    45 
    45     pbUndo = addButton(tr("Undo"), pageLayout, 4, 0);
    46     sbBrushSize = new QSpinBox(this);
    46     pbClear = addButton(tr("Clear"), pageLayout, 5, 0);
    47     sbBrushSize->setWhatsThis(tr("Brush size"));
       
    48     sbBrushSize->setRange(DRAWN_MAP_BRUSH_SIZE_MIN, DRAWN_MAP_BRUSH_SIZE_MAX);
       
    49     sbBrushSize->setValue(DRAWN_MAP_BRUSH_SIZE_START);
       
    50     sbBrushSize->setSingleStep(DRAWN_MAP_BRUSH_SIZE_STEP);
       
    51     pageLayout->addWidget(sbBrushSize, 4, 0);
    47 
    52 
    48     pbOptimize = addButton(tr("Optimize"), pageLayout, 6, 0);
    53     pbUndo = addButton(tr("Undo"), pageLayout, 5, 0);
       
    54     pbClear = addButton(tr("Clear"), pageLayout, 6, 0);
       
    55 
       
    56     pbOptimize = addButton(tr("Optimize"), pageLayout, 7, 0);
    49     // The optimize button is quite buggy, so we disable it for now.
    57     // The optimize button is quite buggy, so we disable it for now.
    50     // TODO: Re-enable optimize button when it's finished.
    58     // TODO: Re-enable optimize button when it's finished.
    51     pbOptimize->setVisible(false);
    59     pbOptimize->setVisible(false);
    52 
    60 
    53     drawMapWidget = new DrawMapWidget(this);
    61     drawMapWidget = new DrawMapWidget(this);
    77 {
    85 {
    78     connect(cbEraser, SIGNAL(toggled(bool)), drawMapWidget, SLOT(setErasing(bool)));
    86     connect(cbEraser, SIGNAL(toggled(bool)), drawMapWidget, SLOT(setErasing(bool)));
    79     connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo()));
    87     connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo()));
    80     connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear()));
    88     connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear()));
    81     connect(pbOptimize, SIGNAL(clicked()), drawMapWidget, SLOT(optimize()));
    89     connect(pbOptimize, SIGNAL(clicked()), drawMapWidget, SLOT(optimize()));
       
    90     connect(sbBrushSize, SIGNAL(valueChanged(int)), drawMapWidget, SLOT(setBrushSize(int)));
       
    91 
       
    92     connect(drawMapWidget, SIGNAL(brushSizeChanged(int)), this, SLOT(brushSizeChanged(int)));
       
    93 
    82     connect(pbLoad, SIGNAL(clicked()), this, SLOT(load()));
    94     connect(pbLoad, SIGNAL(clicked()), this, SLOT(load()));
    83     connect(pbSave, SIGNAL(clicked()), this, SLOT(save()));
    95     connect(pbSave, SIGNAL(clicked()), this, SLOT(save()));
    84 
    96 
    85     connect(rbPolyline, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool)));
    97     connect(rbPolyline, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool)));
    86     connect(rbRectangle, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool)));
    98     connect(rbRectangle, SIGNAL(toggled(bool)), this, SLOT(pathTypeSwitched(bool)));
   115         if(rbPolyline->isChecked()) drawMapWidget->setPathType(DrawMapScene::Polyline);
   127         if(rbPolyline->isChecked()) drawMapWidget->setPathType(DrawMapScene::Polyline);
   116         else if(rbRectangle->isChecked()) drawMapWidget->setPathType(DrawMapScene::Rectangle);
   128         else if(rbRectangle->isChecked()) drawMapWidget->setPathType(DrawMapScene::Rectangle);
   117         else if(rbEllipse->isChecked()) drawMapWidget->setPathType(DrawMapScene::Ellipse);
   129         else if(rbEllipse->isChecked()) drawMapWidget->setPathType(DrawMapScene::Ellipse);
   118     }
   130     }
   119 }
   131 }
       
   132 
       
   133 void PageDrawMap::brushSizeChanged(int brushSize)
       
   134 {
       
   135     sbBrushSize->setValue(brushSize);
       
   136 }