mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-19 06:45:39 +00:00
Qt: Add open button to memory card editor
This commit is contained in:
parent
175bc66c91
commit
44ea51306a
|
@ -77,6 +77,8 @@ void MemoryCardEditorDialog::connectUi()
|
||||||
[this](int index) { loadCardFromComboBox(&m_card_b, index); });
|
[this](int index) { loadCardFromComboBox(&m_card_b, index); });
|
||||||
connect(m_ui.newCardA, &QPushButton::clicked, [this]() { newCard(&m_card_a); });
|
connect(m_ui.newCardA, &QPushButton::clicked, [this]() { newCard(&m_card_a); });
|
||||||
connect(m_ui.newCardB, &QPushButton::clicked, [this]() { newCard(&m_card_b); });
|
connect(m_ui.newCardB, &QPushButton::clicked, [this]() { newCard(&m_card_b); });
|
||||||
|
connect(m_ui.openCardA, &QPushButton::clicked, [this]() { openCard(&m_card_a); });
|
||||||
|
connect(m_ui.openCardB, &QPushButton::clicked, [this]() { openCard(&m_card_b); });
|
||||||
connect(m_ui.saveCardA, &QPushButton::clicked, [this]() { saveCard(&m_card_a); });
|
connect(m_ui.saveCardA, &QPushButton::clicked, [this]() { saveCard(&m_card_a); });
|
||||||
connect(m_ui.saveCardB, &QPushButton::clicked, [this]() { saveCard(&m_card_b); });
|
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.importCardA, &QPushButton::clicked, [this]() { importCard(&m_card_a); });
|
||||||
|
@ -258,6 +260,35 @@ void MemoryCardEditorDialog::newCard(Card* card)
|
||||||
saveCard(card);
|
saveCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemoryCardEditorDialog::openCard(Card* card)
|
||||||
|
{
|
||||||
|
promptForSave(card);
|
||||||
|
|
||||||
|
QString filename =
|
||||||
|
QFileDialog::getOpenFileName(this, tr("Select Memory Card"), QString(), tr(MEMORY_CARD_IMAGE_FILTER));
|
||||||
|
if (filename.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!MemoryCardImage::LoadFromFile(&card->data, filename.toUtf8().constData()))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Failed to load memory card image."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// add to combo box
|
||||||
|
QFileInfo file(filename);
|
||||||
|
QSignalBlocker sb(card->path_cb);
|
||||||
|
card->path_cb->addItem(file.baseName(), QVariant(filename));
|
||||||
|
card->path_cb->setCurrentIndex(card->path_cb->count() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
card->filename = filename.toStdString();
|
||||||
|
updateCardTable(card);
|
||||||
|
updateCardBlocksFree(card);
|
||||||
|
updateButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
void MemoryCardEditorDialog::saveCard(Card* card)
|
void MemoryCardEditorDialog::saveCard(Card* card)
|
||||||
{
|
{
|
||||||
if (card->filename.empty())
|
if (card->filename.empty())
|
||||||
|
|
|
@ -52,6 +52,7 @@ private:
|
||||||
void updateCardBlocksFree(Card* card);
|
void updateCardBlocksFree(Card* card);
|
||||||
void setCardDirty(Card* card);
|
void setCardDirty(Card* card);
|
||||||
void newCard(Card* card);
|
void newCard(Card* card);
|
||||||
|
void openCard(Card* card);
|
||||||
void saveCard(Card* card);
|
void saveCard(Card* card);
|
||||||
void promptForSave(Card* card);
|
void promptForSave(Card* card);
|
||||||
void importCard(Card* card);
|
void importCard(Card* card);
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="3">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0">
|
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -73,10 +73,25 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="newCardB">
|
<widget class="QToolButton" name="newCardB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>New...</string>
|
<string>New...</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/document-new.png</normaloff>:/icons/document-new.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="openCardB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -164,7 +179,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -176,10 +191,25 @@
|
||||||
<widget class="QComboBox" name="cardAPath"/>
|
<widget class="QComboBox" name="cardAPath"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="newCardA">
|
<widget class="QToolButton" name="newCardA">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>New...</string>
|
<string>New...</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/document-new.png</normaloff>:/icons/document-new.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="openCardA">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -285,6 +315,8 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="resources/resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
BIN
src/duckstation-qt/resources/icons/document-new.png
Normal file
BIN
src/duckstation-qt/resources/icons/document-new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
src/duckstation-qt/resources/icons/document-new@2x.png
Normal file
BIN
src/duckstation-qt/resources/icons/document-new@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
|
@ -35,6 +35,8 @@
|
||||||
<file>icons/debug-step-into.png</file>
|
<file>icons/debug-step-into.png</file>
|
||||||
<file>icons/debug-step-out.png</file>
|
<file>icons/debug-step-out.png</file>
|
||||||
<file>icons/debug-step-over.png</file>
|
<file>icons/debug-step-over.png</file>
|
||||||
|
<file>icons/document-new.png</file>
|
||||||
|
<file>icons/document-new@2x.png</file>
|
||||||
<file>icons/document-open.png</file>
|
<file>icons/document-open.png</file>
|
||||||
<file>icons/document-open@2x.png</file>
|
<file>icons/document-open@2x.png</file>
|
||||||
<file>icons/document-save.png</file>
|
<file>icons/document-save.png</file>
|
||||||
|
|
Loading…
Reference in a new issue