mirror of https://github.com/OpenMW/openmw.git
String setting to CSMPrefs, part of dehardcoding animation files
parent
d3c865d909
commit
95272e0f14
@ -0,0 +1,54 @@
|
||||
|
||||
#include "stringsetting.hpp"
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QMutexLocker>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "category.hpp"
|
||||
#include "state.hpp"
|
||||
|
||||
CSMPrefs::StringSetting::StringSetting (Category *parent, Settings::Manager *values,
|
||||
QMutex *mutex, const std::string& key, const std::string& label, std::string default_)
|
||||
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr)
|
||||
{}
|
||||
|
||||
CSMPrefs::StringSetting& CSMPrefs::StringSetting::setTooltip (const std::string& tooltip)
|
||||
{
|
||||
mTooltip = tooltip;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::pair<QWidget *, QWidget *> CSMPrefs::StringSetting::makeWidgets (QWidget *parent)
|
||||
{
|
||||
mWidget = new QTextEdit (QString::fromUtf8 (mDefault.c_str()), parent);
|
||||
|
||||
if (!mTooltip.empty())
|
||||
{
|
||||
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||
mWidget->setToolTip (tooltip);
|
||||
}
|
||||
|
||||
connect (mWidget, SIGNAL (textChanged (std::string)), this, SLOT (textChanged (std::string)));
|
||||
|
||||
return std::make_pair (static_cast<QWidget *> (nullptr), mWidget);
|
||||
}
|
||||
|
||||
void CSMPrefs::StringSetting::updateWidget()
|
||||
{
|
||||
if (mWidget)
|
||||
{
|
||||
//mWidget->setValue(getValues().getString(getKey(), getParent()->getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
void CSMPrefs::StringSetting::textChanged (std::string text)
|
||||
{
|
||||
{
|
||||
QMutexLocker lock (getMutex());
|
||||
getValues().setString (getKey(), getParent()->getKey(), text);
|
||||
}
|
||||
|
||||
getParent()->getState()->update (*this);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef CSM_PREFS_StringSetting_H
|
||||
#define CSM_PREFS_StringSetting_H
|
||||
|
||||
#include "setting.hpp"
|
||||
|
||||
class QTextEdit;
|
||||
|
||||
namespace CSMPrefs
|
||||
{
|
||||
class StringSetting : public Setting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
std::string mTooltip;
|
||||
std::string mDefault;
|
||||
QTextEdit* mWidget;
|
||||
|
||||
public:
|
||||
|
||||
StringSetting (Category *parent, Settings::Manager *values,
|
||||
QMutex *mutex, const std::string& key, const std::string& label, std::string default_);
|
||||
|
||||
StringSetting& setTooltip (const std::string& tooltip);
|
||||
|
||||
/// Return label, input widget.
|
||||
std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent) override;
|
||||
|
||||
void updateWidget() override;
|
||||
|
||||
private slots:
|
||||
|
||||
void textChanged (std::string text);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue