From e662f34f8b46f5ad8bacffca2c008d24cb47e054 Mon Sep 17 00:00:00 2001
From: Connor McLaughlin <stenzek@gmail.com>
Date: Sun, 22 Mar 2020 13:17:03 +1000
Subject: [PATCH] Qt: Add help for general settings

---
 src/duckstation-qt/generalsettingswidget.cpp | 36 ++++++++++++++++++--
 src/duckstation-qt/generalsettingswidget.h   |  3 +-
 src/duckstation-qt/settingsdialog.cpp        |  2 +-
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/src/duckstation-qt/generalsettingswidget.cpp b/src/duckstation-qt/generalsettingswidget.cpp
index 1000ec851..c37f2fe5b 100644
--- a/src/duckstation-qt/generalsettingswidget.cpp
+++ b/src/duckstation-qt/generalsettingswidget.cpp
@@ -1,9 +1,8 @@
 #include "generalsettingswidget.h"
+#include "settingsdialog.h"
 #include "settingwidgetbinder.h"
 
-static constexpr char BIOS_IMAGE_FILTER[] = "Binary Images (*.bin);;All Files (*.*)";
-
-GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
+GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog)
   : QWidget(parent), m_host_interface(host_interface)
 {
   m_ui.setupUi(this);
@@ -29,6 +28,37 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
 
   onEnableSpeedLimiterStateChanged();
   onEmulationSpeedValueChanged(m_ui.emulationSpeed->value());
+
+  dialog->registerWidgetHelp(m_ui.pauseOnStart, "Pause On Start", "Unchecked",
+                             "Pauses the emulator when a game is started.");
+  dialog->registerWidgetHelp(m_ui.startFullscreen, "Start Fullscreen", "Unchecked",
+                             "Automatically switches to fullscreen mode when a game is started.");
+  dialog->registerWidgetHelp(m_ui.saveStateOnExit, "Save State On Exit", "Checked",
+                             "Automatically saves the emulator state when powering down or exiting. You can then "
+                             "resume directly from where you left off next time.");
+  dialog->registerWidgetHelp(m_ui.confirmPowerOff, "Confirm Power Off", "Checked",
+                             "Determines whether a prompt will be displayed to confirm shutting down the emulator/game "
+                             "when the hotkey is pressed.");
+  dialog->registerWidgetHelp(m_ui.enableSpeedLimiter, "Enable Speed Limiter", "Checked",
+                             "Throttles the emulation speed to the chosen speed above. If unchecked, the emulator will "
+                             "run as fast as possible, which may not be playable.");
+  dialog->registerWidgetHelp(m_ui.increaseTimerResolution, "Increase Timer Resolution", "Checked",
+                             "Increases the system timer resolution when emulation is started to provide more accurate "
+                             "frame pacing. May increase battery usage on laptops.");
+  dialog->registerWidgetHelp(m_ui.emulationSpeed, "Emulation Speed", "100%",
+                             "Sets the target emulation speed. It is not guaranteed that this speed will be reached, "
+                             "and if not, the emulator will run as fast as it can manage.");
+  dialog->registerWidgetHelp(m_ui.showOSDMessages, "Show OSD Messages", "Checked",
+                             "Shows on-screen-display messages when events occur such as save states being "
+                             "created/loaded, screenshots being taken, etc.");
+  dialog->registerWidgetHelp(m_ui.showFPS, "Show FPS", "Unchecked",
+                             "Shows the internal frame rate of the game in the top-right corner of the display.");
+  dialog->registerWidgetHelp(m_ui.showVPS, "Show VPS", "Unchecked",
+                             "Shows the number of frames (or v-syncs) displayed per second by the system in the "
+                             "top-right corner of the display.");
+  dialog->registerWidgetHelp(
+    m_ui.showSpeed, "Show Speed", "Unchecked",
+    "Shows the current emulation speed of the system in the top-right corner of the display as a percentage.");
 }
 
 GeneralSettingsWidget::~GeneralSettingsWidget() = default;
diff --git a/src/duckstation-qt/generalsettingswidget.h b/src/duckstation-qt/generalsettingswidget.h
index c97ca4ee2..da85ac79f 100644
--- a/src/duckstation-qt/generalsettingswidget.h
+++ b/src/duckstation-qt/generalsettingswidget.h
@@ -5,13 +5,14 @@
 #include "ui_generalsettingswidget.h"
 
 class QtHostInterface;
+class SettingsDialog;
 
 class GeneralSettingsWidget : public QWidget
 {
   Q_OBJECT
 
 public:
-  explicit GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
+  explicit GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog);
   ~GeneralSettingsWidget();
 
 private Q_SLOTS:
diff --git a/src/duckstation-qt/settingsdialog.cpp b/src/duckstation-qt/settingsdialog.cpp
index 6a7205357..6d4f7908e 100644
--- a/src/duckstation-qt/settingsdialog.cpp
+++ b/src/duckstation-qt/settingsdialog.cpp
@@ -16,7 +16,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
 {
   m_ui.setupUi(this);
 
-  m_general_settings = new GeneralSettingsWidget(host_interface, m_ui.settingsContainer);
+  m_general_settings = new GeneralSettingsWidget(host_interface, m_ui.settingsContainer, this);
   m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer);
   m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer);
   m_hotkey_settings = new HotkeySettingsWidget(host_interface, m_ui.settingsContainer);