diff --git a/res/medusa-bg.jpg b/res/medusa-bg.jpg new file mode 100644 index 000000000..35a156c65 Binary files /dev/null and b/res/medusa-bg.jpg differ diff --git a/src/platform/qt/AboutScreen.cpp b/src/platform/qt/AboutScreen.cpp index f14d19391..7c3ecd1ef 100644 --- a/src/platform/qt/AboutScreen.cpp +++ b/src/platform/qt/AboutScreen.cpp @@ -17,7 +17,7 @@ AboutScreen::AboutScreen(QWidget* parent) { m_ui.setupUi(this); - QPixmap logo(":/res/medusa-1024.png"); + QPixmap logo(":/res/medusa-bg.jpg"); logo = logo.scaled(m_ui.logo->minimumSize() * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation); logo.setDevicePixelRatio(devicePixelRatio()); m_ui.logo->setPixmap(logo); diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 6891fda1b..86b8d2c46 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -88,7 +88,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) , m_logView(new LogView(&m_log)) , m_stateWindow(nullptr) , m_screenWidget(new WindowBackground()) - , m_logo(":/res/medusa-1024.png") + , m_logo(":/res/medusa-bg.jpg") , m_config(config) , m_inputModel(new InputModel(this)) , m_inputController(m_inputModel, playerId, this) @@ -157,7 +157,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) m_screenWidget->setSizeHint(QSize(VIDEO_HORIZONTAL_PIXELS * i, VIDEO_VERTICAL_PIXELS * i)); #endif m_screenWidget->setPixmap(m_logo); - m_screenWidget->setLockAspectRatio(m_logo.width(), m_logo.height()); + m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height()); setCentralWidget(m_screenWidget); connect(m_controller, SIGNAL(gameStarted(mCoreThread*, const QString&)), this, SLOT(gameStarted(mCoreThread*, const QString&))); @@ -833,7 +833,7 @@ void Window::gameStopped() { setWindowFilePath(QString()); updateTitle(); detachWidget(m_display); - m_screenWidget->setLockAspectRatio(m_logo.width(), m_logo.height()); + m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height()); m_screenWidget->setPixmap(m_logo); m_screenWidget->unsetCursor(); #ifdef M_CORE_GB @@ -1648,6 +1648,13 @@ QSize WindowBackground::sizeHint() const { } void WindowBackground::setLockAspectRatio(int width, int height) { + m_centered = false; + m_aspectWidth = width; + m_aspectHeight = height; +} + +void WindowBackground::setCenteredAspectRatio(int width, int height) { + m_centered = true; m_aspectWidth = width; m_aspectHeight = height; } @@ -1659,13 +1666,21 @@ void WindowBackground::paintEvent(QPaintEvent*) { } QPainter painter(this); painter.setRenderHint(QPainter::SmoothPixmapTransform); - painter.fillRect(QRect(QPoint(), size()), Qt::white); + painter.fillRect(QRect(QPoint(), size()), Qt::black); QSize s = size(); QSize ds = s; - if (ds.width() * m_aspectHeight > ds.height() * m_aspectWidth) { - ds.setWidth(ds.height() * m_aspectWidth / m_aspectHeight); - } else if (ds.width() * m_aspectHeight < ds.height() * m_aspectWidth) { - ds.setHeight(ds.width() * m_aspectHeight / m_aspectWidth); + if (m_centered) { + if (ds.width() * m_aspectHeight < ds.height() * m_aspectWidth) { + ds.setWidth(ds.height() * m_aspectWidth / m_aspectHeight); + } else if (ds.width() * m_aspectHeight > ds.height() * m_aspectWidth) { + ds.setHeight(ds.width() * m_aspectHeight / m_aspectWidth); + } + } else { + if (ds.width() * m_aspectHeight > ds.height() * m_aspectWidth) { + ds.setWidth(ds.height() * m_aspectWidth / m_aspectHeight); + } else if (ds.width() * m_aspectHeight < ds.height() * m_aspectWidth) { + ds.setHeight(ds.width() * m_aspectHeight / m_aspectWidth); + } } QPoint origin = QPoint((s.width() - ds.width()) / 2, (s.height() - ds.height()) / 2); QRect full(origin, ds); diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 6afbb1846..5a461a459 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -206,12 +206,14 @@ public: void setSizeHint(const QSize& size); virtual QSize sizeHint() const override; void setLockAspectRatio(int width, int height); + void setCenteredAspectRatio(int width, int height); protected: virtual void paintEvent(QPaintEvent*) override; private: QSize m_sizeHint; + bool m_centered; int m_aspectWidth; int m_aspectHeight; }; diff --git a/src/platform/qt/resources.qrc b/src/platform/qt/resources.qrc index 01a9b3ccc..1f5683da9 100644 --- a/src/platform/qt/resources.qrc +++ b/src/platform/qt/resources.qrc @@ -1,6 +1,6 @@ - ../../../res/medusa-1024.png + ../../../res/medusa-bg.jpg ../../../res/patrons.txt