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:
parent
ec9f7efcff
commit
ddcd2f0ff1
2 changed files with 23 additions and 3 deletions
|
|
@ -61,7 +61,7 @@ void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const
|
||||||
auto out = stdout;
|
auto out = stdout;
|
||||||
switch (mutatedType) {
|
switch (mutatedType) {
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
if (!Settings::value(Settings::Log::GuiDebug).toBool())
|
if (!m_guiDebug)
|
||||||
return;
|
return;
|
||||||
typeString = "DEBUG";
|
typeString = "DEBUG";
|
||||||
break;
|
break;
|
||||||
|
|
@ -86,4 +86,22 @@ void Logger::handleMessage(const QtMsgType type, const QString &fileLine, const
|
||||||
Q_EMIT newLine(logLine);
|
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
|
} // namespace deskflow::gui
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ Q_SIGNALS:
|
||||||
void newLine(const QString &line);
|
void newLine(const QString &line);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Logger() = default;
|
explicit Logger();
|
||||||
~Logger() = default;
|
~Logger();
|
||||||
|
void settingChanged(const QString &key);
|
||||||
|
bool m_guiDebug = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deskflow::gui
|
} // namespace deskflow::gui
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue