refactor: Logger store a local copy of the used setting value for guiDebug, update it went the settings have changed
This commit is contained in:
committed by
Chris Rizzitello
parent
ec9f7efcff
commit
ddcd2f0ff1
@ -61,7 +61,7 @@ void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const
|
||||
auto out = stdout;
|
||||
switch (mutatedType) {
|
||||
case QtDebugMsg:
|
||||
if (!Settings::value(Settings::Log::GuiDebug).toBool())
|
||||
if (!m_guiDebug)
|
||||
return;
|
||||
typeString = "DEBUG";
|
||||
break;
|
||||
@ -86,4 +86,22 @@ void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const
|
||||
Q_EMIT newLine(logLine);
|
||||
}
|
||||
|
||||
Logger::Logger()
|
||||
{
|
||||
m_guiDebug = Settings::value(Settings::Log::GuiDebug).toBool();
|
||||
connect(Settings::instance(), &Settings::settingsChanged, this, &Logger::settingChanged);
|
||||
}
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
disconnect(Settings::instance(), &Settings::settingsChanged, this, &Logger::settingChanged);
|
||||
}
|
||||
|
||||
void Logger::settingChanged(const QString &key)
|
||||
{
|
||||
if (key != Settings::Log::GuiDebug)
|
||||
return;
|
||||
m_guiDebug = Settings::value(Settings::Log::GuiDebug).toBool();
|
||||
}
|
||||
|
||||
} // namespace deskflow::gui
|
||||
|
||||
@ -27,8 +27,10 @@ Q_SIGNALS:
|
||||
void newLine(const QString &line);
|
||||
|
||||
private:
|
||||
explicit Logger() = default;
|
||||
~Logger() = default;
|
||||
explicit Logger();
|
||||
~Logger();
|
||||
void settingChanged(const QString &key);
|
||||
bool m_guiDebug = false;
|
||||
};
|
||||
|
||||
} // namespace deskflow::gui
|
||||
|
||||
Reference in New Issue
Block a user