From b9eae867041bca7f716769011f8076a28e80de5c Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 17 Oct 2020 00:06:34 -0500 Subject: [PATCH] DolphinQt: Add tooltip support to General Graphics tab --- .../Config/Graphics/GeneralWidget.cpp | 146 +++++++++++------- .../DolphinQt/Config/Graphics/GeneralWidget.h | 30 ++-- 2 files changed, 107 insertions(+), 69 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp index 0ccb43a4f1..02b4f06230 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp @@ -23,6 +23,7 @@ #include "DolphinQt/Config/Graphics/GraphicsChoice.h" #include "DolphinQt/Config/Graphics/GraphicsRadio.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" +#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/Settings.h" @@ -32,7 +33,7 @@ #include "VideoCommon/VideoConfig.h" GeneralWidget::GeneralWidget(X11Utils::XRRConfiguration* xrr_config, GraphicsWindow* parent) - : GraphicsWidget(parent), m_xrr_config(xrr_config) + : m_xrr_config(xrr_config) { CreateWidgets(); LoadSettings(); @@ -54,11 +55,11 @@ void GeneralWidget::CreateWidgets() auto* m_video_box = new QGroupBox(tr("Basic")); m_video_layout = new QGridLayout(); - m_backend_combo = new QComboBox(); + m_backend_combo = new ToolTipComboBox(); m_aspect_combo = new GraphicsChoice({tr("Auto"), tr("Force 16:9"), tr("Force 4:3"), tr("Stretch to Window")}, Config::GFX_ASPECT_RATIO); - m_adapter_combo = new QComboBox; + m_adapter_combo = new ToolTipComboBox; m_enable_vsync = new GraphicsBool(tr("V-Sync"), Config::GFX_VSYNC); m_enable_fullscreen = new GraphicsBool(tr("Use Fullscreen"), Config::MAIN_FULLSCREEN); @@ -197,89 +198,122 @@ void GeneralWidget::AddDescriptions() // We need QObject::tr #if defined(_WIN32) static const char TR_BACKEND_DESCRIPTION[] = QT_TR_NOOP( - "Selects which graphics API to use internally.\n\nThe software renderer is extremely " + "Selects which graphics API to use internally.

The software renderer is extremely " "slow and only useful for debugging, so either OpenGL, Direct3D, or Vulkan are " "recommended. Different games and different GPUs will behave differently on each " "backend, so for the best emulation experience it is recommended to try each and " - "select the backend that is least problematic.\n\nIf unsure, select OpenGL."); + "select the backend that is least problematic.

If unsure, " + "select OpenGL."); #else static const char TR_BACKEND_DESCRIPTION[] = QT_TR_NOOP( - "Selects which graphics API to use internally.\n\nThe software renderer is extremely " + "Selects which graphics API to use internally.

The software renderer is extremely " "slow and only useful for debugging, so any of the other backends are " - "recommended.\n\nIf unsure, select OpenGL."); + "recommended.

If unsure, select OpenGL."); #endif static const char TR_ADAPTER_DESCRIPTION[] = - QT_TR_NOOP("Selects a hardware adapter to use.\n\nIf unsure, select the first one."); + QT_TR_NOOP("Selects a hardware adapter to use.

If unsure, " + "select the first one."); static const char TR_FULLSCREEN_DESCRIPTION[] = - QT_TR_NOOP("Uses the entire screen for rendering.\n\nIf disabled, a " - "render window will be created instead.\n\nIf unsure, leave this unchecked."); + QT_TR_NOOP("Uses the entire screen for rendering.

If disabled, a " + "render window will be created instead.

If " + "unsure, leave this unchecked."); static const char TR_AUTOSIZE_DESCRIPTION[] = - QT_TR_NOOP("Automatically adjusts the window size to the internal resolution.\n\nIf unsure, " - "leave this unchecked."); - + QT_TR_NOOP("Automatically adjusts the window size to the internal resolution.

" + "If unsure, leave this unchecked."); static const char TR_RENDER_TO_MAINWINDOW_DESCRIPTION[] = QT_TR_NOOP("Uses the main Dolphin window for rendering rather than " - "a separate render window.\n\nIf unsure, leave this unchecked."); + "a separate render window.

If unsure, leave " + "this unchecked."); static const char TR_ASPECT_RATIO_DESCRIPTION[] = QT_TR_NOOP( - "Selects which aspect ratio to use when rendering.\n\nAuto: Uses the native aspect " - "ratio\nForce 16:9: Mimics an analog TV with a widescreen aspect ratio.\nForce 4:3: " - "Mimics a standard 4:3 analog TV.\nStretch to Window: Stretches the picture to the " - "window size.\n\nIf unsure, select Auto."); - static const char TR_VSYNC_DESCRIPTION[] = - QT_TR_NOOP("Waits for vertical blanks in order to prevent tearing.\n\nDecreases performance " - "if emulation speed is below 100%.\n\nIf unsure, leave this unchecked."); + "Selects which aspect ratio to use when rendering.

Auto: Uses the native aspect " + "ratio
Force 16:9: Mimics an analog TV with a widescreen aspect ratio.
Force 4:3: " + "Mimics a standard 4:3 analog TV.
Stretch to Window: Stretches the picture to the " + "window size.

If unsure, select Auto."); + static const char TR_VSYNC_DESCRIPTION[] = QT_TR_NOOP( + "Waits for vertical blanks in order to prevent tearing.

Decreases performance " + "if emulation speed is below 100%.

If unsure, leave " + "this " + "unchecked."); static const char TR_SHOW_FPS_DESCRIPTION[] = QT_TR_NOOP("Shows the number of frames rendered per second as a measure of " - "emulation speed.\n\nIf unsure, leave this unchecked."); - static const char TR_SHOW_NETPLAY_PING_DESCRIPTION[] = - QT_TR_NOOP("Shows the player's maximum ping while playing on " - "NetPlay.\n\nIf unsure, leave this unchecked."); - static const char TR_LOG_RENDERTIME_DESCRIPTION[] = - QT_TR_NOOP("Logs the render time of every frame to User/Logs/render_time.txt.\n\nUse this " - "feature when to measure the performance of Dolphin.\n\nIf " - "unsure, leave this unchecked."); + "emulation speed.

If unsure, leave this " + "unchecked."); + static const char TR_SHOW_NETPLAY_PING_DESCRIPTION[] = QT_TR_NOOP( + "Shows the player's maximum ping while playing on " + "NetPlay.

If unsure, leave this unchecked."); + static const char TR_LOG_RENDERTIME_DESCRIPTION[] = QT_TR_NOOP( + "Logs the render time of every frame to User/Logs/render_time.txt.

Use this " + "feature when to measure the performance of Dolphin.

If " + "unsure, leave this unchecked."); static const char TR_SHOW_NETPLAY_MESSAGES_DESCRIPTION[] = QT_TR_NOOP("Shows chat messages, buffer changes, and desync alerts " - "while playing NetPlay.\n\nIf unsure, leave this unchecked."); + "while playing NetPlay.

If unsure, leave " + "this unchecked."); static const char TR_SHADER_COMPILE_SYNC_DESCRIPTION[] = QT_TR_NOOP("Ubershaders are never used. Stuttering will occur during shader " - "compilation, but GPU demands are low.\n\nRecommended for low-end hardware. " - "\n\nIf unsure, select this mode."); + "compilation, but GPU demands are low.

Recommended for low-end hardware. " + "

