From 52ca4760dcaf777cbfc0fcca87b6d26857003d6c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 18 Jul 2022 18:10:01 +0300 Subject: [PATCH 38/38] Qt: Adjust UI depending if gold clauses are enabled See osdn #45149 Signed-off-by: Marko Lindqvist --- client/gui-qt/diplodlg.cpp | 52 +++++++++++++++++++++++--------------- client/gui-qt/diplodlg.h | 2 -- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/client/gui-qt/diplodlg.cpp b/client/gui-qt/diplodlg.cpp index 62b800844c..fe884df17a 100644 --- a/client/gui-qt/diplodlg.cpp +++ b/client/gui-qt/diplodlg.cpp @@ -63,8 +63,6 @@ diplo_wdg::diplo_wdg(int counterpart, int initiated_from): QWidget() QLabel *label2; QLabel *label3; QLabel *label4; - QLabel *goldlab1; - QLabel *goldlab2; QPushButton *add_clause1; QPushButton *add_clause2; QPixmap *pix = NULL; @@ -77,6 +75,8 @@ diplo_wdg::diplo_wdg(int counterpart, int initiated_from): QWidget() get_color(tileset, COLOR_MAPVIEW_CITYTEXT), get_color(tileset, COLOR_MAPVIEW_CITYTEXT_DARK) }; + int clause_column; + if (counterpart == initiated_from) { initiated_from = client_player_number(); } @@ -163,22 +163,36 @@ diplo_wdg::diplo_wdg(int counterpart, int initiated_from): QWidget() layout->addWidget(plr2_label, 6, 0); layout->addWidget(label2, 6, 5); layout->addWidget(plr2_accept, 6, 10); - goldlab1 = new QLabel(_("Gold:")); - goldlab1->setAlignment(Qt::AlignRight); - goldlab2 = new QLabel(_("Gold:")); - goldlab2->setAlignment(Qt::AlignRight); - gold_edit1 = new QSpinBox; - gold_edit2 = new QSpinBox; - gold_edit1->setMinimum(0); - gold_edit2->setMinimum(0); - gold_edit1->setFocusPolicy(Qt::ClickFocus); - gold_edit2->setFocusPolicy(Qt::ClickFocus); - if (game.info.trading_gold) { + + if (clause_enabled(CLAUSE_GOLD)) { + QLabel *goldlab1; + QLabel *goldlab2; + QSpinBox *gold_edit1; + QSpinBox *gold_edit2; + + goldlab1 = new QLabel(_("Gold:")); + goldlab1->setAlignment(Qt::AlignRight); + goldlab2 = new QLabel(_("Gold:")); + goldlab2->setAlignment(Qt::AlignRight); + gold_edit1 = new QSpinBox; + gold_edit2 = new QSpinBox; + gold_edit1->setMinimum(0); + gold_edit2->setMinimum(0); + gold_edit1->setFocusPolicy(Qt::ClickFocus); + gold_edit2->setFocusPolicy(Qt::ClickFocus); gold_edit2->setMaximum(player_by_number(player1)->economic.gold); gold_edit1->setMaximum(player_by_number(player2)->economic.gold); + connect(gold_edit1, SIGNAL(valueChanged(int)), SLOT(gold_changed1(int))); + connect(gold_edit2, SIGNAL(valueChanged(int)), SLOT(gold_changed2(int))); + layout->addWidget(goldlab1, 7, 4); + layout->addWidget(goldlab2, 3, 4); + layout->addWidget(gold_edit1, 7, 5); + layout->addWidget(gold_edit2, 3, 5); + clause_column = 6; + } else { + clause_column = 5; } - connect(gold_edit1, SIGNAL(valueChanged(int)), SLOT(gold_changed1(int))); - connect(gold_edit2, SIGNAL(valueChanged(int)), SLOT(gold_changed2(int))); + add_clause1 = new QPushButton(style()->standardIcon(QStyle::SP_ArrowRight), _("Add Clause...")); add_clause2 = new QPushButton(style()->standardIcon(QStyle::SP_ArrowRight), @@ -187,12 +201,8 @@ diplo_wdg::diplo_wdg(int counterpart, int initiated_from): QWidget() add_clause2->setFocusPolicy(Qt::ClickFocus); connect(add_clause1, &QAbstractButton::clicked, this, &diplo_wdg::show_menu_p2); connect(add_clause2, &QAbstractButton::clicked, this, &diplo_wdg::show_menu_p1); - layout->addWidget(goldlab1, 7, 4); - layout->addWidget(goldlab2, 3, 4); - layout->addWidget(gold_edit1, 7, 5); - layout->addWidget(gold_edit2, 3, 5); - layout->addWidget(add_clause1, 7, 6); - layout->addWidget(add_clause2, 3, 6); + layout->addWidget(add_clause1, 7, clause_column); + layout->addWidget(add_clause2, 3, clause_column); text_edit = new QTableWidget(); text_edit->setColumnCount(1); diff --git a/client/gui-qt/diplodlg.h b/client/gui-qt/diplodlg.h index e8a99a1acb..c47880a300 100644 --- a/client/gui-qt/diplodlg.h +++ b/client/gui-qt/diplodlg.h @@ -54,8 +54,6 @@ class diplo_wdg: public QWidget QLabel *plr2_accept; QPushButton *accept_treaty; QPushButton *cancel_treaty; - QSpinBox *gold_edit1; - QSpinBox *gold_edit2; QTableWidget *text_edit; public: -- 2.35.1