qt: Migrate to Qt6. (#6418)

This commit is contained in:
Steveice10
2023-05-05 03:10:34 -07:00
committed by GitHub
parent 70335a7f4d
commit 2273df4d70
32 changed files with 299 additions and 464 deletions

View File

@ -509,7 +509,8 @@ void TouchScreenPreview::mouseMoveEvent(QMouseEvent* event) {
if (!coord_label) {
return;
}
const auto pos = MapToDeviceCoords(event->x(), event->y());
const auto point = event->position().toPoint();
const auto pos = MapToDeviceCoords(point.x(), point.y());
if (pos) {
coord_label->setText(QStringLiteral("X: %1, Y: %2").arg(pos->x()).arg(pos->y()));
} else {
@ -527,7 +528,8 @@ void TouchScreenPreview::mousePressEvent(QMouseEvent* event) {
if (event->button() != Qt::MouseButton::LeftButton) {
return;
}
const auto pos = MapToDeviceCoords(event->x(), event->y());
const auto point = event->position().toPoint();
const auto pos = MapToDeviceCoords(point.x(), point.y());
if (pos) {
emit DotAdded(*pos);
}
@ -543,7 +545,7 @@ bool TouchScreenPreview::eventFilter(QObject* obj, QEvent* event) {
emit DotSelected(obj->property(PropId).toInt());
drag_state.dot = qobject_cast<QLabel*>(obj);
drag_state.start_pos = mouse_event->globalPos();
drag_state.start_pos = mouse_event->globalPosition().toPoint();
return true;
}
case QEvent::Type::MouseMove: {
@ -552,14 +554,13 @@ bool TouchScreenPreview::eventFilter(QObject* obj, QEvent* event) {
}
const auto mouse_event = static_cast<QMouseEvent*>(event);
if (!drag_state.active) {
drag_state.active =
(mouse_event->globalPos() - drag_state.start_pos).manhattanLength() >=
QApplication::startDragDistance();
drag_state.active = (mouse_event->globalPosition().toPoint() - drag_state.start_pos)
.manhattanLength() >= QApplication::startDragDistance();
if (!drag_state.active) {
break;
}
}
auto current_pos = mapFromGlobal(mouse_event->globalPos());
auto current_pos = mapFromGlobal(mouse_event->globalPosition().toPoint());
current_pos.setX(std::clamp(current_pos.x(), contentsMargins().left(),
contentsMargins().left() + contentsRect().width() - 1));
current_pos.setY(std::clamp(current_pos.y(), contentsMargins().top(),