Keep blocks still when switching layers

- The main block reserves the width and rows of its biggest layer, so the
  numpad and function row no longer shift between letters and symbols
- Smaller layers stretch into the room: stretch keys widen, rows grow
  taller (rows above the layer, like the function row, keep their height)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 22:35:00 +02:00
co-authored by Claude Opus 5.5
parent 75bbe2e566
commit ac0bfc2741
5 changed files with 66 additions and 14 deletions
+14
View File
@@ -235,6 +235,20 @@ private Q_SLOTS:
QCOMPARE(model.rowCount(), mainKeys); // never nothing
}
void switchingLayersKeepsTheOtherBlocksStill()
{
model.setLayout(TestLayouts::build("us", KeyboardMode::Full)); // letters have more rows than symbols
model.setVisibleSections({u"function"_s, MainSectionId, u"numpad"_s});
model.setSize({1000, 300});
const auto lastKeyRect = [this] { return model.keyRect(model.rowCount() - 1); }; // numpad "="
const auto firstKeyRect = [this] { return model.keyRect(0); }; // esc
const QRectF numpad = lastKeyRect();
const QRectF esc = firstKeyRect();
model.setLayer(u"numbers"_s);
QCOMPARE(lastKeyRect(), numpad);
QCOMPARE(firstKeyRect(), esc);
}
KeyDef keysymKey(quint32 keysym)
{
KeyDef key = makeKey(KeyType::Keysym);