Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/dialogs.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
dialogs.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__DIALOGS_H
15#define FC__DIALOGS_H
16
17#ifdef HAVE_CONFIG_H
18#include <fc_config.h>
19#endif
20
21extern "C" {
22#include "dialogs_g.h"
23}
24
25// Qt
26#include <QDialog>
27#include <QMessageBox>
28#include <QVariant>
29
30// gui-qt
31#include "fonts.h"
32#include "hudwidget.h"
33#include "mapview.h"
34
35class QButtonGroup;
36class QComboBox;
37class QGridLayout;
38class QGroupBox;
39class QItemSelection;
40class QRadioButton;
41class QTableView;
42class QTableWidget;
43class QTextEdit;
44class QWidget;
45
46 typedef void (*pfcn_void)(QVariant, QVariant);
47void update_nationset_combo();
48void popup_races_dialog(struct player *pplayer);
49void restart_notify_dialogs();
50
51
52 class qdef_act
53{
54 Q_DISABLE_COPY(qdef_act);
55
56private:
57 explicit qdef_act();
58 static qdef_act* m_instance;
59 action_id vs_city;
60 action_id vs_unit;
61public:
62 static qdef_act* action();
63 static void drop();
64 void vs_city_set(int i);
65 void vs_unit_set(int i);
66 action_id vs_city_get();
67 action_id vs_unit_get();
68};
69
70/***************************************************************************
71 Dialog with themed titlebar
72***************************************************************************/
73 class qfc_dialog : public QDialog
74{
75 Q_OBJECT
76public:
77 qfc_dialog(QWidget *parent);
78 void reactivate();
79private:
80 int titlebar_height;
81 QPoint point;
82 bool moving_now;
83 QPixmap close_pix;
84protected:
85 void paintEvent(QPaintEvent* event);
86 void mouseMoveEvent(QMouseEvent *event);
87 void mousePressEvent(QMouseEvent *event);
88 void mouseReleaseEvent(QMouseEvent *event);
89};
90
91/***************************************************************************
92 Nonmodal message box for disbanding units
93***************************************************************************/
94 class disband_box : public hud_message_box
95{
96 Q_OBJECT
97 struct unit_list *cpunits;
98public:
99 explicit disband_box(struct unit_list *punits, QWidget *parent = 0);
100 ~disband_box();
101private slots:
102 void disband_clicked();
103};
104
105/***************************************************************************
106 Dialog for goto popup
107***************************************************************************/
108 class notify_goto : public QMessageBox
109{
110 Q_OBJECT
111 QPushButton *goto_but;
112 QPushButton *inspect_but;
113 QPushButton *close_but;
114 struct tile *gtile;
115public:
116 notify_goto(const char *headline, const char *lines,
117 const struct text_tag_list *tags, struct tile *ptile,
118 QWidget *parent);
119
120private slots:
121 void goto_tile();
122 void inspect_city();
123};
124
125/***************************************************************************
126 Dialog for selecting nation, style and leader leader
127***************************************************************************/
128 class races_dialog:public qfc_dialog
129{
130 Q_OBJECT
131 QGridLayout *main_layout;
132 QTableWidget *nation_tabs;
133 QList<QWidget*> *nations_tabs_list;
134 QTableWidget *selected_nation_tabs;
135 QComboBox *leader_name;
136 QComboBox *qnation_set;
137 QButtonGroup *sex_buttons;
138 QRadioButton *is_male;
139 QRadioButton *is_female;
140 QTableWidget *styles;
141 QTextEdit *description;
142 QPushButton *ok_button;
143 QPushButton *random_button;
144
145public:
146 races_dialog(struct player *pplayer, QWidget *parent = 0);
147 ~races_dialog();
148 void refresh();
149 void update_nationset_combo();
150
151private slots:
152 void set_index(int index);
153 void nation_selected(const QItemSelection &sl, const QItemSelection &ds);
154 void style_selected(const QItemSelection &sl, const QItemSelection &ds);
155 void group_selected(const QItemSelection &sl, const QItemSelection &ds);
156 void nationset_changed(int index);
157 void leader_selected(int index);
158 void ok_pressed();
159 void cancel_pressed();
160 void random_pressed();
161
162private:
163 int selected_nation;
164 int selected_style;
165 struct player *tplayer;
166 int last_index;
167};
168
169/***************************************************************************
170 Widget around map view to display informations like demographics report,
171 top 5 cities, traveler's report.
172***************************************************************************/
173 class notify_dialog:public fcwidget
174{
175 Q_OBJECT
176public:
177 notify_dialog(const char *caption, const char *headline,
178 const char *lines, QWidget *parent = 0);
179 virtual void update_menu();
180 ~notify_dialog();
181 void restart();
182protected:
183 void mousePressEvent(QMouseEvent *event);
184 void mouseMoveEvent(QMouseEvent *event);
185 void mouseReleaseEvent(QMouseEvent *event);
186private:
187 void paintEvent(QPaintEvent *paint_event);
188 void calc_size(int &x, int&y);
189 close_widget *cw;
190 QLabel *label;
191 QVBoxLayout *layout;
192 QString qcaption;
193 QString qheadline;
194 QStringList qlist;
195 QFont small_font;
196 QPoint cursor;
197};
198
199/***************************************************************************
200 Transparent widget for selecting units
201***************************************************************************/
202 class units_select: public fcwidget
203{
204 Q_OBJECT
205 QPixmap *pix;
206 QPixmap *h_pix;
207 QSize item_size;
208 QList<unit*> unit_list;
210 QFont ufont;
211 QFont info_font;
212 int row_count;
213 close_widget *cw;
214public:
215 units_select(struct tile *ptile, QWidget *parent);
216 ~units_select();
217 void update_menu();
218 void update_units();
219 void create_pixmap();
220 tile *utile;
221protected:
222 void paint(QPainter *painter, QPaintEvent *event);
223 void paintEvent(QPaintEvent *event);
224 void mousePressEvent(QMouseEvent *event);
225 void keyPressEvent(QKeyEvent *event);
226 void mouseMoveEvent(QMouseEvent *event);
227 void wheelEvent(QWheelEvent *event);
228 void closeEvent(QCloseEvent *event);
229private slots:
230 void update_img();
231private:
232 bool more;
233 int show_line;
234 int highligh_num;
235 int unit_count;
236};
237
238/**************************************************************************
239 A QPushButton that includes data like function to call and parmeters
240**************************************************************************/
241 class Choice_dialog_button: public QPushButton
242{
243 Q_OBJECT
244 pfcn_void func;
245 QVariant data1, data2;
246public:
247 Choice_dialog_button(const QString title, pfcn_void func_in,
248 QVariant data1_in, QVariant data2_in);
249 pfcn_void getFunc();
250 QVariant getData1();
251 QVariant getData2();
252 void setData1(QVariant wariat);
253 void setData2(QVariant wariat);
254};
255
256/***************************************************************************
257 Simple choice dialog, allowing choosing one of set actions
258***************************************************************************/
259 class choice_dialog: public QWidget
260{
261 Q_OBJECT
262 QPushButton *target_unit_button;
263 QVBoxLayout *layout;
264 QHBoxLayout *unit_skip;
265 QList<Choice_dialog_button *> buttons_list;
266 QList<Choice_dialog_button *> last_buttons_stack;
267 QList<Choice_dialog_button *> action_button_map;
268 void (*run_on_close)(int);
269 void switch_target();
270public:
271 choice_dialog(const QString title, const QString text,
272 QWidget *parent = NULL,
273 void (*run_on_close_in)(int) = NULL);
274 ~choice_dialog();
275 void set_layout();
276 void add_item(QString title, pfcn_void func, QVariant data1,
277 QVariant data2, QString tool_tip, const int button_id);
278 void show_me();
279 void stack_button(Choice_dialog_button *button);
280 void unstack_all_buttons();
281 QVBoxLayout *get_layout();
282 Choice_dialog_button *get_identified_button(const int id);
283 int unit_id;
284 int target_id[ATK_COUNT];
285 int sub_target_id[ASTK_COUNT];
286 struct unit* targeted_unit;
287 void update_dialog(const struct act_prob *act_probs);
288public slots:
289 void execute_action(const int action);
290private slots:
291 void prev_unit();
292 void next_unit();
293};
294
295void popup_revolution_dialog(struct government *gov = nullptr);
296void revolution_response(struct government *gov);
297void popup_upgrade_dialog(struct unit_list *punits);
298void popup_disband_dialog(struct unit_list *punits);
299bool try_default_unit_action(QVariant q1, QVariant q2);
300bool try_default_city_action(QVariant q1, QVariant q2);
301
302#endif /* FC__DIALOGS_H */
Choice_dialog_button
Definition dialogs.h:242
Choice_dialog_button::data2
QVariant data2
Definition dialogs.h:245
Choice_dialog_button::func
pfcn_void func
Definition dialogs.h:244
Choice_dialog_button::data1
QVariant data1
Definition dialogs.h:245
Choice_dialog_button::getData2
QVariant getData2()
Definition dialogs.cpp:1347
Choice_dialog_button::setData2
void setData2(QVariant wariat)
Definition dialogs.cpp:1363
Choice_dialog_button::setData1
void setData1(QVariant wariat)
Definition dialogs.cpp:1355
Choice_dialog_button::getData1
QVariant getData1()
Definition dialogs.cpp:1338
Choice_dialog_button::getFunc
pfcn_void getFunc()
Definition dialogs.cpp:1329
choice_dialog
Definition dialogs.h:260
choice_dialog::stack_button
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1689
choice_dialog::prev_unit
void prev_unit()
Definition dialogs.cpp:1606
choice_dialog::layout
QVBoxLayout * layout
Definition dialogs.h:263
choice_dialog::unit_id
int unit_id
Definition dialogs.h:283
choice_dialog::targeted_unit
struct unit * targeted_unit
Definition dialogs.h:286
choice_dialog::unstack_all_buttons
void unstack_all_buttons()
Definition dialogs.cpp:1706
choice_dialog::get_identified_button
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1518
choice_dialog::target_unit_button
QPushButton * target_unit_button
Definition dialogs.h:262
choice_dialog::set_layout
void set_layout()
Definition dialogs.cpp:1424
choice_dialog::update_dialog
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1635
choice_dialog::last_buttons_stack
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
choice_dialog::next_unit
void next_unit()
Definition dialogs.cpp:1566
choice_dialog::show_me
void show_me()
Definition dialogs.cpp:1496
choice_dialog::get_layout
QVBoxLayout * get_layout()
Definition dialogs.cpp:1510
choice_dialog::unit_skip
QHBoxLayout * unit_skip
Definition dialogs.h:264
choice_dialog::buttons_list
QList< Choice_dialog_button * > buttons_list
Definition dialogs.h:265
choice_dialog::run_on_close
void(* run_on_close)(int)
Definition dialogs.h:268
choice_dialog::~choice_dialog
~choice_dialog()
Definition dialogs.cpp:1409
choice_dialog::target_id
int target_id[ATK_COUNT]
Definition dialogs.h:284
choice_dialog::switch_target
void switch_target()
Definition dialogs.cpp:1653
choice_dialog::action_button_map
QList< Choice_dialog_button * > action_button_map
Definition dialogs.h:267
choice_dialog::sub_target_id
int sub_target_id[ASTK_COUNT]
Definition dialogs.h:285
choice_dialog::execute_action
void execute_action(const int action)
Definition dialogs.cpp:1672
choice_dialog::add_item
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1466
close_widget
Definition mapview.h:183
disband_box
Definition dialogs.h:95
disband_box::disband_clicked
void disband_clicked()
Definition dialogs.cpp:3821
disband_box::~disband_box
~disband_box()
Definition dialogs.cpp:3833
disband_box::cpunits
struct unit_list * cpunits
Definition dialogs.h:97
fcwidget
Definition mapview.h:172
hud_message_box
Definition hudwidget.h:56
notify_dialog
Definition dialogs.h:174
notify_dialog::label
QLabel * label
Definition dialogs.h:190
notify_dialog::qheadline
QString qheadline
Definition dialogs.h:193
notify_dialog::restart
void restart()
Definition dialogs.cpp:891
notify_dialog::cw
close_widget * cw
Definition dialogs.h:189
notify_dialog::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:982
notify_dialog::small_font
QFont small_font
Definition dialogs.h:195
notify_dialog::qcaption
QString qcaption
Definition dialogs.h:192
notify_dialog::calc_size
void calc_size(int &x, int &y)
Definition dialogs.cpp:919
notify_dialog::~notify_dialog
~notify_dialog()
Definition dialogs.cpp:1001
notify_dialog::paintEvent
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:938
notify_dialog::cursor
QPoint cursor
Definition dialogs.h:196
notify_dialog::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:973
notify_dialog::update_menu
virtual void update_menu()
Definition dialogs.cpp:990
notify_dialog::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:961
notify_dialog::layout
QVBoxLayout * layout
Definition dialogs.h:191
notify_dialog::qlist
QStringList qlist
Definition dialogs.h:194
notify_goto
Definition dialogs.h:109
notify_goto::close_but
QPushButton * close_but
Definition dialogs.h:113
notify_goto::goto_but
QPushButton * goto_but
Definition dialogs.h:111
notify_goto::inspect_city
void inspect_city()
Definition dialogs.cpp:1134
notify_goto::gtile
struct tile * gtile
Definition dialogs.h:114
notify_goto::inspect_but
QPushButton * inspect_but
Definition dialogs.h:112
notify_goto::goto_tile
void goto_tile()
Definition dialogs.cpp:1125
qdef_act
Definition dialogs.h:53
qdef_act::qdef_act
qdef_act()
Definition dialogs.cpp:1010
qdef_act::vs_unit
action_id vs_unit
Definition dialogs.h:60
qdef_act::action
static qdef_act * action()
Definition dialogs.cpp:1019
qdef_act::vs_city_get
action_id vs_city_get()
Definition dialogs.cpp:1057
qdef_act::m_instance
static qdef_act * m_instance
Definition dialogs.h:58
qdef_act::Q_DISABLE_COPY
Q_DISABLE_COPY(qdef_act)
qdef_act::drop
static void drop()
Definition dialogs.cpp:1030
qdef_act::vs_city
action_id vs_city
Definition dialogs.h:59
qdef_act::vs_city_set
void vs_city_set(int i)
Definition dialogs.cpp:1041
qdef_act::vs_unit_set
void vs_unit_set(int i)
Definition dialogs.cpp:1049
qdef_act::vs_unit_get
action_id vs_unit_get()
Definition dialogs.cpp:1065
qfc_dialog
Definition dialogs.h:74
qfc_dialog::point
QPoint point
Definition dialogs.h:81
qfc_dialog::paintEvent
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:330
qfc_dialog::close_pix
QPixmap close_pix
Definition dialogs.h:83
qfc_dialog::reactivate
void reactivate()
Definition dialogs.cpp:322
qfc_dialog::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:371
qfc_dialog::titlebar_height
int titlebar_height
Definition dialogs.h:80
qfc_dialog::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:381
qfc_dialog::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:401
qfc_dialog::moving_now
bool moving_now
Definition dialogs.h:82
races_dialog
Definition dialogs.h:129
races_dialog::selected_style
int selected_style
Definition dialogs.h:164
races_dialog::leader_name
QComboBox * leader_name
Definition dialogs.h:135
races_dialog::random_pressed
void random_pressed()
Definition dialogs.cpp:1081
races_dialog::style_selected
void style_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:786
races_dialog::last_index
int last_index
Definition dialogs.h:166
races_dialog::selected_nation_tabs
QTableWidget * selected_nation_tabs
Definition dialogs.h:134
races_dialog::random_button
QPushButton * random_button
Definition dialogs.h:143
races_dialog::refresh
void refresh()
Definition dialogs.cpp:595
races_dialog::nation_selected
void nation_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:733
races_dialog::selected_nation
int selected_nation
Definition dialogs.h:163
races_dialog::ok_pressed
void ok_pressed()
Definition dialogs.cpp:820
races_dialog::leader_selected
void leader_selected(int index)
Definition dialogs.cpp:805
races_dialog::ok_button
QPushButton * ok_button
Definition dialogs.h:142
races_dialog::nations_tabs_list
QList< QWidget * > * nations_tabs_list
Definition dialogs.h:133
races_dialog::~races_dialog
~races_dialog()
Definition dialogs.cpp:587
races_dialog::description
QTextEdit * description
Definition dialogs.h:141
races_dialog::group_selected
void group_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:661
races_dialog::set_index
void set_index(int index)
Definition dialogs.cpp:679
races_dialog::qnation_set
QComboBox * qnation_set
Definition dialogs.h:136
races_dialog::is_male
QRadioButton * is_male
Definition dialogs.h:138
races_dialog::sex_buttons
QButtonGroup * sex_buttons
Definition dialogs.h:137
races_dialog::update_nationset_combo
void update_nationset_combo()
Definition dialogs.cpp:645
races_dialog::styles
QTableWidget * styles
Definition dialogs.h:140
races_dialog::tplayer
struct player * tplayer
Definition dialogs.h:165
races_dialog::is_female
QRadioButton * is_female
Definition dialogs.h:139
races_dialog::nation_tabs
QTableWidget * nation_tabs
Definition dialogs.h:132
races_dialog::main_layout
QGridLayout * main_layout
Definition dialogs.h:131
races_dialog::cancel_pressed
void cancel_pressed()
Definition dialogs.cpp:1073
units_select
Definition dialogs.h:203
units_select::h_pix
QPixmap * h_pix
Definition dialogs.h:206
units_select::ufont
QFont ufont
Definition dialogs.h:210
units_select::~units_select
~units_select()
Definition dialogs.cpp:4343
units_select::info_font
QFont info_font
Definition dialogs.h:211
units_select::closeEvent
void closeEvent(QCloseEvent *event)
Definition dialogs.cpp:4686
units_select::more
bool more
Definition dialogs.h:232
units_select::update_img
void update_img()
Definition dialogs.cpp:4544
units_select::show_line
int show_line
Definition dialogs.h:233
units_select::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4488
units_select::highligh_num
int highligh_num
Definition dialogs.h:234
units_select::paint
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4553
units_select::update_menu
void update_menu()
Definition dialogs.cpp:4644
units_select::pix
QPixmap * pix
Definition dialogs.h:205
units_select::row_count
int row_count
Definition dialogs.h:212
units_select::unit_list
QList< unit * > unit_list
Definition dialogs.h:208
units_select::update_units
void update_units()
Definition dialogs.cpp:4654
units_select::utile
tile * utile
Definition dialogs.h:220
units_select::unit_count
int unit_count
Definition dialogs.h:235
units_select::item_size
QSize item_size
Definition dialogs.h:207
units_select::paintEvent
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:4631
units_select::create_pixmap
void create_pixmap()
Definition dialogs.cpp:4353
units_select::wheelEvent
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4695
units_select::keyPressEvent
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4719
units_select::mousePressEvent
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4519
units_select::cw
close_widget * cw
Definition dialogs.h:213
dialogs_g.h
caption
const char * caption
Definition dialogs_g.h:36
headline
const char const char * headline
Definition dialogs_g.h:37
event
enum event_type event
Definition events.c:81
action_id
int action_id
Definition fc_types.h:359
fonts.h
title
const char * title
Definition repodlgs.c:1313
pfcn_void
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
try_default_unit_action
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1531
popup_upgrade_dialog
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1444
update_nationset_combo
void update_nationset_combo()
Definition dialogs.cpp:1251
popup_races_dialog
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1223
popup_disband_dialog
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1482
revolution_response
void revolution_response(struct government *gov)
Definition dialogs.cpp:1904
try_default_city_action
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1549
restart_notify_dialogs
void restart_notify_dialogs()
Definition dialogs.cpp:3941
nationset_changed
void nationset_changed(void)
Definition dialogs.c:3556
popup_revolution_dialog
void popup_revolution_dialog(void)
Definition dialogs.c:109
mapview.h
hudwidget.h
func
get_token_fn_t func
Definition inputfile.c:128
lines
char * lines
Definition packhand.c:129
slots
struct player_slot * slots
Definition player.c:50
act_prob
Definition fc_types.h:1092
action
Definition actions.h:379
government
Definition government.h:52
player
Definition player.h:249
tile
Definition tile.h:49
unit
Definition unit.h:138