From 4e66b12727da608b3e8ba6c8d992e6aaf7630691 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 16 May 2020 20:24:41 +1000 Subject: [PATCH] Qt: Hook up export compatibility info to game properties --- src/duckstation-qt/gamepropertiesdialog.cpp | 43 +++++++++++++++------ src/duckstation-qt/gamepropertiesdialog.h | 2 + 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/duckstation-qt/gamepropertiesdialog.cpp b/src/duckstation-qt/gamepropertiesdialog.cpp index cd33243a2..8dcb57d86 100644 --- a/src/duckstation-qt/gamepropertiesdialog.cpp +++ b/src/duckstation-qt/gamepropertiesdialog.cpp @@ -5,6 +5,9 @@ #include "qthostinterface.h" #include "qtutils.h" #include "scmversion/scmversion.h" +#include +#include +#include #include GamePropertiesDialog::GamePropertiesDialog(QtHostInterface* host_interface, QWidget* parent /* = nullptr */) @@ -57,6 +60,7 @@ void GamePropertiesDialog::populate(const GameListEntry* ge) m_ui.compatibility->setDisabled(true); m_ui.upscalingIssues->setDisabled(true); m_ui.versionTested->setDisabled(true); + m_ui.exportCompatibilityInfo->setDisabled(true); } else { @@ -177,20 +181,25 @@ void GamePropertiesDialog::connectUi() connect(m_ui.close, &QPushButton::clicked, this, &QDialog::close); } +void GamePropertiesDialog::fillEntryFromUi(GameListCompatibilityEntry* entry) +{ + entry->code = m_ui.gameCode->text().toStdString(); + entry->title = m_ui.title->text().toStdString(); + entry->version_tested = m_ui.versionTested->text().toStdString(); + entry->upscaling_issues = m_ui.upscalingIssues->text().toStdString(); + entry->comments = m_ui.comments->text().toStdString(); + entry->compatibility_rating = static_cast(m_ui.compatibility->currentIndex()); + entry->region = static_cast(m_ui.region->currentIndex()); +} + void GamePropertiesDialog::saveCompatibilityInfo() { - GameListCompatibilityEntry new_entry; - new_entry.code = m_ui.gameCode->text().toStdString(); - new_entry.title = m_ui.title->text().toStdString(); - new_entry.version_tested = m_ui.versionTested->text().toStdString(); - new_entry.upscaling_issues = m_ui.upscalingIssues->text().toStdString(); - new_entry.comments = m_ui.comments->text().toStdString(); - new_entry.compatibility_rating = static_cast(m_ui.compatibility->currentIndex()); - new_entry.region = static_cast(m_ui.region->currentIndex()); - - if (new_entry.code.empty()) + if (m_ui.gameCode->text().isEmpty()) return; + GameListCompatibilityEntry new_entry; + fillEntryFromUi(&new_entry); + m_host_interface->getGameList()->UpdateCompatibilityEntry(std::move(new_entry), true); emit m_host_interface->gameListRefreshed(); m_compatibility_info_changed = false; @@ -227,5 +236,17 @@ void GamePropertiesDialog::onVerifyDumpClicked() void GamePropertiesDialog::onExportCompatibilityInfoClicked() { - QMessageBox::critical(this, tr("Not yet implemented"), tr("Not yet implemented")); + if (m_ui.gameCode->text().isEmpty()) + return; + + GameListCompatibilityEntry new_entry; + fillEntryFromUi(&new_entry); + + QString xml(QString::fromStdString(GameList::ExportCompatibilityEntry(&new_entry))); + + bool copy_to_clipboard = false; + xml = QInputDialog::getMultiLineText(this, tr("Compatibility Info Export"), tr("Press OK to copy to clipboard."), xml, + ©_to_clipboard); + if (copy_to_clipboard) + QGuiApplication::clipboard()->setText(xml); } diff --git a/src/duckstation-qt/gamepropertiesdialog.h b/src/duckstation-qt/gamepropertiesdialog.h index 51325b8b3..7ec6f2151 100644 --- a/src/duckstation-qt/gamepropertiesdialog.h +++ b/src/duckstation-qt/gamepropertiesdialog.h @@ -4,6 +4,7 @@ #include struct GameListEntry; +struct GameListCompatibilityEntry; class QtHostInterface; @@ -40,6 +41,7 @@ private: void connectUi(); void populateCompatibilityInfo(const std::string& game_code); void populateTracksInfo(const char* image_path); + void fillEntryFromUi(GameListCompatibilityEntry* entry); void onResize(); Ui::GamePropertiesDialog m_ui;