Qt: Reduce indirect includes in mainwindow.h

This commit is contained in:
Stenzek
2025-12-20 14:51:42 +10:00
parent a7637c5b50
commit 0aff70237d
8 changed files with 39 additions and 46 deletions

View File

@@ -123,30 +123,29 @@ int ControllerSettingsWindow::getHotkeyCategoryIndex() const
return 1 + (mtap_enabled[0] ? 4 : 1) + (mtap_enabled[1] ? 4 : 1);
}
ControllerSettingsWindow::Category ControllerSettingsWindow::getCurrentCategory() const
int ControllerSettingsWindow::getCategoryRow() const
{
const int index = m_ui.settingsCategory->currentRow();
if (index == 0)
return Category::GlobalSettings;
else if (index >= getHotkeyCategoryIndex())
return Category::HotkeySettings;
else
return Category::FirstControllerSettings;
return m_ui.settingsCategory->currentRow();
}
void ControllerSettingsWindow::setCategory(Category category)
void ControllerSettingsWindow::setCategoryRow(int row)
{
m_ui.settingsCategory->setCurrentRow(row);
}
void ControllerSettingsWindow::setCategory(u32 category)
{
switch (category)
{
case Category::GlobalSettings:
case CATEGORY_GLOBAL_SETTINGS:
m_ui.settingsCategory->setCurrentRow(0);
break;
case Category::FirstControllerSettings:
case CATEGORY_FIRST_CONTROLLER_SETTINGS:
m_ui.settingsCategory->setCurrentRow(1);
break;
case Category::HotkeySettings:
case CATEGORY_HOTKEY_SETTINGS:
m_ui.settingsCategory->setCurrentRow(getHotkeyCategoryIndex());
break;

View File

@@ -34,14 +34,6 @@ class ControllerSettingsWindow final : public QWidget
Q_OBJECT
public:
enum class Category
{
GlobalSettings,
FirstControllerSettings,
HotkeySettings,
Count
};
ControllerSettingsWindow(INISettingsInterface* game_sif = nullptr, bool edit_profiles = false,
QWidget* parent = nullptr);
~ControllerSettingsWindow();
@@ -61,14 +53,14 @@ public:
ALWAYS_INLINE bool isEditingProfile() const { return m_editing_input_profiles; }
ALWAYS_INLINE INISettingsInterface* getEditingSettingsInterface() { return m_editing_settings_interface; }
Category getCurrentCategory() const;
int getCategoryRow() const;
void setCategoryRow(int row);
void setCategory(u32 category);
void updateListDescription(u32 global_slot, ControllerBindingWidget* widget);
void switchProfile(const std::string_view name);
void setCategory(Category category);
// Helper functions for updating setting values globally or in the profile.
bool getBoolValue(const char* section, const char* key, bool default_value) const;
s32 getIntValue(const char* section, const char* key, s32 default_value) const;
@@ -79,6 +71,10 @@ public:
void clearSettingValue(const char* section, const char* key);
void saveAndReloadGameSettings();
static constexpr u32 CATEGORY_GLOBAL_SETTINGS = 0;
static constexpr u32 CATEGORY_FIRST_CONTROLLER_SETTINGS = 1;
static constexpr u32 CATEGORY_HOTKEY_SETTINGS = 2;
protected:
void closeEvent(QCloseEvent* event) override;

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#include "gamesummarywidget.h"
#include "controllersettingswindow.h"
#include "gamelistwidget.h"
#include "mainwindow.h"
#include "qthost.h"

View File

@@ -7,6 +7,7 @@
#include "settingwidgetbinder.h"
#include "util/host.h"
#include "util/ini_settings_interface.h"
#include <QtCore/QLatin1StringView>
#include <QtCore/QUtf8StringView>

View File

@@ -5,6 +5,7 @@
#include "aboutdialog.h"
#include "achievementlogindialog.h"
#include "autoupdaterdialog.h"
#include "controllersettingswindow.h"
#include "coverdownloadwindow.h"
#include "debuggerwindow.h"
#include "displaywidget.h"
@@ -702,8 +703,7 @@ void MainWindow::recreate()
std::optional<QPoint> settings_window_pos;
int settings_window_row = 0;
std::optional<QPoint> controller_settings_window_pos;
ControllerSettingsWindow::Category controller_settings_window_row =
ControllerSettingsWindow::Category::GlobalSettings;
int controller_settings_window_row = 0;
if (m_settings_window && m_settings_window->isVisible())
{
settings_window_pos = m_settings_window->pos();
@@ -712,7 +712,7 @@ void MainWindow::recreate()
if (m_controller_settings_window && m_controller_settings_window->isVisible())
{
controller_settings_window_pos = m_controller_settings_window->pos();
controller_settings_window_row = m_controller_settings_window->getCurrentCategory();
controller_settings_window_row = m_controller_settings_window->getCategoryRow();
}
// Remove subwindows before switching to surfaceless, because otherwise e.g. the debugger can cause funkyness.
@@ -766,7 +766,7 @@ void MainWindow::recreate()
{
ControllerSettingsWindow* dlg = g_main_window->getControllerSettingsWindow();
dlg->move(controller_settings_window_pos.value());
dlg->setCategory(controller_settings_window_row);
dlg->setCategoryRow(controller_settings_window_row);
dlg->show();
}
if (settings_window_pos.has_value())
@@ -2386,9 +2386,9 @@ void MainWindow::connectSignals()
connect(m_ui.actionEmulationSettings, &QAction::triggered, [this]() { doSettings("Emulation"); });
connect(m_ui.actionGameListSettings, &QAction::triggered, [this]() { doSettings("Game List"); });
connect(m_ui.actionHotkeySettings, &QAction::triggered,
[this]() { doControllerSettings(ControllerSettingsWindow::Category::HotkeySettings); });
[this]() { doControllerSettings(ControllerSettingsWindow::CATEGORY_HOTKEY_SETTINGS); });
connect(m_ui.actionControllerSettings, &QAction::triggered,
[this]() { doControllerSettings(ControllerSettingsWindow::Category::GlobalSettings); });
[this]() { doControllerSettings(ControllerSettingsWindow::CATEGORY_GLOBAL_SETTINGS); });
connect(m_ui.actionMemoryCardSettings, &QAction::triggered, [this]() { doSettings("Memory Cards"); });
connect(m_ui.actionGraphicsSettings, &QAction::triggered, [this]() { doSettings("Graphics"); });
connect(m_ui.actionPostProcessingSettings, &QAction::triggered, [this]() { doSettings("Post-Processing"); });
@@ -2609,7 +2609,7 @@ void MainWindow::onSettingsResetToDefault(bool system, bool controller)
m_controller_settings_window = nullptr;
if (had_controller_settings_window)
doControllerSettings(ControllerSettingsWindow::Category::GlobalSettings);
doControllerSettings(0);
}
updateDebugMenuVisibility();
@@ -2715,13 +2715,11 @@ MemoryEditorWindow* MainWindow::getMemoryEditorWindow()
return m_memory_editor_window;
}
void MainWindow::doControllerSettings(
ControllerSettingsWindow::Category category /*= ControllerSettingsDialog::Category::Count*/)
void MainWindow::doControllerSettings(u32 category /* = 0 */)
{
ControllerSettingsWindow* window = getControllerSettingsWindow();
QtUtils::ShowOrRaiseWindow(window, this, true);
if (category != ControllerSettingsWindow::Category::Count)
window->setCategory(category);
window->setCategory(category);
}
void MainWindow::onViewChangeGameListBackgroundTriggered()

