19 #include <QDialogButtonBox>
21 #include <QHeaderView>
24 #include <QRadioButton>
25 #include <QVBoxLayout>
32 QHBoxLayout *hbox, *hibox;
35 QVBoxLayout *groupbox_layout;
40 setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog
41 | Qt::FramelessWindowHint);
60 no_name =
new QGroupBox();
61 no_name->setTitle(
_(
"Unit type"));
62 this_type =
new QRadioButton(
_(
"Selected type"), no_name);
64 any_type =
new QRadioButton(
_(
"All types"), no_name);
65 connect(
unit_sel_type, qOverload<int>(&QComboBox::currentIndexChanged),
67 connect(
this_type, &QRadioButton::toggled,
this,
69 connect(
any_type, &QRadioButton::toggled,
this,
71 groupbox_layout =
new QVBoxLayout;
74 groupbox_layout->addWidget(
any_type);
75 no_name->setLayout(groupbox_layout);
76 hibox =
new QHBoxLayout;
77 hibox->addWidget(no_name);
79 no_name =
new QGroupBox();
80 no_name->setTitle(
_(
"Unit activity"));
83 fortified =
new QRadioButton(
_(
"Fortified"), no_name);
84 idle =
new QRadioButton(
_(
"Idle"), no_name);
85 sentried =
new QRadioButton(
_(
"Sentried"), no_name);
88 connect(
idle, &QRadioButton::toggled,
this,
90 connect(
fortified, &QRadioButton::toggled,
this,
92 connect(
sentried, &QRadioButton::toggled,
this,
94 groupbox_layout =
new QVBoxLayout;
96 groupbox_layout->addWidget(
idle);
98 groupbox_layout->addWidget(
sentried);
99 no_name->setLayout(groupbox_layout);
100 hibox->addWidget(no_name);
103 no_name =
new QGroupBox();
104 no_name->setTitle(
_(
"Unit HP and MP"));
105 any =
new QRadioButton(
_(
"Any unit"), no_name);
106 full_hp =
new QRadioButton(
_(
"Full HP"), no_name);
107 full_mp =
new QRadioButton(
_(
"Full MP"), no_name);
108 full_hp_mp =
new QRadioButton(
_(
"Full HP and MP"), no_name);
110 connect(
any, &QRadioButton::toggled,
this,
112 connect(
full_hp, &QRadioButton::toggled,
this,
114 connect(
full_mp, &QRadioButton::toggled,
this,
116 connect(
full_hp_mp, &QRadioButton::toggled,
this,
118 groupbox_layout =
new QVBoxLayout;
119 groupbox_layout->addWidget(
any);
120 groupbox_layout->addWidget(
full_hp);
121 groupbox_layout->addWidget(
full_mp);
123 no_name->setLayout(groupbox_layout);
124 hibox =
new QHBoxLayout;
125 hibox->addWidget(no_name);
127 no_name =
new QGroupBox();
128 no_name->setTitle(
_(
"Location"));
129 anywhere =
new QRadioButton(
_(
"Anywhere"), no_name);
130 this_tile =
new QRadioButton(
_(
"Current tile"), no_name);
133 groupbox_layout =
new QVBoxLayout;
146 groupbox_layout->addWidget(
anywhere);
148 no_name->setLayout(groupbox_layout);
149 hibox->addWidget(no_name);
152 select =
new QPushButton(
_(
"Select"));
153 cancel =
new QPushButton(
_(
"Cancel"));
154 connect(
anywhere, &QRadioButton::toggled,
this,
156 connect(
this_tile, &QRadioButton::toggled,
this,
162 connect(
select, &QAbstractButton::clicked,
this,
164 connect(
cancel, &QAbstractButton::clicked,
this,
166 hbox =
new QHBoxLayout;
183 p = QPoint((parentWidget()->width() - sizeHint().width()) / 2,
184 (parentWidget()->height() - sizeHint().height()) / 2);
185 p = parentWidget()->mapToGlobal(p);
202 const struct player *pplayer;
228 const struct player *pplayer;
240 result_label.setText(QString(
PL_(
"%1 unit",
"%1 units", num)).arg(num));
253 if ((
event->key() == Qt::Key_Return) || (
event->key() == Qt::Key_Enter)) {
256 if (
event->key() == Qt::Key_Escape) {
260 QWidget::keyPressEvent(
event);
270 || (punit->
activity == ACTIVITY_IDLE &&
idle->isChecked())
279 return any->isChecked()
327 utype_id = qvar.toInt();
QRadioButton * this_continent
QComboBox * unit_sel_type
QVBoxLayout * main_layout
QRadioButton * main_continent
QRadioButton * full_hp_mp
bool island_filter(struct unit *punit)
Filter by location.
bool type_filter(struct unit *punit)
Filter by type.
unit_hud_selector(QWidget *parent)
Constructor for unit_hud_selector.
void uhs_select()
Selects and closes widget.
~unit_hud_selector() override
Unit_hud_selector destructor.
void select_units(int x=0)
Shows number of selected units on label.
QRadioButton * any_activity
bool activity_filter(struct unit *punit)
Filter by activity.
bool hp_filter(struct unit *punit)
Filter by hp/mp.
void show_me()
Shows and moves to center unit_hud_selector.
void uhs_cancel()
Closes current widget.
void keyPressEvent(QKeyEvent *event) override
Key press event for unit_hud_selector.
struct player * client_player()
Either controlling or observing.
void unit_focus_add(struct unit *punit)
Adds this unit to the list of units in focus.
struct unit * head_of_units_in_focus()
Return head of focus units list.
#define PL_(String1, String2, n)
struct city * player_primary_capital(const struct player *pplayer)
Locate the player's primary capital city, (nullptr Otherwise)
enum unit_activity activity
const struct unit_type * utype
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const char * utype_name_translation(const struct unit_type *punittype)
Return the (translated) name of the unit type.
Unit_type_id utype_index(const struct unit_type *punittype)
Return the unit type index.
#define unit_type_iterate(_p)
#define unit_type_iterate_end