1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 13:53:52 +00:00
openmw-tes3mp/apps/opencs/model/prefs/boolsetting.cpp

48 lines
1.3 KiB
C++
Raw Normal View History

2015-12-10 12:28:48 +00:00
#include "boolsetting.hpp"
#include <QCheckBox>
2015-12-15 11:19:48 +00:00
#include <QMutexLocker>
2015-12-10 12:28:48 +00:00
#include <components/settings/settings.hpp>
#include "category.hpp"
#include "state.hpp"
CSMPrefs::BoolSetting::BoolSetting (Category *parent, Settings::Manager *values,
2015-12-15 11:19:48 +00:00
QMutex *mutex, const std::string& key, const std::string& label, bool default_)
: Setting (parent, values, mutex, key, label), mDefault (default_)
2015-12-10 12:28:48 +00:00
{}
CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& tooltip)
{
mTooltip = tooltip;
return *this;
}
std::pair<QWidget *, QWidget *> CSMPrefs::BoolSetting::makeWidgets (QWidget *parent)
{
QCheckBox *widget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent);
widget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked);
if (!mTooltip.empty())
{
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
widget->setToolTip (tooltip);
}
connect (widget, SIGNAL (stateChanged (int)), this, SLOT (valueChanged (int)));
return std::make_pair (static_cast<QWidget *> (0), widget);
}
void CSMPrefs::BoolSetting::valueChanged (int value)
{
2015-12-15 11:19:48 +00:00
{
QMutexLocker lock (getMutex());
getValues().setBool (getKey(), getParent()->getKey(), value);
}
2015-12-10 12:28:48 +00:00
getParent()->getState()->update (*this);
}