mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-31 03:45:38 +00:00
Qt/MemoryCardEditor: Add format button
This commit is contained in:
parent
ed6145ac77
commit
84fe9aae0e
|
@ -94,6 +94,8 @@ void MemoryCardEditorDialog::connectUi()
|
|||
connect(m_ui.saveCardB, &QPushButton::clicked, [this]() { saveCard(&m_card_b); });
|
||||
connect(m_ui.importCardA, &QPushButton::clicked, [this]() { importCard(&m_card_a); });
|
||||
connect(m_ui.importCardB, &QPushButton::clicked, [this]() { importCard(&m_card_b); });
|
||||
connect(m_ui.formatCardA, &QPushButton::clicked, [this]() { formatCard(&m_card_a); });
|
||||
connect(m_ui.formatCardB, &QPushButton::clicked, [this]() { formatCard(&m_card_b); });
|
||||
connect(m_ui.exportFile, &QPushButton::clicked, this, &MemoryCardEditorDialog::doExportSaveFile);
|
||||
connect(m_ui.importFileToCardA, &QPushButton::clicked, [this]() { importSaveFile(&m_card_a); });
|
||||
connect(m_ui.importFileToCardB, &QPushButton::clicked, [this]() { importSaveFile(&m_card_b); });
|
||||
|
@ -435,6 +437,29 @@ void MemoryCardEditorDialog::importCard(Card* card)
|
|||
updateButtonState();
|
||||
}
|
||||
|
||||
void MemoryCardEditorDialog::formatCard(Card* card)
|
||||
{
|
||||
promptForSave(card);
|
||||
|
||||
if (QMessageBox::question(this, tr("Format memory card?"),
|
||||
tr("Formatting the memory card will destroy all saves, and they will not be recoverable. "
|
||||
"The memory card which will be formatted is located at '%1'.")
|
||||
.arg(QString::fromStdString(card->filename)),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
clearSelection();
|
||||
|
||||
MemoryCardImage::Format(&card->data);
|
||||
|
||||
updateCardTable(card);
|
||||
updateCardBlocksFree(card);
|
||||
setCardDirty(card);
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
void MemoryCardEditorDialog::importSaveFile(Card* card)
|
||||
{
|
||||
QString filename =
|
||||
|
@ -492,4 +517,6 @@ void MemoryCardEditorDialog::updateButtonState()
|
|||
m_ui.importCardB->setEnabled(card_b_present);
|
||||
m_ui.importFileToCardA->setEnabled(card_a_present);
|
||||
m_ui.importFileToCardB->setEnabled(card_b_present);
|
||||
m_ui.formatCardA->setEnabled(card_a_present);
|
||||
m_ui.formatCardB->setEnabled(card_b_present);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
void saveCard(Card* card);
|
||||
void promptForSave(Card* card);
|
||||
void importCard(Card* card);
|
||||
void formatCard(Card* card);
|
||||
|
||||
void doExportSaveFile();
|
||||
void importSaveFile(Card* card);
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,0,0,0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,0,0,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="cardBUsage">
|
||||
<property name="text">
|
||||
|
@ -105,6 +105,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="formatCardB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Format Card</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="importFileToCardB">
|
||||
<property name="enabled">
|
||||
|
@ -138,7 +148,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0,0,0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0,0,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="cardAUsage">
|
||||
<property name="text">
|
||||
|
@ -146,6 +156,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="formatCardA">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Format Card</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="importFileToCardA">
|
||||
<property name="enabled">
|
||||
|
|
Loading…
Reference in a new issue