[qt] Move to modern signal/slot connection mechanism (#138)

This commit is contained in:
Tadej Novak
2021-08-29 22:54:07 +02:00
committed by GitHub
parent fe041b80ca
commit 5c2414463f
13 changed files with 115 additions and 39 deletions

View File

@@ -409,7 +409,11 @@ void MapWindow::keyPressEvent(QKeyEvent *ev)
void MapWindow::mousePressEvent(QMouseEvent *ev)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
m_lastPos = ev->position();
#else
m_lastPos = ev->localPos();
#endif
if (ev->type() == QEvent::MouseButtonPress) {
if (ev->buttons() == (Qt::LeftButton | Qt::RightButton)) {
@@ -430,19 +434,24 @@ void MapWindow::mousePressEvent(QMouseEvent *ev)
void MapWindow::mouseMoveEvent(QMouseEvent *ev)
{
QPointF delta = ev->localPos() - m_lastPos;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const QPointF &position = ev->position();
#else
const QPointF &position = ev->localPos();
#endif
QPointF delta = position - m_lastPos;
if (!delta.isNull()) {
if (ev->buttons() == Qt::LeftButton && ev->modifiers() & Qt::ShiftModifier) {
m_map->pitchBy(delta.y());
} else if (ev->buttons() == Qt::LeftButton) {
m_map->moveBy(delta);
} else if (ev->buttons() == Qt::RightButton) {
m_map->rotateBy(m_lastPos, ev->localPos());
m_map->rotateBy(m_lastPos, position);
}
}
m_lastPos = ev->localPos();
m_lastPos = position;
ev->accept();
}
@@ -468,7 +477,7 @@ void MapWindow::wheelEvent(QWheelEvent *ev)
void MapWindow::initializeGL()
{
m_map.reset(new QMapboxGL(nullptr, m_settings, size(), pixelRatio()));
connect(m_map.data(), SIGNAL(needsRendering()), this, SLOT(update()));
connect(m_map.get(), SIGNAL(needsRendering()), this, SLOT(update()));
// Set default location to Helsinki.
m_map->setCoordinateZoom(QMapbox::Coordinate(60.170448, 24.942046), 5);
@@ -481,11 +490,11 @@ void MapWindow::initializeGL()
setWindowTitle(QString("MapLibre GL: ") + styleUrl);
}
m_bearingAnimation = new QPropertyAnimation(m_map.data(), "bearing");
m_zoomAnimation = new QPropertyAnimation(m_map.data(), "zoom");
m_bearingAnimation = new QPropertyAnimation(m_map.get(), "bearing");
m_zoomAnimation = new QPropertyAnimation(m_map.get(), "zoom");
connect(m_zoomAnimation, SIGNAL(finished()), this, SLOT(animationFinished()));
connect(m_zoomAnimation, SIGNAL(valueChanged(const QVariant&)), this, SLOT(animationValueChanged()));
connect(m_zoomAnimation, &QPropertyAnimation::finished, this, &MapWindow::animationFinished);
connect(m_zoomAnimation, &QPropertyAnimation::valueChanged, this, &MapWindow::animationValueChanged);
}
void MapWindow::paintGL()