From c754b02aae19919b42e77701dc4c017f4a519158 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 17 Oct 2020 00:05:00 -0500 Subject: [PATCH 01/10] DolphinQt: Add BalloonTip which is built off of an internal Qt class. It gives the ability to show a tooltip with an arrow! --- Source/Core/DolphinQt/CMakeLists.txt | 2 + .../DolphinQt/Config/Graphics/BalloonTip.cpp | 269 ++++++++++++++++++ .../DolphinQt/Config/Graphics/BalloonTip.h | 42 +++ Source/Core/DolphinQt/DolphinQt.vcxproj | 2 + 4 files changed, 315 insertions(+) create mode 100644 Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp create mode 100644 Source/Core/DolphinQt/Config/Graphics/BalloonTip.h diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index bbf7890da1..d059eb83fc 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -81,6 +81,8 @@ add_executable(dolphin-emu Config/GeckoCodeWidget.h Config/Graphics/AdvancedWidget.cpp Config/Graphics/AdvancedWidget.h + Config/Graphics/BalloonTip.cpp + Config/Graphics/BalloonTip.h Config/Graphics/EnhancementsWidget.cpp Config/Graphics/EnhancementsWidget.h Config/Graphics/GeneralWidget.cpp diff --git a/Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp b/Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp new file mode 100644 index 0000000000..6be2c637f0 --- /dev/null +++ b/Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp @@ -0,0 +1,269 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/Graphics/BalloonTip.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#include +#else +#include +#include +#endif + +#if defined(__APPLE__) +#include +#endif + +namespace +{ +std::unique_ptr s_the_balloon_tip = nullptr; +} // namespace + +void BalloonTip::ShowBalloon(const QIcon& icon, const QString& title, const QString& message, + const QPoint& pos, QWidget* parent, ShowArrow show_arrow) +{ + HideBalloon(); + if (message.isEmpty() && title.isEmpty()) + return; + +#if defined(__APPLE__) + QString the_message = message; + the_message.replace(QStringLiteral(""), QStringLiteral("")); + the_message.replace(QStringLiteral(""), QStringLiteral("")); + QToolTip::showText(pos, the_message, parent); +#else + s_the_balloon_tip = std::make_unique(PrivateTag{}, icon, title, message, parent); + s_the_balloon_tip->UpdateBoundsAndRedraw(pos, show_arrow); +#endif +} + +void BalloonTip::HideBalloon() +{ +#if defined(__APPLE__) + QToolTip::hideText(); +#else + if (!s_the_balloon_tip) + return; + s_the_balloon_tip->hide(); + s_the_balloon_tip.reset(); +#endif +} + +BalloonTip::BalloonTip(PrivateTag, const QIcon& icon, QString title, QString message, + QWidget* parent) + : QWidget(nullptr, Qt::ToolTip) +{ + setAttribute(Qt::WA_DeleteOnClose); + setAutoFillBackground(true); + + const QPalette& pal = parent->palette(); + + const auto theme_window_color = pal.color(QPalette::Base); + const auto theme_window_hsv = theme_window_color.toHsv(); + + const auto brightness = theme_window_hsv.value(); + + QColor window_color; + QColor text_color; + QColor dolphin_emphasis; + if (brightness > 128) + { + // Our theme color is light, so make it darker + window_color = QColor(72, 72, 72); + text_color = Qt::white; + dolphin_emphasis = Qt::yellow; + m_border_color = palette().color(QPalette::Window).darker(160); + } + else + { + // Our theme color is dark, so make it lighter + window_color = Qt::white; + text_color = Qt::black; + dolphin_emphasis = QColor(QStringLiteral("#0090ff")); + m_border_color = palette().color(QPalette::Window).darker(160); + } + + const auto style_sheet = QStringLiteral("background-color: #%1; color: #%2;") + .arg(window_color.rgba(), 0, 16) + .arg(text_color.rgba(), 0, 16); + setStyleSheet(style_sheet); + + // Replace text in our our message + // if specific "tags" are used + message.replace(QStringLiteral(""), + QStringLiteral("").arg(dolphin_emphasis.rgba(), 0, 16)); + message.replace(QStringLiteral(""), QStringLiteral("")); + + auto* title_label = new QLabel; + title_label->installEventFilter(this); + title_label->setText(title); + QFont f = title_label->font(); + f.setBold(true); + title_label->setFont(f); + title_label->setTextFormat(Qt::RichText); + title_label->setSizePolicy(QSizePolicy::Policy::MinimumExpanding, + QSizePolicy::Policy::MinimumExpanding); + + auto* message_label = new QLabel; + message_label->installEventFilter(this); + message_label->setText(message); + message_label->setTextFormat(Qt::RichText); + message_label->setAlignment(Qt::AlignTop | Qt::AlignLeft); + +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + const int limit = QApplication::desktop()->availableGeometry(message_label).width() / 3; +#else + const int limit = message_label->screen()->availableGeometry().width() / 3; +#endif + message_label->setMaximumWidth(limit); + message_label->setSizePolicy(QSizePolicy::Policy::MinimumExpanding, + QSizePolicy::Policy::MinimumExpanding); + if (message_label->sizeHint().width() > limit) + { + message_label->setWordWrap(true); + } + + auto* layout = new QGridLayout; + layout->addWidget(title_label, 0, 0, 1, 2); + + layout->addWidget(message_label, 1, 0, 1, 3); + layout->setSizeConstraint(QLayout::SetMinimumSize); + setLayout(layout); +} + +void BalloonTip::paintEvent(QPaintEvent*) +{ + QPainter painter(this); + painter.drawPixmap(rect(), m_pixmap); +} + +void BalloonTip::UpdateBoundsAndRedraw(const QPoint& pos, ShowArrow show_arrow) +{ + m_show_arrow = show_arrow == ShowArrow::Yes; + +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + const QRect screen_rect = QApplication::desktop()->screenGeometry(pos); +#else + QScreen* screen = QGuiApplication::screenAt(pos); + if (!screen) + screen = QGuiApplication::primaryScreen(); + const QRect screen_rect = screen->geometry(); +#endif + QSize sh = sizeHint(); + const int border = 1; + const int arrow_height = 18; + const int arrow_width = 18; + const int arrow_offset = 52; + const int rect_center = 7; + const bool arrow_at_bottom = (pos.y() - sh.height() - arrow_height > 0); + const bool arrow_at_left = (pos.x() + sh.width() - arrow_width < screen_rect.width()); + const int default_padding = 10; + layout()->setContentsMargins(border + 3 + default_padding, + border + (arrow_at_bottom ? 0 : arrow_height) + 2 + default_padding, + border + 3 + default_padding, + border + (arrow_at_bottom ? arrow_height : 0) + 2 + default_padding); + updateGeometry(); + sh = sizeHint(); + + int ml, mr, mt, mb; + QSize sz = sizeHint(); + if (arrow_at_bottom) + { + ml = mt = 0; + mr = sz.width() - 1; + mb = sz.height() - arrow_height - 1; + } + else + { + ml = 0; + mt = arrow_height; + mr = sz.width() - 1; + mb = sz.height() - 1; + } + + QPainterPath path; + path.moveTo(ml + rect_center, mt); + if (!arrow_at_bottom && arrow_at_left) + { + if (m_show_arrow) + { + path.lineTo(ml + arrow_offset - arrow_width, mt); + path.lineTo(ml + arrow_offset, mt - arrow_height); + path.lineTo(ml + arrow_offset + arrow_width, mt); + } + move(qMax(pos.x() - arrow_offset, screen_rect.left() + 2), pos.y()); + } + else if (!arrow_at_bottom && !arrow_at_left) + { + if (m_show_arrow) + { + path.lineTo(mr - arrow_offset - arrow_width, mt); + path.lineTo(mr - arrow_offset, mt - arrow_height); + path.lineTo(mr - arrow_offset + arrow_width, mt); + } + move(qMin(pos.x() - sh.width() + arrow_offset, screen_rect.right() - sh.width() - 2), pos.y()); + } + path.lineTo(mr - rect_center, mt); + path.arcTo(QRect(mr - rect_center * 2, mt, rect_center * 2, rect_center * 2), 90, -90); + path.lineTo(mr, mb - rect_center); + path.arcTo(QRect(mr - rect_center * 2, mb - rect_center * 2, rect_center * 2, rect_center * 2), 0, + -90); + if (arrow_at_bottom && !arrow_at_left) + { + if (m_show_arrow) + { + path.lineTo(mr - arrow_offset + arrow_width, mb); + path.lineTo(mr - arrow_offset, mb + arrow_height); + path.lineTo(mr - arrow_offset - arrow_width, mb); + } + move(qMin(pos.x() - sh.width() + arrow_offset, screen_rect.right() - sh.width() - 2), + pos.y() - sh.height()); + } + else if (arrow_at_bottom && arrow_at_left) + { + if (m_show_arrow) + { + path.lineTo(arrow_offset + arrow_width, mb); + path.lineTo(arrow_offset, mb + arrow_height); + path.lineTo(arrow_offset - arrow_width, mb); + } + move(qMax(pos.x() - arrow_offset, screen_rect.x() + 2), pos.y() - sh.height()); + } + path.lineTo(ml + rect_center, mb); + path.arcTo(QRect(ml, mb - rect_center * 2, rect_center * 2, rect_center * 2), -90, -90); + path.lineTo(ml, mt + rect_center); + path.arcTo(QRect(ml, mt, rect_center * 2, rect_center * 2), 180, -90); + + // Set the mask + QBitmap bitmap(sizeHint()); + bitmap.fill(Qt::color0); + QPainter painter1(&bitmap); + painter1.setPen(QPen(Qt::color1, border)); + painter1.setBrush(QBrush(Qt::color1)); + painter1.drawPath(path); + setMask(bitmap); + + // Draw the border + m_pixmap = QPixmap(sz); + QPainter painter2(&m_pixmap); + painter2.setPen(QPen(m_border_color)); + painter2.setBrush(palette().color(QPalette::Window)); + painter2.drawPath(path); + + show(); +} diff --git a/Source/Core/DolphinQt/Config/Graphics/BalloonTip.h b/Source/Core/DolphinQt/Config/Graphics/BalloonTip.h new file mode 100644 index 0000000000..0bfb013f3c --- /dev/null +++ b/Source/Core/DolphinQt/Config/Graphics/BalloonTip.h @@ -0,0 +1,42 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include + +class BalloonTip : public QWidget +{ + Q_OBJECT + + struct PrivateTag + { + }; + +public: + enum class ShowArrow + { + Yes, + No + }; + static void ShowBalloon(const QIcon& icon, const QString& title, const QString& msg, + const QPoint& pos, QWidget* parent, + ShowArrow show_arrow = ShowArrow::Yes); + static void HideBalloon(); + + BalloonTip(PrivateTag, const QIcon& icon, QString title, QString msg, QWidget* parent); + +private: + void UpdateBoundsAndRedraw(const QPoint&, ShowArrow); + +protected: + void paintEvent(QPaintEvent*) override; + +private: + QColor m_border_color; + QPixmap m_pixmap; + bool m_show_arrow = true; +}; diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 04f86f2015..56edeccf7a 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -60,6 +60,7 @@ + @@ -222,6 +223,7 @@ + From 613d8b1cba514b8e4063dc58e609cec2609d0ee6 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Tue, 20 Oct 2020 22:14:06 -0500 Subject: [PATCH 02/10] DolphinQt: Remove description box handling from graphics widget and window --- Source/Core/DolphinQt/CMakeLists.txt | 1 - .../Config/Graphics/GraphicsWidget.cpp | 20 ------- .../Config/Graphics/GraphicsWidget.h | 11 ---- .../Config/Graphics/GraphicsWindow.cpp | 55 ++----------------- .../Config/Graphics/GraphicsWindow.h | 7 --- Source/Core/DolphinQt/DolphinQt.vcxproj | 1 - 6 files changed, 5 insertions(+), 90 deletions(-) delete mode 100644 Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.cpp diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index d059eb83fc..73811e4839 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -97,7 +97,6 @@ add_executable(dolphin-emu Config/Graphics/GraphicsRadio.h Config/Graphics/GraphicsSlider.cpp Config/Graphics/GraphicsSlider.h - Config/Graphics/GraphicsWidget.cpp Config/Graphics/GraphicsWidget.h Config/Graphics/GraphicsWindow.cpp Config/Graphics/GraphicsWindow.h diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.cpp deleted file mode 100644 index 8c8bae4bc4..0000000000 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include "DolphinQt/Config/Graphics/GraphicsWidget.h" - -#include -#include - -#include "DolphinQt/Config/Graphics/GraphicsWindow.h" - -GraphicsWidget::GraphicsWidget(GraphicsWindow* parent) -{ - parent->RegisterWidget(this); -} - -void GraphicsWidget::AddDescription(QWidget* widget, const char* description) -{ - emit DescriptionAdded(widget, description); -} diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.h b/Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.h index 46cdc8b971..fbe9bb8c1e 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsWidget.h @@ -6,23 +6,12 @@ #include -class GraphicsWindow; class QFormLayout; -class QGroupBox; -class QLabel; class GraphicsWidget : public QWidget { Q_OBJECT -public: - explicit GraphicsWidget(GraphicsWindow* parent); - -signals: - void DescriptionAdded(QWidget* widget, const char* description); - protected: - void AddDescription(QWidget* widget, const char* description); - virtual void LoadSettings() = 0; virtual void SaveSettings() = 0; diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp b/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp index b9ca205b08..c5c35ed783 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.cpp @@ -40,26 +40,12 @@ GraphicsWindow::GraphicsWindow(X11Utils::XRRConfiguration* xrr_config, MainWindo void GraphicsWindow::CreateMainLayout() { auto* main_layout = new QVBoxLayout(); - auto* description_box = new QGroupBox(tr("Description")); - auto* description_layout = new QVBoxLayout(); - m_description = - new QLabel(tr("Move the mouse pointer over an option to display a detailed description.")); m_tab_widget = new QTabWidget(); m_button_box = new QDialogButtonBox(QDialogButtonBox::Close); connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); - description_box->setLayout(description_layout); - description_box->setFixedHeight(200); - - m_description->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - m_description->setWordWrap(true); - m_description->setAlignment(Qt::AlignTop | Qt::AlignLeft); - - description_layout->addWidget(m_description); - main_layout->addWidget(m_tab_widget); - main_layout->addWidget(description_box); main_layout->addWidget(m_button_box); m_general_widget = new GeneralWidget(m_xrr_config, this); @@ -73,11 +59,11 @@ void GraphicsWindow::CreateMainLayout() connect(m_software_renderer, &SoftwareRendererWidget::BackendChanged, this, &GraphicsWindow::OnBackendChanged); - m_wrapped_general = GetWrappedWidget(m_general_widget, this, 50, 305); - m_wrapped_enhancements = GetWrappedWidget(m_enhancements_widget, this, 50, 305); - m_wrapped_hacks = GetWrappedWidget(m_hacks_widget, this, 50, 305); - m_wrapped_advanced = GetWrappedWidget(m_advanced_widget, this, 50, 305); - m_wrapped_software = GetWrappedWidget(m_software_renderer, this, 50, 305); + m_wrapped_general = GetWrappedWidget(m_general_widget, this, 50, 100); + m_wrapped_enhancements = GetWrappedWidget(m_enhancements_widget, this, 50, 100); + m_wrapped_hacks = GetWrappedWidget(m_hacks_widget, this, 50, 100); + m_wrapped_advanced = GetWrappedWidget(m_advanced_widget, this, 50, 100); + m_wrapped_software = GetWrappedWidget(m_software_renderer, this, 50, 100); if (Config::Get(Config::MAIN_GFX_BACKEND) != "Software Renderer") { @@ -118,34 +104,3 @@ void GraphicsWindow::OnBackendChanged(const QString& backend_name) emit BackendChanged(backend_name); } - -void GraphicsWindow::RegisterWidget(GraphicsWidget* widget) -{ - connect(widget, &GraphicsWidget::DescriptionAdded, this, &GraphicsWindow::OnDescriptionAdded); -} - -void GraphicsWindow::OnDescriptionAdded(QWidget* widget, const char* description) -{ - m_widget_descriptions[widget] = description; - widget->installEventFilter(this); -} - -bool GraphicsWindow::eventFilter(QObject* object, QEvent* event) -{ - if (!m_widget_descriptions.contains(object)) - return false; - - if (event->type() == QEvent::Enter) - { - m_description->setText(tr(m_widget_descriptions[object])); - return false; - } - - if (event->type() == QEvent::Leave) - { - m_description->setText( - tr("Move the mouse pointer over an option to display a detailed description.")); - } - - return false; -} diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.h b/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.h index 1850180dcd..6d4d2664e2 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.h +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsWindow.h @@ -11,7 +11,6 @@ class AdvancedWidget; class EnhancementsWidget; class HacksWidget; class GeneralWidget; -class GraphicsWidget; class MainWindow; class QLabel; class QTabWidget; @@ -29,18 +28,14 @@ class GraphicsWindow final : public QDialog public: explicit GraphicsWindow(X11Utils::XRRConfiguration* xrr_config, MainWindow* parent); - void RegisterWidget(GraphicsWidget* widget); - bool eventFilter(QObject* object, QEvent* event) override; signals: void BackendChanged(const QString& backend); private: void CreateMainLayout(); void OnBackendChanged(const QString& backend); - void OnDescriptionAdded(QWidget* widget, const char* description); QTabWidget* m_tab_widget; - QLabel* m_description; QDialogButtonBox* m_button_box; AdvancedWidget* m_advanced_widget; @@ -56,6 +51,4 @@ private: QWidget* m_wrapped_software; X11Utils::XRRConfiguration* m_xrr_config; - - QHash m_widget_descriptions; }; diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 56edeccf7a..45d95b552e 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -68,7 +68,6 @@ - From af0161cafdb5044d46814ab64ac5b7fb82e8c343 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Tue, 20 Oct 2020 01:37:03 -0500 Subject: [PATCH 03/10] DolphinQt: Add generic tooltip controls --- Source/Core/DolphinQt/CMakeLists.txt | 11 ++++ .../ToolTipControls/ToolTipCheckBox.cpp | 27 +++++++++ .../Config/ToolTipControls/ToolTipCheckBox.h | 18 ++++++ .../ToolTipControls/ToolTipComboBox.cpp | 10 ++++ .../Config/ToolTipControls/ToolTipComboBox.h | 15 +++++ .../ToolTipControls/ToolTipRadioButton.cpp | 27 +++++++++ .../ToolTipControls/ToolTipRadioButton.h | 18 ++++++ .../Config/ToolTipControls/ToolTipSlider.cpp | 26 +++++++++ .../Config/ToolTipControls/ToolTipSlider.h | 18 ++++++ .../Config/ToolTipControls/ToolTipSpinBox.cpp | 10 ++++ .../Config/ToolTipControls/ToolTipSpinBox.h | 15 +++++ .../Config/ToolTipControls/ToolTipWidget.h | 55 +++++++++++++++++++ Source/Core/DolphinQt/DolphinQt.vcxproj | 11 ++++ 13 files changed, 261 insertions(+) create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.cpp create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.cpp create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.h create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.cpp create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.cpp create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.h create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.cpp create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h create mode 100644 Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 73811e4839..e0d21f0754 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -171,6 +171,17 @@ add_executable(dolphin-emu Config/PropertiesDialog.h Config/SettingsWindow.cpp Config/SettingsWindow.h + Config/ToolTipControls/ToolTipCheckBox.cpp + Config/ToolTipControls/ToolTipCheckBox.h + Config/ToolTipControls/ToolTipComboBox.cpp + Config/ToolTipControls/ToolTipComboBox.h + Config/ToolTipControls/ToolTipRadioButton.cpp + Config/ToolTipControls/ToolTipRadioButton.h + Config/ToolTipControls/ToolTipSlider.cpp + Config/ToolTipControls/ToolTipSlider.h + Config/ToolTipControls/ToolTipSpinBox.cpp + Config/ToolTipControls/ToolTipSpinBox.h + Config/ToolTipControls/ToolTipWidget.h Config/VerifyWidget.cpp Config/VerifyWidget.h Debugger/BreakpointWidget.cpp diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.cpp new file mode 100644 index 0000000000..0a6a3769ff --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.cpp @@ -0,0 +1,27 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" + +#include +#include + +ToolTipCheckBox::ToolTipCheckBox(const QString& label) : ToolTipWidget(label) +{ + SetTitle(label); +} + +QPoint ToolTipCheckBox::GetToolTipPosition() const +{ + int checkbox_width = 18; + if (style()) + { + QStyleOptionButton opt; + initStyleOption(&opt); + checkbox_width = + style()->subElementRect(QStyle::SubElement::SE_CheckBoxIndicator, &opt, this).width(); + } + + return pos() + QPoint(checkbox_width / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h new file mode 100644 index 0000000000..88f840b3d9 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h @@ -0,0 +1,18 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipCheckBox : public ToolTipWidget +{ +public: + explicit ToolTipCheckBox(const QString& label); + +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.cpp new file mode 100644 index 0000000000..cbf267197c --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.cpp @@ -0,0 +1,10 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h" + +QPoint ToolTipComboBox::GetToolTipPosition() const +{ + return pos() + QPoint(width() / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.h new file mode 100644 index 0000000000..e8fb586514 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.h @@ -0,0 +1,15 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipComboBox : public ToolTipWidget +{ +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.cpp new file mode 100644 index 0000000000..5e9f35727e --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.cpp @@ -0,0 +1,27 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h" + +#include +#include + +ToolTipRadioButton::ToolTipRadioButton(const QString& label) : ToolTipWidget(label) +{ + SetTitle(label); +} + +QPoint ToolTipRadioButton::GetToolTipPosition() const +{ + int radio_button_width = 18; + if (style()) + { + QStyleOptionButton opt; + initStyleOption(&opt); + radio_button_width = + style()->subElementRect(QStyle::SubElement::SE_RadioButtonIndicator, &opt, this).width(); + } + + return pos() + QPoint(radio_button_width / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h new file mode 100644 index 0000000000..5c9cbf9e16 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h @@ -0,0 +1,18 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipRadioButton : public ToolTipWidget +{ +public: + explicit ToolTipRadioButton(const QString& label); + +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.cpp new file mode 100644 index 0000000000..304ce30a38 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.cpp @@ -0,0 +1,26 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h" + +#include +#include + +ToolTipSlider::ToolTipSlider(Qt::Orientation orientation) : ToolTipWidget(orientation) +{ +} + +QPoint ToolTipSlider::GetToolTipPosition() const +{ + QRect handle_rect(0, 0, 15, 15); + if (style()) + { + QStyleOptionSlider opt; + initStyleOption(&opt); + handle_rect = style()->subControlRect(QStyle::ComplexControl::CC_Slider, &opt, + QStyle::SubControl::SC_SliderHandle, this); + } + + return pos() + handle_rect.center(); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.h new file mode 100644 index 0000000000..0c21fd644e --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.h @@ -0,0 +1,18 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipSlider : public ToolTipWidget +{ +public: + explicit ToolTipSlider(Qt::Orientation orientation); + +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.cpp new file mode 100644 index 0000000000..d00c588845 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.cpp @@ -0,0 +1,10 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h" + +QPoint ToolTipSpinBox::GetToolTipPosition() const +{ + return pos() + QPoint(width() / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h new file mode 100644 index 0000000000..296e627138 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h @@ -0,0 +1,15 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipSpinBox : public ToolTipWidget +{ +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h new file mode 100644 index 0000000000..8b5ffe5518 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h @@ -0,0 +1,55 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +#include + +#include "DolphinQt/Config/Graphics/BalloonTip.h" + +template +class ToolTipWidget : public Derived +{ +public: + using Derived::Derived; + + void SetTitle(QString title) { m_title = std::move(title); } + + void SetDescription(QString description) { m_description = std::move(description); } + +private: + void enterEvent(QEvent* event) override + { + if (m_timer_id) + return; + m_timer_id = this->startTimer(300); + } + + void leaveEvent(QEvent* event) override + { + if (m_timer_id) + { + this->killTimer(*m_timer_id); + m_timer_id.reset(); + } + BalloonTip::HideBalloon(); + } + + void timerEvent(QTimerEvent* event) override + { + this->killTimer(*m_timer_id); + m_timer_id.reset(); + + BalloonTip::ShowBalloon(QIcon(), m_title, m_description, + this->parentWidget()->mapToGlobal(GetToolTipPosition()), this); + } + + virtual QPoint GetToolTipPosition() const = 0; + + std::optional m_timer_id; + QString m_title; + QString m_description; +}; diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 45d95b552e..de63050059 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -105,6 +105,11 @@ + + + + + @@ -263,6 +268,12 @@ + + + + + + From a9271aa167f0fca3780bdad32b682cb964db116f Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 17 Oct 2020 00:05:43 -0500 Subject: [PATCH 04/10] DolphinQt: Add the ability to show a tooltip for custom graphics controls --- Source/Core/DolphinQt/Config/Graphics/GraphicsBool.cpp | 6 ++++-- Source/Core/DolphinQt/Config/Graphics/GraphicsBool.h | 8 ++++---- Source/Core/DolphinQt/Config/Graphics/GraphicsChoice.h | 4 ++-- Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.cpp | 2 +- Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.h | 4 ++-- Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.cpp | 2 +- Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.h | 4 ++-- Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.cpp | 2 +- Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.h | 4 ++-- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.cpp b/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.cpp index 4d5eaf6973..e05f956463 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "DolphinQt/Config/Graphics/GraphicsBool.h" +#include "DolphinQt/Config/Graphics/BalloonTip.h" #include @@ -10,10 +11,11 @@ #include "DolphinQt/Settings.h" +#include #include GraphicsBool::GraphicsBool(const QString& label, const Config::Info& setting, bool reverse) - : QCheckBox(label), m_setting(setting), m_reverse(reverse) + : ToolTipCheckBox(label), m_setting(setting), m_reverse(reverse) { connect(this, &QCheckBox::toggled, this, &GraphicsBool::Update); setChecked(Config::Get(m_setting) ^ reverse); @@ -35,7 +37,7 @@ void GraphicsBool::Update() GraphicsBoolEx::GraphicsBoolEx(const QString& label, const Config::Info& setting, bool reverse) - : QRadioButton(label), m_setting(setting), m_reverse(reverse) + : ToolTipRadioButton(label), m_setting(setting), m_reverse(reverse) { connect(this, &QCheckBox::toggled, this, &GraphicsBoolEx::Update); setChecked(Config::Get(m_setting) ^ reverse); diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.h b/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.h index bb772e4c77..1d3ceb4d5d 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.h +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsBool.h @@ -4,8 +4,8 @@ #pragma once -#include -#include +#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" +#include "DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h" namespace Config { @@ -13,7 +13,7 @@ template struct Info; } -class GraphicsBool : public QCheckBox +class GraphicsBool : public ToolTipCheckBox { Q_OBJECT public: @@ -26,7 +26,7 @@ private: bool m_reverse; }; -class GraphicsBoolEx : public QRadioButton +class GraphicsBoolEx : public ToolTipRadioButton { Q_OBJECT public: diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsChoice.h b/Source/Core/DolphinQt/Config/Graphics/GraphicsChoice.h index fc2116c123..734c7d56bb 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsChoice.h +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsChoice.h @@ -4,11 +4,11 @@ #pragma once -#include +#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h" #include "Common/Config/Config.h" -class GraphicsChoice : public QComboBox +class GraphicsChoice : public ToolTipComboBox { Q_OBJECT public: diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.cpp b/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.cpp index b69f02ecdb..1fd529687e 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.cpp @@ -12,7 +12,7 @@ GraphicsInteger::GraphicsInteger(int minimum, int maximum, const Config::Info& setting, int step) - : QSpinBox(), m_setting(setting) + : ToolTipSpinBox(), m_setting(setting) { setMinimum(minimum); setMaximum(maximum); diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.h b/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.h index dda8737f02..4f0cea9cb3 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.h +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsInteger.h @@ -4,7 +4,7 @@ #pragma once -#include +#include "DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h" namespace Config { @@ -12,7 +12,7 @@ template struct Info; } -class GraphicsInteger : public QSpinBox +class GraphicsInteger : public ToolTipSpinBox { Q_OBJECT public: diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.cpp b/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.cpp index eb15527b71..2a8d2b5205 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.cpp @@ -12,7 +12,7 @@ GraphicsRadioInt::GraphicsRadioInt(const QString& label, const Config::Info& setting, int value) - : QRadioButton(label), m_setting(setting), m_value(value) + : ToolTipRadioButton(label), m_setting(setting), m_value(value) { setChecked(Config::Get(m_setting) == m_value); connect(this, &QRadioButton::toggled, this, &GraphicsRadioInt::Update); diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.h b/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.h index 288acc16c1..91ba241589 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.h +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsRadio.h @@ -4,11 +4,11 @@ #pragma once -#include +#include "DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h" #include "Common/Config/Config.h" -class GraphicsRadioInt : public QRadioButton +class GraphicsRadioInt : public ToolTipRadioButton { Q_OBJECT public: diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.cpp b/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.cpp index 350873c570..39b97fc424 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.cpp @@ -11,7 +11,7 @@ #include "DolphinQt/Settings.h" GraphicsSlider::GraphicsSlider(int minimum, int maximum, const Config::Info& setting, int tick) - : QSlider(Qt::Horizontal), m_setting(setting) + : ToolTipSlider(Qt::Horizontal), m_setting(setting) { setMinimum(minimum); setMaximum(maximum); diff --git a/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.h b/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.h index 96fdcfda4e..9c45f81ac4 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.h +++ b/Source/Core/DolphinQt/Config/Graphics/GraphicsSlider.h @@ -4,7 +4,7 @@ #pragma once -#include +#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h" namespace Config { @@ -12,7 +12,7 @@ template struct Info; } -class GraphicsSlider : public QSlider +class GraphicsSlider : public ToolTipSlider { Q_OBJECT public: From b9eae867041bca7f716769011f8076a28e80de5c Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 17 Oct 2020 00:06:34 -0500 Subject: [PATCH 05/10] 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; }; From d083dae7fdb5dd9e7634a2c455cedf43f585c27e Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 17 Oct 2020 21:27:09 -0500 Subject: [PATCH 06/10] DolphinQt: Add tooltip support to Enhancements Graphics tab --- .../Config/Graphics/EnhancementsWidget.cpp | 156 +++++++++++------- .../Config/Graphics/EnhancementsWidget.h | 36 ++-- 2 files changed, 114 insertions(+), 78 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index d84a8b0174..c3f1bca409 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -30,8 +30,7 @@ #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" -EnhancementsWidget::EnhancementsWidget(GraphicsWindow* parent) - : GraphicsWidget(parent), m_block_save(false) +EnhancementsWidget::EnhancementsWidget(GraphicsWindow* parent) : m_block_save(false) { CreateWidgets(); LoadSettings(); @@ -74,11 +73,11 @@ void EnhancementsWidget::CreateWidgets() m_ir_combo = new GraphicsChoice(resolution_options, Config::GFX_EFB_SCALE); m_ir_combo->setMaxVisibleItems(visible_resolution_option_count); - m_aa_combo = new QComboBox(); + m_aa_combo = new ToolTipComboBox(); m_af_combo = new GraphicsChoice({tr("1x"), tr("2x"), tr("4x"), tr("8x"), tr("16x")}, Config::GFX_ENHANCE_MAX_ANISOTROPY); - m_pp_effect = new QComboBox(); + m_pp_effect = new ToolTipComboBox(); m_configure_pp_effect = new QPushButton(tr("Configure")); m_scaled_efb_copy = new GraphicsBool(tr("Scaled EFB Copy"), Config::GFX_HACK_COPY_EFB_SCALED); m_per_pixel_lighting = @@ -290,97 +289,130 @@ void EnhancementsWidget::SaveSettings() void EnhancementsWidget::AddDescriptions() { static const char TR_INTERNAL_RESOLUTION_DESCRIPTION[] = - QT_TR_NOOP("Controls the rendering resolution.\n\nA high resolution greatly improves " + QT_TR_NOOP("Controls the rendering resolution.

A high resolution greatly improves " "visual quality, but also greatly increases GPU load and can cause issues in " "certain games. Generally speaking, the lower the internal resolution, the " - "better performance will be.\n\nIf unsure, select Native."); - + "better performance will be.

If unsure, " + "select Native."); static const char TR_ANTIALIAS_DESCRIPTION[] = QT_TR_NOOP( "Reduces the amount of aliasing caused by rasterizing 3D graphics, resulting " "in smoother edges on objects. Increases GPU load and sometimes causes graphical " - "issues.\n\nSSAA is significantly more demanding than MSAA, but provides top quality " + "issues.

SSAA is significantly more demanding than MSAA, but provides top quality " "geometry anti-aliasing and also applies anti-aliasing to lighting, shader " - "effects, and textures.\n\nIf unsure, select None."); - + "effects, and textures.

If unsure, select " + "None."); static const char TR_ANISOTROPIC_FILTERING_DESCRIPTION[] = QT_TR_NOOP( "Enables anisotropic filtering, which enhances the visual quality of textures that " - "are at oblique viewing angles.\n\nMight cause issues in a small " - "number of games.\n\nIf unsure, select 1x."); - - static const char TR_POSTPROCESSING_DESCRIPTION[] = QT_TR_NOOP( - "Applies a post-processing effect after rendering a frame.\n\nIf unsure, select (off)."); - + "are at oblique viewing angles.

Might cause issues in a small " + "number of games.

If unsure, select 1x."); + static const char TR_POSTPROCESSING_DESCRIPTION[] = + QT_TR_NOOP("Applies a post-processing effect after rendering a frame.

If unsure, select (off)."); static const char TR_SCALED_EFB_COPY_DESCRIPTION[] = QT_TR_NOOP("Greatly increases the quality of textures generated using render-to-texture " - "effects.\n\nSlightly increases GPU load and causes relatively few graphical " + "effects.

Slightly increases GPU load and causes relatively few graphical " "issues. Raising the internal resolution will improve the effect of this setting. " - "\n\nIf unsure, leave this checked."); + "

If unsure, leave this checked."); static const char TR_PER_PIXEL_LIGHTING_DESCRIPTION[] = QT_TR_NOOP( "Calculates lighting of 3D objects per-pixel rather than per-vertex, smoothing out the " - "appearance of lit polygons and making individual triangles less noticeable.\n\nRarely " - "causes slowdowns or graphical issues.\n\nIf unsure, leave this unchecked."); + "appearance of lit polygons and making individual triangles less noticeable.

Rarely " + "causes slowdowns or graphical issues.

If unsure, leave " + "this unchecked."); static const char TR_WIDESCREEN_HACK_DESCRIPTION[] = QT_TR_NOOP( "Forces the game to output graphics for any aspect ratio. Use with \"Aspect Ratio\" set to " - "\"Force 16:9\" to force 4:3-only games to run at 16:9.\n\nRarely produces good results and " + "\"Force 16:9\" to force 4:3-only games to run at 16:9.

Rarely produces good " + "results and " "often partially breaks graphics and game UIs. Unnecessary (and detrimental) if using any " - "AR/Gecko-code widescreen patches.\n\nIf unsure, leave this unchecked."); + "AR/Gecko-code widescreen patches.

If unsure, leave " + "this unchecked."); static const char TR_REMOVE_FOG_DESCRIPTION[] = QT_TR_NOOP("Makes distant objects more visible by removing fog, thus increasing the overall " - "detail.\n\nDisabling fog will break some games which rely on proper fog " - "emulation.\n\nIf unsure, leave this unchecked."); + "detail.

Disabling fog will break some games which rely on proper fog " + "emulation.

If unsure, leave this " + "unchecked."); static const char TR_3D_MODE_DESCRIPTION[] = QT_TR_NOOP( "Selects the stereoscopic 3D mode. Stereoscopy allows a better feeling " "of depth if the necessary hardware is present. Heavily decreases " - "emulation speed and sometimes causes issues.\n\nSide-by-Side and Top-and-Bottom are " - "used by most 3D TVs.\nAnaglyph is used for Red-Cyan colored glasses.\nHDMI 3D is " - "used when the monitor supports 3D display resolutions.\nPassive is another type of 3D " - "used by some TVs.\n\nIf unsure, select Off."); + "emulation speed and sometimes causes issues.

Side-by-Side and Top-and-Bottom are " + "used by most 3D TVs.
Anaglyph is used for Red-Cyan colored glasses.
HDMI 3D is " + "used when the monitor supports 3D display resolutions.
Passive is another type of 3D " + "used by some TVs.

If unsure, select Off."); static const char TR_3D_DEPTH_DESCRIPTION[] = QT_TR_NOOP( - "Controls the separation distance between the virtual cameras. \n\nA higher " + "Controls the separation distance between the virtual cameras.

A higher " "value creates a stronger feeling of depth while a lower value is more comfortable."); static const char TR_3D_CONVERGENCE_DESCRIPTION[] = QT_TR_NOOP( "Controls the distance of the convergence plane. This is the distance at which " - "virtual objects will appear to be in front of the screen.\n\nA higher value creates " + "virtual objects will appear to be in front of the screen.

A higher value creates " "stronger out-of-screen effects while a lower value is more comfortable."); - static const char TR_3D_SWAP_EYES_DESCRIPTION[] = - QT_TR_NOOP("Swaps the left and right eye. Most useful in side-by-side stereoscopy " - "mode.\n\nIf unsure, leave this unchecked."); - static const char TR_FORCE_24BIT_DESCRIPTION[] = - QT_TR_NOOP("Forces the game to render the RGB color channels in 24-bit, thereby increasing " - "quality by reducing color banding.\n\nHas no impact on performance and causes " - "few graphical issues.\n\nIf unsure, leave this checked."); + static const char TR_3D_SWAP_EYES_DESCRIPTION[] = QT_TR_NOOP( + "Swaps the left and right eye. Most useful in side-by-side stereoscopy " + "mode.

If unsure, leave this unchecked."); + static const char TR_FORCE_24BIT_DESCRIPTION[] = QT_TR_NOOP( + "Forces the game to render the RGB color channels in 24-bit, thereby increasing " + "quality by reducing color banding.

Has no impact on performance and causes " + "few graphical issues.

If unsure, leave this " + "checked."); static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP("Filters all textures, including any that the game explicitly set as " - "unfiltered.\n\nMay improve quality of certain textures in some games, but " - "will cause issues in others.\n\nIf unsure, leave this unchecked."); - static const char TR_DISABLE_COPY_FILTER_DESCRIPTION[] = - QT_TR_NOOP("Disables the blending of adjacent rows when copying the EFB. This is known in " - "some games as \"deflickering\" or \"smoothing\". \n\nDisabling the filter has no " - "effect on performance, but may result in a sharper image. Causes few " - "graphical issues.\n\nIf unsure, leave this checked."); + "unfiltered.

