|
|
@@ -155,7 +155,9 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) |
|
|
#endif
|
|
|
m_screenWidget->setPixmap(m_logo);
|
|
|
m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height());
|
|
|
+ m_screenWidget->setDimensions(m_logo.width(), m_logo.height());
|
|
|
m_screenWidget->setLockIntegerScaling(false);
|
|
|
+ m_screenWidget->setLockAspectRatio(true);
|
|
|
setCentralWidget(m_screenWidget);
|
|
|
|
|
|
connect(m_controller, &GameController::gameStarted, this, &Window::gameStarted);
|
|
|
@@ -173,7 +175,6 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) |
|
|
QPixmap pixmap;
|
|
|
pixmap.convertFromImage(currentImage);
|
|
|
m_screenWidget->setPixmap(pixmap);
|
|
|
- m_screenWidget->setLockAspectRatio(width, height);
|
|
|
});
|
|
|
connect(m_controller, &GameController::gamePaused, m_display, &Display::pauseDrawing);
|
|
|
#ifndef Q_OS_MAC
|
|
|
@@ -803,7 +804,9 @@ void Window::gameStarted(mCoreThread* context, const QString& fname) { |
|
|
context->core->desiredVideoDimensions(context->core, &width, &height);
|
|
|
m_display->setMinimumSize(width, height);
|
|
|
m_screenWidget->setMinimumSize(m_display->minimumSize());
|
|
|
+ m_screenWidget->setDimensions(width, height);
|
|
|
m_config->updateOption("lockIntegerScaling");
|
|
|
+ m_config->updateOption("lockAspectRatio");
|
|
|
if (m_savedScale > 0) {
|
|
|
resizeFrame(QSize(width, height) * m_savedScale);
|
|
|
}
|
|
|
@@ -867,7 +870,9 @@ void Window::gameStopped() { |
|
|
updateTitle();
|
|
|
detachWidget(m_display);
|
|
|
m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height());
|
|
|
+ m_screenWidget->setDimensions(m_logo.width(), m_logo.height());
|
|
|
m_screenWidget->setLockIntegerScaling(false);
|
|
|
+ m_screenWidget->setLockAspectRatio(true);
|
|
|
m_screenWidget->setPixmap(m_logo);
|
|
|
m_screenWidget->unsetCursor();
|
|
|
#ifdef M_CORE_GB
|
|
|
@@ -1341,6 +1346,9 @@ void Window::setupMenu(QMenuBar* menubar) { |
|
|
lockAspectRatio->addBoolean(tr("Lock aspect ratio"), avMenu);
|
|
|
lockAspectRatio->connect([this](const QVariant& value) {
|
|
|
m_display->lockAspectRatio(value.toBool());
|
|
|
+ if (m_controller->isLoaded()) {
|
|
|
+ m_screenWidget->setLockAspectRatio(value.toBool());
|
|
|
+ }
|
|
|
}, this);
|
|
|
m_config->updateOption("lockAspectRatio");
|
|
|
|
|
|
@@ -1670,14 +1678,13 @@ QSize WindowBackground::sizeHint() const { |
|
|
return m_sizeHint;
|
|
|
}
|
|
|
|
|
|
-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_lockAspectRatio = true;
|
|
|
+ setDimensions(width, height);
|
|
|
+}
|
|
|
+
|
|
|
+void WindowBackground::setDimensions(int width, int height) {
|
|
|
m_aspectWidth = width;
|
|
|
m_aspectHeight = height;
|
|
|
}
|
|
|
@@ -1686,6 +1693,11 @@ void WindowBackground::setLockIntegerScaling(bool lock) { |
|
|
m_lockIntegerScaling = lock;
|
|
|
}
|
|
|
|
|
|
+void WindowBackground::setLockAspectRatio(bool lock) {
|
|
|
+ m_centered = false;
|
|
|
+ m_lockAspectRatio = lock;
|
|
|
+}
|
|
|
+
|
|
|
void WindowBackground::paintEvent(QPaintEvent*) {
|
|
|
const QPixmap* logo = pixmap();
|
|
|
if (!logo) {
|
|
|
@@ -1702,7 +1714,7 @@ void WindowBackground::paintEvent(QPaintEvent*) { |
|
|
} else if (ds.width() * m_aspectHeight > ds.height() * m_aspectWidth) {
|
|
|
ds.setHeight(ds.width() * m_aspectHeight / m_aspectWidth);
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else if (m_lockAspectRatio) {
|
|
|
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) {
|
|
|
|