| 256 | } |
| 257 | |
| 258 | void 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 | |
| 294 | void MemoryCardSettingsWidget::convertCard() |
| 295 | { |
nothing calls this directly
no test coverage detected