May improve quality of certain textures in some games, but " + "will cause issues in others.

If unsure, leave this " + "unchecked."); + static const char TR_DISABLE_COPY_FILTER_DESCRIPTION[] = QT_TR_NOOP( + "Disables the blending of adjacent rows when copying the EFB. This is known in " + "some games as \"deflickering\" or \"smoothing\".

Disabling the filter has no " + "effect on performance, but may result in a sharper image. Causes few " + "graphical issues.

If unsure, leave this " + "checked."); static const char TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION[] = QT_TR_NOOP( "Enables detection of arbitrary mipmaps, which some games use for special distance-based " - "effects.\n\nMay have false positives that result in blurry textures at increased internal " + "effects.

May have false positives that result in blurry textures at increased " + "internal " "resolution, such as in games that use very low resolution mipmaps. Disabling this can also " "reduce stutter in games that frequently load new textures. This feature is not compatible " - "with GPU Texture Decoding.\n\nIf unsure, leave this checked."); + "with GPU Texture Decoding.

If unsure, leave this " + "checked."); - AddDescription(m_ir_combo, TR_INTERNAL_RESOLUTION_DESCRIPTION); - AddDescription(m_aa_combo, TR_ANTIALIAS_DESCRIPTION); - AddDescription(m_af_combo, TR_ANISOTROPIC_FILTERING_DESCRIPTION); - AddDescription(m_pp_effect, TR_POSTPROCESSING_DESCRIPTION); - AddDescription(m_scaled_efb_copy, TR_SCALED_EFB_COPY_DESCRIPTION); - AddDescription(m_per_pixel_lighting, TR_PER_PIXEL_LIGHTING_DESCRIPTION); - AddDescription(m_widescreen_hack, TR_WIDESCREEN_HACK_DESCRIPTION); - AddDescription(m_disable_fog, TR_REMOVE_FOG_DESCRIPTION); - AddDescription(m_force_24bit_color, TR_FORCE_24BIT_DESCRIPTION); - AddDescription(m_force_texture_filtering, TR_FORCE_TEXTURE_FILTERING_DESCRIPTION); - AddDescription(m_disable_copy_filter, TR_DISABLE_COPY_FILTER_DESCRIPTION); - AddDescription(m_arbitrary_mipmap_detection, TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION); - AddDescription(m_3d_mode, TR_3D_MODE_DESCRIPTION); - AddDescription(m_3d_depth, TR_3D_DEPTH_DESCRIPTION); - AddDescription(m_3d_convergence, TR_3D_CONVERGENCE_DESCRIPTION); - AddDescription(m_3d_swap_eyes, TR_3D_SWAP_EYES_DESCRIPTION); + m_ir_combo->SetTitle(tr("Internal Resolution")); + m_ir_combo->SetDescription(QString::fromStdString(TR_INTERNAL_RESOLUTION_DESCRIPTION)); + + m_aa_combo->SetTitle(tr("Anti-Aliasing")); + m_aa_combo->SetDescription(QString::fromStdString(TR_ANTIALIAS_DESCRIPTION)); + + m_af_combo->SetTitle(tr("Anisotropic Filtering")); + m_af_combo->SetDescription(QString::fromStdString(TR_ANISOTROPIC_FILTERING_DESCRIPTION)); + + m_pp_effect->SetTitle(tr("Post-Processing Effect")); + m_pp_effect->SetDescription(QString::fromStdString(TR_POSTPROCESSING_DESCRIPTION)); + + m_scaled_efb_copy->SetDescription(QString::fromStdString(TR_SCALED_EFB_COPY_DESCRIPTION)); + + m_per_pixel_lighting->SetDescription(QString::fromStdString(TR_PER_PIXEL_LIGHTING_DESCRIPTION)); + + m_widescreen_hack->SetDescription(QString::fromStdString(TR_WIDESCREEN_HACK_DESCRIPTION)); + + m_disable_fog->SetDescription(QString::fromStdString(TR_REMOVE_FOG_DESCRIPTION)); + + m_force_24bit_color->SetDescription(QString::fromStdString(TR_FORCE_24BIT_DESCRIPTION)); + + m_force_texture_filtering->SetDescription( + QString::fromStdString(TR_FORCE_TEXTURE_FILTERING_DESCRIPTION)); + + m_disable_copy_filter->SetDescription(QString::fromStdString(TR_DISABLE_COPY_FILTER_DESCRIPTION)); + + m_arbitrary_mipmap_detection->SetDescription( + QString::fromStdString(TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION)); + + m_3d_mode->SetTitle(tr("Stereoscopic 3D Mode")); + m_3d_mode->SetDescription(QString::fromStdString(TR_3D_MODE_DESCRIPTION)); + + m_3d_depth->SetTitle(tr("Depth")); + m_3d_depth->SetDescription(QString::fromStdString(TR_3D_DEPTH_DESCRIPTION)); + + m_3d_convergence->SetTitle(tr("Convergence")); + m_3d_convergence->SetDescription(QString::fromStdString(TR_3D_CONVERGENCE_DESCRIPTION)); + + m_3d_swap_eyes->SetDescription(QString::fromStdString(TR_3D_SWAP_EYES_DESCRIPTION)); } void EnhancementsWidget::ConfigurePostProcessingShader() diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h index b32296ab4e..e8aa9241a4 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h @@ -6,11 +6,15 @@ #include "DolphinQt/Config/Graphics/GraphicsWidget.h" +class GraphicsBool; +class GraphicsChoice; +class GraphicsSlider; class GraphicsWindow; class QCheckBox; class QComboBox; class QPushButton; class QSlider; +class ToolTipComboBox; class EnhancementsWidget final : public GraphicsWidget { @@ -29,25 +33,25 @@ private: void LoadPPShaders(); // Enhancements - QComboBox* m_ir_combo; - QComboBox* m_aa_combo; - QComboBox* m_af_combo; - QComboBox* m_pp_effect; + GraphicsChoice* m_ir_combo; + ToolTipComboBox* m_aa_combo; + GraphicsChoice* m_af_combo; + ToolTipComboBox* m_pp_effect; QPushButton* m_configure_pp_effect; - QCheckBox* m_scaled_efb_copy; - QCheckBox* m_per_pixel_lighting; - QCheckBox* m_force_texture_filtering; - QCheckBox* m_widescreen_hack; - QCheckBox* m_disable_fog; - QCheckBox* m_force_24bit_color; - QCheckBox* m_disable_copy_filter; - QCheckBox* m_arbitrary_mipmap_detection; + GraphicsBool* m_scaled_efb_copy; + GraphicsBool* m_per_pixel_lighting; + GraphicsBool* m_force_texture_filtering; + GraphicsBool* m_widescreen_hack; + GraphicsBool* m_disable_fog; + GraphicsBool* m_force_24bit_color; + GraphicsBool* m_disable_copy_filter; + GraphicsBool* m_arbitrary_mipmap_detection; // Stereoscopy - QComboBox* m_3d_mode; - QSlider* m_3d_depth; - QSlider* m_3d_convergence; - QCheckBox* m_3d_swap_eyes; + GraphicsChoice* m_3d_mode; + GraphicsSlider* m_3d_depth; + GraphicsSlider* m_3d_convergence; + GraphicsBool* m_3d_swap_eyes; int m_msaa_modes; bool m_block_save; From 1673442794e870a7613ea6e3a345eb6363d28d01 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Tue, 20 Oct 2020 20:01:33 -0500 Subject: [PATCH 07/10] DolphinQt: Add tooltip support to Advanced Graphics tab --- .../Config/Graphics/AdvancedWidget.cpp | 148 +++++++++++------- .../Config/Graphics/AdvancedWidget.h | 46 +++--- 2 files changed, 113 insertions(+), 81 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index 173d1f4b34..6a6fae11d9 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -20,11 +20,12 @@ #include "DolphinQt/Config/Graphics/GraphicsChoice.h" #include "DolphinQt/Config/Graphics/GraphicsInteger.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" +#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" #include "DolphinQt/Settings.h" #include "VideoCommon/VideoConfig.h" -AdvancedWidget::AdvancedWidget(GraphicsWindow* parent) : GraphicsWidget(parent) +AdvancedWidget::AdvancedWidget(GraphicsWindow* parent) { CreateWidgets(); LoadSettings(); @@ -128,7 +129,7 @@ void AdvancedWidget::CreateWidgets() misc_box->setLayout(misc_layout); m_enable_cropping = new GraphicsBool(tr("Crop"), Config::GFX_CROP); - m_enable_prog_scan = new QCheckBox(tr("Enable Progressive Scan")); + m_enable_prog_scan = new ToolTipCheckBox(tr("Enable Progressive Scan")); m_backend_multithreading = new GraphicsBool(tr("Backend Multithreading"), Config::GFX_BACKEND_MULTITHREADING); @@ -209,111 +210,138 @@ void AdvancedWidget::OnEmulationStateChanged(bool running) void AdvancedWidget::AddDescriptions() { static const char TR_WIREFRAME_DESCRIPTION[] = - QT_TR_NOOP("Renders the scene as a wireframe.\n\nIf unsure, leave this unchecked."); + QT_TR_NOOP("Renders the scene as a wireframe.

If unsure, leave " + "this unchecked."); static const char TR_SHOW_STATS_DESCRIPTION[] = - QT_TR_NOOP("Shows various rendering statistics.\n\nIf unsure, leave this unchecked."); - static const char TR_TEXTURE_FORMAT_DESCRIPTION[] = QT_TR_NOOP( - "Modifies textures to show the format they're encoded in.\n\nMay require an emulation " - "reset to apply.\n\nIf unsure, leave this unchecked."); + QT_TR_NOOP("Shows various rendering statistics.

If unsure, " + "leave this unchecked."); + static const char TR_TEXTURE_FORMAT_DESCRIPTION[] = + QT_TR_NOOP("Modifies textures to show the format they're encoded in.

May require " + "an emulation " + "reset to apply.

If unsure, leave this " + "unchecked."); static const char TR_VALIDATION_LAYER_DESCRIPTION[] = QT_TR_NOOP("Enables validation of API calls made by the video backend, which may assist in " - "debugging graphical issues.\n\nIf unsure, leave this unchecked."); + "debugging graphical issues.

If unsure, leave this " + "unchecked."); static const char TR_DUMP_TEXTURE_DESCRIPTION[] = QT_TR_NOOP("Dumps decoded game textures based on the other flags to " - "User/Dump/Textures//.\n\nIf unsure, leave " - "this unchecked."); + "User/Dump/Textures//.

