mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
Better elision.
This commit is contained in:
parent
3cad29bbe2
commit
919da0663f
1 changed files with 8 additions and 1 deletions
|
|
@ -192,13 +192,20 @@ void ArchidektApiResponseDeckEntryDisplayWidget::updateScaledPreview()
|
||||||
QPixmap scaled =
|
QPixmap scaled =
|
||||||
originalPixmap.scaled(newWidth, newHeight, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
originalPixmap.scaled(newWidth, newHeight, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
|
|
||||||
// 2. Crop to exact target size (for safety)
|
// 2. Crop to exact target size
|
||||||
QRect cropRect((scaled.width() - newWidth) / 2, (scaled.height() - newHeight) / 2, newWidth, newHeight);
|
QRect cropRect((scaled.width() - newWidth) / 2, (scaled.height() - newHeight) / 2, newWidth, newHeight);
|
||||||
QPixmap cropped = scaled.copy(cropRect);
|
QPixmap cropped = scaled.copy(cropRect);
|
||||||
|
|
||||||
picture->setPixmap(cropped);
|
picture->setPixmap(cropped);
|
||||||
picture->setFixedSize(newWidth, newHeight);
|
picture->setFixedSize(newWidth, newHeight);
|
||||||
|
|
||||||
|
// Update the elided deck name based on new width
|
||||||
|
int textMaxWidth = int(newWidth * 0.7); // allow 70% of width for text
|
||||||
|
QFontMetrics fm(previewWidget->topLeftLabel->font());
|
||||||
|
QString elided = fm.elidedText(response.getName(), Qt::ElideRight, textMaxWidth);
|
||||||
|
previewWidget->topLeftLabel->setText(elided);
|
||||||
|
previewWidget->topLeftLabel->setToolTip(response.getName());
|
||||||
|
|
||||||
setFixedWidth(newWidth);
|
setFixedWidth(newWidth);
|
||||||
|
|
||||||
layout->invalidate();
|
layout->invalidate();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue