Skip to content

Commit

Permalink
Make version number in splash scalable too
Browse files Browse the repository at this point in the history
  • Loading branch information
10110111 committed Jan 25, 2025
1 parent eef23d8 commit 2cab699
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/StelSplashScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
#include <cmath>

static constexpr int BASE_FONT_SIZE = 11;
static constexpr int BASE_PIXMAP_HEIGHT = 365;

SplashScreen::SplashScreenWidget* SplashScreen::instance;

static QPixmap makePixmap(const double sizeRatio)
{
QPixmap pixmap(StelFileMgr::findFile("data/splash.png"));
pixmap = pixmap.scaledToHeight(std::lround(pixmap.height() * sizeRatio),
pixmap = pixmap.scaledToHeight(std::lround(BASE_PIXMAP_HEIGHT * sizeRatio),
Qt::SmoothTransformation);
return pixmap;
}
Expand Down Expand Up @@ -66,6 +67,7 @@ void SplashScreen::clearMessage()

SplashScreen::SplashScreenWidget::SplashScreenWidget(QPixmap const& pixmap, const double sizeRatio)
: QSplashScreen(pixmap)
, sizeRatio(sizeRatio)
{
splashFont.setPixelSize(std::lround(BASE_FONT_SIZE * sizeRatio));

Expand Down Expand Up @@ -94,11 +96,12 @@ void SplashScreen::SplashScreenWidget::paintEvent(QPaintEvent* event)
#else
QFont versionFont(splashFont);
QString version = StelUtils::getApplicationPublicVersion();
versionFont.setPixelSize(23);
versionFont.setPixelSize(23 * sizeRatio);
versionFont.setBold(true);
QFontMetrics versionMetrics(versionFont);
p.setFont(versionFont);
p.drawText(365 - versionMetrics.horizontalAdvance(version), 293, version);
const int height = BASE_PIXMAP_HEIGHT * sizeRatio;
p.drawText(height - versionMetrics.horizontalAdvance(version), 0.803 * height, version);
#endif

painted=true;
Expand Down
1 change: 1 addition & 0 deletions src/StelSplashScreen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SplashScreen

protected:
void paintEvent(QPaintEvent*) override;
double sizeRatio = 1;
};

static SplashScreenWidget* instance;
Expand Down

0 comments on commit 2cab699

Please sign in to comment.