If unsure, select this mode."); static const char TR_SHADER_COMPILE_SYNC_UBER_DESCRIPTION[] = QT_TR_NOOP( "Ubershaders will always be used. Provides a near stutter-free experience at the cost of " - "high GPU performance requirements.\n\nOnly recommended for high-end systems."); - static const char TR_SHADER_COMPILE_ASYNC_UBER_DESCRIPTION[] = - QT_TR_NOOP("Ubershaders will be used to prevent stuttering during shader compilation, but " - "specialized shaders will be used when they will not cause stuttering.\n\nIn the " - "best case it eliminates shader compilation stuttering while having minimal " - "performance impact, but results depend on video driver behavior."); + "high GPU performance requirements.

Only recommended " + "for high-end systems."); + static const char TR_SHADER_COMPILE_ASYNC_UBER_DESCRIPTION[] = QT_TR_NOOP( + "Ubershaders will be used to prevent stuttering during shader compilation, but " + "specialized shaders will be used when they will not cause stuttering.

In the " + "best case it eliminates shader compilation stuttering while having minimal " + "performance impact, but results depend on video driver behavior."); static const char TR_SHADER_COMPILE_ASYNC_SKIP_DESCRIPTION[] = QT_TR_NOOP( "Prevents shader compilation stuttering by not rendering waiting objects. Can work in " "scenarios where Ubershaders doesn't, at the cost of introducing visual glitches and broken " - "effects.\n\nNot recommended, only use if the other options give poor results."); + "effects.

Not recommended, only use if the other " + "options give poor results."); static const char TR_SHADER_COMPILE_BEFORE_START_DESCRIPTION[] = QT_TR_NOOP("Waits for all shaders to finish compiling before starting a game. Enabling this " "option may reduce stuttering or hitching for a short time after the game is " "started, at the cost of a longer delay before the game starts. For systems with " "two or fewer cores, it is recommended to enable this option, as a large shader " - "queue may reduce frame rates.\n\nOtherwise, if unsure, leave this unchecked."); + "queue may reduce frame rates.

Otherwise, if " + "unsure, leave this unchecked."); - AddDescription(m_backend_combo, TR_BACKEND_DESCRIPTION); - AddDescription(m_adapter_combo, TR_ADAPTER_DESCRIPTION); - AddDescription(m_aspect_combo, TR_ASPECT_RATIO_DESCRIPTION); - AddDescription(m_enable_vsync, TR_VSYNC_DESCRIPTION); - AddDescription(m_enable_fullscreen, TR_FULLSCREEN_DESCRIPTION); - AddDescription(m_show_fps, TR_SHOW_FPS_DESCRIPTION); - AddDescription(m_show_ping, TR_SHOW_NETPLAY_PING_DESCRIPTION); - AddDescription(m_log_render_time, TR_LOG_RENDERTIME_DESCRIPTION); - AddDescription(m_autoadjust_window_size, TR_AUTOSIZE_DESCRIPTION); - AddDescription(m_show_messages, TR_SHOW_NETPLAY_MESSAGES_DESCRIPTION); - AddDescription(m_render_main_window, TR_RENDER_TO_MAINWINDOW_DESCRIPTION); - AddDescription(m_shader_compilation_mode[0], TR_SHADER_COMPILE_SYNC_DESCRIPTION); - AddDescription(m_shader_compilation_mode[1], TR_SHADER_COMPILE_SYNC_UBER_DESCRIPTION); - AddDescription(m_shader_compilation_mode[2], TR_SHADER_COMPILE_ASYNC_UBER_DESCRIPTION); - AddDescription(m_shader_compilation_mode[3], TR_SHADER_COMPILE_ASYNC_SKIP_DESCRIPTION); - AddDescription(m_wait_for_shaders, TR_SHADER_COMPILE_BEFORE_START_DESCRIPTION); + m_backend_combo->SetTitle(tr("Backend")); + m_backend_combo->SetDescription(QString::fromStdString(TR_BACKEND_DESCRIPTION)); + + m_adapter_combo->SetTitle(tr("Adapter")); + m_adapter_combo->SetDescription(QString::fromStdString(TR_ADAPTER_DESCRIPTION)); + + m_aspect_combo->SetTitle(tr("Aspect Ratio")); + m_aspect_combo->SetDescription(QString::fromStdString(TR_ASPECT_RATIO_DESCRIPTION)); + + m_enable_vsync->SetDescription(QString::fromStdString(TR_VSYNC_DESCRIPTION)); + + m_enable_fullscreen->SetDescription(QString::fromStdString(TR_FULLSCREEN_DESCRIPTION)); + + m_show_fps->SetDescription(QString::fromStdString(TR_SHOW_FPS_DESCRIPTION)); + + m_show_ping->SetDescription(QString::fromStdString(TR_SHOW_NETPLAY_PING_DESCRIPTION)); + + m_log_render_time->SetDescription(QString::fromStdString(TR_LOG_RENDERTIME_DESCRIPTION)); + + m_autoadjust_window_size->SetDescription(QString::fromStdString(TR_AUTOSIZE_DESCRIPTION)); + + m_show_messages->SetDescription(QString::fromStdString(TR_SHOW_NETPLAY_MESSAGES_DESCRIPTION)); + + m_render_main_window->SetDescription(QString::fromStdString(TR_RENDER_TO_MAINWINDOW_DESCRIPTION)); + + m_shader_compilation_mode[0]->SetDescription( + QString::fromStdString(TR_SHADER_COMPILE_SYNC_DESCRIPTION)); + + m_shader_compilation_mode[1]->SetDescription( + QString::fromStdString(TR_SHADER_COMPILE_SYNC_UBER_DESCRIPTION)); + + m_shader_compilation_mode[2]->SetDescription( + QString::fromStdString(TR_SHADER_COMPILE_ASYNC_UBER_DESCRIPTION)); + + m_shader_compilation_mode[3]->SetDescription( + QString::fromStdString(TR_SHADER_COMPILE_ASYNC_SKIP_DESCRIPTION)); + + m_wait_for_shaders->SetDescription( + QString::fromStdString(TR_SHADER_COMPILE_BEFORE_START_DESCRIPTION)); } void GeneralWidget::OnBackendChanged(const QString& backend_name) diff --git a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.h b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.h index cd11a5607d..d398f0a9d7 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.h @@ -7,11 +7,15 @@ #include #include "DolphinQt/Config/Graphics/GraphicsWidget.h" +class GraphicsBool; +class GraphicsChoice; +class GraphicsRadioInt; class GraphicsWindow; class QCheckBox; class QComboBox; class QRadioButton; class QGridLayout; +class ToolTipComboBox; namespace X11Utils { @@ -39,21 +43,21 @@ private: // Video QGridLayout* m_video_layout; - QComboBox* m_backend_combo; - QComboBox* m_adapter_combo; - QComboBox* m_aspect_combo; - QCheckBox* m_enable_vsync; - QCheckBox* m_enable_fullscreen; + ToolTipComboBox* m_backend_combo; + ToolTipComboBox* m_adapter_combo; + GraphicsChoice* m_aspect_combo; + GraphicsBool* m_enable_vsync; + GraphicsBool* m_enable_fullscreen; // Options - QCheckBox* m_show_fps; - QCheckBox* m_show_ping; - QCheckBox* m_log_render_time; - QCheckBox* m_autoadjust_window_size; - QCheckBox* m_show_messages; - QCheckBox* m_render_main_window; - std::array m_shader_compilation_mode{}; - QCheckBox* m_wait_for_shaders; + GraphicsBool* m_show_fps; + GraphicsBool* m_show_ping; + GraphicsBool* m_log_render_time; + GraphicsBool* m_autoadjust_window_size; + GraphicsBool* m_show_messages; + GraphicsBool* m_render_main_window; + std::array m_shader_compilation_mode{}; + GraphicsBool* m_wait_for_shaders; X11Utils::XRRConfiguration* m_xrr_config; };