diff --git a/CHANGES b/CHANGES index 4ad150ddf..5d52ef752 100644 --- a/CHANGES +++ b/CHANGES @@ -113,6 +113,7 @@ Misc: - GBA BIOS: Stub out SoundBias - Qt: Gamepads can now have both buttons and analog axes mapped to the same key - Qt: Increase usability of key mapper + - Qt: Show checkmark for window sizes 0.2.1: (2015-05-13) Bugfixes: diff --git a/src/platform/qt/ShortcutController.h b/src/platform/qt/ShortcutController.h index 5cc6f06a4..811a34f34 100644 --- a/src/platform/qt/ShortcutController.h +++ b/src/platform/qt/ShortcutController.h @@ -103,6 +103,8 @@ public: const QKeySequence& shortcut, const QString& visibleName, const QString& name); void addMenu(QMenu* menu, QMenu* parent = nullptr); + QAction* getAction(const QString& name); + QKeySequence shortcutAt(const QModelIndex& index) const; bool isMenuAt(const QModelIndex& index) const; diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index f0c219c4b..94b007c25 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -427,11 +427,27 @@ void Window::keyReleaseEvent(QKeyEvent* event) { event->accept(); } -void Window::resizeEvent(QResizeEvent*) { +void Window::resizeEvent(QResizeEvent* event) { if (!isFullScreen()) { m_config->setOption("height", m_screenWidget->height()); m_config->setOption("width", m_screenWidget->width()); } + + int factor = 0; + if (event->size().width() % VIDEO_HORIZONTAL_PIXELS == 0 && event->size().height() % VIDEO_VERTICAL_PIXELS == 0 && + event->size().width() / VIDEO_HORIZONTAL_PIXELS == event->size().height() / VIDEO_VERTICAL_PIXELS) { + factor = event->size().width() / VIDEO_HORIZONTAL_PIXELS; + } + for (QMap::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()->blockSignals(enableSignals); + } + m_config->setOption("fullscreen", isFullScreen()); } @@ -920,10 +936,12 @@ void Window::setupMenu(QMenuBar* menubar) { 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); connect(setSize, &QAction::triggered, [this, i]() { showNormal(); resizeFrame(VIDEO_HORIZONTAL_PIXELS * i, VIDEO_VERTICAL_PIXELS * i); }); + m_frameSizes[i] = setSize; addControlledAction(frameMenu, setSize, QString("frame%1x").arg(QString::number(i))); } QKeySequence fullscreenKeys; diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 0e0bfe6d4..16295f264 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -148,6 +148,7 @@ private: GameController* m_controller; Display* m_display; QList m_gameActions; + QMap m_frameSizes; LogController m_log; LogView* m_logView; LoadSaveState* m_stateWindow;