diff --git a/src/duckstation-qt/settingswindow.cpp b/src/duckstation-qt/settingswindow.cpp index c113f016a..687bd413a 100644 --- a/src/duckstation-qt/settingswindow.cpp +++ b/src/duckstation-qt/settingswindow.cpp @@ -30,7 +30,9 @@ #include "common/file_system.h" #include "common/log.h" +#include #include +#include #include Log_SetChannel(SettingsWindow); @@ -68,10 +70,11 @@ SettingsWindow::~SettingsWindow() void SettingsWindow::addPages() { - addWidget(m_general_settings = new GeneralSettingsWidget(this, m_ui.settingsContainer), tr("General"), - QStringLiteral("settings-3-line"), - tr("General Settings
These options control how the emulator looks and " - "behaves.

Mouse over an option for additional information.")); + addWidget( + m_general_settings = new GeneralSettingsWidget(this, m_ui.settingsContainer), tr("General"), + QStringLiteral("settings-3-line"), + tr("General Settings
These options control how the emulator looks and " + "behaves.

Mouse over an option for additional information, and Shift+Wheel to scroll this panel.")); if (!isPerGameSettings()) { @@ -83,18 +86,20 @@ void SettingsWindow::addPages() "recursive/non-recursive.")); } - addWidget(m_bios_settings = new BIOSSettingsWidget(this, m_ui.settingsContainer), tr("BIOS"), - QStringLiteral("chip-line"), - tr("BIOS Settings
These options control which BIOS is used and how it will be " - "patched.

Mouse over an option for additional information.")); - addWidget(m_console_settings = new ConsoleSettingsWidget(this, m_ui.settingsContainer), tr("Console"), - QStringLiteral("chip-2-line"), - tr("Console Settings
These options determine the configuration of the simulated " - "console.

Mouse over an option for additional information.")); - addWidget(m_emulation_settings = new EmulationSettingsWidget(this, m_ui.settingsContainer), tr("Emulation"), - QStringLiteral("emulation-line"), - tr("Emulation Settings
These options determine the speed and runahead behavior of the " - "system.

Mouse over an option for additional information.")); + addWidget( + m_bios_settings = new BIOSSettingsWidget(this, m_ui.settingsContainer), tr("BIOS"), QStringLiteral("chip-line"), + tr("BIOS Settings
These options control which BIOS is used and how it will be " + "patched.

Mouse over an option for additional information, and Shift+Wheel to scroll this panel.")); + addWidget( + m_console_settings = new ConsoleSettingsWidget(this, m_ui.settingsContainer), tr("Console"), + QStringLiteral("chip-2-line"), + tr("Console Settings
These options determine the configuration of the simulated " + "console.

Mouse over an option for additional information, and Shift+Wheel to scroll this panel.")); + addWidget( + m_emulation_settings = new EmulationSettingsWidget(this, m_ui.settingsContainer), tr("Emulation"), + QStringLiteral("emulation-line"), + tr("Emulation Settings
These options determine the speed and runahead behavior of the " + "system.

Mouse over an option for additional information, and Shift+Wheel to scroll this panel.")); addWidget( m_memory_card_settings = new MemoryCardSettingsWidget(this, m_ui.settingsContainer), tr("Memory Cards"), QStringLiteral("memcard-line"), @@ -109,7 +114,8 @@ void SettingsWindow::addPages() m_enhancement_settings = new EnhancementSettingsWidget(this, m_ui.settingsContainer), tr("Enhancements"), QStringLiteral("sparkle-fill"), tr("Enhancement Settings
These options control enhancements which can improve visuals compared " - "to the original console. Mouse over each option for additional information.")); + "to the original console. Mouse over each option for additional information, and Shift+Wheel to scroll this " + "panel.")); addWidget( m_post_processing_settings = new PostProcessingSettingsWidget(this, m_ui.settingsContainer), tr("Post-Processing"), QStringLiteral("sun-fill"), @@ -124,7 +130,7 @@ void SettingsWindow::addPages() QString title(tr("Achievements")); QString icon_text(QStringLiteral("trophy-line")); QString help_text(tr("Achievement Settings
These options control RetroAchievements. Mouse over " - "an option for additional information.")); + "an option for additional information, and Shift+Wheel to scroll this panel.")); if (!Achievements::IsUsingRAIntegration()) { @@ -153,7 +159,7 @@ void SettingsWindow::addPages() addWidget(m_advanced_settings = new AdvancedSettingsWidget(this, m_ui.settingsContainer), tr("Advanced"), QStringLiteral("tools-line"), tr("Advanced Settings
These options control logging and internal behavior of the " - "emulator. Mouse over an option for additional information.")); + "emulator. Mouse over an option for additional information, and Shift+Wheel to scroll this panel.")); if (isPerGameSettings()) { @@ -255,10 +261,38 @@ bool SettingsWindow::eventFilter(QObject* object, QEvent* event) m_ui.helpText->setText(m_category_help_text[m_ui.settingsCategory->currentRow()]); } } + else if (event->type() == QEvent::Wheel) + { + if (handleWheelEvent(static_cast(event))) + return true; + } return QWidget::eventFilter(object, event); } +bool SettingsWindow::handleWheelEvent(QWheelEvent* event) +{ + if (!(event->modifiers() & Qt::ShiftModifier)) + return false; + + const int amount = event->hasPixelDelta() ? event->pixelDelta().y() : (event->angleDelta().y() / 20); + + QScrollBar* sb = m_ui.helpText->verticalScrollBar(); + if (!sb) + return false; + + sb->setSliderPosition(std::max(sb->sliderPosition() - amount, 0)); + return true; +} + +void SettingsWindow::wheelEvent(QWheelEvent* event) +{ + if (handleWheelEvent(event)) + return; + + QWidget::wheelEvent(event); +} + bool SettingsWindow::getEffectiveBoolValue(const char* section, const char* key, bool default_value) const { bool value; @@ -501,7 +535,8 @@ void SettingsWindow::openGamePropertiesDialog(const std::string& path, const std // check for an existing dialog with this crc for (SettingsWindow* dialog : s_open_game_properties_dialogs) { - if (dialog->isPerGameSettings() && static_cast(dialog->getSettingsInterface())->GetFileName() == ini_filename) + if (dialog->isPerGameSettings() && + static_cast(dialog->getSettingsInterface())->GetFileName() == ini_filename) { dialog->show(); dialog->raise(); diff --git a/src/duckstation-qt/settingswindow.h b/src/duckstation-qt/settingswindow.h index e37a943a0..e4d24f5ff 100644 --- a/src/duckstation-qt/settingswindow.h +++ b/src/duckstation-qt/settingswindow.h @@ -11,6 +11,8 @@ #include #include +class QWheelEvent; + class SettingsInterface; enum class DiscRegion : u8; @@ -95,6 +97,9 @@ private Q_SLOTS: void onCategoryCurrentRowChanged(int row); void onRestoreDefaultsClicked(); +protected: + void wheelEvent(QWheelEvent* event); + private: enum : u32 { @@ -103,6 +108,7 @@ private: void addPages(); void addWidget(QWidget* widget, QString title, QString icon, QString help_text); + bool handleWheelEvent(QWheelEvent* event); Ui::SettingsWindow m_ui;