Fix delete cheats button (#1731)

This commit is contained in:
DanielSvoboda 2024-12-10 13:57:30 -03:00 committed by GitHub
parent 00543fe640
commit ea8ad35947
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 3 deletions

View file

@ -955,15 +955,33 @@ void CheatsPatches::createFilesJson(const QString& repository) {
jsonFile.close();
}
void CheatsPatches::addCheatsToLayout(const QJsonArray& modsArray, const QJsonArray& creditsArray) {
void CheatsPatches::clearListCheats() {
QLayoutItem* item;
while ((item = rightLayout->takeAt(0)) != nullptr) {
delete item->widget();
delete item;
QWidget* widget = item->widget();
if (widget) {
delete widget;
} else {
QLayout* layout = item->layout();
if (layout) {
QLayoutItem* innerItem;
while ((innerItem = layout->takeAt(0)) != nullptr) {
QWidget* innerWidget = innerItem->widget();
if (innerWidget) {
delete innerWidget;
}
delete innerItem;
}
delete layout;
}
}
}
m_cheats.clear();
m_cheatCheckBoxes.clear();
}
void CheatsPatches::addCheatsToLayout(const QJsonArray& modsArray, const QJsonArray& creditsArray) {
clearListCheats();
int maxWidthButton = 0;
for (const QJsonValue& modValue : modsArray) {
@ -1056,6 +1074,8 @@ void CheatsPatches::addCheatsToLayout(const QJsonArray& modsArray, const QJsonAr
}
void CheatsPatches::populateFileListCheats() {
clearListCheats();
QString cheatsDir;
Common::FS::PathToQString(cheatsDir, Common::FS::GetUserPath(Common::FS::PathType::CheatsDir));

View file

@ -36,6 +36,7 @@ public:
const QString& m_gameVersion, bool showMessageBox);
void downloadPatches(const QString repository, const bool showMessageBox);
void createFilesJson(const QString& repository);
void clearListCheats();
void compatibleVersionNotice(const QString repository);
signals: