From 892154f7eadfa1d7807b8d07c3a864b7d1aba127 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Jan 2021 04:33:01 -0500 Subject: [PATCH] DolphinQt: Resolve deprecated usage of margin() This function has been marked as obsolete. In Qt 6.0 it's removed entirely, so we must use getContentsMargin() explicitly instead (margin() would do this for us). Ditto for setMargin(), in which case we use setContentsMargin instead. setMargin() would just pass its argument to all four parameters of setContentsMargin(), so we can do the same. --- Source/Core/DolphinQt/MainWindow.cpp | 2 +- Source/Core/DolphinQt/QtUtils/FlowLayout.cpp | 6 +++++- Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 8bd3988f45..20572d88b2 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -654,7 +654,7 @@ void MainWindow::ConnectStack() layout->addWidget(m_game_list); layout->addWidget(m_search_bar); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); connect(m_search_bar, &SearchBar::Search, m_game_list, &GameList::SetSearchTerm); diff --git a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp index bd481ea624..e986f2f382 100644 --- a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp +++ b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp @@ -151,7 +151,11 @@ QSize FlowLayout::minimumSize() const for (const auto& item : m_item_list) size = size.expandedTo(item->minimumSize()); - size += QSize(2 * margin(), 2 * margin()); + // Any direction's margin works, as they all set the same within the constructor. + int margin = 0; + getContentsMargins(&margin, nullptr, nullptr, nullptr); + + size += QSize(2 * margin, 2 * margin); return size; } diff --git a/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp b/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp index 11758dd47a..20810fcec3 100644 --- a/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp +++ b/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp @@ -48,7 +48,7 @@ void WrapInScrollArea(QWidget* parent, QLayout* wrapped_layout, QWidget* to_resi auto* scroll_layout = new QVBoxLayout; scroll_layout->addWidget(scroll_area); - scroll_layout->setMargin(0); + scroll_layout->setContentsMargins(0, 0, 0, 0); parent->setLayout(scroll_layout); }