From af36a2dcbdf3617b90aa2a5bddfaa3c9635ecd37 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 16 Oct 2022 09:52:02 +0300 Subject: [PATCH 29/29] Qt: Add Relations and Techs display toggles to plrdlg See osdn #45048 Signed-off-by: Marko Lindqvist --- client/gui-qt/plrdlg.cpp | 55 ++++++++++++++++++++++++++++++++++++---- client/gui-qt/plrdlg.h | 4 +++ 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/client/gui-qt/plrdlg.cpp b/client/gui-qt/plrdlg.cpp index ec075f6024..3e9d878fd0 100644 --- a/client/gui-qt/plrdlg.cpp +++ b/client/gui-qt/plrdlg.cpp @@ -427,6 +427,7 @@ void plr_widget::nation_selected(const QItemSelection &sl, struct player *me; Tech_type_id tech_id; bool global_observer = client_is_global_observer(); + bool intel; other_player = NULL; intel_str.clear(); @@ -482,8 +483,10 @@ void plr_widget::nation_selected(const QItemSelection &sl, elux = _("(Unknown)"); cult = _("(Unknown)"); } - if (global_observer || pplayer == me - || could_intel_with_player(me, pplayer)) { + + intel = global_observer || could_intel_with_player(me, pplayer); + + if (intel || pplayer == me) { egold = QString::number(pplayer->economic.gold); egov = QString(government_name_for_player(pplayer)); } else { @@ -532,8 +535,7 @@ void plr_widget::nation_selected(const QItemSelection &sl, continue; } state = player_diplstate_get(pplayer, other); - if (static_cast(state->type) == i - && (global_observer || could_intel_with_player(me, pplayer))) { + if (static_cast(state->type) == i && intel) { if (!added) { ally_str = ally_str + QString("") + QString(diplstate_type_translated_name( @@ -688,6 +690,8 @@ plr_widget::~plr_widget() **************************************************************************/ plr_report::plr_report():QWidget() { + QFrame *line; + v_splitter = new QSplitter(Qt::Vertical); h_splitter = new QSplitter(Qt::Horizontal); layout = new QVBoxLayout; @@ -721,8 +725,12 @@ plr_report::plr_report():QWidget() withdraw_but->setText(_("Withdraw Vision")); toggle_ai_but = new QPushButton; toggle_ai_but->setText(_("Toggle AI Mode")); + show_relations = new QPushButton; + show_relations->setText(_("Hide Relations")); + show_techs = new QPushButton; + show_techs->setText(_("Hide Techs")); show_wonders = new QPushButton; - show_wonders->setText(_("Show Wonders")); + show_wonders->setText(_("Hide Wonders")); meet_but->setDisabled(true); cancel_but->setDisabled(true); withdraw_but->setDisabled(true); @@ -738,6 +746,11 @@ plr_report::plr_report():QWidget() hlayout->addWidget(cancel_but); hlayout->addWidget(withdraw_but); hlayout->addWidget(toggle_ai_but); + line = new QFrame(); + line->setFrameShape(QFrame::VLine); + hlayout->addWidget(line); + hlayout->addWidget(show_relations); + hlayout->addWidget(show_techs); hlayout->addWidget(show_wonders); hlayout->addStretch(); layout->addLayout(hlayout); @@ -745,6 +758,8 @@ plr_report::plr_report():QWidget() connect(cancel_but, &QAbstractButton::pressed, this, &plr_report::req_caancel_threaty); connect(withdraw_but, &QAbstractButton::pressed, this, &plr_report::req_wiithdrw_vision); connect(toggle_ai_but, &QAbstractButton::pressed, this, &plr_report::toggle_ai_mode); + connect(show_relations, &QAbstractButton::pressed, this, &plr_report::show_relations_toggle); + connect(show_techs, &QAbstractButton::pressed, this, &plr_report::show_techs_toggle); connect(show_wonders, &QAbstractButton::pressed, this, &plr_report::show_wonders_toggle); setLayout(layout); if (gui()->qt_settings.player_repo_sort_col != -1) { @@ -851,6 +866,34 @@ void plr_report::toggle_ai_mode() } +/************************************************************************** + Slot to enable/disable relations display +**************************************************************************/ +void plr_report::show_relations_toggle() +{ + if (ally_label->isVisible()) { + ally_label->hide(); + show_relations->setText(_("Show Relations")); + } else { + ally_label->show(); + show_relations->setText(_("Hide Relations")); + } +} + +/************************************************************************** + Slot to enable/disable techs display +**************************************************************************/ +void plr_report::show_techs_toggle() +{ + if (tech_label->isVisible()) { + tech_label->hide(); + show_techs->setText(_("Show Techs")); + } else { + tech_label->show(); + show_techs->setText(_("Hide Techs")); + } +} + /************************************************************************** Slot to enable/disable wonders display **************************************************************************/ @@ -858,8 +901,10 @@ void plr_report::show_wonders_toggle() { if (wonder_label->isVisible()) { wonder_label->hide(); + show_wonders->setText(_("Show Wonders")); } else { wonder_label->show(); + show_wonders->setText(_("Hide Wonders")); } } diff --git a/client/gui-qt/plrdlg.h b/client/gui-qt/plrdlg.h index febd2034dd..277a538144 100644 --- a/client/gui-qt/plrdlg.h +++ b/client/gui-qt/plrdlg.h @@ -155,6 +155,8 @@ class plr_report: public QWidget QPushButton *cancel_but; QPushButton *withdraw_but; QPushButton *toggle_ai_but; + QPushButton *show_relations; + QPushButton *show_techs; QPushButton *show_wonders; QVBoxLayout *layout; QHBoxLayout *hlayout; @@ -174,6 +176,8 @@ private slots: * autoconnect */ void req_wiithdrw_vision(); void toggle_ai_mode(); + void show_relations_toggle(); + void show_techs_toggle(); void show_wonders_toggle(); }; -- 2.35.1