|
143 | 143 | #include "templates/template.h" |
144 | 144 | #include "templates/template_dialog_reopen.h" |
145 | 145 | #include "templates/template_track.h" |
| 146 | +#include "tools/box_zoom_tool.h" |
146 | 147 | #include "tools/cut_tool.h" |
147 | 148 | #include "tools/cut_hole_tool.h" |
148 | 149 | #include "tools/cutout_tool.h" |
@@ -1006,6 +1007,7 @@ void MapEditorController::createActions() |
1006 | 1007 | follow_position_act = newCheckAction("follow-position", tr("Keep my location on screen"), this, SLOT(followPositionClicked(bool)), nullptr, QString{}, "view_menu.html"); |
1007 | 1008 | zoom_in_act = newAction("zoomin", tr("Zoom in"), this, SLOT(zoomIn()), "view-zoom-in.png", QString{}, "view_menu.html"); |
1008 | 1009 | zoom_out_act = newAction("zoomout", tr("Zoom out"), this, SLOT(zoomOut()), "view-zoom-out.png", QString{}, "view_menu.html"); |
| 1010 | + box_zoom_act = newCheckAction("boxzoom", tr("Zoom to box"), this, SLOT(boxZoom(bool)), "view-box-zoom.png", QString{}, "view_menu.html"); |
1009 | 1011 | show_all_act = newAction("showall", tr("Show whole map"), this, SLOT(showWholeMap()), "view-show-all.png", QString{}, "view_menu.html"); |
1010 | 1012 | fullscreen_act = newAction("fullscreen", tr("Toggle fullscreen mode"), window, SLOT(toggleFullscreenMode()), nullptr, QString{}, "view_menu.html"); |
1011 | 1013 | custom_zoom_act = newAction("setzoom", tr("Set custom zoom factor..."), this, SLOT(setCustomZoomFactorClicked()), nullptr, QString{}, "view_menu.html"); |
@@ -1186,6 +1188,7 @@ void MapEditorController::createMenuAndToolbars() |
1186 | 1188 | view_menu->addAction(pan_act); |
1187 | 1189 | view_menu->addAction(zoom_in_act); |
1188 | 1190 | view_menu->addAction(zoom_out_act); |
| 1191 | + view_menu->addAction(box_zoom_act); |
1189 | 1192 | view_menu->addAction(show_all_act); |
1190 | 1193 | view_menu->addAction(custom_zoom_act); |
1191 | 1194 | view_menu->addSeparator(); |
@@ -1319,6 +1322,7 @@ void MapEditorController::createMenuAndToolbars() |
1319 | 1322 | toolbar_view->addAction(pan_act); |
1320 | 1323 | toolbar_view->addAction(zoom_in_act); |
1321 | 1324 | toolbar_view->addAction(zoom_out_act); |
| 1325 | + toolbar_view->addAction(box_zoom_act); |
1322 | 1326 | toolbar_view->addAction(show_all_act); |
1323 | 1327 | toolbar_view->addAction(template_window_act); |
1324 | 1328 |
|
@@ -2084,10 +2088,20 @@ void MapEditorController::zoomIn() |
2084 | 2088 | { |
2085 | 2089 | main_view->zoomSteps(1); |
2086 | 2090 | } |
| 2091 | + |
2087 | 2092 | void MapEditorController::zoomOut() |
2088 | 2093 | { |
2089 | 2094 | main_view->zoomSteps(-1); |
2090 | 2095 | } |
| 2096 | + |
| 2097 | +void MapEditorController::boxZoom(bool checked) |
| 2098 | +{ |
| 2099 | + if (checked) |
| 2100 | + setTool(new BoxZoomTool(this, box_zoom_act)); |
| 2101 | + else |
| 2102 | + setTool(nullptr); |
| 2103 | +} |
| 2104 | + |
2091 | 2105 | void MapEditorController::setCustomZoomFactorClicked() |
2092 | 2106 | { |
2093 | 2107 | bool ok; |
@@ -2448,7 +2462,7 @@ void MapEditorController::selectedSymbolsChanged() |
2448 | 2462 | if (symbol && !symbol->isHidden() && !symbol->isProtected() && current_tool) |
2449 | 2463 | { |
2450 | 2464 | // Auto-switch to a draw tool when selecting a symbol under certain conditions |
2451 | | - if (current_tool->toolType() == MapEditorTool::Pan || current_tool->toolType() == MapEditorTool::Scribble |
| 2465 | + if (current_tool->toolType() == MapEditorTool::Pan || current_tool->toolType() == MapEditorTool::BoxZoom || current_tool->toolType() == MapEditorTool::Scribble |
2452 | 2466 | || ((current_tool->toolType() == MapEditorTool::EditLine || current_tool->toolType() == MapEditorTool::EditPoint) && map->getNumSelectedObjects() == 0)) |
2453 | 2467 | { |
2454 | 2468 | current_tool->switchToDefaultDrawTool(active_symbol); |
@@ -4299,6 +4313,7 @@ QHash<const Symbol*, Symbol*> MapEditorController::importMap( |
4299 | 4313 | void MapEditorController::setViewOptionsEnabled(bool enabled) |
4300 | 4314 | { |
4301 | 4315 | pan_act->setEnabled(enabled); |
| 4316 | + box_zoom_act->setEnabled(enabled); |
4302 | 4317 | show_grid_act->setEnabled(enabled); |
4303 | 4318 | // hatch_areas_view_act->setEnabled(enabled); |
4304 | 4319 | // baseline_view_act->setEnabled(enabled); |
|
0 commit comments