View File

@@ -3,9 +3,6 @@
#pragma once
#include "controllersettingswindow.h"
#include "displaywidget.h"
#include "settingswindow.h"
#include "ui_mainwindow.h"
#include "core/types.h"
@@ -13,22 +10,23 @@
#include "util/imgui_manager.h"
#include "util/window_info.h"
#include <QtCore/QThread>
#include <QtGui/QShortcut>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QStackedWidget>
#include <memory>
#include <optional>
class QLabel;
class QThread;
class QProgressBar;
class QShortcut;
class MainWindow;
class GameListWidget;
class EmuThread;
class GameListWidget;
class DisplayWidget;
class DisplayContainer;
class SettingsWindow;
class ControllerSettingsWindow;
class AutoUpdaterDialog;
class MemoryCardEditorWindow;
class DebuggerWindow;
@@ -192,7 +190,7 @@ private:
void doSettings(const char* category = nullptr);
void openGamePropertiesForCurrentGame(const char* category = nullptr);
void doControllerSettings(ControllerSettingsWindow::Category category = ControllerSettingsWindow::Category::Count);
void doControllerSettings(u32 category = 0);
void openSelectDiscDialog(const QString& title, std::function<void(std::string)> callback);
void setGameListEntryCoverImage(const GameList::Entry* entry);

View File

@@ -8,6 +8,7 @@
#include "mainwindow.h"
#include "qtprogresscallback.h"
#include "qtutils.h"
#include "settingswindow.h"
#include "setupwizarddialog.h"
#include "core/achievements.h"

View File

@@ -57,8 +57,6 @@ public:
// Helper for externally setting fields in game settings ini.
static bool setGameSettingsBoolForSerial(const std::string& serial, const char* section, const char* key, bool value);
int getCategoryRow() const;
ALWAYS_INLINE bool isPerGameSettings() const { return static_cast<bool>(m_sif); }
ALWAYS_INLINE INISettingsInterface* getSettingsInterface() const { return m_sif.get(); }
ALWAYS_INLINE const std::string& getGameTitle() const { return m_title; }
@@ -109,8 +107,9 @@ public:
bool hasGameTrait(GameDatabase::Trait trait);
bool isGameHashStable() const;
void setCategory(const char* category);
int getCategoryRow() const;
void setCategoryRow(int index);
void setCategory(const char* category);
Q_SIGNALS:
void settingsResetToDefaults();