If unsure, leave " + "this unchecked."); static const char TR_DUMP_MIP_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( "Whether to dump mipmapped game textures to " "User/Dump/Textures//. This includes arbitrary mipmapped textures if 'Arbitrary " - "Mipmap Detection' is enabled in Enhancements.\n\nIf unsure, leave " - "this checked."); + "Mipmap Detection' is enabled in Enhancements.

If unsure, leave " + "this checked."); static const char TR_DUMP_BASE_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( "Whether to dump base game textures to " "User/Dump/Textures//. This includes arbitrary base textures if 'Arbitrary " - "Mipmap Detection' is enabled in Enhancements.\n\nIf unsure, leave " - "this checked."); + "Mipmap Detection' is enabled in Enhancements.

If unsure, leave " + "this checked."); static const char TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION[] = QT_TR_NOOP("Loads custom textures from User/Load/Textures// and " - "User/Load/DynamicInputTextures//.\n\nIf unsure, leave this " - "unchecked."); + "User/Load/DynamicInputTextures//.

If " + "unsure, leave this " + "unchecked."); static const char TR_CACHE_CUSTOM_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( - "Caches custom textures to system RAM on startup.\n\nThis can require exponentially " - "more RAM but fixes possible stuttering.\n\nIf unsure, leave this unchecked."); - static const char TR_DUMP_EFB_DESCRIPTION[] = QT_TR_NOOP( - "Dumps the contents of EFB copies to User/Dump/Textures/.\n\nIf unsure, leave this " - "unchecked."); + "Caches custom textures to system RAM on startup.

