| 473 | } |
| 474 | |
| 475 | void KeyWidget::mouseMoveEvent(QMouseEvent* event){ |
| 476 | event->accept(); |
| 477 | QString tooltip; |
| 478 | |
| 479 | // Find selection rectangle |
| 480 | mouseCurrentX = event->x(); |
| 481 | mouseCurrentY = event->y(); |
| 482 | float scale, offX, offY; |
| 483 | drawInfo(scale, offX, offY); |
| 484 | float mx = mouseCurrentX / scale - offX, my = mouseCurrentY / scale - offY; |
| 485 | float mx1, mx2, my1, my2; |
| 486 | if(mouseCurrentX >= mouseDownX){ |
| 487 | mx1 = mouseDownX / scale - offX; |
| 488 | mx2 = mouseCurrentX / scale - offX; |
| 489 | } else { |
| 490 | mx1 = mouseCurrentX / scale - offX; |
| 491 | mx2 = mouseDownX / scale - offX; |
| 492 | } |
| 493 | if(mouseCurrentY >= mouseDownY){ |
| 494 | my1 = mouseDownY / scale - offY; |
| 495 | my2 = mouseCurrentY / scale - offY; |
| 496 | } else { |
| 497 | my1 = mouseCurrentY / scale - offY; |
| 498 | my2 = mouseDownY / scale - offY; |
| 499 | } |
| 500 | // Clear new selection |
| 501 | if(mouseDownMode != NONE) |
| 502 | newSelection.fill(false); |
| 503 | // See if the event hit any keys |
| 504 | QHashIterator<QString, Key> k(keyMap); |
| 505 | uint i = -1; |
| 506 | while(k.hasNext()){ |
| 507 | k.next(); |
| 508 | i++; |
| 509 | const Key& key = k.value(); |
| 510 | if((_rgbMode && !key.hasLed) |
| 511 | || (!_rgbMode && !key.hasScan)) |
| 512 | continue; |
| 513 | // Update tooltip with the mouse hover (if any), even if it's not selectable |
| 514 | if(fabs(key.x - mx) <= key.width / 2.f - 1.f && fabs(key.y - my) <= key.height / 2.f - 1.f |
| 515 | && tooltip.isEmpty()) |
| 516 | tooltip = key.friendlyName(false); |
| 517 | // on STRAFE Sidelights and indicators can't be assigned color the way other keys are colored |
| 518 | if(keyMap.model() == KeyMap::STRAFE && (!strcmp(key.name, "lsidel") || !strcmp(key.name, "rsidel") || _indicators.contains(key.name))) // FIX: _indicators check fails whenever _indicators is empty because "show animated" is unchecked |
| 519 | continue; |
| 520 | float kx1 = key.x - key.width / 2.f + 1.f; |
| 521 | float ky1 = key.y - key.height / 2.f + 1.f; |
| 522 | float kx2 = kx1 + key.width - 2.f; |
| 523 | float ky2 = ky1 + key.height - 2.f; |
| 524 | // If they overlap, add the key to the selection |
| 525 | if(!(mx1 >= kx2 || kx1 >= mx2) |
| 526 | && !(my1 >= ky2 || ky1 >= my2) |
| 527 | && mouseDownMode != NONE) |
| 528 | newSelection.setBit(i); |
| 529 | } |
| 530 | |
| 531 | if(mouseDownMode != NONE) |
| 532 | update(); |
nothing calls this directly
no test coverage detected