Qt: Show checkmark for window sizes
Jeffrey Pfau jeffrey@endrift.com
Wed, 05 Aug 2015 18:09:47 -0700
4 files changed,
23 insertions(+),
1 deletions(-)
M
CHANGES
→
CHANGES
@@ -113,6 +113,7 @@ - GBA Input: Allow axes and buttons to be mapped to the same key
- 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:
M
src/platform/qt/ShortcutController.h
→
src/platform/qt/ShortcutController.h
@@ -103,6 +103,8 @@ void addFunctions(QMenu* menu, std::function<void()> press, std::function<void()> release,
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;
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -427,11 +427,27 @@ m_controller->keyReleased(key);
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<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()->blockSignals(enableSignals); + } + m_config->setOption("fullscreen", isFullScreen()); }@@ -920,10 +936,12 @@ QMenu* frameMenu = avMenu->addMenu(tr("Frame size"));
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;
M
src/platform/qt/Window.h
→
src/platform/qt/Window.h
@@ -148,6 +148,7 @@
GameController* m_controller; Display* m_display; QList<QAction*> m_gameActions; + QMap<int, QAction*> m_frameSizes; LogController m_log; LogView* m_logView; LoadSaveState* m_stateWindow;