MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / renameCard

Method renameCard

pcsx2-qt/Settings/MemoryCardSettingsWidget.cpp:258–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258void MemoryCardSettingsWidget::renameCard()
259{
260 const QString selectedCard(getSelectedCard());
261 if (selectedCard.isEmpty())
262 return;
263
264 const QString newName(QInputDialog::getText(
265 QtUtils::GetRootWidget(this), tr("Rename Memory Card"), tr("New Card Name"), QLineEdit::Normal, selectedCard));
266 if (newName.isEmpty() || newName == selectedCard)
267 return;
268
269 if (!newName.endsWith(QStringLiteral(".ps2")) || newName.length() <= 4)
270 {
271 QMessageBox::critical(
272 QtUtils::GetRootWidget(this), tr("Rename Memory Card"), tr("New name is invalid, it must end with .ps2"));
273 return;
274 }
275
276 const std::string newNameStr(newName.toStdString());
277 if (FileMcd_GetCardInfo(newNameStr).has_value())
278 {
279 QMessageBox::critical(QtUtils::GetRootWidget(this), tr("Rename Memory Card"),
280 tr("New name is invalid, a card with this name already exists."));
281 return;
282 }
283
284 if (!FileMcd_RenameCard(selectedCard.toStdString(), newNameStr))
285 {
286 QMessageBox::critical(QtUtils::GetRootWidget(this), tr("Rename Memory Card"),
287 tr("Failed to rename Memory Card. The log may contain more information."));
288 return;
289 }
290
291 refresh();
292}
293
294void MemoryCardSettingsWidget::convertCard()
295{

Callers

nothing calls this directly

Calls 5

GetRootWidgetFunction · 0.85
FileMcd_GetCardInfoFunction · 0.85
FileMcd_RenameCardFunction · 0.85
isEmptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected