DolphinWX: remove INI logic from LogConfigWindow

This commit is contained in:
Michael Maltese 2017-07-07 16:16:57 -07:00
parent c9e8289e82
commit 13721d35e7
2 changed files with 8 additions and 34 deletions

View File

@ -12,7 +12,6 @@
#include <wx/validate.h> #include <wx/validate.h>
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Common/Logging/ConsoleListener.h" #include "Common/Logging/ConsoleListener.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/Logging/LogManager.h" #include "Common/Logging/LogManager.h"
@ -90,39 +89,18 @@ void LogConfigWindow::CreateGUIControls()
void LogConfigWindow::LoadSettings() void LogConfigWindow::LoadSettings()
{ {
IniFile ini; m_verbosity->SetSelection(m_LogManager->GetLogLevel());
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
IniFile::Section* options = ini.GetOrCreateSection("Options");
// Retrieve the verbosity value from the config ini file.
int verbosity;
options->Get("Verbosity", &verbosity, 0);
// Ensure the verbosity level is valid.
if (verbosity < 1)
verbosity = 1;
if (verbosity > MAX_LOGLEVEL)
verbosity = MAX_LOGLEVEL;
// Actually set the logging verbosity.
m_verbosity->SetSelection(verbosity - 1);
// Get the logger output settings from the config ini file. // Get the logger output settings from the config ini file.
options->Get("WriteToFile", &m_writeFile, false); m_writeFileCB->SetValue(m_LogManager->IsListenerEnabled(LogListener::FILE_LISTENER));
m_writeFileCB->SetValue(m_writeFile); m_writeConsoleCB->SetValue(m_LogManager->IsListenerEnabled(LogListener::CONSOLE_LISTENER));
options->Get("WriteToConsole", &m_writeConsole, true); m_writeWindowCB->SetValue(m_LogManager->IsListenerEnabled(LogListener::LOG_WINDOW_LISTENER));
m_writeConsoleCB->SetValue(m_writeConsole);
options->Get("WriteToWindow", &m_writeWindow, true);
m_writeWindowCB->SetValue(m_writeWindow);
// Run through all of the log types and check each checkbox for each logging type // Run through all of the log types and check each checkbox for each logging type
// depending on its set value within the config ini. // depending on its set value within the config ini.
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{ {
bool log_enabled; bool log_enabled = m_LogManager->IsEnabled(static_cast<LogTypes::LOG_TYPE>(i));
ini.GetOrCreateSection("Logs")->Get(m_LogManager->GetShortName((LogTypes::LOG_TYPE)i),
&log_enabled, false);
if (log_enabled) if (log_enabled)
enableAll = false; enableAll = false;
@ -147,20 +125,17 @@ void LogConfigWindow::OnVerbosityChange(wxCommandEvent& event)
void LogConfigWindow::OnWriteFileChecked(wxCommandEvent& event) void LogConfigWindow::OnWriteFileChecked(wxCommandEvent& event)
{ {
m_writeFile = event.IsChecked(); m_LogManager->EnableListener(LogListener::FILE_LISTENER, event.IsChecked());
m_LogManager->EnableListener(LogListener::FILE_LISTENER, m_writeFile);
} }
void LogConfigWindow::OnWriteConsoleChecked(wxCommandEvent& event) void LogConfigWindow::OnWriteConsoleChecked(wxCommandEvent& event)
{ {
m_writeConsole = event.IsChecked(); m_LogManager->EnableListener(LogListener::CONSOLE_LISTENER, event.IsChecked());
m_LogManager->EnableListener(LogListener::CONSOLE_LISTENER, m_writeConsole);
} }
void LogConfigWindow::OnWriteWindowChecked(wxCommandEvent& event) void LogConfigWindow::OnWriteWindowChecked(wxCommandEvent& event)
{ {
m_writeWindow = event.IsChecked(); m_LogManager->EnableListener(LogListener::LOG_WINDOW_LISTENER, event.IsChecked());
m_LogManager->EnableListener(LogListener::LOG_WINDOW_LISTENER, m_writeWindow);
} }
void LogConfigWindow::OnToggleAll(wxCommandEvent& WXUNUSED(event)) void LogConfigWindow::OnToggleAll(wxCommandEvent& WXUNUSED(event))

View File

@ -22,7 +22,6 @@ public:
private: private:
LogManager* m_LogManager; LogManager* m_LogManager;
bool m_writeFile, m_writeConsole, m_writeWindow;
bool enableAll; bool enableAll;
// Controls // Controls