Freeciv21
Develop your civilization from humble roots to a global empire
choice_dialog Class Reference

#include <dialogs.h>

+ Inheritance diagram for choice_dialog:
+ Collaboration diagram for choice_dialog:

Public Slots

void execute_action (const int action)
 Run chosen action and close dialog. More...
 

Public Member Functions

 choice_dialog (const QString title, const QString text, QWidget *parent=nullptr, void(*run_on_close_in)(int)=nullptr)
 Constructor for choice_dialog. More...
 
 ~choice_dialog () override
 Destructor for choice dialog. More...
 
void set_layout ()
 Sets layout for choice dialog. More...
 
void add_item (QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
 Adds new action for choice dialog. More...
 
void show_me ()
 Shows choice dialog. More...
 
void stack_button (Choice_dialog_button *button)
 Put the button in the stack and temporarily remove it. More...
 
void unstack_all_buttons ()
 Put all the buttons in the stack back to the dialog. More...
 
QVBoxLayout * get_layout ()
 Returns layout in choice dialog. More...
 
Choice_dialog_buttonget_identified_button (const int id)
 Get the button with the given identity. More...
 
void update_dialog (const struct act_prob *act_probs)
 Update dialog for new target (targeted_unit) More...
 

Public Attributes

int unit_id
 
int target_id [ATK_COUNT]
 
int sub_target_id [ASTK_COUNT]
 
struct unittargeted_unit
 

Private Slots

void prev_unit ()
 Focus previous target. More...
 
void next_unit ()
 Focus next target. More...
 

Private Member Functions

void switch_target ()
 Switches target unit. More...
 

Private Attributes

QPushButton * target_unit_button
 
QVBoxLayout * layout
 
QHBoxLayout * unit_skip
 
QList< Choice_dialog_button * > buttons_list
 
QList< Choice_dialog_button * > last_buttons_stack
 
QList< Choice_dialog_button * > action_button_map
 
void(* run_on_close )(int)
 

Detailed Description

Definition at line 183 of file dialogs.h.

Constructor & Destructor Documentation

◆ choice_dialog()

choice_dialog::choice_dialog ( const QString  title,
const QString  text,
QWidget *  parent = nullptr,
void(*)(int)  run_on_close_in = nullptr 
)

Constructor for choice_dialog.

Definition at line 1139 of file dialogs.cpp.

◆ ~choice_dialog()

choice_dialog::~choice_dialog ( )
override

Destructor for choice dialog.

Definition at line 1176 of file dialogs.cpp.

Member Function Documentation

◆ add_item()

void choice_dialog::add_item ( QString  title,
pfcn_void  func,
QVariant  data1,
QVariant  data2,
QString  tool_tip = QLatin1String(""),
const int  button_id = -1 
)

Adds new action for choice dialog.

Definition at line 1236 of file dialogs.cpp.

Referenced by action_entry(), popup_action_selection(), popup_pillage_dialog(), popup_sabotage_dialog(), and spy_steal_shared().

◆ execute_action

void choice_dialog::execute_action ( const int  action)
slot

Run chosen action and close dialog.

Definition at line 1441 of file dialogs.cpp.

Referenced by add_item().

◆ get_identified_button()

Choice_dialog_button * choice_dialog::get_identified_button ( const int  id)

Get the button with the given identity.

Definition at line 1284 of file dialogs.cpp.

Referenced by action_selection_refresh().

◆ get_layout()

QVBoxLayout * choice_dialog::get_layout ( )

Returns layout in choice dialog.

Definition at line 1279 of file dialogs.cpp.

◆ next_unit

void choice_dialog::next_unit ( )
privateslot

Focus next target.

Definition at line 1332 of file dialogs.cpp.

Referenced by set_layout().

◆ prev_unit

void choice_dialog::prev_unit ( )
privateslot

Focus previous target.

Definition at line 1374 of file dialogs.cpp.

Referenced by set_layout().

◆ set_layout()

void choice_dialog::set_layout ( )

Sets layout for choice dialog.

Definition at line 1191 of file dialogs.cpp.

Referenced by popup_action_selection(), popup_pillage_dialog(), popup_sabotage_dialog(), and spy_steal_shared().

◆ show_me()

void choice_dialog::show_me ( )

Shows choice dialog.

Definition at line 1265 of file dialogs.cpp.

Referenced by popup_action_selection(), popup_pillage_dialog(), popup_sabotage_dialog(), and spy_steal_shared().

◆ stack_button()

void choice_dialog::stack_button ( Choice_dialog_button button)

Put the button in the stack and temporarily remove it.

When unstack_all_buttons() is called all buttons in the stack will be added to the end of the dialog.

Can be used to place a button below existing buttons or below buttons added while it was in the stack.

Definition at line 1458 of file dialogs.cpp.

Referenced by action_selection_refresh().

◆ switch_target()

void choice_dialog::switch_target ( )
private

Switches target unit.

Definition at line 1425 of file dialogs.cpp.

Referenced by next_unit(), and prev_unit().

◆ unstack_all_buttons()

void choice_dialog::unstack_all_buttons ( )

Put all the buttons in the stack back to the dialog.

They will appear after any other buttons. See stack_button()

Definition at line 1475 of file dialogs.cpp.

Referenced by action_selection_refresh().

◆ update_dialog()

void choice_dialog::update_dialog ( const struct act_prob act_probs)

Update dialog for new target (targeted_unit)

Definition at line 1405 of file dialogs.cpp.

Referenced by popup_action_selection().

Member Data Documentation

◆ action_button_map

QList<Choice_dialog_button *> choice_dialog::action_button_map
private

Definition at line 190 of file dialogs.h.

Referenced by add_item(), choice_dialog(), get_identified_button(), and ~choice_dialog().

◆ buttons_list

QList<Choice_dialog_button *> choice_dialog::buttons_list
private

◆ last_buttons_stack

QList<Choice_dialog_button *> choice_dialog::last_buttons_stack
private

Definition at line 189 of file dialogs.h.

Referenced by stack_button(), and unstack_all_buttons().

◆ layout

QVBoxLayout* choice_dialog::layout
private

◆ run_on_close

void(* choice_dialog::run_on_close) (int)
private

Definition at line 191 of file dialogs.h.

Referenced by choice_dialog(), and ~choice_dialog().

◆ sub_target_id

int choice_dialog::sub_target_id[ASTK_COUNT]

◆ target_id

◆ target_unit_button

QPushButton* choice_dialog::target_unit_button
private

Definition at line 185 of file dialogs.h.

Referenced by next_unit(), prev_unit(), and set_layout().

◆ targeted_unit

struct unit* choice_dialog::targeted_unit

◆ unit_id

◆ unit_skip

QHBoxLayout* choice_dialog::unit_skip
private

Definition at line 187 of file dialogs.h.

Referenced by set_layout(), switch_target(), and update_dialog().