From cd8f17dbd012674b12dba6629ff778a9e4dd9519 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 2 Dec 2020 00:56:31 +1000 Subject: [PATCH] Qt: Allow memory card editing from playlist context menu --- src/duckstation-qt/mainwindow.cpp | 7 ++-- src/duckstation-qt/qthostinterface.cpp | 49 ++++++++++++++------------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 4add39b07..1d0c22a9c 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -538,11 +538,8 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL if (!m_emulation_running) { - if (!entry->code.empty()) - { - m_host_interface->populateGameListContextMenu(entry, this, &menu); - menu.addSeparator(); - } + m_host_interface->populateGameListContextMenu(entry, this, &menu); + menu.addSeparator(); connect(menu.addAction(tr("Default Boot")), &QAction::triggered, [this, entry]() { m_host_interface->bootSystem(std::make_shared(entry->path)); diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 73ce25d19..58015c4aa 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -907,32 +907,35 @@ void QtHostInterface::populateGameListContextMenu(const GameListEntry* entry, QW QMenu* load_state_menu = menu->addMenu(tr("Load State")); load_state_menu->setEnabled(false); - const std::vector available_states(GetAvailableSaveStates(entry->code.c_str())); - const QString timestamp_format = QLocale::system().dateTimeFormat(QLocale::ShortFormat); - for (const SaveStateInfo& ssi : available_states) + if (!entry->code.empty()) { - if (ssi.global) - continue; - - const s32 slot = ssi.slot; - const QDateTime timestamp(QDateTime::fromSecsSinceEpoch(static_cast(ssi.timestamp))); - const QString timestamp_str(timestamp.toString(timestamp_format)); - const QString path(QString::fromStdString(ssi.path)); - - QAction* action; - if (slot < 0) + const std::vector available_states(GetAvailableSaveStates(entry->code.c_str())); + const QString timestamp_format = QLocale::system().dateTimeFormat(QLocale::ShortFormat); + for (const SaveStateInfo& ssi : available_states) { - resume_action->setText(tr("Resume (%1)").arg(timestamp_str)); - resume_action->setEnabled(true); - action = resume_action; - } - else - { - load_state_menu->setEnabled(true); - action = load_state_menu->addAction(tr("Game Save %1 (%2)").arg(slot).arg(timestamp_str)); - } + if (ssi.global) + continue; - connect(action, &QAction::triggered, [this, path]() { loadState(path); }); + const s32 slot = ssi.slot; + const QDateTime timestamp(QDateTime::fromSecsSinceEpoch(static_cast(ssi.timestamp))); + const QString timestamp_str(timestamp.toString(timestamp_format)); + const QString path(QString::fromStdString(ssi.path)); + + QAction* action; + if (slot < 0) + { + resume_action->setText(tr("Resume (%1)").arg(timestamp_str)); + resume_action->setEnabled(true); + action = resume_action; + } + else + { + load_state_menu->setEnabled(true); + action = load_state_menu->addAction(tr("Game Save %1 (%2)").arg(slot).arg(timestamp_str)); + } + + connect(action, &QAction::triggered, [this, path]() { loadState(path); }); + } } QAction* open_memory_cards_action = menu->addAction(tr("Edit Memory Cards..."));