Qt: Save fullscreen setting

This commit is contained in:
Jeffrey Pfau 2015-03-28 23:23:32 -07:00
parent 7a9807f030
commit 44d3718eb0
2 changed files with 21 additions and 9 deletions

View File

@ -181,6 +181,10 @@ void Window::loadConfig() {
resizeFrame(opts->width, opts->height); resizeFrame(opts->width, opts->height);
} }
if (opts->fullscreen) {
enterFullScreen();
}
m_mruFiles = m_config->getMRU(); m_mruFiles = m_config->getMRU();
updateMRU(); updateMRU();
@ -345,6 +349,7 @@ void Window::keyReleaseEvent(QKeyEvent* event) {
void Window::resizeEvent(QResizeEvent*) { void Window::resizeEvent(QResizeEvent*) {
m_config->setOption("height", m_screenWidget->height()); m_config->setOption("height", m_screenWidget->height());
m_config->setOption("width", m_screenWidget->width()); m_config->setOption("width", m_screenWidget->width());
m_config->setOption("fullscreen", isFullScreen());
} }
void Window::closeEvent(QCloseEvent* event) { void Window::closeEvent(QCloseEvent* event) {
@ -380,6 +385,18 @@ void Window::dropEvent(QDropEvent* event) {
m_controller->loadGame(url.path()); m_controller->loadGame(url.path());
} }
void Window::enterFullScreen() {
if (isFullScreen()) {
return;
}
showFullScreen();
#ifndef Q_OS_MAC
if (m_controller->isLoaded() && !m_controller->isPaused()) {
menuBar()->hide();
}
#endif
}
void Window::exitFullScreen() { void Window::exitFullScreen() {
if (!isFullScreen()) { if (!isFullScreen()) {
return; return;
@ -390,15 +407,9 @@ void Window::exitFullScreen() {
void Window::toggleFullScreen() { void Window::toggleFullScreen() {
if (isFullScreen()) { if (isFullScreen()) {
showNormal(); exitFullScreen();
menuBar()->show();
} else { } else {
showFullScreen(); enterFullScreen();
#ifndef Q_OS_MAC
if (m_controller->isLoaded() && !m_controller->isPaused()) {
menuBar()->hide();
}
#endif
} }
} }
@ -831,7 +842,7 @@ void Window::setupMenu(QMenuBar* menubar) {
m_controller->setTurbo(false, false); m_controller->setTurbo(false, false);
}, QKeySequence(Qt::Key_Tab), tr("Fast Forward (held)"), "holdFastForward"); }, QKeySequence(Qt::Key_Tab), tr("Fast Forward (held)"), "holdFastForward");
addControlledAction(other, other->addAction(tr("Exit fullscreen"), this, SLOT(exitFullScreen()), QKeySequence("Esc")), "exitFullscreen"); addControlledAction(other, other->addAction(tr("Exit fullscreen"), this, SLOT(exitFullScreen()), QKeySequence("Esc")), "exitFullScreen");
foreach (QAction* action, m_gameActions) { foreach (QAction* action, m_gameActions) {
action->setDisabled(true); action->setDisabled(true);

View File

@ -59,6 +59,7 @@ public slots:
void selectROM(); void selectROM();
void selectBIOS(); void selectBIOS();
void selectPatch(); void selectPatch();
void enterFullScreen();
void exitFullScreen(); void exitFullScreen();
void toggleFullScreen(); void toggleFullScreen();
void loadConfig(); void loadConfig();