Merge pull request #12236 from AdmiralCurtiss/qt-clear-layout

DolphinQt: Move GraphicsModListWidget::ClearLayoutRecursively() to QtUtils.
This commit is contained in:
JosJuice 2023-10-15 19:17:01 +02:00 committed by GitHub
commit b3b660b446
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 27 deletions

View File

@ -279,6 +279,8 @@ add_executable(dolphin-emu
QtUtils/AspectRatioWidget.h
QtUtils/BlockUserInputFilter.cpp
QtUtils/BlockUserInputFilter.h
QtUtils/ClearLayoutRecursively.cpp
QtUtils/ClearLayoutRecursively.h
QtUtils/DolphinFileDialog.cpp
QtUtils/DolphinFileDialog.h
QtUtils/DoubleClickEventFilter.cpp

View File

@ -19,6 +19,7 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinQt/Config/GraphicsModWarningWidget.h"
#include "DolphinQt/QtUtils/ClearLayoutRecursively.h"
#include "DolphinQt/Settings.h"
#include "UICommon/GameFile.h"
#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
@ -240,31 +241,6 @@ void GraphicsModListWidget::SaveModList()
m_needs_save = true;
}
void GraphicsModListWidget::ClearLayoutRecursively(QLayout* layout)
{
while (QLayoutItem* child = layout->takeAt(0))
{
if (child == nullptr)
continue;
if (child->widget())
{
layout->removeWidget(child->widget());
delete child->widget();
}
else if (child->layout())
{
ClearLayoutRecursively(child->layout());
layout->removeItem(child);
}
else
{
layout->removeItem(child);
}
delete child;
}
}
void GraphicsModListWidget::SaveToDisk()
{
m_needs_save = false;

View File

@ -56,8 +56,6 @@ private:
void SaveModList();
void ClearLayoutRecursively(QLayout* layout);
void OpenGraphicsModDir();
void CalculateGameRunning(Core::State state);

View File

@ -181,6 +181,7 @@
</ClCompile>
<ClCompile Include="QtUtils\AspectRatioWidget.cpp" />
<ClCompile Include="QtUtils\BlockUserInputFilter.cpp" />
<ClCompile Include="QtUtils\ClearLayoutRecursively.cpp" />
<ClCompile Include="QtUtils\DolphinFileDialog.cpp" />
<ClCompile Include="QtUtils\DoubleClickEventFilter.cpp" />
<ClCompile Include="QtUtils\ElidedButton.cpp" />
@ -240,6 +241,7 @@
<ClInclude Include="Debugger\RegisterColumn.h" />
<ClInclude Include="GBAHost.h" />
<ClInclude Include="QtUtils\ActionHelper.h" />
<ClInclude Include="QtUtils\ClearLayoutRecursively.h" />
<ClInclude Include="QtUtils\DolphinFileDialog.h" />
<ClInclude Include="QtUtils\ImageConverter.h" />
<ClInclude Include="QtUtils\ModalMessageBox.h" />

View File

@ -0,0 +1,33 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/QtUtils/ClearLayoutRecursively.h"
#include <QLayout>
#include <QLayoutItem>
#include <QWidget>
void ClearLayoutRecursively(QLayout* layout)
{
while (QLayoutItem* child = layout->takeAt(0))
{
if (child == nullptr)
continue;
if (child->widget())
{
layout->removeWidget(child->widget());
delete child->widget();
}
else if (child->layout())
{
ClearLayoutRecursively(child->layout());
layout->removeItem(child);
}
else
{
layout->removeItem(child);
}
delete child;
}
}

View File

@ -0,0 +1,8 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
class QLayout;
void ClearLayoutRecursively(QLayout* layout);