Skip to content

Commit

Permalink
City Dialog: ExpCol present units list
Browse files Browse the repository at this point in the history
  • Loading branch information
jwrober committed Oct 31, 2024
1 parent ea4e231 commit e19e7e2
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 74 deletions.
30 changes: 29 additions & 1 deletion client/citydlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ city_dialog::city_dialog(QWidget *parent) : QWidget(parent)
connect(ui.p_table_p->selectionModel(),
&QItemSelectionModel::selectionChanged, this,
&city_dialog::item_selected);
connect(ui.present_units_exp_col_but, &QAbstractButton::clicked, this,
&city_dialog::present_units_exp_col);

// governor tab
ui.qgbox->setTitle(_("Presets:"));
Expand Down Expand Up @@ -1789,11 +1791,37 @@ void city_dialog::update_units()
units = pcity->tile->units;
}

// set direction of the expand/collapse arrow
if (present_units_exp == false) {
ui.present_units_exp_col_but->setArrowType(Qt::UpArrow);
} else {
ui.present_units_exp_col_but->setArrowType(Qt::DownArrow);
}

n = unit_list_size(units);
ui.present_units_list->setLayoutDirection(Qt::LeftToRight);
ui.present_units_list->set_units(units);
ui.present_units_list->setVisible(n > 0);
fc_snprintf(buf, sizeof(buf), _("Present units: %d"), n);
ui.curr_units->setText(QString(buf));
ui.present_units_label->setText(QString(buf));
}

/**
* Slot to expand or collapse the present units list
*/
void city_dialog::present_units_exp_col()
{
if (present_units_exp == false) {
ui.present_units_group_box->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Expanding);
ui.present_units_exp_col_but->setArrowType(Qt::DownArrow);
present_units_exp = true;
} else {
ui.present_units_group_box->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Minimum);
ui.present_units_exp_col_but->setArrowType(Qt::UpArrow);
present_units_exp = false;
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions client/citydlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class city_dialog : public QWidget {
void refresh();
struct city *pcity = nullptr;
bool dont_focus{false};
bool present_units_exp = false;

private:
void update_title();
Expand Down Expand Up @@ -342,6 +343,7 @@ private slots:
void cma_context_menu(const QPoint p);
void save_cma();
void city_rename();
void present_units_exp_col();

protected:
void showEvent(QShowEvent *event) override;
Expand Down
Loading

0 comments on commit e19e7e2

Please sign in to comment.