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
46typedef void (*pfcn_void)(QVariant, QVariant);
48void popup_races_dialog(struct player *pplayer);
50
51
53{
55
56private:
57 explicit qdef_act();
61public:
62 static qdef_act* action();
63 static void drop();
64 void vs_city_set(int i);
65 void vs_unit_set(int i);
68};
69
70/***************************************************************************
71 Dialog with themed titlebar
72***************************************************************************/
73class qfc_dialog : public QDialog
74{
75 Q_OBJECT
76public:
77 qfc_dialog(QWidget *parent);
78 void reactivate();
79private:
81 QPoint point;
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***************************************************************************/
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***************************************************************************/
108class 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***************************************************************************/
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);
148 void refresh();
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:
167};
168
169/***************************************************************************
170 Widget around map view to display informations like demographics report,
171 top 5 cities, traveler's report.
172***************************************************************************/
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();
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);
190 QLabel *label;
191 QVBoxLayout *layout;
192 QString qcaption;
193 QString qheadline;
194 QStringList qlist;
196 QPoint cursor;
197};
198
199/***************************************************************************
200 Transparent widget for selecting units
201***************************************************************************/
203{
204 Q_OBJECT
205 QPixmap *pix;
206 QPixmap *h_pix;
207 QSize item_size;
208 QList<unit*> unit_list;
210 QFont ufont;
214public:
215 units_select(struct tile *ptile, QWidget *parent);
217 void update_menu();
218 void update_units();
219 void create_pixmap();
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;
236};
237
238/**************************************************************************
239 A QPushButton that includes data like function to call and parmeters
240**************************************************************************/
241class Choice_dialog_button: public QPushButton
242{
243 Q_OBJECT
245 QVariant data1, data2;
246public:
247 Choice_dialog_button(const QString title, pfcn_void func_in,
248 QVariant data1_in, QVariant data2_in);
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***************************************************************************/
259class 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);
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();
280 void unstack_all_buttons();
281 QVBoxLayout *get_layout();
284 int target_id[ATK_COUNT];
285 int sub_target_id[ASTK_COUNT];
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 */
void setData2(QVariant wariat)
Definition dialogs.cpp:1364
void setData1(QVariant wariat)
Definition dialogs.cpp:1356
pfcn_void getFunc()
Definition dialogs.cpp:1330
void stack_button(Choice_dialog_button *button)
Definition dialogs.cpp:1690
void prev_unit()
Definition dialogs.cpp:1607
QVBoxLayout * layout
Definition dialogs.h:263
struct unit * targeted_unit
Definition dialogs.h:286
void unstack_all_buttons()
Definition dialogs.cpp:1707
Choice_dialog_button * get_identified_button(const int id)
Definition dialogs.cpp:1519
QPushButton * target_unit_button
Definition dialogs.h:262
void set_layout()
Definition dialogs.cpp:1425
void update_dialog(const struct act_prob *act_probs)
Definition dialogs.cpp:1636
QList< Choice_dialog_button * > last_buttons_stack
Definition dialogs.h:266
void next_unit()
Definition dialogs.cpp:1567
QVBoxLayout * get_layout()
Definition dialogs.cpp:1511
QHBoxLayout * unit_skip
Definition dialogs.h:264
QList< Choice_dialog_button * > buttons_list
Definition dialogs.h:265
void(* run_on_close)(int)
Definition dialogs.h:268
int target_id[ATK_COUNT]
Definition dialogs.h:284
void switch_target()
Definition dialogs.cpp:1654
QList< Choice_dialog_button * > action_button_map
Definition dialogs.h:267
int sub_target_id[ASTK_COUNT]
Definition dialogs.h:285
void execute_action(const int action)
Definition dialogs.cpp:1673
void add_item(QString title, pfcn_void func, QVariant data1, QVariant data2, QString tool_tip, const int button_id)
Definition dialogs.cpp:1467
void disband_clicked()
Definition dialogs.cpp:3822
struct unit_list * cpunits
Definition dialogs.h:97
QLabel * label
Definition dialogs.h:190
QString qheadline
Definition dialogs.h:193
void restart()
Definition dialogs.cpp:890
close_widget * cw
Definition dialogs.h:189
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:983
QFont small_font
Definition dialogs.h:195
QString qcaption
Definition dialogs.h:192
void calc_size(int &x, int &y)
Definition dialogs.cpp:918
void paintEvent(QPaintEvent *paint_event)
Definition dialogs.cpp:937
QPoint cursor
Definition dialogs.h:196
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:973
virtual void update_menu()
Definition dialogs.cpp:991
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:960
QVBoxLayout * layout
Definition dialogs.h:191
QStringList qlist
Definition dialogs.h:194
QPushButton * close_but
Definition dialogs.h:113
QPushButton * goto_but
Definition dialogs.h:111
void inspect_city()
Definition dialogs.cpp:1135
struct tile * gtile
Definition dialogs.h:114
QPushButton * inspect_but
Definition dialogs.h:112
void goto_tile()
Definition dialogs.cpp:1126
action_id vs_unit
Definition dialogs.h:60
static qdef_act * action()
Definition dialogs.cpp:1020
action_id vs_city_get()
Definition dialogs.cpp:1058
static qdef_act * m_instance
Definition dialogs.h:58
Q_DISABLE_COPY(qdef_act)
static void drop()
Definition dialogs.cpp:1031
action_id vs_city
Definition dialogs.h:59
void vs_city_set(int i)
Definition dialogs.cpp:1042
void vs_unit_set(int i)
Definition dialogs.cpp:1050
action_id vs_unit_get()
Definition dialogs.cpp:1066
QPoint point
Definition dialogs.h:81
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:330
QPixmap close_pix
Definition dialogs.h:83
void reactivate()
Definition dialogs.cpp:322
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:371
int titlebar_height
Definition dialogs.h:80
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:381
void mouseReleaseEvent(QMouseEvent *event)
Definition dialogs.cpp:401
bool moving_now
Definition dialogs.h:82
int selected_style
Definition dialogs.h:164
QComboBox * leader_name
Definition dialogs.h:135
void random_pressed()
Definition dialogs.cpp:1082
void style_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:785
int last_index
Definition dialogs.h:166
QTableWidget * selected_nation_tabs
Definition dialogs.h:134
QPushButton * random_button
Definition dialogs.h:143
void refresh()
Definition dialogs.cpp:595
void nation_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:732
int selected_nation
Definition dialogs.h:163
void ok_pressed()
Definition dialogs.cpp:819
void leader_selected(int index)
Definition dialogs.cpp:804
QPushButton * ok_button
Definition dialogs.h:142
QList< QWidget * > * nations_tabs_list
Definition dialogs.h:133
QTextEdit * description
Definition dialogs.h:141
void group_selected(const QItemSelection &sl, const QItemSelection &ds)
Definition dialogs.cpp:661
void set_index(int index)
Definition dialogs.cpp:678
QComboBox * qnation_set
Definition dialogs.h:136
QRadioButton * is_male
Definition dialogs.h:138
QButtonGroup * sex_buttons
Definition dialogs.h:137
void update_nationset_combo()
Definition dialogs.cpp:645
QTableWidget * styles
Definition dialogs.h:140
struct player * tplayer
Definition dialogs.h:165
QRadioButton * is_female
Definition dialogs.h:139
QTableWidget * nation_tabs
Definition dialogs.h:132
QGridLayout * main_layout
Definition dialogs.h:131
void cancel_pressed()
Definition dialogs.cpp:1074
QPixmap * h_pix
Definition dialogs.h:206
QFont ufont
Definition dialogs.h:210
QFont info_font
Definition dialogs.h:211
void closeEvent(QCloseEvent *event)
Definition dialogs.cpp:4687
void update_img()
Definition dialogs.cpp:4545
int show_line
Definition dialogs.h:233
void mouseMoveEvent(QMouseEvent *event)
Definition dialogs.cpp:4489
int highligh_num
Definition dialogs.h:234
void paint(QPainter *painter, QPaintEvent *event)
Definition dialogs.cpp:4554
void update_menu()
Definition dialogs.cpp:4645
QPixmap * pix
Definition dialogs.h:205
int row_count
Definition dialogs.h:212
QList< unit * > unit_list
Definition dialogs.h:208
void update_units()
Definition dialogs.cpp:4655
tile * utile
Definition dialogs.h:220
int unit_count
Definition dialogs.h:235
QSize item_size
Definition dialogs.h:207
void paintEvent(QPaintEvent *event)
Definition dialogs.cpp:4632
void create_pixmap()
Definition dialogs.cpp:4354
void wheelEvent(QWheelEvent *event)
Definition dialogs.cpp:4696
void keyPressEvent(QKeyEvent *event)
Definition dialogs.cpp:4720
void mousePressEvent(QMouseEvent *event)
Definition dialogs.cpp:4520
close_widget * cw
Definition dialogs.h:213
const char * caption
Definition dialogs_g.h:36
const char const char * headline
Definition dialogs_g.h:37
enum event_type event
Definition events.c:81
int action_id
Definition fc_types.h:359
const char * title
Definition repodlgs.c:1313
void(* pfcn_void)(QVariant, QVariant)
Definition dialogs.h:46
bool try_default_unit_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1532
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1444
void update_nationset_combo()
Definition dialogs.cpp:1252
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1223
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1482
void revolution_response(struct government *gov)
Definition dialogs.cpp:1905
bool try_default_city_action(QVariant q1, QVariant q2)
Definition dialogs.cpp:1550
void restart_notify_dialogs()
Definition dialogs.cpp:3942
void nationset_changed(void)
Definition dialogs.c:3556
void popup_revolution_dialog(void)
Definition dialogs.c:109
get_token_fn_t func
Definition inputfile.c:128
char * lines
Definition packhand.c:129
struct player_slot * slots
Definition player.c:50
Definition tile.h:49
Definition unit.h:138