Skip to content

Commit 1e57a5b

Browse files
committed
Qt: Make the memory card modified state more obvious
1 parent f5bd7c1 commit 1e57a5b

File tree

3 files changed

+79
-14
lines changed

3 files changed

+79
-14
lines changed

src/duckstation-qt/memorycardeditorwindow.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "memorycardeditorwindow.h"
55
#include "mainwindow.h"
6+
#include "qthost.h"
67
#include "qtutils.h"
78

89
#include "core/host.h"
@@ -139,9 +140,13 @@ MemoryCardEditorWindow::MemoryCardEditorWindow() : QWidget()
139140
m_card_a.path_cb = m_ui.cardAPath;
140141
m_card_a.table = m_ui.cardA;
141142
m_card_a.blocks_free_label = m_ui.cardAUsage;
143+
m_card_a.modified_icon_label = m_ui.cardAModifiedIcon;
144+
m_card_a.modified_label = m_ui.cardAModified;
142145
m_card_b.path_cb = m_ui.cardBPath;
143146
m_card_b.table = m_ui.cardB;
144147
m_card_b.blocks_free_label = m_ui.cardBUsage;
148+
m_card_b.modified_icon_label = m_ui.cardBModifiedIcon;
149+
m_card_b.modified_label = m_ui.cardBModified;
145150

146151
m_file_icon_width = MEMORY_CARD_ICON_SIZE + (m_card_a.table->showGrid() ? 1 : 0);
147152
m_file_icon_height = MEMORY_CARD_ICON_SIZE + (m_card_a.table->showGrid() ? 1 : 0);
@@ -155,6 +160,8 @@ MemoryCardEditorWindow::MemoryCardEditorWindow() : QWidget()
155160
connectCardUi(&m_card_b, m_ui.buttonBoxB);
156161
populateComboBox(m_ui.cardAPath);
157162
populateComboBox(m_ui.cardBPath);
163+
updateCardBlocksFree(&m_card_a);
164+
updateCardBlocksFree(&m_card_b);
158165
updateButtonState();
159166

160167
const QString new_card_hover_text(tr("New Card..."));
@@ -236,6 +243,7 @@ bool MemoryCardEditorWindow::event(QEvent* event)
236243

237244
void MemoryCardEditorWindow::createCardButtons(Card* card, QDialogButtonBox* buttonBox)
238245
{
246+
card->modified_icon_label->setPixmap(QIcon(QtHost::GetResourceQPath("images/warning.svg", true)).pixmap(16, 16));
239247
card->format_button = buttonBox->addButton(tr("Format Card"), QDialogButtonBox::ActionRole);
240248
card->import_file_button = buttonBox->addButton(tr("Import File..."), QDialogButtonBox::ActionRole);
241249
card->import_button = buttonBox->addButton(tr("Import Card..."), QDialogButtonBox::ActionRole);
@@ -351,13 +359,12 @@ bool MemoryCardEditorWindow::loadCard(const QString& filename, Card* card)
351359
card->table->setRowCount(0);
352360
card->dirty = false;
353361
card->save_button->setEnabled(false);
354-
card->blocks_free_label->clear();
355-
356362
card->filename.clear();
357363

358364
if (filename.isEmpty())
359365
{
360366
updateButtonState();
367+
updateCardBlocksFree(card);
361368
return false;
362369
}
363370

@@ -468,9 +475,19 @@ void MemoryCardEditorWindow::incrementAnimationFrame()
468475

469476
void MemoryCardEditorWindow::updateCardBlocksFree(Card* card)
470477
{
471-
card->blocks_free = MemoryCardImage::GetFreeBlockCount(card->data);
472-
card->blocks_free_label->setText(
473-
tr("%n block(s) free%1", "", card->blocks_free).arg(card->dirty ? QStringLiteral(" (*)") : QString()));
478+
if (!card->filename.empty())
479+
{
480+
card->blocks_free = MemoryCardImage::GetFreeBlockCount(card->data);
481+
card->blocks_free_label->setText(tr("%n block(s) free", "", card->blocks_free));
482+
card->modified_icon_label->setVisible(card->dirty);
483+
card->modified_label->setVisible(card->dirty);
484+
}
485+
else
486+
{
487+
card->blocks_free_label->clear();
488+
card->modified_icon_label->setVisible(false);
489+
card->modified_label->setVisible(false);
490+
}
474491
}
475492

476493
void MemoryCardEditorWindow::setCardDirty(Card* card)

src/duckstation-qt/memorycardeditorwindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class MemoryCardEditorWindow : public QWidget
4646
QComboBox* path_cb = nullptr;
4747
QTableWidget* table = nullptr;
4848
QLabel* blocks_free_label = nullptr;
49+
QLabel* modified_icon_label = nullptr;
50+
QLabel* modified_label = nullptr;
4951
QPushButton* save_button = nullptr;
5052
QPushButton* import_button = nullptr;
5153
QPushButton* import_file_button = nullptr;

src/duckstation-qt/memorycardeditorwindow.ui

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,34 @@
102102
<item row="2" column="3">
103103
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,0">
104104
<item>
105-
<widget class="QLabel" name="cardBUsage">
106-
<property name="text">
107-
<string notr="true"/>
105+
<widget class="QLabel" name="cardBUsage" />
106+
</item>
107+
<item>
108+
<spacer name="horizontalSpacer">
109+
<property name="orientation">
110+
<enum>Qt::Orientation::Horizontal</enum>
108111
</property>
109-
</widget>
112+
<property name="sizeHint" stdset="0">
113+
<size>
114+
<width>0</width>
115+
<height>0</height>
116+
</size>
117+
</property>
118+
</spacer>
119+
</item>
120+
<item>
121+
<layout class="QHBoxLayout" name="cardBModifiedLayout">
122+
<item>
123+
<widget class="QLabel" name="cardBModifiedIcon" />
124+
</item>
125+
<item>
126+
<widget class="QLabel" name="cardBModified">
127+
<property name="text">
128+
<string>Card Modified</string>
129+
</property>
130+
</widget>
131+
</item>
132+
</layout>
110133
</item>
111134
<item>
112135
<widget class="QDialogButtonBox" name="buttonBoxB">
@@ -118,13 +141,36 @@
118141
</layout>
119142
</item>
120143
<item row="2" column="0">
121-
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0">
144+
<layout class="QHBoxLayout" name="horizontalLayout_4">
122145
<item>
123-
<widget class="QLabel" name="cardAUsage">
124-
<property name="text">
125-
<string notr="true"/>
146+
<widget class="QLabel" name="cardAUsage" />
147+
</item>
148+
<item>
149+
<spacer name="horizontalSpacer_2">
150+
<property name="orientation">
151+
<enum>Qt::Orientation::Horizontal</enum>
126152
</property>
127-
</widget>
153+
<property name="sizeHint" stdset="0">
154+
<size>
155+
<width>0</width>
156+
<height>0</height>
157+
</size>
158+
</property>
159+
</spacer>
160+
</item>
161+
<item>
162+
<layout class="QHBoxLayout" name="cardAModifiedLayout">
163+
<item>
164+
<widget class="QLabel" name="cardAModifiedIcon" />
165+
</item>
166+
<item>
167+
<widget class="QLabel" name="cardAModified">
168+
<property name="text">
169+
<string>Card Modified</string>
170+
</property>
171+
</widget>
172+
</item>
173+
</layout>
128174
</item>
129175
<item>
130176
<widget class="QDialogButtonBox" name="buttonBoxA">

0 commit comments

Comments
 (0)