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