Qt: Show checkmark for window sizes

This commit is contained in:
Jeffrey Pfau 2015-08-05 18:09:47 -07:00
parent cf8e84a1f8
commit 8e735a4668
4 changed files with 23 additions and 1 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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<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 @@ 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;

View File

@ -148,6 +148,7 @@ private:
GameController* m_controller;
Display* m_display;
QList<QAction*> m_gameActions;
QMap<int, QAction*> m_frameSizes;
LogController m_log;
LogView* m_logView;
LoadSaveState* m_stateWindow;