[viewer] fix qt6

This commit is contained in:
Mathis Logemann 2021-10-07 20:05:11 +02:00
parent d96b6843b3
commit 8714432a67
2 changed files with 19 additions and 2 deletions

View file

@ -38,7 +38,7 @@ void LayerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
painter->setBrush(QBrush(QColor(255, 0, 0, 64)));
painter->drawRoundRect(option.rect,4,4);
painter->drawRoundedRect(option.rect,4,4);
if (option.state & QStyle::State_Selected)
painter->setBrush(option.palette.highlightedText());

View file

@ -293,7 +293,23 @@ void MapWidget::wheelEvent(QWheelEvent* e)
{
return;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QPointF corner(map_->width(), map_->height());
QPointF zoomCoords;
double zoom;
if (e->angleDelta().y() > 0)
{
zoom = 0.5;
QPointF center = corner / 2;
QPointF delta = e->position() - center;
zoomCoords = zoom * delta + center;
}
else
{
zoom = 2.0;
zoomCoords = corner - e->position();
}
#else
QPoint corner(map_->width(), map_->height());
QPoint zoomCoords;
double zoom;
@ -309,6 +325,7 @@ void MapWidget::wheelEvent(QWheelEvent* e)
zoom = 2.0;
zoomCoords = corner - e->pos();
}
#endif
map_->pan_and_zoom(zoomCoords.x(), zoomCoords.y(), zoom);
updateMap();