From 35e81de5c0d1461a42f2eb02915ea1ecbc2b8758 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 10 Apr 2023 13:46:23 +0300 Subject: [PATCH 35/35] Qt: Save nations dialog panel options See osdn #45049 Signed-off-by: Marko Lindqvist --- client/gui-qt/plrdlg.cpp | 31 ++++++++++++++++++++++++++++--- client/options.c | 32 ++++++++++++++++++++++++++------ client/options.h | 3 +++ 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/client/gui-qt/plrdlg.cpp b/client/gui-qt/plrdlg.cpp index 3f51861a33..e7598267b2 100644 --- a/client/gui-qt/plrdlg.cpp +++ b/client/gui-qt/plrdlg.cpp @@ -825,12 +825,28 @@ plr_report::plr_report():QWidget() withdraw_but->setText(_("Withdraw Vision")); toggle_ai_but = new QPushButton; toggle_ai_but->setText(_("AI Mode")); + show_relations = new QPushButton; - show_relations->setText(_("Hide Relations")); + if (gui_options.gui_qt_show_relations_panel) { + show_relations->setText(_("Hide Relations")); + } else { + show_relations->setText(_("Show Relations")); + } + show_techs = new QPushButton; - show_techs->setText(_("Hide Techs")); + if (gui_options.gui_qt_show_techs_panel) { + show_techs->setText(_("Hide Techs")); + } else { + show_techs->setText(_("Show Techs")); + } + show_wonders = new QPushButton; - show_wonders->setText(_("Hide Wonders")); + if (gui_options.gui_qt_show_wonders_panel) { + show_wonders->setText(_("Hide Wonders")); + } else { + show_wonders->setText(_("Show Wonders")); + } + meet_but->setDisabled(true); cancel_but->setDisabled(true); withdraw_but->setDisabled(true); @@ -839,6 +855,9 @@ plr_report::plr_report():QWidget() h_splitter->addWidget(ally_label); h_splitter->addWidget(tech_label); h_splitter->addWidget(wonder_label); + ally_label->setVisible(gui_options.gui_qt_show_relations_panel); + tech_label->setVisible(gui_options.gui_qt_show_techs_panel); + wonder_label->setVisible(gui_options.gui_qt_show_wonders_panel); v_splitter->addWidget(h_splitter); layout->addWidget(v_splitter); hlayout->addWidget(meet_but); @@ -989,9 +1008,11 @@ void plr_report::show_relations_toggle() if (ally_label->isVisible()) { ally_label->hide(); show_relations->setText(_("Show Relations")); + gui_options.gui_qt_show_relations_panel = FALSE; } else { ally_label->show(); show_relations->setText(_("Hide Relations")); + gui_options.gui_qt_show_relations_panel = TRUE; } } @@ -1003,9 +1024,11 @@ void plr_report::show_techs_toggle() if (tech_label->isVisible()) { tech_label->hide(); show_techs->setText(_("Show Techs")); + gui_options.gui_qt_show_techs_panel = FALSE; } else { tech_label->show(); show_techs->setText(_("Hide Techs")); + gui_options.gui_qt_show_techs_panel = TRUE; } } @@ -1017,9 +1040,11 @@ void plr_report::show_wonders_toggle() if (wonder_label->isVisible()) { wonder_label->hide(); show_wonders->setText(_("Show Wonders")); + gui_options.gui_qt_show_wonders_panel = FALSE; } else { wonder_label->show(); show_wonders->setText(_("Hide Wonders")); + gui_options.gui_qt_show_wonders_panel = TRUE; } } diff --git a/client/options.c b/client/options.c index 8652c62744..5e879f0193 100644 --- a/client/options.c +++ b/client/options.c @@ -368,7 +368,10 @@ struct client_options gui_options = { .gui_qt_font_city_productions = "Sans Serif,10,-1,5,50,1,0,0,0,0", .gui_qt_font_reqtree_text = "Sans Serif,10,-1,5,50,1,0,0,0,0", .gui_qt_show_titlebar = TRUE, - .gui_qt_wakeup_text = "Wake up %1" + .gui_qt_wakeup_text = "Wake up %1", + .gui_qt_show_relations_panel = TRUE, + .gui_qt_show_techs_panel = TRUE, + .gui_qt_show_wonders_panel = TRUE }; /* Set to TRUE after the first call to options_init(), to avoid the usage @@ -5868,11 +5871,21 @@ void options_load(void) "%s.flag_qt_default_fonts_set", prefix); /* These are not gui-enabled yet */ - gui_options.zoom_set = - secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix); - gui_options.zoom_default_level = - secfile_lookup_float_default(sf, 1.0, - "%s.zoom_default_level", prefix); + gui_options.zoom_set + = secfile_lookup_bool_default(sf, FALSE, "%s.zoom_set", prefix); + gui_options.zoom_default_level + = secfile_lookup_float_default(sf, 1.0, + "%s.zoom_default_level", prefix); + + gui_options.gui_qt_show_relations_panel + = secfile_lookup_bool_default(sf, TRUE, + "%s.gui_qt_show_relations_panel", prefix); + gui_options.gui_qt_show_techs_panel + = secfile_lookup_bool_default(sf, TRUE, + "%s.gui_qt_show_techs_panel", prefix); + gui_options.gui_qt_show_wonders_panel + = secfile_lookup_bool_default(sf, TRUE, + "%s.gui_qt_show_wonders_panel", prefix); str = secfile_lookup_str_default(sf, NULL, "client.default_tileset_name"); if (str != NULL) { @@ -6006,6 +6019,13 @@ void options_save(option_save_log_callback log_cb) secfile_insert_float(sf, gui_options.zoom_default_level, "client.zoom_default_level"); + secfile_insert_bool(sf, gui_options.gui_qt_show_relations_panel, + "client.gui_qt_show_relations_panel"); + secfile_insert_bool(sf, gui_options.gui_qt_show_techs_panel, + "client.gui_qt_show_techs_panel"); + secfile_insert_bool(sf, gui_options.gui_qt_show_wonders_panel, + "client.gui_qt_show_wonders_panel"); + if (gui_options.default_tileset_name[0] != '\0') { secfile_insert_str(sf, gui_options.default_tileset_name, "client.default_tileset_name"); diff --git a/client/options.h b/client/options.h index 8d7faedcda..419dd766e4 100644 --- a/client/options.h +++ b/client/options.h @@ -394,6 +394,9 @@ struct client_options char gui_qt_font_reqtree_text[512]; bool gui_qt_show_titlebar; char gui_qt_wakeup_text[512]; + bool gui_qt_show_relations_panel; + bool gui_qt_show_techs_panel; + bool gui_qt_show_wonders_panel; struct overview overview; }; -- 2.39.2