all repos — mgba @ c8db38f93b391b53d4b323122720b01b371823b2

mGBA Game Boy Advance Emulator

Qt: Remember scale option independent of core dimensions
Jeffrey Pfau jeffrey@endrift.com
Tue, 04 Oct 2016 11:24:56 -0700
commit

c8db38f93b391b53d4b323122720b01b371823b2

parent

0b2f8bb4dcf74ffc0bd28c7349e73450aea4010d

3 files changed, 28 insertions(+), 9 deletions(-)

jump to
M CHANGESCHANGES

@@ -37,6 +37,7 @@ - GB Video: Improved video timings

- All: Split out install locations for Libretro and OpenEmu - GBA Video: Clean up unused timers - Qt: Manage window sizes slightly better + - Qt: Remember scale option independent of core dimensions 0.5.0: (2016-09-19) Features:
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -89,8 +89,14 @@ m_logo = m_logo; // Free memory left over in old pixmap

m_screenWidget->setMinimumSize(m_display->minimumSize()); m_screenWidget->setSizePolicy(m_display->sizePolicy()); + int i = 2; + QVariant multiplier = m_config->getOption("scaleMultiplier"); + if (!multiplier.isNull()) { + m_savedScale = multiplier.toInt(); + i = m_savedScale; + } #ifdef M_CORE_GBA - m_screenWidget->setSizeHint(QSize(VIDEO_HORIZONTAL_PIXELS * 2, VIDEO_VERTICAL_PIXELS * 2)); + 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());

@@ -569,17 +575,15 @@ QSize size(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);

if (m_controller->isLoaded()) { size = m_controller->screenDimensions(); } - if (event->size().width() % size.width() == 0 && event->size().height() % size.height() == 0 && - event->size().width() / size.width() == event->size().height() / size.height()) { - factor = event->size().width() / size.width(); + if (m_screenWidget->width() % size.width() == 0 && m_screenWidget->height() % size.height() == 0 && + m_screenWidget->width() / size.width() == m_screenWidget->height() / size.height()) { + factor = m_screenWidget->width() / size.width(); + } else { + m_savedScale = 0; } for (QMap<int, QAction*>::iterator iter = m_frameSizes.begin(); iter != m_frameSizes.end(); ++iter) { bool enableSignals = iter.value()->blockSignals(true); - if (iter.key() == factor) { - iter.value()->setChecked(true); - } else { - iter.value()->setChecked(false); - } + iter.value()->setChecked(iter.key() == factor); iter.value()->blockSignals(enableSignals); }

@@ -605,6 +609,11 @@

void Window::closeEvent(QCloseEvent* event) { emit shutdown(); m_config->setQtOption("windowPos", pos()); + + if (m_savedScale > 0) { + m_config->setOption("height", VIDEO_VERTICAL_PIXELS * m_savedScale); + m_config->setOption("width", VIDEO_HORIZONTAL_PIXELS * m_savedScale); + } saveConfig(); QMainWindow::closeEvent(event); }

@@ -708,6 +717,9 @@ unsigned width, height;

context->core->desiredVideoDimensions(context->core, &width, &height); m_display->setMinimumSize(width, height); m_screenWidget->setMinimumSize(m_display->minimumSize()); + if (m_savedScale > 0) { + resizeFrame(QSize(width, height) * m_savedScale); + } attachWidget(m_display); #ifndef Q_OS_MAC

@@ -1174,6 +1186,9 @@ m_shortcutController->addMenu(frameMenu, avMenu);

for (int i = 1; i <= 6; ++i) { QAction* setSize = new QAction(tr("%1x").arg(QString::number(i)), avMenu); setSize->setCheckable(true); + if (m_savedScale == i) { + setSize->setChecked(true); + } connect(setSize, &QAction::triggered, [this, i, setSize]() { showNormal(); QSize size(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);

@@ -1181,6 +1196,8 @@ if (m_controller->isLoaded()) {

size = m_controller->screenDimensions(); } size *= i; + m_savedScale = i; + m_config->setOption("scaleMultiplier", i); // TODO: Port to other resizeFrame(size); bool enableSignals = setSize->blockSignals(true); setSize->setChecked(true);
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -153,6 +153,7 @@ QString getFiltersArchive() const;

GameController* m_controller; Display* m_display; + int m_savedScale; // TODO: Move these to a new class QList<QAction*> m_gameActions; QList<QAction*> m_nonMpActions;