| 917 | } |
| 918 | |
| 919 | void ChessBoard::mouseReleaseEvent(QMouseEvent *ev) |
| 920 | { |
| 921 | if (ev->button() != Qt::LeftButton || m_bIsOver== true) { // 排除鼠标右键点击 游戏已结束则直接返回 |
| 922 | return; |
| 923 | } |
| 924 | |
| 925 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 926 | const QPointF globalPos = ev->globalPosition(); |
| 927 | #else |
| 928 | const QPointF globalPos = ev->globalPos(); |
| 929 | #endif |
| 930 | const QPointF windowTopLeft = mapToGlobal(QPoint(0, 0)); |
| 931 | const QPointF mousePos = globalPos - windowTopLeft; // 统一转换为 ChessBoard 坐标系 |
| 932 | |
| 933 | QPointF pt = getRealPoint(mousePos); // 转换为虚拟坐标 |
| 934 | click(pt); |
| 935 | } |
| 936 | |
| 937 | void ChessBoard::click(QPointF pt) |
| 938 | { |
nothing calls this directly
no outgoing calls
no test coverage detected