1
0
Fork 0
forked from suyu/suyu

main: Refactor to reduce code duplication in ShowFullscreen()

This commit is contained in:
ameerj 2021-12-19 02:02:09 -05:00
parent 39bb6851e4
commit 3074b2eb93

View file

@ -2546,39 +2546,30 @@ void GMainWindow::ToggleFullscreen() {
} }
void GMainWindow::ShowFullscreen() { void GMainWindow::ShowFullscreen() {
const auto show_fullscreen = [](QWidget* window) {
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
window->showFullScreen();
return;
}
window->hide();
window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint);
const auto screen_geometry = QApplication::desktop()->screenGeometry(window);
window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(),
screen_geometry.height() + 1);
window->raise();
window->showNormal();
};
if (ui->action_Single_Window_Mode->isChecked()) { if (ui->action_Single_Window_Mode->isChecked()) {
UISettings::values.geometry = saveGeometry(); UISettings::values.geometry = saveGeometry();
ui->menubar->hide(); ui->menubar->hide();
statusBar()->hide(); statusBar()->hide();
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { show_fullscreen(this);
showFullScreen();
return;
}
hide();
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
const auto screen_geometry = QApplication::desktop()->screenGeometry(this);
setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(),
screen_geometry.height() + 1);
raise();
showNormal();
} else { } else {
UISettings::values.renderwindow_geometry = render_window->saveGeometry(); UISettings::values.renderwindow_geometry = render_window->saveGeometry();
show_fullscreen(render_window);
if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) {
render_window->showFullScreen();
return;
}
render_window->hide();
render_window->setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
const auto screen_geometry = QApplication::desktop()->screenGeometry(render_window);
render_window->setGeometry(screen_geometry.x(), screen_geometry.y(),
screen_geometry.width(), screen_geometry.height() + 1);
render_window->raise();
render_window->showNormal();
} }
} }