Skip to content

Commit

Permalink
add UI option for Shift JIS conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterMute committed Feb 17, 2024
1 parent a6da53e commit 174447b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/Core/Common/Logging/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class LogManager
void SetEnable(LogType type, bool enable);
bool IsEnabled(LogType type, LogLevel level = LogLevel::LNOTICE) const;

void SetEnableConvertSJIS(bool enable) { m_convert_sjis = enable;}
bool IsEnabledConvertSJIS() const { return m_convert_sjis; }

std::map<std::string, std::string> GetLogTypes();

const char* GetShortName(LogType type) const;
Expand All @@ -67,6 +70,8 @@ class LogManager
bool m_enable = false;
};

bool m_convert_sjis = true;

LogManager();
~LogManager();

Expand Down
9 changes: 9 additions & 0 deletions Source/Core/DolphinQt/Config/LogConfigWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void LogConfigWidget::CreateWidgets()
m_out_file = new QCheckBox(tr("Write to File"));
m_out_console = new QCheckBox(tr("Write to Console"));
m_out_window = new QCheckBox(tr("Write to Window"));
m_convert_sjis = new QCheckBox(tr("Convert from Shift JIS"));

auto* types = new QGroupBox(tr("Log Types"));
auto* types_layout = new QVBoxLayout;
Expand Down Expand Up @@ -84,6 +85,7 @@ void LogConfigWidget::CreateWidgets()
outputs_layout->addWidget(m_out_file);
outputs_layout->addWidget(m_out_console);
outputs_layout->addWidget(m_out_window);
outputs_layout->addWidget(m_convert_sjis);

layout->addWidget(types);
types_layout->addWidget(m_types_toggle);
Expand All @@ -107,6 +109,7 @@ void LogConfigWidget::ConnectWidgets()
connect(m_out_file, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_out_console, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_out_window, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_convert_sjis, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);

connect(m_types_toggle, &QPushButton::clicked, [this] {
m_all_enabled = !m_all_enabled;
Expand Down Expand Up @@ -162,6 +165,7 @@ void LogConfigWidget::LoadSettings()

m_types_list->item(i)->setCheckState(log_enabled ? Qt::Checked : Qt::Unchecked);
}
m_convert_sjis->setCheckState(m_convert_sjis ? Qt::Checked : Qt::Unchecked);
}

void LogConfigWidget::SaveSettings()
Expand Down Expand Up @@ -213,6 +217,11 @@ void LogConfigWidget::SaveSettings()
if (enabled != was_enabled)
log_manager->SetEnable(type, enabled);
}
const bool enabled = m_convert_sjis->checkState() == Qt::Checked;
bool was_enabled = log_manager->IsEnabledConvertSJIS();

if (enabled != was_enabled)
log_manager->SetEnableConvertSJIS(enabled);
}

void LogConfigWidget::closeEvent(QCloseEvent*)
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinQt/Config/LogConfigWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class LogConfigWidget final : public QDockWidget
QCheckBox* m_out_file;
QCheckBox* m_out_console;
QCheckBox* m_out_window;
QCheckBox* m_convert_sjis;

QPushButton* m_types_toggle;
QListWidget* m_types_list;

Expand Down

0 comments on commit 174447b

Please sign in to comment.