mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -07:00
Small fixes.
Took 7 minutes Took 13 seconds
This commit is contained in:
parent
02918adf81
commit
069bea9370
3 changed files with 9 additions and 8 deletions
|
|
@ -126,13 +126,16 @@ QString ColorBar::tooltipForPosition(int x) const
|
||||||
for (int v : colors.values())
|
for (int v : colors.values())
|
||||||
total += v;
|
total += v;
|
||||||
|
|
||||||
|
if (total == 0)
|
||||||
|
return {};
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (auto it = colors.begin(); it != colors.end(); ++it) {
|
for (auto it = colors.cbegin(); it != colors.cend(); ++it) {
|
||||||
double ratio = double(it.value()) / total;
|
const double ratio = double(it.value()) / total;
|
||||||
int segmentWidth = int(ratio * width());
|
const int segmentWidth = int(ratio * width());
|
||||||
|
|
||||||
if (x >= pos && x < pos + segmentWidth) {
|
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));
|
return QString("%1: %2 cards (%3%)").arg(it.key()).arg(it.value()).arg(QString::number(percent, 'f', 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,9 +174,6 @@ void ArchidektApiResponseDeckEntryDisplayWidget::onPreviewImageLoadFinished(QNet
|
||||||
|
|
||||||
originalPixmap = loaded;
|
originalPixmap = loaded;
|
||||||
|
|
||||||
// universal fallback/design aspect ratio
|
|
||||||
static constexpr float DESIGN_RATIO = 150.0f / 267.0f;
|
|
||||||
|
|
||||||
// Always scale preview widget to this ratio
|
// Always scale preview widget to this ratio
|
||||||
previewWidget->setAspectRatio(DESIGN_RATIO);
|
previewWidget->setAspectRatio(DESIGN_RATIO);
|
||||||
previewWidget->setPreviewWidth(400);
|
previewWidget->setPreviewWidth(400);
|
||||||
|
|
@ -195,7 +192,7 @@ void ArchidektApiResponseDeckEntryDisplayWidget::updateScaledPreview()
|
||||||
|
|
||||||
int baseWidth = 400;
|
int baseWidth = 400;
|
||||||
int newWidth = baseWidth * scaleFactor / 100;
|
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);
|
previewWidget->setFixedSize(newWidth, newHeight);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ private:
|
||||||
QPixmap originalPixmap; ///< Original image for scaling (avoids degradation)
|
QPixmap originalPixmap; ///< Original image for scaling (avoids degradation)
|
||||||
int scaleFactor = 100; ///< Current scaling percentage
|
int scaleFactor = 100; ///< Current scaling percentage
|
||||||
BackgroundPlateWidget *backgroundPlateWidget; ///< Plate for metadata labels
|
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
|
#endif // COCKATRICE_ARCHIDEKT_API_RESPONSE_DECK_ENTRY_DISPLAY_WIDGET_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue