Layouts, iPad-style rendering, taps, shift and layers

- JSON layouts (en-US, sv-SE inheriting number/symbol layers via base)
- LayoutModel + KeyGeometry: proportional rows, nearest-key hit testing
- KeyboardSurface: multi-pointer touch/mouse routing to the controller
- KeyboardController + ShiftState: iOS shift/caps-lock, layers, globe, dismiss
- QML view with light/dark iPad palette and drag handle
- DevHooks: SLOPOSK_AUTOTYPE, SLOPOSK_SCREENSHOT for headless checks
- Unit tests for shift, loader, geometry and controller

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 14:50:21 +02:00
co-authored by Claude Opus 5.5
parent cdef9b4ad0
commit be14bbcc62
35 changed files with 1970 additions and 65 deletions
+55
View File
@@ -0,0 +1,55 @@
#include "layout/KeyGeometry.h"
#include <QTest>
using namespace Qt::StringLiterals;
namespace {
KeyDef key(qreal width = 1.0, KeyType type = KeyType::Character)
{
KeyDef k;
k.type = type;
k.label = u"x"_s;
k.width = width;
return k;
}
} // namespace
class TestKeyGeometry : public QObject
{
Q_OBJECT
private Q_SLOTS:
void fillsWidthAndHeight()
{
const Layer layer{u"l"_s, {{key(), key()}, {key(2)}}};
const KeyboardMetrics metrics{.padding = 10, .gap = 10};
const auto rects = computeKeyRects(layer, {210, 110}, metrics);
QCOMPARE(rects.size(), 3);
QCOMPARE(rects[0], QRectF(10, 10, 90, 40));
QCOMPARE(rects[1], QRectF(110, 10, 90, 40));
QCOMPARE(rects[2], QRectF(10, 60, 190, 40)); // a 2-unit key spans the gap
}
void spacersShiftFollowingKeys()
{
const Layer layer{u"l"_s, {{key(), key(), key()}, {key(0.5, KeyType::Spacer), key(), key(1.5)}}};
const auto rects = computeKeyRects(layer, {300, 100}, {.padding = 0, .gap = 0});
QCOMPARE(rects[4].left(), 50.0);
QCOMPARE(rects[5].right(), 300.0);
}
void shorterRowsAreCentered()
{
const Layer layer{u"l"_s, {{key(), key(), key(), key()}, {key(), key()}}};
const auto rects = computeKeyRects(layer, {400, 100}, {.padding = 0, .gap = 0});
QCOMPARE(rects[4].left(), 100.0);
QCOMPARE(rects[5].right(), 300.0);
}
};
QTEST_GUILESS_MAIN(TestKeyGeometry)
#include "tst_keygeometry.moc"