mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 02:26:07 +00:00
Delete Patches Button (#1722)
This commit is contained in:
parent
cd9fc5d0e9
commit
aa5293e3ad
|
@ -51,6 +51,9 @@ void CheatsPatches::setupUI() {
|
||||||
QString CHEATS_DIR_QString;
|
QString CHEATS_DIR_QString;
|
||||||
Common::FS::PathToQString(CHEATS_DIR_QString,
|
Common::FS::PathToQString(CHEATS_DIR_QString,
|
||||||
Common::FS::GetUserPath(Common::FS::PathType::CheatsDir));
|
Common::FS::GetUserPath(Common::FS::PathType::CheatsDir));
|
||||||
|
QString PATCHS_DIR_QString;
|
||||||
|
Common::FS::PathToQString(PATCHS_DIR_QString,
|
||||||
|
Common::FS::GetUserPath(Common::FS::PathType::PatchesDir));
|
||||||
QString NameCheatJson = m_gameSerial + "_" + m_gameVersion + ".json";
|
QString NameCheatJson = m_gameSerial + "_" + m_gameVersion + ".json";
|
||||||
m_cheatFilePath = CHEATS_DIR_QString + "/" + NameCheatJson;
|
m_cheatFilePath = CHEATS_DIR_QString + "/" + NameCheatJson;
|
||||||
|
|
||||||
|
@ -237,9 +240,45 @@ void CheatsPatches::setupUI() {
|
||||||
});
|
});
|
||||||
patchesControlLayout->addWidget(patchesButton);
|
patchesControlLayout->addWidget(patchesButton);
|
||||||
|
|
||||||
|
QPushButton* deletePatchButton = new QPushButton(tr("Delete File"));
|
||||||
|
connect(deletePatchButton, &QPushButton::clicked, [this, PATCHS_DIR_QString]() {
|
||||||
|
QStringListModel* model = qobject_cast<QStringListModel*>(patchesListView->model());
|
||||||
|
if (!model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QItemSelectionModel* selectionModel = patchesListView->selectionModel();
|
||||||
|
if (!selectionModel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
|
||||||
|
if (selectedIndexes.isEmpty()) {
|
||||||
|
QMessageBox::warning(this, tr("Delete File"), tr("No files selected."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QModelIndex selectedIndex = selectedIndexes.first();
|
||||||
|
QString selectedFileName = model->data(selectedIndex).toString();
|
||||||
|
|
||||||
|
int ret = QMessageBox::warning(
|
||||||
|
this, tr("Delete File"),
|
||||||
|
QString(tr("Do you want to delete the selected file?\\n%1").replace("\\n", "\n"))
|
||||||
|
.arg(selectedFileName),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
|
if (ret == QMessageBox::Yes) {
|
||||||
|
QString fileName = selectedFileName.split('|').first().trimmed();
|
||||||
|
QString directoryName = selectedFileName.split('|').last().trimmed();
|
||||||
|
QString filePath = PATCHS_DIR_QString + "/" + directoryName + "/" + fileName;
|
||||||
|
|
||||||
|
QFile::remove(filePath);
|
||||||
|
createFilesJson(directoryName);
|
||||||
|
populateFileListPatches();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
QPushButton* saveButton = new QPushButton(tr("Save"));
|
QPushButton* saveButton = new QPushButton(tr("Save"));
|
||||||
connect(saveButton, &QPushButton::clicked, this, &CheatsPatches::onSaveButtonClicked);
|
connect(saveButton, &QPushButton::clicked, this, &CheatsPatches::onSaveButtonClicked);
|
||||||
|
|
||||||
|
patchesControlLayout->addWidget(deletePatchButton);
|
||||||
patchesControlLayout->addWidget(saveButton);
|
patchesControlLayout->addWidget(saveButton);
|
||||||
|
|
||||||
patchesLayout->addLayout(patchesControlLayout);
|
patchesLayout->addLayout(patchesControlLayout);
|
||||||
|
|
|
@ -841,7 +841,7 @@
|
||||||
<message>
|
<message>
|
||||||
<location filename="../cheats_patches.cpp" line="44"/>
|
<location filename="../cheats_patches.cpp" line="44"/>
|
||||||
<source>Cheats / Patches for </source>
|
<source>Cheats / Patches for </source>
|
||||||
<translation>Cheats / Patches for </translation>
|
<translation>Cheats / Patches para </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../cheats_patches.cpp" line="50"/>
|
<location filename="../cheats_patches.cpp" line="50"/>
|
||||||
|
|
Loading…
Reference in a new issue