cutter/src/common/TempConfig.cpp
Itay Cohen c923576b7e
Fix the "all green" navbar (#2305)
* Specify the search range for search.in
* Add  config_set(key, const char*) overloads to prevent char* being automatically casted to bool and config_set(key, bool) being chosen unexpectedly.
2020-07-20 23:11:31 +03:00

66 lines
1.5 KiB
C++

#include <cassert>
#include "core/Cutter.h"
#include "TempConfig.h"
TempConfig::~TempConfig()
{
for (auto i = resetValues.constBegin(); i != resetValues.constEnd(); ++i) {
switch (i.value().type()) {
case QVariant::String:
Core()->setConfig(i.key(), i.value().toString());
break;
case QVariant::Int:
Core()->setConfig(i.key(), i.value().toInt());
break;
case QVariant::Bool:
Core()->setConfig(i.key(), i.value().toBool());
break;
default:
assert(false);
break;
}
}
}
TempConfig &TempConfig::set(const QString &key, const QString &value)
{
if (!resetValues.contains(key)) {
resetValues[key] = Core()->getConfig(key);
}
Core()->setConfig(key, value);
return *this;
}
TempConfig &TempConfig::set(const QString &key, const char *value)
{
if (!resetValues.contains(key)) {
resetValues[key] = Core()->getConfig(key);
}
Core()->setConfig(key, value);
return *this;
}
TempConfig &TempConfig::set(const QString &key, int value)
{
if (!resetValues.contains(key)) {
resetValues[key] = Core()->getConfigi(key);
}
Core()->setConfig(key, value);
return *this;
}
TempConfig &TempConfig::set(const QString &key, bool value)
{
if (!resetValues.contains(key)) {
resetValues[key] = Core()->getConfigb(key);
}
Core()->setConfig(key, value);
return *this;
}