This can require exponentially " + "more RAM but fixes possible stuttering.

If unsure, leave this " + "unchecked."); + static const char TR_DUMP_EFB_DESCRIPTION[] = + QT_TR_NOOP("Dumps the contents of EFB copies to User/Dump/Textures/.

If unsure, leave this " + "unchecked."); static const char TR_DISABLE_VRAM_COPIES_DESCRIPTION[] = QT_TR_NOOP("Disables the VRAM copy of the EFB, forcing a round-trip to RAM. Inhibits all " - "upscaling.\n\nIf unsure, leave this unchecked."); + "upscaling.

If unsure, leave this " + "unchecked."); static const char TR_INTERNAL_RESOLUTION_FRAME_DUMPING_DESCRIPTION[] = QT_TR_NOOP( "Creates frame dumps and screenshots at the internal resolution of the renderer, rather than " - "the size of the window it is displayed within.\n\nIf the aspect ratio is widescreen, the " - "output image will be scaled horizontally to preserve the vertical resolution.\n\nIf " - "unsure, leave this unchecked."); + "the size of the window it is displayed within.

If the aspect ratio is " + "widescreen, the " + "output image will be scaled horizontally to preserve the vertical resolution.

If " + "unsure, leave this unchecked."); #if defined(HAVE_FFMPEG) static const char TR_USE_FFV1_DESCRIPTION[] = - QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.\n\nIf unsure, leave this unchecked."); + QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.

If " + "unsure, leave this unchecked."); #endif static const char TR_FREE_LOOK_DESCRIPTION[] = QT_TR_NOOP( "Allows manipulation of the in-game camera. Move the mouse while holding the right button " - "to pan or middle button to roll.\n\nUse the WASD keys while holding SHIFT to move the " + "to pan or middle button to roll.

Use the WASD keys while holding SHIFT to move " + "the " "camera. Press SHIFT+2 to increase speed or SHIFT+1 to decrease speed. Press SHIFT+R " - "to reset the camera or SHIFT+F to reset the speed.\n\nIf unsure, leave this unchecked. "); + "to reset the camera or SHIFT+F to reset the speed.

If unsure, " + "leave this unchecked."); static const char TR_FREE_LOOK_CONTROL_TYPE_DESCRIPTION[] = QT_TR_NOOP( - "Changes the in-game camera type during freelook.\n\n" + "Changes the in-game camera type during freelook.

" "Six Axis: Offers full camera control on all axes, akin to moving a spacecraft in zero " - "gravity. This is the most powerful freelook option but is the most challenging to use.\n" + "gravity. This is the most powerful freelook option but is the most challenging to use.

" "First Person: Controls the free camera similarly to a first person video game. The camera " - "can rotate and travel, but roll is impossible. Easy to use, but limiting.\n" + "can rotate and travel, but roll is impossible. Easy to use, but limiting.

" "Orbital: Rotates the free camera around the original camera. Has no lateral movement, only " "rotation and you may zoom up to the camera's origin point."); - static const char TR_CROPPING_DESCRIPTION[] = - QT_TR_NOOP("Crops the picture from its native aspect ratio to 4:3 or " - "16:9.\n\nIf unsure, leave this unchecked."); + static const char TR_CROPPING_DESCRIPTION[] = QT_TR_NOOP( + "Crops the picture from its native aspect ratio to 4:3 or " + "16:9.

If unsure, leave this unchecked."); static const char TR_PROGRESSIVE_SCAN_DESCRIPTION[] = QT_TR_NOOP( "Enables progressive scan if supported by the emulated software. Most games don't have " - "any issue with this.\n\nIf unsure, leave this unchecked."); + "any issue with this.

