1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00
OpenMW/apps/opencs/model/prefs/setting.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.3 KiB
C++
Raw Normal View History

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
#include <components/settings/settings.hpp>
2023-11-11 23:52:09 +00:00
#include <components/settings/settingvalue.hpp>
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(
Category* parent, QMutex* mutex, std::string_view key, const QString& label, Settings::Index& index)
: 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);
}