Skip to content

Commit

Permalink
Don't move moveable widgets when hiding the minimap
Browse files Browse the repository at this point in the history
See #1103.
  • Loading branch information
lmoureaux committed Jul 9, 2022
1 parent 65a12f3 commit 9e08fec
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions client/page_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,48 +509,50 @@ bool fc_game_tab_widget::event(QEvent *event)
if (C_S_RUNNING <= client_state()
&& (event->type() == QEvent::Resize
|| event->type() == QEvent::LayoutRequest)) {
auto size = event->type() == QEvent::Resize
? static_cast<QResizeEvent *>(event)->size()
: this->size();

map_canvas_resized(size.width(), size.height());
queen()->message->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->message->move(size.width() - queen()->message->width(), 0);
queen()->chat->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->chat->move(
qRound((size.width() * king()->qt_settings.chat_fx_pos)),
qRound((size.height() * king()->qt_settings.chat_fy_pos)));
queen()->battlelog_wdg->set_scale(king()->qt_settings.battlelog_scale);
queen()->battlelog_wdg->move(
qRound(king()->qt_settings.battlelog_x * mapview.width),
qRound(king()->qt_settings.battlelog_y * mapview.height));
queen()->x_vote->move(width() / 2 - queen()->x_vote->width() / 2, 0);
queen()->updateSidebarTooltips();
queen()->minimap_panel->turn_done()->setEnabled(
get_turn_done_button_state());
queen()->mapview_wdg->resize(size.width(), size.height());
queen()->city_overlay->resize(queen()->mapview_wdg->size());
queen()->unitinfo_wdg->update_actions(nullptr);
queen()->civ_status->move(
qRound(king()->qt_settings.civstatus_x * mapview.width),
qRound(king()->qt_settings.civstatus_y * mapview.height));

/*
* Resize the panel at the bottom right.
*/
const auto max_size = QSize(std::max(300, size.width() / 4),
std::max(200, size.height() / 3));
const auto panel_size =
QLayout::closestAcceptableSize(queen()->minimap_panel, max_size);
const auto location = size - panel_size;
queen()->minimap_panel->move(location.width(), location.height());
queen()->minimap_panel->resize(panel_size);

return true;
const auto size = event->type() == QEvent::Resize
? static_cast<QResizeEvent *>(event)->size()
: this->size();
if (event->type() == QEvent::Resize) {
map_canvas_resized(size.width(), size.height());
queen()->message->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->message->move(size.width() - queen()->message->width(), 0);
queen()->chat->resize(
qRound((size.width() * king()->qt_settings.chat_fwidth)),
qRound((size.height() * king()->qt_settings.chat_fheight)));
queen()->chat->move(
qRound((size.width() * king()->qt_settings.chat_fx_pos)),
qRound((size.height() * king()->qt_settings.chat_fy_pos)));
queen()->battlelog_wdg->set_scale(king()->qt_settings.battlelog_scale);
queen()->battlelog_wdg->move(
qRound(king()->qt_settings.battlelog_x * mapview.width),
qRound(king()->qt_settings.battlelog_y * mapview.height));
queen()->x_vote->move(width() / 2 - queen()->x_vote->width() / 2, 0);
queen()->civ_status->move(
qRound(king()->qt_settings.civstatus_x * mapview.width),
qRound(king()->qt_settings.civstatus_y * mapview.height));

queen()->updateSidebarTooltips();
queen()->minimap_panel->turn_done()->setEnabled(
get_turn_done_button_state());
queen()->mapview_wdg->resize(size.width(), size.height());
queen()->city_overlay->resize(queen()->mapview_wdg->size());
queen()->unitinfo_wdg->update_actions(nullptr);
}

/*
* Resize the panel at the bottom right.
*/
const auto max_size = QSize(std::max(300, size.width() / 4),
std::max(200, size.height() / 3));
const auto panel_size =
QLayout::closestAcceptableSize(queen()->minimap_panel, max_size);
const auto location = size - panel_size;
queen()->minimap_panel->move(location.width(), location.height());
queen()->minimap_panel->resize(panel_size);

return true;
}

return QWidget::event(event);
Expand Down

0 comments on commit 9e08fec

Please sign in to comment.