aztec: GUI: fix layers calc from width;

add overrun check of `adjusted_string` before padding in
  user-specified size case but probably can't happen;
  various fiddlings with code to make a bit more concise
This commit is contained in:
gitlost 2023-11-24 15:34:08 +00:00
parent 86748999a4
commit 0601b580b2
3 changed files with 127 additions and 296 deletions

View file

@ -3584,7 +3584,13 @@ void MainWindow::automatic_info_set()
if (w <= 27) { // Note Zint always favours Compact on automatic
txt->setText(QString::asprintf("(%d X %d Compact)", w, w));
} else {
txt->setText(QString::asprintf("(%d X %d (%d Layers))", w, w, (w - 15) / 4));
int layers;
if (w <= 95) {
layers = (w - 16 + (w <= 61)) / 4;
} else {
layers = (w - 20 + (w <= 125) * 2) / 4;
}
txt->setText(QString::asprintf("(%d X %d (%d Layers))", w, w, layers));
}
} else {
txt->setText(QSL(""));