From 59bb8f0e9747c4c75513ab0399e85f75523a9501 Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Thu, 16 Jun 2022 13:08:51 +0200 Subject: [PATCH] Move the Turn Done button to the bottom right This is a more experimental commit, aimed at understanding which code would be touched by the changes described in #1002 -- anchoring the button to the bottom right together with the minimap. Use a command link button to benefit from the built-in description. --- client/mapview.cpp | 5 +++-- client/page_game.cpp | 22 ++++++++++++++-------- client/page_game.h | 4 +++- client/top_bar.cpp | 7 ++++--- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/client/mapview.cpp b/client/mapview.cpp index 94b89e751f..5bcd2e1049 100644 --- a/client/mapview.cpp +++ b/client/mapview.cpp @@ -11,8 +11,10 @@ #include // Qt +#include #include #include + // utility #include "log.h" // common @@ -469,8 +471,7 @@ void update_mouse_cursor(enum cursor_type new_cursor_type) */ void update_timeout_label() { - queen()->sw_endturn->setCustomLabels(QString(get_timeout_label_text())); - queen()->sw_endturn->update(); + queen()->endturn->setDescription(get_timeout_label_text()); } /** diff --git a/client/page_game.cpp b/client/page_game.cpp index 272358c5be..193515208c 100644 --- a/client/page_game.cpp +++ b/client/page_game.cpp @@ -13,8 +13,10 @@ #include "page_game.h" // Qt +#include #include #include + // utility #include "fcintl.h" // common @@ -101,10 +103,6 @@ pageGame::pageGame(QWidget *parent) sw_economy->setIcon( fcIcons::instance()->getIcon(QStringLiteral("economy"))); sw_economy->setCheckable(true); - sw_endturn = new top_bar_widget(_("Turn Done"), QLatin1String(""), - top_bar_finish_turn); - sw_endturn->setIcon( - fcIcons::instance()->getIcon(QStringLiteral("endturn"))); sw_cunit->setRightClick(top_bar_center_unit); sw_cunit->setWheelUp(cycle_enemy_units); sw_cunit->setWheelDown(key_unit_wait); @@ -139,6 +137,11 @@ pageGame::pageGame(QWidget *parent) } }); + endturn = new QCommandLinkButton(_("Turn Done"), QLatin1String("")); + connect(endturn, &QAbstractButton::clicked, top_bar_finish_turn); + endturn->setIcon(fcIcons::instance()->getIcon(QStringLiteral("endturn"))); + endturn->setParent(mapview_wdg); + top_bar_wdg->addWidget(sw_map); top_bar_wdg->addWidget(sw_cunit); top_bar_wdg->addWidget(sw_cities); @@ -147,7 +150,6 @@ pageGame::pageGame(QWidget *parent) top_bar_wdg->addWidget(sw_economy); top_bar_wdg->addWidget(sw_tax); top_bar_wdg->addWidget(sw_indicators); - top_bar_wdg->addWidget(sw_endturn); top_bar_wdg->addWidget(sw_message); civ_status = new civstatus(mapview_wdg); @@ -211,10 +213,9 @@ void pageGame::reloadSidebarIcons() fcIcons::instance()->getIcon(QStringLiteral("research"))); sw_economy->setIcon( fcIcons::instance()->getIcon(QStringLiteral("economy"))); - sw_endturn->setIcon( - fcIcons::instance()->getIcon(QStringLiteral("endturn"))); sw_message->setIcon( fcIcons::instance()->getIcon(QStringLiteral("messages"))); + endturn->setIcon(fcIcons::instance()->getIcon(QStringLiteral("endturn"))); } /** @@ -545,7 +546,12 @@ void fc_game_tab_widget::resizeEvent(QResizeEvent *event) queen()->civ_status->move( qRound(king()->qt_settings.civstatus_x * mapview.width), qRound(king()->qt_settings.civstatus_y * mapview.height)); - // It could be resized before mapview, so delayed it a bit + + // QT6: remove the cast (QTBUG-68722) + const auto hint = qobject_cast(queen()->endturn)->sizeHint(); + const auto location = size - hint; + queen()->endturn->move(location.width(), location.height()); + queen()->endturn->resize(hint); } event->setAccepted(true); } diff --git a/client/page_game.h b/client/page_game.h index cd34d639da..10cd49205e 100644 --- a/client/page_game.h +++ b/client/page_game.h @@ -16,6 +16,8 @@ #include #include +class QCommandLinkButton; + class city_dialog; class fc_client; class map_view; @@ -83,7 +85,7 @@ class pageGame : public QWidget { civstatus *civ_status; top_bar_widget *sw_diplo; indicators_widget *sw_indicators; - top_bar_widget *sw_endturn; + QCommandLinkButton *endturn; top_bar_widget *sw_science; public slots: private slots: diff --git a/client/top_bar.cpp b/client/top_bar.cpp index c41af7021d..fdadee194f 100644 --- a/client/top_bar.cpp +++ b/client/top_bar.cpp @@ -11,6 +11,7 @@ // Qt #include #include +#include #include #include #include @@ -492,7 +493,7 @@ void top_bar_disable_end_turn(bool do_restore) if (king()->current_page() != PAGE_GAME) { return; } - queen()->sw_endturn->setEnabled(do_restore); + queen()->endturn->setEnabled(do_restore); } /** @@ -503,8 +504,8 @@ void top_bar_blink_end_turn(bool do_restore) if (king()->current_page() != PAGE_GAME) { return; } - queen()->sw_endturn->blink = !do_restore; - queen()->sw_endturn->update(); + //queen()->endturn->blink = !do_restore; + queen()->endturn->update(); } /**