Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

City Dialog: ExpCol present units list #2428

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions 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,41 @@ void city_dialog::update_units()
units = pcity->tile->units;
}

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

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);
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) {
ui.present_units_group_box->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Minimum);
ui.present_units_exp_col_but->setArrowType(Qt::UpArrow);
ui.present_units_exp_col_but->setToolTip(
_("Click to expand the present units list"));
present_units_exp = false;
} else {
ui.present_units_group_box->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Expanding);
ui.present_units_exp_col_but->setArrowType(Qt::DownArrow);
ui.present_units_exp_col_but->setToolTip(
_("Click to collapse the present units list"));
present_units_exp = true;
}
}

/**
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
Loading