From b03ab9a9a5b4ff6f9d7af2ac58ceede1b03bdf7c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 12 Jun 2023 01:51:01 +0300 Subject: [PATCH 38/38] 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 | 20 ++++++++++++++++++-- client/gui-qt/fc_client.h | 1 + client/gui-qt/gui_main.cpp | 10 ++++++++++ client/gui-qt/menu.cpp | 10 ++-------- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/client/gui-qt/fc_client.cpp b/client/gui-qt/fc_client.cpp index 8f4bc23e40..bd7cd0b6c0 100644 --- a/client/gui-qt/fc_client.cpp +++ b/client/gui-qt/fc_client.cpp @@ -366,10 +366,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(); + apply_fullscreen(); } + menuBar()->setVisible(true); mapview_wdg->setFocus(); center_on_something(); @@ -405,6 +406,21 @@ void fc_client::switch_page(int new_pg) } } +/************************************************************************//** + 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(); + } +} + /************************************************************************//** Returns currently open page ****************************************************************************/ diff --git a/client/gui-qt/fc_client.h b/client/gui-qt/fc_client.h index feeb588a6b..6d9f1f6498 100644 --- a/client/gui-qt/fc_client.h +++ b/client/gui-qt/fc_client.h @@ -250,6 +250,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 4018f8881d..e30107a5b7 100644 --- a/client/gui-qt/gui_main.cpp +++ b/client/gui-qt/gui_main.cpp @@ -73,6 +73,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 @@ -254,6 +255,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 } @@ -470,6 +473,13 @@ static void apply_notify_font(struct 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 2200be25ae..06b0eddad3 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -3154,15 +3154,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