added colour settings
parent
590d6eba9b
commit
73ffdd5ac5
@ -0,0 +1,49 @@
|
||||
|
||||
#include "coloursetting.hpp"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../../view/widget/coloreditor.hpp"
|
||||
|
||||
#include "category.hpp"
|
||||
#include "state.hpp"
|
||||
|
||||
CSMPrefs::ColourSetting::ColourSetting (Category *parent, Settings::Manager *values,
|
||||
const std::string& key, const std::string& label, QColor default_)
|
||||
: Setting (parent, values, key, label), mDefault (default_)
|
||||
{}
|
||||
|
||||
CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip (const std::string& tooltip)
|
||||
{
|
||||
mTooltip = tooltip;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::pair<QWidget *, QWidget *> CSMPrefs::ColourSetting::makeWidgets (QWidget *parent)
|
||||
{
|
||||
QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent);
|
||||
|
||||
CSVWidget::ColorEditor *widget = new CSVWidget::ColorEditor (mDefault, parent);
|
||||
|
||||
if (!mTooltip.empty())
|
||||
{
|
||||
QString tooltip = QString::fromUtf8 (mTooltip.c_str());
|
||||
label->setToolTip (tooltip);
|
||||
widget->setToolTip (tooltip);
|
||||
}
|
||||
|
||||
connect (widget, SIGNAL (pickingFinished()), this, SLOT (valueChanged()));
|
||||
|
||||
return std::make_pair (label, widget);
|
||||
}
|
||||
|
||||
void CSMPrefs::ColourSetting::valueChanged()
|
||||
{
|
||||
CSVWidget::ColorEditor& widget = dynamic_cast<CSVWidget::ColorEditor&> (*sender());
|
||||
getValues().setString (getKey(), getParent()->getKey(), widget.color().name().toUtf8().data());
|
||||
getParent()->getState()->update (*this);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#ifndef CSM_PREFS_COLOURSETTING_H
|
||||
#define CSM_PREFS_COLOURSETTING_H
|
||||
|
||||
#include "setting.hpp"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
namespace CSMPrefs
|
||||
{
|
||||
class ColourSetting : public Setting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
std::string mTooltip;
|
||||
QColor mDefault;
|
||||
|
||||
public:
|
||||
|
||||
ColourSetting (Category *parent, Settings::Manager *values,
|
||||
const std::string& key, const std::string& label, QColor default_);
|
||||
|
||||
ColourSetting& setTooltip (const std::string& tooltip);
|
||||
|
||||
/// Return label, input widget.
|
||||
virtual std::pair<QWidget *, QWidget *> makeWidgets (QWidget *parent);
|
||||
|
||||
private slots:
|
||||
|
||||
void valueChanged();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue