Qt: Always display version info in settings

This commit is contained in:
Stenzek 2024-08-23 15:50:17 +10:00
parent 417c1e43dd
commit 5433b30fec
No known key found for this signature in database
4 changed files with 38 additions and 21 deletions

View File

@ -103,6 +103,15 @@ bool AutoUpdaterDialog::isSupported()
#endif #endif
} }
bool AutoUpdaterDialog::isOfficialBuild()
{
#if !__has_include("scmversion/tag.h")
return false;
#else
return true;
#endif
}
bool AutoUpdaterDialog::warnAboutUnofficialBuild() bool AutoUpdaterDialog::warnAboutUnofficialBuild()
{ {
// //
@ -746,7 +755,8 @@ bool AutoUpdaterDialog::processUpdate(const std::vector<u8>& update_data)
} }
if (info.suffix() != QStringLiteral("app")) if (info.suffix() != QStringLiteral("app"))
{ {
reportError(fmt::format("Unexpected application suffix {} on {}.", info.suffix().toStdString(), bundle_path.value())); reportError(
fmt::format("Unexpected application suffix {} on {}.", info.suffix().toStdString(), bundle_path.value()));
return false; return false;
} }

View File

@ -33,6 +33,7 @@ public:
static QStringList getTagList(); static QStringList getTagList();
static std::string getDefaultTag(); static std::string getDefaultTag();
static void cleanupAfterUpdate(); static void cleanupAfterUpdate();
static bool isOfficialBuild();
static bool warnAboutUnofficialBuild(); static bool warnAboutUnofficialBuild();
Q_SIGNALS: Q_SIGNALS:

View File

@ -82,7 +82,8 @@ InterfaceSettingsWidget::InterfaceSettingsWidget(SettingsWindow* dialog, QWidget
populateLanguageDropdown(m_ui.language); populateLanguageDropdown(m_ui.language);
SettingWidgetBinder::BindWidgetToStringSetting(sif, m_ui.language, "Main", "Language", QtHost::GetDefaultLanguage()); SettingWidgetBinder::BindWidgetToStringSetting(sif, m_ui.language, "Main", "Language", QtHost::GetDefaultLanguage());
connect(m_ui.language, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &InterfaceSettingsWidget::onLanguageChanged); connect(m_ui.language, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&InterfaceSettingsWidget::onLanguageChanged);
onRenderToSeparateWindowChanged(); onRenderToSeparateWindowChanged();
@ -118,24 +119,27 @@ InterfaceSettingsWidget::InterfaceSettingsWidget(SettingsWindow* dialog, QWidget
dialog->registerWidgetHelp(m_ui.enableDiscordPresence, tr("Enable Discord Presence"), tr("Unchecked"), dialog->registerWidgetHelp(m_ui.enableDiscordPresence, tr("Enable Discord Presence"), tr("Unchecked"),
tr("Shows the game you are currently playing as part of your profile in Discord.")); tr("Shows the game you are currently playing as part of your profile in Discord."));
dialog->registerWidgetHelp(m_ui.autoUpdateEnabled, tr("Enable Automatic Update Check"), tr("Checked"),
tr("Automatically checks for updates to the program on startup. Updates can be deferred "
"until later or skipped entirely."));
m_ui.autoUpdateCurrentVersion->setText(tr("%1 (%2)").arg(g_scm_tag_str).arg(g_scm_date_str));
if (!m_dialog->isPerGameSettings() && AutoUpdaterDialog::isSupported()) if (!m_dialog->isPerGameSettings() && AutoUpdaterDialog::isSupported())
{ {
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.autoUpdateEnabled, "AutoUpdater", "CheckAtStartup", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.autoUpdateEnabled, "AutoUpdater", "CheckAtStartup", true);
dialog->registerWidgetHelp(m_ui.autoUpdateEnabled, tr("Enable Automatic Update Check"), tr("Checked"),
tr("Automatically checks for updates to the program on startup. Updates can be deferred "
"until later or skipped entirely."));
m_ui.autoUpdateTag->addItems(AutoUpdaterDialog::getTagList()); m_ui.autoUpdateTag->addItems(AutoUpdaterDialog::getTagList());
SettingWidgetBinder::BindWidgetToStringSetting(sif, m_ui.autoUpdateTag, "AutoUpdater", "UpdateTag", SettingWidgetBinder::BindWidgetToStringSetting(sif, m_ui.autoUpdateTag, "AutoUpdater", "UpdateTag",
AutoUpdaterDialog::getDefaultTag()); AutoUpdaterDialog::getDefaultTag());
connect(m_ui.checkForUpdates, &QPushButton::clicked, this, []() { g_main_window->checkForUpdates(true); });
m_ui.autoUpdateCurrentVersion->setText(tr("%1 (%2)").arg(g_scm_tag_str).arg(g_scm_date_str));
connect(m_ui.checkForUpdates, &QPushButton::clicked, []() { g_main_window->checkForUpdates(true); });
} }
else else
{ {
m_ui.verticalLayout->removeWidget(m_ui.updatesGroup); m_ui.autoUpdateTag->addItem(tr("Unavailable"));
m_ui.updatesGroup->hide(); m_ui.autoUpdateEnabled->setEnabled(false);
m_ui.autoUpdateTag->setEnabled(false);
m_ui.checkForUpdates->setEnabled(false);
m_ui.updatesGroup->setEnabled(false);
} }
} }

View File

@ -2872,16 +2872,18 @@ void MainWindow::checkForUpdates(bool display_message)
mbox.setTextFormat(Qt::RichText); mbox.setTextFormat(Qt::RichText);
QString message; QString message;
#ifdef _WIN32 if (!AutoUpdaterDialog::isOfficialBuild())
message = {
tr("<p>Sorry, you are trying to update a DuckStation version which is not an official GitHub release. To " message =
"prevent incompatibilities, the auto-updater is only enabled on official builds.</p>" tr("<p>Sorry, you are trying to update a DuckStation version which is not an official GitHub release. To "
"<p>To obtain an official build, please follow the instructions under \"Downloading and Running\" at the " "prevent incompatibilities, the auto-updater is only enabled on official builds.</p>"
"link below:</p>" "<p>Please download an official release from from <a "
"<p><a href=\"https://github.com/stenzek/duckstation/\">https://github.com/stenzek/duckstation/</a></p>"); "href=\"https://www.duckstation.org/\">duckstation.org</a>.</p>");
#else }
message = tr("Automatic updating is not supported on the current platform."); else
#endif {
message = tr("Automatic updating is not supported on the current platform.");
}
mbox.setText(message); mbox.setText(message);
mbox.setIcon(QMessageBox::Critical); mbox.setIcon(QMessageBox::Critical);