Qt: Hook up export compatibility info to game properties

This commit is contained in:
Connor McLaughlin 2020-05-16 20:24:41 +10:00
parent 669934eb1a
commit 4e66b12727
2 changed files with 34 additions and 11 deletions

View File

@ -5,6 +5,9 @@
#include "qthostinterface.h"
#include "qtutils.h"
#include "scmversion/scmversion.h"
#include <QtGui/QClipboard>
#include <QtGui/QGuiApplication>
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QMessageBox>
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<GameListCompatibilityRating>(m_ui.compatibility->currentIndex());
entry->region = static_cast<DiscRegion>(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<GameListCompatibilityRating>(m_ui.compatibility->currentIndex());
new_entry.region = static_cast<DiscRegion>(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,
&copy_to_clipboard);
if (copy_to_clipboard)
QGuiApplication::clipboard()->setText(xml);
}

View File

@ -4,6 +4,7 @@
#include <QtWidgets/QDialog>
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;