If unsure, leave this " + "unchecked."); static const char TR_BACKEND_MULTITHREADING_DESCRIPTION[] = QT_TR_NOOP("Enables multithreaded command submission in backends where supported. Enabling " "this option may result in a performance improvement on systems with more than " - "two CPU cores. Currently, this is limited to the Vulkan backend.\n\nIf unsure, " - "leave this checked."); + "two CPU cores. Currently, this is limited to the Vulkan backend.

If unsure, " + "leave this checked."); static const char TR_DEFER_EFB_ACCESS_INVALIDATION_DESCRIPTION[] = QT_TR_NOOP( "Defers invalidation of the EFB access cache until a GPU synchronization command " "is executed. If disabled, the cache will be invalidated with every draw call. " - "\n\nMay improve performance in some games which rely on CPU EFB Access at the cost " - "of stability.\n\nIf unsure, leave this unchecked."); + "

May improve performance in some games which rely on CPU EFB Access at the cost " + "of stability.

If unsure, leave this " + "unchecked."); #ifdef _WIN32 static const char TR_BORDERLESS_FULLSCREEN_DESCRIPTION[] = QT_TR_NOOP( "Implements fullscreen mode with a borderless window spanning the whole screen instead of " "using exclusive mode. Allows for faster transitions between fullscreen and windowed mode, " "but slightly increases input latency, makes movement less smooth and slightly decreases " - "performance.\n\nIf unsure, leave this unchecked."); + "performance.

If unsure, leave this " + "unchecked."); #endif - AddDescription(m_enable_wireframe, TR_WIREFRAME_DESCRIPTION); - AddDescription(m_show_statistics, TR_SHOW_STATS_DESCRIPTION); - AddDescription(m_enable_format_overlay, TR_TEXTURE_FORMAT_DESCRIPTION); - AddDescription(m_enable_api_validation, TR_VALIDATION_LAYER_DESCRIPTION); - AddDescription(m_dump_textures, TR_DUMP_TEXTURE_DESCRIPTION); - AddDescription(m_dump_mip_textures, TR_DUMP_MIP_TEXTURE_DESCRIPTION); - AddDescription(m_dump_base_textures, TR_DUMP_BASE_TEXTURE_DESCRIPTION); - AddDescription(m_load_custom_textures, TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION); - AddDescription(m_prefetch_custom_textures, TR_CACHE_CUSTOM_TEXTURE_DESCRIPTION); - AddDescription(m_dump_efb_target, TR_DUMP_EFB_DESCRIPTION); - AddDescription(m_disable_vram_copies, TR_DISABLE_VRAM_COPIES_DESCRIPTION); - AddDescription(m_use_fullres_framedumps, TR_INTERNAL_RESOLUTION_FRAME_DUMPING_DESCRIPTION); + m_enable_wireframe->SetDescription(QString::fromStdString(TR_WIREFRAME_DESCRIPTION)); + m_show_statistics->SetDescription(QString::fromStdString(TR_SHOW_STATS_DESCRIPTION)); + m_enable_format_overlay->SetDescription(QString::fromStdString(TR_TEXTURE_FORMAT_DESCRIPTION)); + m_enable_api_validation->SetDescription(QString::fromStdString(TR_VALIDATION_LAYER_DESCRIPTION)); + m_dump_textures->SetDescription(QString::fromStdString(TR_DUMP_TEXTURE_DESCRIPTION)); + m_dump_mip_textures->SetDescription(QString::fromStdString(TR_DUMP_MIP_TEXTURE_DESCRIPTION)); + m_dump_base_textures->SetDescription(QString::fromStdString(TR_DUMP_BASE_TEXTURE_DESCRIPTION)); + m_load_custom_textures->SetDescription( + QString::fromStdString(TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION)); + m_prefetch_custom_textures->SetDescription( + QString::fromStdString(TR_CACHE_CUSTOM_TEXTURE_DESCRIPTION)); + m_dump_efb_target->SetDescription(QString::fromStdString(TR_DUMP_EFB_DESCRIPTION)); + m_disable_vram_copies->SetDescription(QString::fromStdString(TR_DISABLE_VRAM_COPIES_DESCRIPTION)); + m_use_fullres_framedumps->SetDescription( + QString::fromStdString(TR_INTERNAL_RESOLUTION_FRAME_DUMPING_DESCRIPTION)); #ifdef HAVE_FFMPEG - AddDescription(m_dump_use_ffv1, TR_USE_FFV1_DESCRIPTION); + m_dump_use_ffv1->SetDescription(QString::fromStdString(TR_USE_FFV1_DESCRIPTION)); #endif - AddDescription(m_enable_cropping, TR_CROPPING_DESCRIPTION); - AddDescription(m_enable_prog_scan, TR_PROGRESSIVE_SCAN_DESCRIPTION); - AddDescription(m_enable_freelook, TR_FREE_LOOK_DESCRIPTION); - AddDescription(m_freelook_control_type, TR_FREE_LOOK_CONTROL_TYPE_DESCRIPTION); - AddDescription(m_backend_multithreading, TR_BACKEND_MULTITHREADING_DESCRIPTION); + m_enable_cropping->SetDescription(QString::fromStdString(TR_CROPPING_DESCRIPTION)); + m_enable_prog_scan->SetDescription(QString::fromStdString(TR_PROGRESSIVE_SCAN_DESCRIPTION)); + m_enable_freelook->SetDescription(QString::fromStdString(TR_FREE_LOOK_DESCRIPTION)); + m_freelook_control_type->SetTitle(tr("Free Look Control Type")); + m_freelook_control_type->SetDescription( + QString::fromStdString(TR_FREE_LOOK_CONTROL_TYPE_DESCRIPTION)); + m_backend_multithreading->SetDescription( + QString::fromStdString(TR_BACKEND_MULTITHREADING_DESCRIPTION)); #ifdef _WIN32 - AddDescription(m_borderless_fullscreen, TR_BORDERLESS_FULLSCREEN_DESCRIPTION); + m_borderless_fullscreen->SetDescription( + QString::fromStdString(TR_BORDERLESS_FULLSCREEN_DESCRIPTION)); #endif - AddDescription(m_defer_efb_access_invalidation, TR_DEFER_EFB_ACCESS_INVALIDATION_DESCRIPTION); + m_defer_efb_access_invalidation->SetDescription( + QString::fromStdString(TR_DEFER_EFB_ACCESS_INVALIDATION_DESCRIPTION)); } diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h index 3cf5dce519..a73d9ae1de 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h @@ -6,10 +6,14 @@ #include "DolphinQt/Config/Graphics/GraphicsWidget.h" +class GraphicsBool; +class GraphicsChoice; +class GraphicsInteger; class GraphicsWindow; class QCheckBox; class QComboBox; class QSpinBox; +class ToolTipCheckBox; class AdvancedWidget final : public GraphicsWidget { @@ -28,35 +32,35 @@ private: void OnEmulationStateChanged(bool running); // Debugging - QCheckBox* m_enable_wireframe; - QCheckBox* m_show_statistics; - QCheckBox* m_enable_format_overlay; - QCheckBox* m_enable_api_validation; + GraphicsBool* m_enable_wireframe; + GraphicsBool* m_show_statistics; + GraphicsBool* m_enable_format_overlay; + GraphicsBool* m_enable_api_validation; // Utility - QCheckBox* m_prefetch_custom_textures; - QCheckBox* m_dump_efb_target; - QCheckBox* m_disable_vram_copies; - QCheckBox* m_load_custom_textures; - QCheckBox* m_enable_freelook; - QComboBox* m_freelook_control_type; + GraphicsBool* m_prefetch_custom_textures; + GraphicsBool* m_dump_efb_target; + GraphicsBool* m_disable_vram_copies; + GraphicsBool* m_load_custom_textures; + GraphicsBool* m_enable_freelook; + GraphicsChoice* m_freelook_control_type; // Texture dumping - QCheckBox* m_dump_textures; - QCheckBox* m_dump_mip_textures; - QCheckBox* m_dump_base_textures; + GraphicsBool* m_dump_textures; + GraphicsBool* m_dump_mip_textures; + GraphicsBool* m_dump_base_textures; // Frame dumping - QCheckBox* m_dump_use_ffv1; - QCheckBox* m_use_fullres_framedumps; - QSpinBox* m_dump_bitrate; + GraphicsBool* m_dump_use_ffv1; + GraphicsBool* m_use_fullres_framedumps; + GraphicsInteger* m_dump_bitrate; // Misc - QCheckBox* m_enable_cropping; - QCheckBox* m_enable_prog_scan; - QCheckBox* m_backend_multithreading; - QCheckBox* m_borderless_fullscreen; + GraphicsBool* m_enable_cropping; + ToolTipCheckBox* m_enable_prog_scan; + GraphicsBool* m_backend_multithreading; + GraphicsBool* m_borderless_fullscreen; // Experimental - QCheckBox* m_defer_efb_access_invalidation; + GraphicsBool* m_defer_efb_access_invalidation; }; From 2bfb8ebf96206e2e042a0c2743f8516c969f3ede Mon Sep 17 00:00:00 2001 From: iwubcode Date: Tue, 20 Oct 2020 20:02:43 -0500 Subject: [PATCH 08/10] DolphinQt: Add tooltip support to Hacks Graphics tab --- .../DolphinQt/Config/Graphics/HacksWidget.cpp | 131 ++++++++++-------- .../DolphinQt/Config/Graphics/HacksWidget.h | 31 ++--- 2 files changed, 87 insertions(+), 75 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp index 5aaf31480b..5719a1190b 100644 --- a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp @@ -17,11 +17,12 @@ #include "DolphinQt/Config/Graphics/GraphicsBool.h" #include "DolphinQt/Config/Graphics/GraphicsSlider.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" +#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h" #include "DolphinQt/Settings.h" #include "VideoCommon/VideoConfig.h" -HacksWidget::HacksWidget(GraphicsWindow* parent) : GraphicsWidget(parent) +HacksWidget::HacksWidget(GraphicsWindow* parent) { CreateWidgets(); LoadSettings(); @@ -60,7 +61,7 @@ void HacksWidget::CreateWidgets() auto* texture_cache_layout = new QGridLayout(); texture_cache_box->setLayout(texture_cache_layout); - m_accuracy = new QSlider(Qt::Horizontal); + m_accuracy = new ToolTipSlider(Qt::Horizontal); m_accuracy->setMinimum(0); m_accuracy->setMaximum(2); m_accuracy->setPageStep(1); @@ -207,81 +208,93 @@ void HacksWidget::SaveSettings() void HacksWidget::AddDescriptions() { - static const char TR_SKIP_EFB_CPU_ACCESS_DESCRIPTION[] = - QT_TR_NOOP("Ignores any requests from the CPU to read from or write to the EFB. " - "\n\nImproves performance in some games, but will disable all EFB-based " - "graphical effects or gameplay-related features.\n\nIf unsure, " - "leave this unchecked."); + static const char TR_SKIP_EFB_CPU_ACCESS_DESCRIPTION[] = QT_TR_NOOP( + "Ignores any requests from the CPU to read from or write to the EFB. " + "

Improves performance in some games, but will disable all EFB-based " + "graphical effects or gameplay-related features.

