13 #include <QApplication>
14 #include <QCommandLinkButton>
15 #include <QHBoxLayout>
17 #include <QPaintEvent>
21 #include <QStyleOptionToolButton>
22 #include <QTextStream>
50 setToolButtonStyle(Qt::ToolButtonIconOnly);
51 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
71 content_size.setWidth(10 * content_size.width());
76 QStyleOptionToolButton opt;
77 initStyleOption(&opt);
79 return style()->sizeFromContents(QStyle::CT_ToolButton, &opt, content_size,
94 QToolButton::paintEvent(
event);
103 auto icon_size = tax->size();
104 auto center =
size() / 2;
106 auto x = center.width() - 5 * icon_size.width();
107 auto y = center.height() - icon_size.height() / 2;
110 for (
int i = 0; i < 10; ++i) {
111 if (i < client.conn.playing->economic.tax / 10) {
112 p.drawPixmap(QPointF(x, y), *tax);
116 p.drawPixmap(QPointF(x, y), *sci);
118 p.drawPixmap(QPointF(x, y), *lux);
121 x += icon_size.width();
130 setToolButtonStyle(Qt::ToolButtonIconOnly);
131 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
148 content_size.setWidth(2 * content_size.width());
150 content_size.setWidth(4 * content_size.width());
156 QStyleOptionToolButton opt;
157 initStyleOption(&opt);
159 return style()->sizeFromContents(QStyle::CT_ToolButton, &opt, content_size,
169 QToolButton::paintEvent(
event);
175 auto center =
size() / 2;
177 auto x = center.width()
179 auto y = center.height() - icon_size.height() / 2;
183 x += icon_size.width();
187 x += icon_size.width();
189 x += icon_size.width();
199 : QToolButton(), blink(false), keep_blinking(false), page(pg),
200 right_click(nullptr), wheel_down(nullptr), wheel_up(nullptr),
204 setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
205 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
206 setContextMenuPolicy(Qt::CustomContextMenu);
207 setIconSize(QSize(22, 22));
210 timer->setSingleShot(
false);
211 timer->setInterval(700);
231 if (!
page.isEmpty()) {
233 setChecked(i ==
queen()->game_tab_widget->currentIndex());
236 QToolButton::paintEvent(
event);
242 p.setCompositionMode(QPainter::CompositionMode_SoftLight);
243 p.setBrush(palette().color(QPalette::HighlightedText));
244 p.drawRect(0, 0, width(), height());
281 QToolButton::mousePressEvent(
event);
305 if (!
timer->isActive()) {
311 if (
timer->isActive()) {
326 struct player *obs_player;
329 act = qobject_cast<QAction *>(sender());
332 if (!qvar.isValid()) {
336 if (act->property(
"scimenu").toBool()) {
337 dsend_packet_player_research(&
client.
conn, qvar.toInt());
341 if (qvar.toInt() == -1) {
346 obs_player =
reinterpret_cast<struct
player *
>(qvar.value<
void *>());
347 if (obs_player !=
nullptr) {
351 s = QStringLiteral(
"/observe \"%1\"").arg(obs_player->
name);
352 cn_bytes = s.toLocal8Bit();
363 setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
364 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
388 if (m_income < 0 && m_gold + m_income >= 0) {
399 style()->unpolish(
this);
400 style()->polish(
this);
415 QToolButton::paintEvent(
event);
424 layout->setContentsMargins(0, 0, 0, 0);
427 setProperty(
"top_bar",
true);
428 setAutoFillBackground(
true);
477 menu->popup(QCursor::pos());
488 QMenu *menu =
new QMenu(
king()->central_wdg);
497 erwischt = QString(
_(
"Observe %1")).arg(pplayer->name);
500 eiskalt =
new QAction(erwischt,
queen()->mapview_wdg);
501 eiskalt->setData(QVariant::fromValue((
void *) pplayer));
502 QObject::connect(eiskalt, &QAction::triggered,
queen()->sw_diplo,
504 menu->addAction(eiskalt);
510 eiskalt =
new QAction(
_(
"Observe globally"),
queen()->mapview_wdg);
511 eiskalt->setData(-1);
512 menu->addAction(eiskalt);
513 QObject::connect(eiskalt, &QAction::triggered,
queen()->sw_diplo,
517 menu->setAttribute(Qt::WA_DeleteOnClose);
518 menu->popup(QCursor::pos());
540 item.tech_str = QString::fromUtf8(
543 curr_list.append(
item);
547 if (curr_list.isEmpty()) {
551 menu =
new QMenu(
king()->central_wdg);
552 for (
int i = 0; i < curr_list.count(); i++) {
555 qvar = curr_list.at(i).id;
560 act =
new QAction(ic, curr_list.at(i).tech_str,
queen()->mapview_wdg);
562 act->setProperty(
"scimenu",
true);
563 menu->addAction(act);
564 QObject::connect(act, &QAction::triggered,
queen()->sw_science,
567 menu->setAttribute(Qt::WA_DeleteOnClose);
568 menu->popup(QCursor::pos());
584 if (!
queen()->isRepoDlgOpen(QStringLiteral(
"SCI"))) {
590 if (w->isVisible()) {
608 if (!
queen()->isRepoDlgOpen(QStringLiteral(
"UNI"))) {
615 if (w->isVisible()) {
int send_chat(const char *message)
Send the message as a chat to the server.
void popdown_city_dialog()
Closes the city overlay.
int gimmeIndexOf(const QString &str)
Returns index on game tab page of given report dialog.
fc_game_tab_widget * game_tab_widget
void init(bool raise)
Updates science_report and marks it as opened It has to be called soon after constructor.
void addWidget(QWidget *fsw)
Adds new top_bar widget.
top_bar()
Sidebar constructor.
QList< QWidget * > objects
~top_bar() override
Sidebar destructor.
Table widget to display units view (F2)
void init()
Initializes place in tab for units view.
void update_view()
Refresh all widgets for units view.
void update_units()
Updates the units table.
bool client_is_global_observer()
Returns whether client is global observer.
struct player * client_player()
Either controlling or observing.
bool client_is_observer()
Returns whether client is observer.
const QPixmap * client_government_sprite()
Return the sprite for the government indicator.
const QPixmap * client_research_sprite()
Return the sprite for the research indicator.
const QPixmap * client_warming_sprite()
Return the sprite for the global-warming indicator.
const QPixmap * client_cooling_sprite()
Return the sprite for the global-cooling indicator.
void request_center_focus_unit()
Center to focus unit.
void key_end_turn()
Handle user 'end turn' input.
class fc_client * king()
Return fc_client instance.
const char * nation_plural_translation(const struct nation_type *pnation)
Return the (translated) plural noun of the given nation.
pageGame * queen()
Return game instandce.
#define players_iterate_end
#define players_iterate(_pplayer)
void economy_report_dialog_popup()
Display the economy report.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
struct player_economic economic
struct nation_style * style
struct research::research_invention inventions[A_LAST]
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
const char * advance_name_translation(const struct advance *padvance)
Return the (translated) name of the given advance/technology.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
const QPixmap * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Return the sprite for the technology/advance.
const QPixmap * get_tax_sprite(const struct tileset *t, Output_type_id otype)
Return a tax sprite for the given output type (usually gold/lux/sci).
void top_bar_right_click_diplomacy()
Right click for diplomacy Opens diplomacy meeting for player For observer popups menu.
void top_bar_right_click_science()
Right click for science, allowing to choose current tech.
void top_bar_units_view()
Click for units view, allowing to close/open.
void top_bar_indicators_menu()
Popups menu on indicators widget.
void top_bar_left_click_science()
Left click for science, allowing to close/open.
void top_bar_show_map()
Callback to show map.
void top_bar_center_unit()
Callback to center on current unit.
void top_bar_finish_turn()
Callback for finishing turn.
bool comp_less_than(const qlist_item &q1, const qlist_item &q2)
Compare unit_items (used for techs) by name.