From 919da0663f9072f3f4510f8e80c4f550fa3cac88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=BCbach=2C=20Lukas?= Date: Tue, 25 Nov 2025 12:17:11 +0100 Subject: [PATCH] Better elision. --- .../archidekt_api_response_deck_entry_display_widget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_entry_display_widget.cpp b/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_entry_display_widget.cpp index e482bf477..72af400a4 100644 --- a/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_entry_display_widget.cpp +++ b/cockatrice/src/interface/widgets/tabs/api/archidekt/display/archidekt_api_response_deck_entry_display_widget.cpp @@ -192,13 +192,20 @@ void ArchidektApiResponseDeckEntryDisplayWidget::updateScaledPreview() QPixmap scaled = 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); QPixmap cropped = scaled.copy(cropRect); picture->setPixmap(cropped); 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); layout->invalidate();