From b91bd2eb6f447ccd3d46b0e66ac5e70ab483614e Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Sat, 16 Oct 2021 00:30:56 +0200 Subject: [PATCH] Prevent clicking on HUD widgets from acting on the map Clicking on a widget displayed on top of the map was sometimes triggering actions as if the map had been clicked underneath. Prevent this by disabling the propagation of mouse events to the parent widget. Closes #687. Closes #566. --- client/gui-qt/citydlg.cpp | 5 +++++ client/gui-qt/page_game.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index 4a44fbfd7a..c3e52fdc0c 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -1321,6 +1321,11 @@ city_dialog::city_dialog(QWidget *parent) : QWidget(parent) small_font = fcFont::instance()->getFont(fonts::notify_label); ui.setupUi(this); + // Prevent mouse events from going through the panels to the main map + for (auto child : findChildren()) { + child->setAttribute(Qt::WA_NoMousePropagation); + } + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setMouseTracking(true); selected_row_p = -1; diff --git a/client/gui-qt/page_game.cpp b/client/gui-qt/page_game.cpp index a328aa7481..f6606f86eb 100644 --- a/client/gui-qt/page_game.cpp +++ b/client/gui-qt/page_game.cpp @@ -115,20 +115,27 @@ pageGame::pageGame(QWidget *parent) sidebar_wdg->addWidget(sw_endturn); civ_status = new civstatus(mapview_wdg); + civ_status->setAttribute(Qt::WA_NoMousePropagation); civ_status->show(); city_overlay = new city_dialog(mapview_wdg); city_overlay->hide(); minimapview_wdg = new minimap_view(mapview_wdg); + minimapview_wdg->setAttribute(Qt::WA_NoMousePropagation); minimapview_wdg->show(); unitinfo_wdg = new hud_units(mapview_wdg); + unitinfo_wdg->setAttribute(Qt::WA_NoMousePropagation); battlelog_wdg = new hud_battle_log(mapview_wdg); + battlelog_wdg->setAttribute(Qt::WA_NoMousePropagation); battlelog_wdg->hide(); infotab = new info_tab(mapview_wdg); + infotab->setAttribute(Qt::WA_NoMousePropagation); infotab->show(); x_vote = new xvote(mapview_wdg); + x_vote->setAttribute(Qt::WA_NoMousePropagation); x_vote->hide(); gtd = new goto_dialog(mapview_wdg); + gtd->setAttribute(Qt::WA_NoMousePropagation); gtd->hide(); game_layout->addWidget(mapview_wdg, 1, 0);