2015-12-08 16:21:58 +00:00
|
|
|
|
|
|
|
#include "setting.hpp"
|
|
|
|
|
2015-12-11 10:50:06 +00:00
|
|
|
#include <QColor>
|
2015-12-15 11:19:48 +00:00
|
|
|
#include <QMutexLocker>
|
2015-12-11 10:50:06 +00:00
|
|
|
|
2022-07-11 16:41:07 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
2023-11-11 23:52:09 +00:00
|
|
|
#include <components/settings/settingvalue.hpp>
|
2022-07-11 16:41:07 +00:00
|
|
|
|
2015-12-08 16:21:58 +00:00
|
|
|
#include "category.hpp"
|
|
|
|
#include "state.hpp"
|
|
|
|
|
2015-12-15 11:19:48 +00:00
|
|
|
QMutex* CSMPrefs::Setting::getMutex()
|
|
|
|
{
|
|
|
|
return mMutex;
|
|
|
|
}
|
|
|
|
|
2023-11-11 23:52:09 +00:00
|
|
|
CSMPrefs::Setting::Setting(
|
2023-11-15 07:23:06 +00:00
|
|
|
Category* parent, QMutex* mutex, std::string_view key, const QString& label, Settings::Index& index)
|
2022-07-11 16:41:07 +00:00
|
|
|
: QObject(parent->getState())
|
|
|
|
, mParent(parent)
|
|
|
|
, mMutex(mutex)
|
|
|
|
, mKey(key)
|
|
|
|
, mLabel(label)
|
2023-11-11 23:52:09 +00:00
|
|
|
, mIndex(index)
|
2015-12-11 10:22:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-08 16:21:58 +00:00
|
|
|
const CSMPrefs::Category* CSMPrefs::Setting::getParent() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& CSMPrefs::Setting::getKey() const
|
|
|
|
{
|
|
|
|
return mKey;
|
|
|
|
}
|
|
|
|
|
2015-12-11 10:50:06 +00:00
|
|
|
QColor CSMPrefs::Setting::toColor() const
|
|
|
|
{
|
2015-12-15 18:32:42 +00:00
|
|
|
// toString() handles lock
|
2015-12-11 10:50:06 +00:00
|
|
|
return QColor(QString::fromUtf8(toString().c_str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSMPrefs::operator==(const Setting& setting, const std::string& key)
|
|
|
|
{
|
|
|
|
std::string fullKey = setting.getParent()->getKey() + "/" + setting.getKey();
|
|
|
|
return fullKey == key;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSMPrefs::operator==(const std::string& key, const Setting& setting)
|
|
|
|
{
|
|
|
|
return setting == key;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSMPrefs::operator!=(const Setting& setting, const std::string& key)
|
|
|
|
{
|
|
|
|
return !(setting == key);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSMPrefs::operator!=(const std::string& key, const Setting& setting)
|
|
|
|
{
|
|
|
|
return !(key == setting);
|
|
|
|
}
|