From ce1492e1907fd58b2ff6bf54dace2650a663152c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 12 Jun 2023 01:57:37 +0300 Subject: [PATCH 15/15] Qt: Apply changes to 'fullscreen' option changes immediately When 'fullscreen' option was changed via options dialog, it was taken to use only after a client restart. Add an option changed callback to Qt-client that apply the change immediately. Reported by onluntuva See osdn #48180 Signed-off-by: Marko Lindqvist --- client/gui-qt/fc_client.cpp | 24 ++++++++++++++++++++---- client/gui-qt/fc_client.h | 1 + client/gui-qt/gui_main.cpp | 10 ++++++++++ client/gui-qt/menu.cpp | 10 ++-------- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/client/gui-qt/fc_client.cpp b/client/gui-qt/fc_client.cpp index 6abab5fc65..fba829b812 100644 --- a/client/gui-qt/fc_client.cpp +++ b/client/gui-qt/fc_client.cpp @@ -363,10 +363,11 @@ void fc_client::switch_page(int new_pg) showMaximized(); gui()->infotab->chtwdg->update_widgets(); status_bar->setVisible(false); - if (gui_options.gui_qt_fullscreen){ - gui()->showFullScreen(); - gui()->game_tab_widget->showFullScreen(); + + if (gui_options.gui_qt_fullscreen) { + apply_fullscreen(); } + menuBar()->setVisible(true); mapview_wdg->setFocus(); center_on_something(); @@ -1226,7 +1227,22 @@ void pregame_options::update_buttons() } } -/************************************************************************//** +/**************************************************************************** + Apply current fullscreen option +****************************************************************************/ +void fc_client::apply_fullscreen() +{ + if (gui_options.gui_qt_fullscreen) { + gui()->showFullScreen(); + gui()->game_tab_widget->showFullScreen(); + } else { + // FIXME: Doesn't return properly, probably something with sidebar + gui()->showNormal(); + gui()->game_tab_widget->showNormal(); + } +} + +/**************************************************************************** Updates the AI skill level control ****************************************************************************/ void pregame_options::update_ai_level() diff --git a/client/gui-qt/fc_client.h b/client/gui-qt/fc_client.h index 12824e714e..96162d5e8f 100644 --- a/client/gui-qt/fc_client.h +++ b/client/gui-qt/fc_client.h @@ -253,6 +253,7 @@ public: const char *message); choice_dialog *get_diplo_dialog(); void update_sidebar_position(); + void apply_fullscreen(); mr_idle mr_idler; QWidget *central_wdg; diff --git a/client/gui-qt/gui_main.cpp b/client/gui-qt/gui_main.cpp index cbd2dba67c..7b89002fc1 100644 --- a/client/gui-qt/gui_main.cpp +++ b/client/gui-qt/gui_main.cpp @@ -79,6 +79,7 @@ static void apply_help_font(struct option *poption); static void apply_notify_font(struct option *poption); static void apply_sidebar(struct option *poption); static void apply_titlebar(struct option *poption); +static void apply_fullscreen(struct option *poption); /**************************************************************************** Return fc_client instance @@ -257,6 +258,8 @@ void qtg_options_extra_init() apply_titlebar); option_var_set_callback(gui_qt_sidebar_left, apply_sidebar); + option_var_set_callback(gui_qt_fullscreen, + apply_fullscreen); #undef option_var_set_callback } @@ -477,6 +480,13 @@ void apply_city_font(option *poption) } } +/**********************************************************************//** + Applies fullscreen changes +**************************************************************************/ +static void apply_fullscreen(struct option *poption) +{ + gui()->apply_fullscreen(); +} /**************************************************************************** Stub for editor function diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 5e072fd0aa..b4053f5605 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -3091,15 +3091,9 @@ void enable_interface(bool enable) ***************************************************************************/ void mr_menu::slot_fullscreen() { - if (!gui_options.gui_qt_fullscreen) { - gui()->showFullScreen(); - gui()->game_tab_widget->showFullScreen(); - } else { - // FIXME Doesnt return properly, probably something with sidebar - gui()->showNormal(); - gui()->game_tab_widget->showNormal(); - } gui_options.gui_qt_fullscreen = !gui_options.gui_qt_fullscreen; + + gui()->apply_fullscreen(); } /**************************************************************** -- 2.39.2