From 74d3580eec508b05583db529f07fc02edc17f352 Mon Sep 17 00:00:00 2001 From: Dino Date: Sun, 8 Nov 2026 20:25:25 -0500 Subject: [PATCH] qt: help -> units show all tech requirements RM #1604 --- client/gui-qt/helpdlg.cpp | 62 ++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index bf5c7f090c..ca7999be30 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -883,11 +883,12 @@ void help_widget::set_topic_unit(const help_item *topic, struct canvas *canvas; const struct unit_type *obsolete; struct unit_type *utype, *max_utype; - QList list; QString str; utype = unit_type_by_translated_name(title); if (utype) { + int num_tech_reqs = 0; + helptext_unit(buffer, sizeof(buffer), client.conn.playing, topic->text, utype, TRUE); text_browser->setPlainText(buffer); @@ -935,26 +936,53 @@ void help_widget::set_topic_unit(const help_item *topic, add_info_separator(); - // Tech requirement - tech = utype_primary_tech_req(utype); - if (advance_number(tech) != A_NONE) { - QLabel *tb; + // Tech requirements + // count number of tech reqs + unit_tech_reqs_iterate(utype, padv) { + (void) padv; /* suppress unused variable warning */ + num_tech_reqs++; + } unit_tech_reqs_iterate_end; - tb = new QLabel(this); + if (num_tech_reqs == 0) { + add_info_label(_("No technology required.")); + } else { + // there is >= 1 req // TRANS: this and similar literal strings interpreted as (Qt) HTML str = _("Requires"); - str = "" + str + " " - + link_me(advance_name_translation(tech), HELP_TECH); + str = "" + str + " "; - tb->setProperty(fonts::help_label, "true"); - tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); - tb->setTextFormat(Qt::RichText); - tb->setText(str.trimmed()); - connect(tb, &QLabel::linkActivated, - this, &help_widget::anchor_clicked); - info_layout->addWidget(tb); - } else { - add_info_label(_("No technology required.")); + // iterate all the reqs + QLabel *tb; + int num_reqs_on_this_line = 0; + unit_tech_reqs_iterate(utype, padv) { + str = str + link_me(advance_name_translation(padv), HELP_TECH); + if (++num_reqs_on_this_line == 3) { + // start a new line when we get 3 on this line + tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); + tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); + tb->setTextFormat(Qt::RichText); + tb->setText(str.trimmed()); + connect(tb, &QLabel::linkActivated, + this, &help_widget::anchor_clicked); + info_layout->addWidget(tb); + + num_reqs_on_this_line = 0; + str = ""; + } + } unit_tech_reqs_iterate_end; + + // finish any leftovers on last line + if (num_reqs_on_this_line != 0) { + tb = new QLabel(this); + tb->setProperty(fonts::help_label, "true"); + tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse); + tb->setTextFormat(Qt::RichText); + tb->setText(str.trimmed()); + connect(tb, &QLabel::linkActivated, + this, &help_widget::anchor_clicked); + info_layout->addWidget(tb); + } } // Obsolescence -- 2.31.0