If unsure, " + "leave this unchecked."); static const char TR_IGNORE_FORMAT_CHANGE_DESCRIPTION[] = QT_TR_NOOP( - "Ignores any changes to the EFB format.\n\nImproves performance in many games without " + "Ignores any changes to the EFB format.

Improves performance in many games " + "without " "any negative effect. Causes graphical defects in a small number of other " - "games.\n\nIf unsure, leave this checked."); + "games.

If unsure, leave this checked."); static const char TR_STORE_EFB_TO_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( "Stores EFB copies exclusively on the GPU, bypassing system memory. Causes graphical defects " - "in a small number of games.\n\nEnabled = EFB Copies to Texture\nDisabled = EFB Copies to " - "RAM (and Texture)\n\nIf unsure, leave this checked."); + "in a small number of games.

Enabled = EFB Copies to Texture
Disabled = EFB " + "Copies to " + "RAM (and Texture)

If unsure, leave this " + "checked."); static const char TR_DEFER_EFB_COPIES_DESCRIPTION[] = QT_TR_NOOP( "Waits until the game synchronizes with the emulated GPU before writing the contents of EFB " - "copies to RAM.\n\nReduces the overhead of EFB RAM copies, providing a performance boost in " + "copies to RAM.

Reduces the overhead of EFB RAM copies, providing a performance " + "boost in " "many games, at the risk of breaking those which do not safely synchronize with the " - "emulated GPU.\n\nIf unsure, leave this checked."); + "emulated GPU.

If unsure, leave this " + "checked."); static const char TR_ACCUARCY_DESCRIPTION[] = QT_TR_NOOP( - "Adjusts the accuracy at which the GPU receives texture updates from RAM.\n\n" + "Adjusts the accuracy at which the GPU receives texture updates from RAM.

" "The \"Safe\" setting eliminates the likelihood of the GPU missing texture updates " "from RAM. Lower accuracies cause in-game text to appear garbled in certain " - "games.\n\nIf unsure, select the rightmost value."); - + "games.

If unsure, select the rightmost " + "value."); static const char TR_STORE_XFB_TO_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( "Stores XFB copies exclusively on the GPU, bypassing system memory. Causes graphical defects " - "in a small number of games.\n\nEnabled = XFB Copies to " - "Texture\nDisabled = XFB Copies to RAM (and Texture)\n\nIf unsure, leave this checked."); - - static const char TR_IMMEDIATE_XFB_DESCRIPTION[] = - QT_TR_NOOP("Displays XFB copies as soon as they are created, instead of waiting for " - "scanout.\n\nCan cause graphical defects in some games if the game doesn't " - "expect all XFB copies to be displayed. However, turning this setting on reduces " - "latency.\n\nIf unsure, leave this unchecked."); - + "in a small number of games.

Enabled = XFB Copies to " + "Texture
Disabled = XFB Copies to RAM (and Texture)

If " + "unsure, leave this checked."); + static const char TR_IMMEDIATE_XFB_DESCRIPTION[] = QT_TR_NOOP( + "Displays XFB copies as soon as they are created, instead of waiting for " + "scanout.

Can cause graphical defects in some games if the game doesn't " + "expect all XFB copies to be displayed. However, turning this setting on reduces " + "latency.

If unsure, leave this unchecked."); static const char TR_SKIP_DUPLICATE_XFBS_DESCRIPTION[] = QT_TR_NOOP( "Skips presentation of duplicate frames (XFB copies) in 25fps/30fps games. This may improve " - "performance on low-end devices, while making frame pacing less consistent.\n\nDisable this " - "option as well as enabling V-Sync for optimal frame pacing.\n\nIf unsure, leave this " - "checked."); - - static const char TR_GPU_DECODING_DESCRIPTION[] = - QT_TR_NOOP("Enables texture decoding using the GPU instead of the CPU.\n\nThis may result in " - "performance gains in some scenarios, or on systems where the CPU is the " - "bottleneck.\n\nIf unsure, leave this unchecked."); - + "performance on low-end devices, while making frame pacing less consistent.

Disable this " + "option as well as enabling V-Sync for optimal frame pacing.

If " + "unsure, leave this " + "checked."); + static const char TR_GPU_DECODING_DESCRIPTION[] = QT_TR_NOOP( + "Enables texture decoding using the GPU instead of the CPU.

This may result in " + "performance gains in some scenarios, or on systems where the CPU is the " + "bottleneck.

If unsure, leave this " + "unchecked."); static const char TR_FAST_DEPTH_CALC_DESCRIPTION[] = QT_TR_NOOP( - "Uses a less accurate algorithm to calculate depth values.\n\nCauses issues in a few " + "Uses a less accurate algorithm to calculate depth values.

Causes issues in a few " "games, but can result in a decent speed increase depending on the game and/or " - "GPU.\n\nIf unsure, leave this checked."); + "GPU.

If unsure, leave this checked."); static const char TR_DISABLE_BOUNDINGBOX_DESCRIPTION[] = - QT_TR_NOOP("Disables bounding box emulation.\n\nThis may improve GPU performance " - "significantly, but some games will break.\n\nIf unsure, leave this checked."); - static const char TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION[] = QT_TR_NOOP( - "Includes the contents of the embedded frame buffer (EFB) and upscaled EFB copies " - "in save states. Fixes missing and/or non-upscaled textures/objects when loading " - "states at the cost of additional save/load time.\n\nIf unsure, leave this checked."); - static const char TR_VERTEX_ROUNDING_DESCRIPTION[] = - QT_TR_NOOP("Rounds 2D vertices to whole pixels.\n\nFixes graphical problems in some games at " - "higher internal resolutions. This setting has no effect when native internal " - "resolution is used.\n\nIf unsure, leave this unchecked."); + QT_TR_NOOP("Disables bounding box emulation.

This may improve GPU performance " + "significantly, but some games will break.

If " + "unsure, leave this checked."); + static const char TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION[] = + QT_TR_NOOP("Includes the contents of the embedded frame buffer (EFB) and upscaled EFB copies " + "in save states. Fixes missing and/or non-upscaled textures/objects when loading " + "states at the cost of additional save/load time.

If " + "unsure, leave this checked."); + static const char TR_VERTEX_ROUNDING_DESCRIPTION[] = QT_TR_NOOP( + "Rounds 2D vertices to whole pixels.

Fixes graphical problems in some games at " + "higher internal resolutions. This setting has no effect when native internal " + "resolution is used.

If unsure, leave this " + "unchecked."); - AddDescription(m_skip_efb_cpu, TR_SKIP_EFB_CPU_ACCESS_DESCRIPTION); - AddDescription(m_ignore_format_changes, TR_IGNORE_FORMAT_CHANGE_DESCRIPTION); - AddDescription(m_store_efb_copies, TR_STORE_EFB_TO_TEXTURE_DESCRIPTION); - AddDescription(m_defer_efb_copies, TR_DEFER_EFB_COPIES_DESCRIPTION); - AddDescription(m_accuracy, TR_ACCUARCY_DESCRIPTION); - AddDescription(m_store_xfb_copies, TR_STORE_XFB_TO_TEXTURE_DESCRIPTION); - AddDescription(m_immediate_xfb, TR_IMMEDIATE_XFB_DESCRIPTION); - AddDescription(m_skip_duplicate_xfbs, TR_SKIP_DUPLICATE_XFBS_DESCRIPTION); - AddDescription(m_gpu_texture_decoding, TR_GPU_DECODING_DESCRIPTION); - AddDescription(m_fast_depth_calculation, TR_FAST_DEPTH_CALC_DESCRIPTION); - AddDescription(m_disable_bounding_box, TR_DISABLE_BOUNDINGBOX_DESCRIPTION); - AddDescription(m_save_texture_cache_state, TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION); - AddDescription(m_vertex_rounding, TR_VERTEX_ROUNDING_DESCRIPTION); + m_skip_efb_cpu->SetDescription(QString::fromStdString(TR_SKIP_EFB_CPU_ACCESS_DESCRIPTION)); + m_ignore_format_changes->SetDescription( + QString::fromStdString(TR_IGNORE_FORMAT_CHANGE_DESCRIPTION)); + m_store_efb_copies->SetDescription(QString::fromStdString(TR_STORE_EFB_TO_TEXTURE_DESCRIPTION)); + m_defer_efb_copies->SetDescription(QString::fromStdString(TR_DEFER_EFB_COPIES_DESCRIPTION)); + m_accuracy->SetTitle(tr("Texture Cache Accuracy")); + m_accuracy->SetDescription(QString::fromStdString(TR_ACCUARCY_DESCRIPTION)); + m_store_xfb_copies->SetDescription(QString::fromStdString(TR_STORE_XFB_TO_TEXTURE_DESCRIPTION)); + m_immediate_xfb->SetDescription(QString::fromStdString(TR_IMMEDIATE_XFB_DESCRIPTION)); + m_skip_duplicate_xfbs->SetDescription(QString::fromStdString(TR_SKIP_DUPLICATE_XFBS_DESCRIPTION)); + m_gpu_texture_decoding->SetDescription(QString::fromStdString(TR_GPU_DECODING_DESCRIPTION)); + m_fast_depth_calculation->SetDescription(QString::fromStdString(TR_FAST_DEPTH_CALC_DESCRIPTION)); + m_disable_bounding_box->SetDescription( + QString::fromStdString(TR_DISABLE_BOUNDINGBOX_DESCRIPTION)); + m_save_texture_cache_state->SetDescription( + QString::fromStdString(TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION)); + m_vertex_rounding->SetDescription(QString::fromStdString(TR_VERTEX_ROUNDING_DESCRIPTION)); } void HacksWidget::UpdateDeferEFBCopiesEnabled() diff --git a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.h b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.h index b6ca90dbd4..534fb0e0d2 100644 --- a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.h @@ -6,11 +6,10 @@ #include "DolphinQt/Config/Graphics/GraphicsWidget.h" +class GraphicsBool; class GraphicsWindow; -class QCheckBox; class QLabel; -class QRadioButton; -class QSlider; +class ToolTipSlider; class HacksWidget final : public GraphicsWidget { @@ -25,26 +24,26 @@ private: void OnBackendChanged(const QString& backend_name); // EFB - QCheckBox* m_skip_efb_cpu; - QCheckBox* m_ignore_format_changes; - QCheckBox* m_store_efb_copies; + GraphicsBool* m_skip_efb_cpu; + GraphicsBool* m_ignore_format_changes; + GraphicsBool* m_store_efb_copies; // Texture Cache QLabel* m_accuracy_label; - QSlider* m_accuracy; - QCheckBox* m_gpu_texture_decoding; + ToolTipSlider* m_accuracy; + GraphicsBool* m_gpu_texture_decoding; // External Framebuffer - QCheckBox* m_store_xfb_copies; - QCheckBox* m_immediate_xfb; - QCheckBox* m_skip_duplicate_xfbs; + GraphicsBool* m_store_xfb_copies; + GraphicsBool* m_immediate_xfb; + GraphicsBool* m_skip_duplicate_xfbs; // Other - QCheckBox* m_fast_depth_calculation; - QCheckBox* m_disable_bounding_box; - QCheckBox* m_vertex_rounding; - QCheckBox* m_save_texture_cache_state; - QCheckBox* m_defer_efb_copies; + GraphicsBool* m_fast_depth_calculation; + GraphicsBool* m_disable_bounding_box; + GraphicsBool* m_vertex_rounding; + GraphicsBool* m_save_texture_cache_state; + GraphicsBool* m_defer_efb_copies; void CreateWidgets(); void ConnectWidgets(); From 9c204428fe3a8d2cccf01cc508a72459b5d9da2c Mon Sep 17 00:00:00 2001 From: iwubcode Date: Tue, 20 Oct 2020 20:03:15 -0500 Subject: [PATCH 09/10] DolphinQt: Add tooltip support to Software Renderer Graphics tab --- .../Graphics/SoftwareRendererWidget.cpp | 58 +++++++++---------- .../Config/Graphics/SoftwareRendererWidget.h | 16 ++--- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp index 5bf638ffc5..56aa3a9c7c 100644 --- a/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.cpp @@ -18,6 +18,7 @@ #include "DolphinQt/Config/Graphics/GraphicsBool.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" +#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h" #include "DolphinQt/Settings.h" #include "UICommon/VideoUtils.h" @@ -25,7 +26,7 @@ #include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoConfig.h" -SoftwareRendererWidget::SoftwareRendererWidget(GraphicsWindow* parent) : GraphicsWidget(parent) +SoftwareRendererWidget::SoftwareRendererWidget(GraphicsWindow* parent) { CreateWidgets(); LoadSettings(); @@ -45,7 +46,7 @@ void SoftwareRendererWidget::CreateWidgets() auto* rendering_box = new QGroupBox(tr("Rendering")); auto* rendering_layout = new QGridLayout(); - m_backend_combo = new QComboBox(); + m_backend_combo = new ToolTipComboBox(); rendering_box->setLayout(rendering_layout); rendering_layout->addWidget(new QLabel(tr("Backend:")), 1, 1); @@ -154,38 +155,37 @@ void SoftwareRendererWidget::SaveSettings() void SoftwareRendererWidget::AddDescriptions() { - static const char TR_BACKEND_DESCRIPTION[] = - QT_TR_NOOP("Selects what graphics API to use internally.\nThe software renderer is extremely " - "slow and only useful for debugging, so you'll want to use either Direct3D or " - "OpenGL. Different games and different GPUs will behave differently on each " - "backend, so for the best emulation experience it's recommended to try both and " - "choose the one that's less problematic.\n\nIf unsure, select OpenGL."); - + static const char TR_BACKEND_DESCRIPTION[] = QT_TR_NOOP( + "Selects what graphics API to use internally.
The software renderer is extremely " + "slow and only useful for debugging, so you'll want to use either Direct3D or " + "OpenGL. Different games and different GPUs will behave differently on each " + "backend, so for the best emulation experience it's recommended to try both and " + "choose the one that's less problematic.

