mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-26 15:40:41 +00:00
Qt: Add log level/channels to debug menu
This commit is contained in:
parent
6551358212
commit
145fbff79b
@ -1617,58 +1617,14 @@ void MainWindow::setupAdditionalUi()
|
||||
|
||||
m_ui.actionGridViewShowTitles->setChecked(m_game_list_widget->isShowingGridCoverTitles());
|
||||
|
||||
updateDebugMenuVisibility();
|
||||
|
||||
for (u32 i = 0; i < static_cast<u32>(CPUExecutionMode::Count); i++)
|
||||
{
|
||||
const CPUExecutionMode mode = static_cast<CPUExecutionMode>(i);
|
||||
QAction* action =
|
||||
m_ui.menuCPUExecutionMode->addAction(QString::fromUtf8(Settings::GetCPUExecutionModeDisplayName(mode)));
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, [this, mode]() {
|
||||
Host::SetBaseStringSettingValue("CPU", "ExecutionMode", Settings::GetCPUExecutionModeName(mode));
|
||||
Host::CommitBaseSettingChanges();
|
||||
g_emu_thread->applySettings();
|
||||
updateDebugMenuCPUExecutionMode();
|
||||
});
|
||||
}
|
||||
updateDebugMenuCPUExecutionMode();
|
||||
|
||||
for (u32 i = 0; i < static_cast<u32>(GPURenderer::Count); i++)
|
||||
{
|
||||
const GPURenderer renderer = static_cast<GPURenderer>(i);
|
||||
QAction* action = m_ui.menuRenderer->addAction(QString::fromUtf8(Settings::GetRendererDisplayName(renderer)));
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, [this, renderer]() {
|
||||
Host::SetBaseStringSettingValue("GPU", "Renderer", Settings::GetRendererName(renderer));
|
||||
Host::CommitBaseSettingChanges();
|
||||
g_emu_thread->applySettings();
|
||||
updateDebugMenuGPURenderer();
|
||||
});
|
||||
}
|
||||
updateDebugMenuGPURenderer();
|
||||
|
||||
for (u32 i = 0; i < static_cast<u32>(DisplayCropMode::Count); i++)
|
||||
{
|
||||
const DisplayCropMode crop_mode = static_cast<DisplayCropMode>(i);
|
||||
QAction* action =
|
||||
m_ui.menuCropMode->addAction(QString::fromUtf8(Settings::GetDisplayCropModeDisplayName(crop_mode)));
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, [this, crop_mode]() {
|
||||
Host::SetBaseStringSettingValue("Display", "CropMode", Settings::GetDisplayCropModeName(crop_mode));
|
||||
Host::CommitBaseSettingChanges();
|
||||
g_emu_thread->applySettings();
|
||||
updateDebugMenuCropMode();
|
||||
});
|
||||
}
|
||||
updateDebugMenuCropMode();
|
||||
|
||||
for (u32 scale = 1; scale <= 10; scale++)
|
||||
{
|
||||
QAction* action = m_ui.menuWindowSize->addAction(tr("%1x Scale").arg(scale));
|
||||
connect(action, &QAction::triggered, [scale]() { g_emu_thread->requestDisplaySize(scale); });
|
||||
}
|
||||
|
||||
updateDebugMenuVisibility();
|
||||
|
||||
#ifdef ENABLE_RAINTEGRATION
|
||||
if (Achievements::IsUsingRAIntegration())
|
||||
{
|
||||
@ -2064,6 +2020,21 @@ void MainWindow::connectSignals()
|
||||
connect(m_game_list_widget, &GameListWidget::addGameDirectoryRequested, this,
|
||||
[this]() { getSettingsWindow()->getGameListSettingsWidget()->addSearchDirectory(this); });
|
||||
|
||||
SettingWidgetBinder::BindMenuToEnumSetting(m_ui.menuCPUExecutionMode, "CPU", "ExecutionMode",
|
||||
&Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName,
|
||||
&Settings::GetCPUExecutionModeDisplayName,
|
||||
Settings::DEFAULT_CPU_EXECUTION_MODE, CPUExecutionMode::Count);
|
||||
SettingWidgetBinder::BindMenuToEnumSetting(m_ui.menuRenderer, "GPU", "Renderer", &Settings::ParseRendererName,
|
||||
&Settings::GetRendererName, &Settings::GetRendererDisplayName,
|
||||
Settings::DEFAULT_GPU_RENDERER, GPURenderer::Count);
|
||||
SettingWidgetBinder::BindMenuToEnumSetting(
|
||||
m_ui.menuCropMode, "Display", "CropMode", &Settings::ParseDisplayCropMode, &Settings::GetDisplayCropModeName,
|
||||
&Settings::GetDisplayCropModeDisplayName, Settings::DEFAULT_DISPLAY_CROP_MODE, DisplayCropMode::Count);
|
||||
SettingWidgetBinder::BindMenuToEnumSetting(m_ui.menuLogLevel, "Logging", "LogLevel", &Settings::ParseLogLevelName,
|
||||
&Settings::GetLogLevelName, &Settings::GetLogLevelDisplayName,
|
||||
Settings::DEFAULT_LOG_LEVEL, Log::Level::MaxCount);
|
||||
connect(m_ui.menuLogChannels, &QMenu::aboutToShow, this, &MainWindow::onDebugLogChannelsMenuAboutToShow);
|
||||
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionDisableAllEnhancements, "Main",
|
||||
"DisableAllEnhancements", false);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(nullptr, m_ui.actionDebugDumpCPUtoVRAMCopies, "Debug",
|
||||
@ -2155,9 +2126,6 @@ void MainWindow::onSettingsResetToDefault(bool system, bool controller)
|
||||
doControllerSettings(ControllerSettingsWindow::Category::GlobalSettings);
|
||||
}
|
||||
|
||||
updateDebugMenuCPUExecutionMode();
|
||||
updateDebugMenuGPURenderer();
|
||||
updateDebugMenuCropMode();
|
||||
updateDebugMenuVisibility();
|
||||
}
|
||||
|
||||
@ -2292,58 +2260,6 @@ void MainWindow::openInputProfileEditor(const std::string_view name)
|
||||
dlg->switchProfile(name);
|
||||
}
|
||||
|
||||
void MainWindow::updateDebugMenuCPUExecutionMode()
|
||||
{
|
||||
std::optional<CPUExecutionMode> current_mode =
|
||||
Settings::ParseCPUExecutionMode(Host::GetBaseStringSettingValue("CPU", "ExecutionMode").c_str());
|
||||
if (!current_mode.has_value())
|
||||
return;
|
||||
|
||||
const QString current_mode_display_name =
|
||||
QString::fromUtf8(Settings::GetCPUExecutionModeDisplayName(current_mode.value()));
|
||||
for (QObject* obj : m_ui.menuCPUExecutionMode->children())
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(obj);
|
||||
if (action)
|
||||
action->setChecked(action->text() == current_mode_display_name);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateDebugMenuGPURenderer()
|
||||
{
|
||||
// update the menu with the new selected renderer
|
||||
std::optional<GPURenderer> current_renderer =
|
||||
Settings::ParseRendererName(Host::GetBaseStringSettingValue("GPU", "Renderer").c_str());
|
||||
if (!current_renderer.has_value())
|
||||
return;
|
||||
|
||||
const QString current_renderer_display_name =
|
||||
QString::fromUtf8(Settings::GetRendererDisplayName(current_renderer.value()));
|
||||
for (QObject* obj : m_ui.menuRenderer->children())
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(obj);
|
||||
if (action)
|
||||
action->setChecked(action->text() == current_renderer_display_name);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateDebugMenuCropMode()
|
||||
{
|
||||
std::optional<DisplayCropMode> current_crop_mode =
|
||||
Settings::ParseDisplayCropMode(Host::GetBaseStringSettingValue("Display", "CropMode").c_str());
|
||||
if (!current_crop_mode.has_value())
|
||||
return;
|
||||
|
||||
const QString current_crop_mode_display_name =
|
||||
QString::fromUtf8(Settings::GetDisplayCropModeDisplayName(current_crop_mode.value()));
|
||||
for (QObject* obj : m_ui.menuCropMode->children())
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(obj);
|
||||
if (action)
|
||||
action->setChecked(action->text() == current_crop_mode_display_name);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QMainWindow::showEvent(event);
|
||||
@ -2833,6 +2749,12 @@ void MainWindow::onUpdateCheckComplete()
|
||||
m_auto_updater_dialog = nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::onDebugLogChannelsMenuAboutToShow()
|
||||
{
|
||||
m_ui.menuLogChannels->clear();
|
||||
LogWindow::populateFilterMenu(m_ui.menuLogChannels);
|
||||
}
|
||||
|
||||
MainWindow::SystemLock MainWindow::pauseAndLockSystem()
|
||||
{
|
||||
// To switch out of fullscreen when displaying a popup, or not to?
|
||||
|
@ -194,6 +194,7 @@ private Q_SLOTS:
|
||||
|
||||
void onUpdateCheckComplete();
|
||||
|
||||
void onDebugLogChannelsMenuAboutToShow();
|
||||
void openCPUDebugger();
|
||||
|
||||
protected:
|
||||
@ -247,9 +248,6 @@ private:
|
||||
void openGamePropertiesForCurrentGame(const char* category = nullptr);
|
||||
void doControllerSettings(ControllerSettingsWindow::Category category = ControllerSettingsWindow::Category::Count);
|
||||
|
||||
void updateDebugMenuCPUExecutionMode();
|
||||
void updateDebugMenuGPURenderer();
|
||||
void updateDebugMenuCropMode();
|
||||
std::string getDeviceDiscPath(const QString& title);
|
||||
void setGameListEntryCoverImage(const GameList::Entry* entry);
|
||||
void clearGameListEntryPlayTime(const GameList::Entry* entry);
|
||||
|
@ -153,11 +153,24 @@
|
||||
<string>Switch Crop Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuLogLevel">
|
||||
<property name="title">
|
||||
<string>Log Level</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuLogChannels">
|
||||
<property name="title">
|
||||
<string>Log Channels</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuCPUExecutionMode"/>
|
||||
<addaction name="menuRenderer"/>
|
||||
<addaction name="menuCropMode"/>
|
||||
<addaction name="actionDisableAllEnhancements"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuLogLevel"/>
|
||||
<addaction name="menuLogChannels"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCPUDebugger"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDumpRAM"/>
|
||||
@ -918,6 +931,16 @@
|
||||
<string>Capture GPU Frame</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionasdf">
|
||||
<property name="text">
|
||||
<string>asdf</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionaaa">
|
||||
<property name="text">
|
||||
<string>aaa</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources/duckstation-qt.qrc"/>
|
||||
|
@ -13,9 +13,11 @@
|
||||
#include "common/assert.h"
|
||||
#include "common/file_system.h"
|
||||
#include "common/path.h"
|
||||
#include "common/small_string.h"
|
||||
|
||||
#include <QtCore/QtCore>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QActionGroup>
|
||||
#include <QtWidgets/QAbstractButton>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QComboBox>
|
||||
@ -27,6 +29,7 @@
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QSlider>
|
||||
#include <QtWidgets/QSpinBox>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
|
||||
@ -1133,6 +1136,43 @@ static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget,
|
||||
}
|
||||
}
|
||||
|
||||
template<typename DataType, typename ValueCountType>
|
||||
static void BindMenuToEnumSetting(QMenu* menu, std::string section, std::string key,
|
||||
std::optional<DataType> (*from_string_function)(const char* str),
|
||||
const char* (*to_string_function)(DataType value),
|
||||
const char* (*to_display_name_function)(DataType value), DataType default_value,
|
||||
ValueCountType value_count)
|
||||
{
|
||||
QActionGroup* group = new QActionGroup(menu);
|
||||
|
||||
const std::optional<DataType> typed_value = from_string_function(
|
||||
Host::GetBaseSmallStringSettingValue(section.c_str(), key.c_str(), to_string_function(default_value)).c_str());
|
||||
|
||||
// need a shared pointer, otherwise we dupe it a ton...
|
||||
struct CallbackData
|
||||
{
|
||||
std::string section;
|
||||
std::string key;
|
||||
};
|
||||
std::shared_ptr<CallbackData> data = std::make_shared<CallbackData>();
|
||||
data->section = std::move(section);
|
||||
data->key = std::move(key);
|
||||
|
||||
for (u32 i = 0; i < static_cast<u32>(value_count); i++)
|
||||
{
|
||||
QAction* action = group->addAction(QString::fromUtf8(to_display_name_function(static_cast<DataType>(i))));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(typed_value.has_value() && typed_value.value() == static_cast<DataType>(i));
|
||||
menu->addAction(action);
|
||||
QObject::connect(action, &QAction::triggered, menu, [data, to_string_function, i]() {
|
||||
Host::SetBaseStringSettingValue(data->section.c_str(), data->key.c_str(),
|
||||
to_string_function(static_cast<DataType>(i)));
|
||||
Host::CommitBaseSettingChanges();
|
||||
g_emu_thread->applySettings();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
template<typename WidgetType, typename DataType>
|
||||
static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
|
||||
const char** enum_names, DataType default_value)
|
||||
|
Loading…
Reference in New Issue
Block a user