From 16c9f07f08dc0b0270da22fac7849ab05284ccac Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 10 Oct 2021 22:36:58 +0300 Subject: [PATCH 46/47] Qt: Do not ignore sex user has explicitly selected for leader Toggling leader sex did not have any effect, sex was selected only when one tool predefined leader from the list. See osdn #42964 Signed-off-by: Marko Lindqvist --- client/gui-qt/dialogs.cpp | 15 ++++++--------- client/gui-qt/dialogs.h | 13 +++++++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/client/gui-qt/dialogs.cpp b/client/gui-qt/dialogs.cpp index a28729674c..7cbd7dd05b 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -17,6 +17,7 @@ // Qt #include +#include #include #include #include @@ -437,7 +438,6 @@ races_dialog::races_dialog(struct player *pplayer, selected_nation = -1; selected_style = -1; - selected_sex = -1; setWindowTitle(_("Select Nation")); selected_nation_tabs->setRowCount(0); selected_nation_tabs->setColumnCount(1); @@ -471,8 +471,11 @@ races_dialog::races_dialog(struct player *pplayer, qgroupbox_layout = new QGridLayout; no_name = new QGroupBox(parent); leader_name = new QComboBox(no_name); + sex_buttons = new QButtonGroup(no_name); is_male = new QRadioButton(no_name); + sex_buttons->addButton(is_male, 1); is_female = new QRadioButton(no_name); + sex_buttons->addButton(is_female, 0); leader_name->setEditable(true); qgroupbox_layout->addWidget(leader_name, 1, 0, 1, 2); @@ -809,11 +812,9 @@ void races_dialog::leader_selected(int index) if (leader_name->itemData(index).toBool()) { is_male->setChecked(true); is_female->setChecked(false); - selected_sex = 1; } else { is_male->setChecked(false); is_female->setChecked(true); - selected_sex = 0; } } @@ -829,11 +830,6 @@ void races_dialog::ok_pressed() return; } - if (selected_sex == -1) { - output_window_append(ftc_client, _("You must select your sex.")); - return; - } - if (selected_style == -1) { output_window_append(ftc_client, _("You must select your style.")); return; @@ -849,9 +845,10 @@ void races_dialog::ok_pressed() _("Nation has been chosen by other player")); return; } + ln_bytes = leader_name->currentText().toUtf8(); dsend_packet_nation_select_req(&client.conn, player_number(tplayer), - selected_nation, selected_sex, + selected_nation, sex_buttons->checkedId(), ln_bytes.data(), selected_style); close(); diff --git a/client/gui-qt/dialogs.h b/client/gui-qt/dialogs.h index eca29d5e6f..dd6a15c849 100644 --- a/client/gui-qt/dialogs.h +++ b/client/gui-qt/dialogs.h @@ -32,6 +32,7 @@ extern "C" { #include "hudwidget.h" #include "mapview.h" +class QButtonGroup; class QComboBox; class QGridLayout; class QGroupBox; @@ -101,7 +102,7 @@ private slots: }; /*************************************************************************** - Dialog for goto popup + Dialog for goto popup ***************************************************************************/ class notify_goto : public QMessageBox { @@ -121,7 +122,7 @@ private slots: }; /*************************************************************************** - Dialog for selecting nation, style and leader leader + Dialog for selecting nation, style and leader leader ***************************************************************************/ class races_dialog:public qfc_dialog { @@ -132,6 +133,7 @@ class races_dialog:public qfc_dialog QTableWidget *selected_nation_tabs; QComboBox *leader_name; QComboBox *qnation_set; + QButtonGroup *sex_buttons; QRadioButton *is_male; QRadioButton *is_female; QTableWidget *styles; @@ -159,14 +161,13 @@ private slots: private: int selected_nation; int selected_style; - int selected_sex; struct player *tplayer; int last_index; }; /*************************************************************************** - Widget around map view to display informations like demographics report, - top 5 cities, traveler's report. + Widget around map view to display informations like demographics report, + top 5 cities, traveler's report. ***************************************************************************/ class notify_dialog:public fcwidget { @@ -195,7 +196,7 @@ private: }; /*************************************************************************** - Transparent widget for selecting units + Transparent widget for selecting units ***************************************************************************/ class units_select: public fcwidget { -- 2.33.0