If unsure, select " + "OpenGL."); static const char TR_SHOW_STATISTICS_DESCRIPTION[] = - QT_TR_NOOP("Show various rendering statistics.\n\nIf unsure, leave this unchecked."); - + QT_TR_NOOP("Show various rendering statistics.

If unsure, leave " + "this unchecked."); static const char TR_DUMP_TEXTURES_DESCRIPTION[] = - QT_TR_NOOP("Dump decoded game textures to User/Dump/Textures//.\n\nIf unsure, leave " - "this unchecked."); - + QT_TR_NOOP("Dump decoded game textures to User/Dump/Textures//.

If unsure, leave " + "this unchecked."); static const char TR_DUMP_OBJECTS_DESCRIPTION[] = - QT_TR_NOOP("Dump objects to User/Dump/Objects/.\n\nIf unsure, leave " - "this unchecked."); - + QT_TR_NOOP("Dump objects to User/Dump/Objects/.

If unsure, leave " + "this unchecked."); static const char TR_DUMP_TEV_STAGES_DESCRIPTION[] = - QT_TR_NOOP("Dump TEV Stages to User/Dump/Objects/.\n\nIf unsure, leave " - "this unchecked."); + QT_TR_NOOP("Dump TEV Stages to User/Dump/Objects/.

If unsure, leave " + "this unchecked."); + static const char TR_DUMP_TEV_FETCHES_DESCRIPTION[] = QT_TR_NOOP( + "Dump Texture Fetches to User/Dump/Objects/.

If unsure, leave " + "this unchecked."); - static const char TR_DUMP_TEV_FETCHES_DESCRIPTION[] = - QT_TR_NOOP("Dump Texture Fetches to User/Dump/Objects/.\n\nIf unsure, leave " - "this unchecked."); - - AddDescription(m_backend_combo, TR_BACKEND_DESCRIPTION); - AddDescription(m_show_statistics, TR_SHOW_STATISTICS_DESCRIPTION); - AddDescription(m_dump_textures, TR_DUMP_TEXTURES_DESCRIPTION); - AddDescription(m_dump_objects, TR_DUMP_OBJECTS_DESCRIPTION); - AddDescription(m_dump_tev_stages, TR_DUMP_TEV_STAGES_DESCRIPTION); - AddDescription(m_dump_tev_fetches, TR_DUMP_TEV_FETCHES_DESCRIPTION); + m_backend_combo->SetTitle(tr("Backend")); + m_backend_combo->SetDescription(QString::fromStdString(TR_BACKEND_DESCRIPTION)); + m_show_statistics->SetDescription(QString::fromStdString(TR_SHOW_STATISTICS_DESCRIPTION)); + m_dump_textures->SetDescription(QString::fromStdString(TR_DUMP_TEXTURES_DESCRIPTION)); + m_dump_objects->SetDescription(QString::fromStdString(TR_DUMP_OBJECTS_DESCRIPTION)); + m_dump_tev_stages->SetDescription(QString::fromStdString(TR_DUMP_TEV_STAGES_DESCRIPTION)); + m_dump_tev_fetches->SetDescription(QString::fromStdString(TR_DUMP_TEV_FETCHES_DESCRIPTION)); } void SoftwareRendererWidget::OnEmulationStateChanged(bool running) diff --git a/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.h b/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.h index 5b3ce64b5b..9b641eef0c 100644 --- a/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/SoftwareRendererWidget.h @@ -6,10 +6,10 @@ #include "DolphinQt/Config/Graphics/GraphicsWidget.h" +class GraphicsBool; class GraphicsWindow; -class QCheckBox; -class QComboBox; class QSpinBox; +class ToolTipComboBox; class SoftwareRendererWidget final : public GraphicsWidget { @@ -30,12 +30,12 @@ private: void OnEmulationStateChanged(bool running); - QComboBox* m_backend_combo; - QCheckBox* m_show_statistics; - QCheckBox* m_dump_textures; - QCheckBox* m_dump_objects; - QCheckBox* m_dump_tev_stages; - QCheckBox* m_dump_tev_fetches; + ToolTipComboBox* m_backend_combo; + GraphicsBool* m_show_statistics; + GraphicsBool* m_dump_textures; + GraphicsBool* m_dump_objects; + GraphicsBool* m_dump_tev_stages; + GraphicsBool* m_dump_tev_fetches; QSpinBox* m_object_range_min; QSpinBox* m_object_range_max; From cc837a59d64298d8a777ddec90b8ac26432886bd Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 24 Oct 2020 23:30:14 -0500 Subject: [PATCH 10/10] Core / DolphinQt: Add ini only option to force low-contrast tooltips --- Source/Core/Core/Config/MainSettings.cpp | 2 + Source/Core/Core/Config/MainSettings.h | 1 + .../DolphinQt/Config/Graphics/BalloonTip.cpp | 43 ++++++++++++++----- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 6715a2a877..0c2b331cc9 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -156,6 +156,8 @@ const Info MAIN_NETWORK_SSL_DUMP_PEER_CERT{{System::Main, "Network", "SSLD // Main.Interface +const Info MAIN_USE_HIGH_CONTRAST_TOOLTIPS{ + {System::Main, "Interface", "UseHighContrastTooltips"}, true}; const Info MAIN_USE_PANIC_HANDLERS{{System::Main, "Interface", "UsePanicHandlers"}, true}; const Info MAIN_OSD_MESSAGES{{System::Main, "Interface", "OnScreenDisplayMessages"}, true}; const Info MAIN_SKIP_NKIT_WARNING{{System::Main, "Interface", "SkipNKitWarning"}, false}; diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index ddd6cac340..d842fc3f49 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -130,6 +130,7 @@ extern const Info MAIN_NETWORK_SSL_DUMP_PEER_CERT; // Main.Interface +extern const Info MAIN_USE_HIGH_CONTRAST_TOOLTIPS; extern const Info MAIN_USE_PANIC_HANDLERS; extern const Info MAIN_OSD_MESSAGES; extern const Info MAIN_SKIP_NKIT_WARNING; diff --git a/Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp b/Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp index 6be2c637f0..98b5062934 100644 --- a/Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/BalloonTip.cpp @@ -29,6 +29,8 @@ #include #endif +#include "Core/Config/MainSettings.h" + namespace { std::unique_ptr s_the_balloon_tip = nullptr; @@ -81,21 +83,42 @@ BalloonTip::BalloonTip(PrivateTag, const QIcon& icon, QString title, QString mes QColor window_color; QColor text_color; QColor dolphin_emphasis; + const bool use_high_contrast = Config::Get(Config::MAIN_USE_HIGH_CONTRAST_TOOLTIPS); if (brightness > 128) { - // Our theme color is light, so make it darker - window_color = QColor(72, 72, 72); - text_color = Qt::white; - dolphin_emphasis = Qt::yellow; - m_border_color = palette().color(QPalette::Window).darker(160); + if (use_high_contrast) + { + // Our theme color is light, so make it darker + window_color = QColor(72, 72, 72); + text_color = Qt::white; + dolphin_emphasis = Qt::yellow; + m_border_color = palette().color(QPalette::Window).darker(160); + } + else + { + window_color = pal.color(QPalette::Window); + text_color = pal.color(QPalette::Text); + dolphin_emphasis = QColor(QStringLiteral("#0090ff")); + m_border_color = pal.color(QPalette::Text); + } } else { - // Our theme color is dark, so make it lighter - window_color = Qt::white; - text_color = Qt::black; - dolphin_emphasis = QColor(QStringLiteral("#0090ff")); - m_border_color = palette().color(QPalette::Window).darker(160); + if (use_high_contrast) + { + // Our theme color is dark, so make it lighter + window_color = Qt::white; + text_color = Qt::black; + dolphin_emphasis = QColor(QStringLiteral("#0090ff")); + m_border_color = palette().color(QPalette::Window).darker(160); + } + else + { + window_color = pal.color(QPalette::Window); + text_color = pal.color(QPalette::Text); + dolphin_emphasis = Qt::yellow; + m_border_color = pal.color(QPalette::Text); + } } const auto style_sheet = QStringLiteral("background-color: #%1; color: #%2;")