bool DrawPointTool::keyPress(QKeyEvent* event) { if (event->key() == Qt::Key_Tab) deactivate(); else if (event->key() == Qt::Key_Control) { if (isDragging() && rotating) { angle_helper->setActive(true, preview_object->getCoordF()); calcConstrainedPositions(cur_map_widget); dragMove(); } } else if (event->key() == Qt::Key_Shift) { snap_helper->setFilter(SnappingToolHelper::AllTypes); calcConstrainedPositions(cur_map_widget); if (isDragging()) dragMove(); else mouseMove(); } else return false; return true; }
bool MapEditorToolBase::mousePressEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { active_modifiers = Qt::KeyboardModifiers(event->modifiers() | (key_button_bar ? key_button_bar->activeModifiers() : 0)); if (event->button() == Qt::LeftButton) { cur_map_widget = widget; click_pos = event->pos(); click_pos_map = map_coord; cur_pos = click_pos; cur_pos_map = click_pos_map; calcConstrainedPositions(widget); clickPress(); return true; } else if (event->button() == Qt::RightButton) { // Do not show the ring menu when editing return editingInProgress(); } else { return false; } }
void MapEditorToolBase::reapplyConstraintHelpers() { calcConstrainedPositions(cur_map_widget); if (dragging) dragMove(); else mouseMove(); }
bool DrawPointTool::keyRelease(QKeyEvent* event) { if (event->key() == Qt::Key_Control && angle_helper->isActive()) { angle_helper->setActive(false); calcConstrainedPositions(cur_map_widget); if (isDragging()) dragMove(); } else if (event->key() == Qt::Key_Shift) { snap_helper->setFilter(SnappingToolHelper::NoSnapping); calcConstrainedPositions(cur_map_widget); if (isDragging()) dragMove(); else mouseMove(); } else return false; return true; }
bool MapEditorToolBase::mouseMoveEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { auto old_constrained_pos = constrained_pos; auto old_constrained_pos_map = constrained_pos_map; active_modifiers = Qt::KeyboardModifiers(event->modifiers() | (key_button_bar ? key_button_bar->activeModifiers() : 0)); cur_pos = event->pos(); cur_pos_map = map_coord; calcConstrainedPositions(widget); if (event->buttons().testFlag(Qt::LeftButton)) { if (dragging) { updateDragging(); } else if (dragging_canceled) { click_pos = cur_pos; click_pos_map = cur_pos_map; dragging_canceled = false; } else if ((cur_pos - click_pos).manhattanLength() >= start_drag_distance) { // Use the actual click and current position to detect dragging, but // use the constrained variant of the click position as start of the // dragging operation. click_pos = old_constrained_pos; click_pos_map = old_constrained_pos_map; startDragging(); } return true; } else { mouseMove(); return false; } }