Small fixes.

Took 7 minutes

Took 13 seconds
This commit is contained in:
Lukas Brübach 2025-11-30 08:19:15 +01:00
parent 02918adf81
commit 069bea9370
3 changed files with 9 additions and 8 deletions

View file

@ -126,13 +126,16 @@ QString ColorBar::tooltipForPosition(int x) const
for (int v : colors.values())
total += v;
if (total == 0)
return {};
int pos = 0;
for (auto it = colors.begin(); it != colors.end(); ++it) {
double ratio = double(it.value()) / total;
int segmentWidth = int(ratio * width());
for (auto it = colors.cbegin(); it != colors.cend(); ++it) {
const double ratio = double(it.value()) / total;
const int segmentWidth = int(ratio * width());
if (x >= pos && x < pos + segmentWidth) {
double percent = (100.0 * it.value()) / total;
const double percent = (100.0 * it.value()) / total;
return QString("%1: %2 cards (%3%)").arg(it.key()).arg(it.value()).arg(QString::number(percent, 'f', 1));
}

View file

@ -174,9 +174,6 @@ void ArchidektApiResponseDeckEntryDisplayWidget::onPreviewImageLoadFinished(QNet
originalPixmap = loaded;
// universal fallback/design aspect ratio
static constexpr float DESIGN_RATIO = 150.0f / 267.0f;
// Always scale preview widget to this ratio
previewWidget->setAspectRatio(DESIGN_RATIO);
previewWidget->setPreviewWidth(400);
@ -195,7 +192,7 @@ void ArchidektApiResponseDeckEntryDisplayWidget::updateScaledPreview()
int baseWidth = 400;
int newWidth = baseWidth * scaleFactor / 100;
int newHeight = int(newWidth * (150.0 / 267.0));
int newHeight = static_cast<int>(newWidth * DESIGN_RATIO);
previewWidget->setFixedSize(newWidth, newHeight);

View file

@ -115,6 +115,7 @@ private:
QPixmap originalPixmap; ///< Original image for scaling (avoids degradation)
int scaleFactor = 100; ///< Current scaling percentage
BackgroundPlateWidget *backgroundPlateWidget; ///< Plate for metadata labels
static constexpr float DESIGN_RATIO = 150.0f / 267.0f; ///< Design aspect ratio
};
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_ENTRY_DISPLAY_WIDGET_H