Long-press popups: one owner, always on screen

- A second long-press finishes the first (typing its choice) before
  opening its own popup, instead of sharing one
- Popups move down over their key when the room above is too small
- No popup over an unknown key: an empty rect made every cell zero wide
- A repeated touch id cancels the stale pointer instead of leaking it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 10:13:33 +02:00
co-authored by Claude Opus 5.5
parent 139a845151
commit 3a62599a3f
7 changed files with 117 additions and 25 deletions
+18 -4
View File
@@ -12,7 +12,7 @@ private Q_SLOTS:
void opensAboveKeyExtendingRight()
{
AlternatesPicker picker;
picker.open(QRectF(100, 100, 50, 60), {u"é"_s, u"è"_s, u"ê"_s}, 1000, 8);
picker.open(QRectF(100, 100, 50, 60), {u"é"_s, u"è"_s, u"ê"_s}, 1000, -1000, 8);
QVERIFY(picker.isOpen());
QCOMPARE(picker.rect(), QRectF(100, 32, 150, 60));
QCOMPARE(picker.selectedText(), u"é");
@@ -21,7 +21,7 @@ private Q_SLOTS:
void staysInsideRightEdgeAndSelectsUnderFinger()
{
AlternatesPicker picker;
picker.open(QRectF(900, 100, 50, 60), {u"a"_s, u"b"_s, u"c"_s}, 1000, 8);
picker.open(QRectF(900, 100, 50, 60), {u"a"_s, u"b"_s, u"c"_s}, 1000, -1000, 8);
QCOMPARE(picker.rect().left(), 850.0);
QCOMPARE(picker.selectedText(), u"b"); // key center x=925 lies over the second cell
}
@@ -29,7 +29,7 @@ private Q_SLOTS:
void selectionFollowsFingerAndClamps()
{
AlternatesPicker picker;
picker.open(QRectF(100, 100, 50, 60), {u"a"_s, u"b"_s, u"c"_s}, 1000, 8);
picker.open(QRectF(100, 100, 50, 60), {u"a"_s, u"b"_s, u"c"_s}, 1000, -1000, 8);
picker.selectAt(210);
QCOMPARE(picker.selected(), 2);
picker.selectAt(-50);
@@ -41,11 +41,25 @@ private Q_SLOTS:
void closeClears()
{
AlternatesPicker picker;
picker.open(QRectF(0, 0, 10, 10), {u"a"_s}, 100, 0);
picker.open(QRectF(0, 0, 10, 10), {u"a"_s}, 100, -1000, 0);
picker.close();
QVERIFY(!picker.isOpen());
QVERIFY(picker.selectedText().isEmpty());
}
void emptyKeyRectDoesNotOpen()
{
AlternatesPicker picker;
picker.open(QRectF(), {u"a"_s, u"b"_s}, 1000, -1000, 8);
QVERIFY(!picker.isOpen());
}
void lowersToStayBelowMinTop()
{
AlternatesPicker picker;
picker.open(QRectF(100, 10, 50, 60), {u"a"_s}, 1000, -20, 8);
QCOMPARE(picker.rect().top(), -20.0);
}
};
QTEST_GUILESS_MAIN(TestAlternatesPicker)