QmlDesigner.propertyEditor: cleanup of Color Widgets

This commit is contained in:
Thomas Hartmann
2010-04-19 12:02:36 +02:00
parent 5a7a6ed248
commit 6e3ffa0599
2 changed files with 431 additions and 421 deletions

View File

@@ -28,12 +28,6 @@
**************************************************************************/ **************************************************************************/
#include "colorwidget.h" #include "colorwidget.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QGradient>
#include <QPainter>
#include <QtDebug>
#include <modelnode.h> #include <modelnode.h>
#include <abstractview.h> #include <abstractview.h>
#include <nodeproperty.h> #include <nodeproperty.h>
@@ -44,17 +38,72 @@
#include <QGradient> #include <QGradient>
#include <metainfo.h> #include <metainfo.h>
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
#include <QGradient>
#include <QPainter>
static inline int clamp(int x, int lower, int upper)
{
if (x < lower)
x = lower;
if (x > upper)
x = upper;
return x;
}
inline QString properName(const QColor &color)
{
QString s;
if (color.alpha() == 255)
s.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue());
else
s.sprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue());
return s;
}
inline QColor properColor(const QString &str)
{
int lalpha = 255;
QString lcolorStr = str;
if (lcolorStr.at(0) == '#' && lcolorStr.length() == 9) {
QString alphaStr = lcolorStr;
alphaStr.truncate(3);
lcolorStr.remove(0, 3);
lcolorStr = "#" + lcolorStr;
alphaStr.remove(0,1);
bool v;
lalpha = alphaStr.toInt(&v, 16);
if (!v)
lalpha = 255;
}
QColor lcolor(lcolorStr);
lcolor.setAlpha(lalpha);
return lcolor;
}
namespace QmlDesigner { namespace QmlDesigner {
void ColorWidget::registerDeclarativeTypes() { void ColorWidget::registerDeclarativeTypes() {
qmlRegisterType<QmlDesigner::ColorButton>("Bauhaus",1,0,"ColorButton"); qmlRegisterType<QmlDesigner::ColorButton>("Bauhaus",1,0,"ColorButton");
qmlRegisterType<QmlDesigner::HueControl>("Bauhaus",1,0,"HueControl"); qmlRegisterType<QmlDesigner::HueControl>("Bauhaus",1,0,"HueControl");
qmlRegisterType<QmlDesigner::ColorBox>("Bauhaus",1,0,"ColorBox"); qmlRegisterType<QmlDesigner::ColorBox>("Bauhaus",1,0,"ColorBox");
qmlRegisterType<QmlDesigner::GradientLine>("Bauhaus",1,0,"GradientLine"); qmlRegisterType<QmlDesigner::GradientLine>("Bauhaus",1,0,"GradientLine");
} }
void ColorButton::paintEvent(QPaintEvent *event) void ColorButton::setColor(const QString &colorStr)
{ {
if (m_colorString == colorStr)
return;
m_colorString = colorStr;
update();
emit colorChanged();
}
void ColorButton::paintEvent(QPaintEvent *event)
{
QToolButton::paintEvent(event); QToolButton::paintEvent(event);
if (!isEnabled()) if (!isEnabled())
return; return;
@@ -94,22 +143,30 @@ namespace QmlDesigner {
p.setPen("#707070"); p.setPen("#707070");
p.setBrush(Qt::white); p.setBrush(Qt::white);
p.drawPolygon(points); p.drawPolygon(points);
} }
void HueControl::setCurrent(int y) void HueControl::setCurrent(int y)
{ {
if (y<0) y=0; y = clamp(y, 0, 120);
if (y>120) y=120;
int oldAlpha = m_color.alpha(); int oldAlpha = m_color.alpha();
m_color.setHsv((y * 359)/120, m_color.hsvSaturation(), m_color.value()); m_color.setHsv((y * 359)/120, m_color.hsvSaturation(), m_color.value());
m_color.setAlpha(oldAlpha); m_color.setAlpha(oldAlpha);
update(); // redraw pointer update(); // redraw pointer
emit hueChanged(); emit hueChanged();
} }
void HueControl::paintEvent(QPaintEvent *event) void HueControl::setHue(int newHue)
{ {
if (m_color.hsvHue() == newHue)
return;
m_color.setHsv(newHue, m_color.hsvSaturation(), m_color.value());
update();
emit hueChanged();
}
void HueControl::paintEvent(QPaintEvent *event)
{
QWidget::paintEvent(event); QWidget::paintEvent(event);
QPainter p(this); QPainter p(this);
@@ -146,23 +203,127 @@ namespace QmlDesigner {
p.setPen(Qt::black); p.setPen(Qt::black);
p.setBrush(QColor("#707070")); p.setBrush(QColor("#707070"));
p.drawPolygon(points); p.drawPolygon(points);
} }
void ColorBox::setCurrent(int x, int y) void HueControl::mousePressEvent(QMouseEvent *e)
{ {
// The current cell marker is set to the cell the mouse is pressed in
QPoint pos = e->pos();
m_mousePressed = true;
setCurrent(pos.y() - 5);
}
void HueControl::mouseReleaseEvent(QMouseEvent * /* event */)
{
m_mousePressed = false;
}
void HueControl::mouseMoveEvent(QMouseEvent *e)
{
if (!m_mousePressed)
return;
QPoint pos = e->pos();
setCurrent(pos.y() - 5);
}
void ColorBox::setHue(int newHue)
{
if (m_color.hsvHue() == newHue)
return;
int oldAlpha = m_color.alpha();
m_color.setHsv(newHue,m_color.hsvSaturation(),m_color.value());
m_color.setAlpha(oldAlpha);
update();
emit hueChanged();
emit colorChanged();
}
int ColorBox::hue() const
{
int retval = m_color.hsvHue();
if (retval<0) retval=0;
if (retval>359) retval=359;
return retval;
}
void ColorBox::setAlpha(int newAlpha)
{
if (m_color.alpha() == newAlpha)
return;
m_color.setAlpha(newAlpha);
update();
emit alphaChanged();
emit colorChanged();
}
QString ColorBox::strColor() const
{
return properName(m_color);
}
void ColorBox::setStrColor(const QString &colorStr)
{
if (properName(m_color) == colorStr)
return;
setColor(properColor(colorStr));
}
void ColorBox::setColor(const QColor &color)
{
if (m_color == color)
return;
int oldsaturation = m_color.hsvSaturation();
int oldvalue = m_color.value();
int oldhue = m_color.hsvHue();
int oldAlpha = m_color.alpha();
m_color=color;
update();
if (oldhue != m_color.hsvHue()) emit hueChanged();
if (oldsaturation != saturation()) emit saturationChanged();
if (oldvalue != value()) emit valueChanged();
if (oldAlpha != alpha()) emit alphaChanged();
emit colorChanged();
}
void ColorBox::setSaturation(int newsaturation)
{
if (m_color.hsvSaturation()==newsaturation) return;
int oldAlpha = m_color.alpha();
m_color.setHsv(m_color.hsvHue(),newsaturation,m_color.value());
m_color.setAlpha(oldAlpha);
update();
emit saturationChanged();
emit colorChanged();
}
void ColorBox::setCurrent(int x, int y)
{
QColor newColor; QColor newColor;
if (x<0) x=0; x = clamp(x, 0, 120);
if (x>120) x=120; y = clamp(y, 0, 120);
if (y<0) y=0;
if (y>120) y=120;
int oldAlpha = m_color.alpha(); int oldAlpha = m_color.alpha();
newColor.setHsv(hue(), (x*255) / 120, 255 - (y*255) / 120); newColor.setHsv(hue(), (x*255) / 120, 255 - (y*255) / 120);
newColor.setAlpha(oldAlpha); newColor.setAlpha(oldAlpha);
setColor(newColor); setColor(newColor);
} }
void ColorBox::paintEvent(QPaintEvent *event) void ColorBox::setValue(int newvalue)
{ {
if (m_color.value()==newvalue) return;
int oldAlpha = m_color.alpha();
m_color.setHsv(m_color.hsvHue(),m_color.hsvSaturation(),newvalue);
m_color.setAlpha(oldAlpha);
update();
emit valueChanged();
emit colorChanged();
}
void ColorBox::paintEvent(QPaintEvent *event)
{
QWidget::paintEvent(event); QWidget::paintEvent(event);
QPainter p(this); QPainter p(this);
@@ -173,10 +334,7 @@ namespace QmlDesigner {
if ((hue() != m_lastHue) || (m_cache.isNull())) { if ((hue() != m_lastHue) || (m_cache.isNull())) {
m_lastHue = hue(); m_lastHue = hue();
int fixedHue = m_lastHue; int fixedHue = clamp(m_lastHue, 0, 359);
if (fixedHue<0) fixedHue=0;
if (fixedHue>359) fixedHue=359;
m_cache = QPixmap(120, 120); m_cache = QPixmap(120, 120);
@@ -197,20 +355,36 @@ namespace QmlDesigner {
p.drawPixmap(5, 5, m_cache); p.drawPixmap(5, 5, m_cache);
int x = m_color.hsvSaturationF() * 120 + 5; int x = clamp(m_color.hsvSaturationF() * 120, 0, 120) + 5;
int y = 120 - m_color.valueF() * 120 + 5; int y = clamp(120 - m_color.valueF() * 120, 0, 120) + 5;
if (x<5) x=5;
if (x>125) x=125;
if (y<5) y=5;
if (y>125) y=125;
p.setPen(Qt::white); p.setPen(Qt::white);
p.drawEllipse(x - 2, y - 2, 4, 4); p.drawEllipse(x - 2, y - 2, 4, 4);
p.setPen(Qt::black); p.setPen(Qt::black);
p.drawRect(QRect(0, 0, width() - 1, height() -1).adjusted(4, 4, -4, -4)); p.drawRect(QRect(0, 0, width() - 1, height() -1).adjusted(4, 4, -4, -4));
} }
void ColorBox::mousePressEvent(QMouseEvent *e)
{
// The current cell marker is set to the cell the mouse is pressed in
QPoint pos = e->pos();
m_mousePressed = true;
setCurrent(pos.x() - 5, pos.y() - 5);
}
void ColorBox::mouseReleaseEvent(QMouseEvent * /* event */)
{
m_mousePressed = false;
}
void ColorBox::mouseMoveEvent(QMouseEvent *e)
{
if (!m_mousePressed)
return;
QPoint pos = e->pos();
setCurrent(pos.x() - 5, pos.y() - 5);
}
void GradientLine::setItemNode(const QVariant &itemNode) void GradientLine::setItemNode(const QVariant &itemNode)
{ {
@@ -229,6 +403,40 @@ static inline QColor invertColor(const QColor color)
return c; return c;
} }
GradientLine::GradientLine(QWidget *parent) : QWidget(parent), m_activeColor(Qt::black), m_gradientName("gradient"), m_dragActive(false), m_yOffset(0), m_create(false), m_active(false)
{
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
setFocusPolicy(Qt::StrongFocus);
setFixedHeight(50);
setMinimumWidth(160);
resize(160, 50);
m_colorList << m_activeColor << QColor(Qt::white);
m_stops << 0 << 1;
updateGradient();
setCurrentIndex(0);
}
void GradientLine::setGradientName(const QString &newName)
{
if (newName == m_gradientName)
return;
m_gradientName = newName;
setup();
emit gradientNameChanged();
}
void GradientLine::setActiveColor(const QColor &newColor)
{
if (newColor.name() == m_activeColor.name() && newColor.alpha() == m_activeColor.alpha())
return;
m_activeColor = newColor;
m_colorList.removeAt(currentColorIndex());
m_colorList.insert(currentColorIndex(), m_activeColor);
updateGradient();
update();
}
void GradientLine::setupGradient() void GradientLine::setupGradient()
{ {
ModelNode modelNode = m_itemNode.modelNode(); ModelNode modelNode = m_itemNode.modelNode();
@@ -255,6 +463,27 @@ void GradientLine::setupGradient()
updateGradient(); updateGradient();
} }
void GradientLine::deleteGradient()
{
if (!m_itemNode.isValid())
return;
if (!m_itemNode.modelNode().metaInfo().hasProperty(m_gradientName))
return;
ModelNode modelNode = m_itemNode.modelNode();
if (m_itemNode.isInBaseState()) {
if (modelNode.hasProperty(m_gradientName)) {
RewriterTransaction transaction;
m_itemNode.modelNode().removeProperty(m_gradientName); //### there is atm a bug in the node instances which lead to a crash if using destroy()
/*ModelNode gradientNode = modelNode.nodeProperty(m_gradientName).modelNode();
if (QmlObjectNode(gradientNode).isValid())
QmlObjectNode(gradientNode).destroy();*/
}
}
}
bool GradientLine::event(QEvent *event) bool GradientLine::event(QEvent *event)
{ {
if (event->type() == QEvent::ShortcutOverride) if (event->type() == QEvent::ShortcutOverride)
@@ -350,7 +579,6 @@ void GradientLine::mousePressEvent(QMouseEvent *event)
} }
setFocus(Qt::MouseFocusReason); setFocus(Qt::MouseFocusReason);
event->accept(); event->accept();
//QWidget::mousePressEvent(event);
} }
void GradientLine::mouseReleaseEvent(QMouseEvent *event) void GradientLine::mouseReleaseEvent(QMouseEvent *event)
@@ -376,7 +604,6 @@ void GradientLine::mouseReleaseEvent(QMouseEvent *event)
update(); update();
updateGradient(); updateGradient();
event->accept(); event->accept();
//QWidget::mouseReleaseEvent(event);
} }
void GradientLine::mouseMoveEvent(QMouseEvent *event) void GradientLine::mouseMoveEvent(QMouseEvent *event)
@@ -445,8 +672,9 @@ void GradientLine::updateGradient()
ModelNode modelNode = m_itemNode.modelNode(); ModelNode modelNode = m_itemNode.modelNode();
if (m_itemNode.isInBaseState()) { if (m_itemNode.isInBaseState()) {
if (modelNode.hasProperty(m_gradientName)) if (modelNode.hasProperty(m_gradientName)) {
modelNode.removeProperty(m_gradientName); modelNode.removeProperty(m_gradientName);
}
ModelNode gradientNode = modelNode.view()->createModelNode("Qt/Gradient", 4, 6); ModelNode gradientNode = modelNode.view()->createModelNode("Qt/Gradient", 4, 6);
@@ -473,4 +701,14 @@ void GradientLine::updateGradient()
} }
} }
void GradientLine::setCurrentIndex(int i)
{
if (i == m_colorIndex)
return;
m_colorIndex = i;
setActiveColor(m_colorList.at(i));
emit activeColorChanged();
update();
}
} }

View File

@@ -54,28 +54,11 @@ Q_OBJECT
Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(bool noColor READ noColor WRITE setNoColor) Q_PROPERTY(bool noColor READ noColor WRITE setNoColor)
public: public:
ColorButton(QWidget *parent = 0) : QToolButton (parent), m_colorString("#ffffff"), m_noColor(false) {}
ColorButton(QWidget *parent = 0) : QToolButton (parent), m_colorString("#ffffff"), m_noColor(false) void setColor(const QString &colorStr);
{ QString color() const { return m_colorString; }
}
void setColor(const QString &colorStr)
{
if (m_colorString == colorStr)
return;
m_colorString = colorStr;
update();
emit colorChanged();
}
QString color() const
{
return m_colorString;
}
bool noColor() const { return m_noColor; } bool noColor() const { return m_noColor; }
void setNoColor(bool f) { m_noColor = f; update(); } void setNoColor(bool f) { m_noColor = f; update(); }
@@ -89,36 +72,6 @@ private:
bool m_noColor; bool m_noColor;
}; };
inline QString properName(const QColor &color)
{
QString s;
if (color.alpha() == 255)
s.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue());
else
s.sprintf("#%02x%02x%02x%02x", color.alpha(), color.red(), color.green(), color.blue());
return s;
}
inline QColor properColor(const QString &str)
{
int lalpha = 255;
QString lcolorStr = str;
if (lcolorStr.at(0) == '#' && lcolorStr.length() == 9) {
QString alphaStr = lcolorStr;
alphaStr.truncate(3);
lcolorStr.remove(0, 3);
lcolorStr = "#" + lcolorStr;
alphaStr.remove(0,1);
bool v;
lalpha = alphaStr.toInt(&v, 16);
if (!v)
lalpha = 255;
}
QColor lcolor(lcolorStr);
lcolor.setAlpha(lalpha);
return lcolor;
}
class ColorBox : public QWidget class ColorBox : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -131,117 +84,24 @@ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(int alpha READ alpha WRITE setAlpha NOTIFY alphaChanged) Q_PROPERTY(int alpha READ alpha WRITE setAlpha NOTIFY alphaChanged)
public: public:
ColorBox(QWidget *parent = 0) : QWidget(parent), m_color(Qt::white), m_saturatedColor(Qt::white), m_lastHue(0)
ColorBox(QWidget *parent = 0) : QWidget(parent), m_color(Qt::white), m_saturatedColor(Qt::white), m_lastHue(0) {
{
setFixedWidth(130); setFixedWidth(130);
setFixedHeight(130); setFixedHeight(130);
} }
void setHue(int newHue) void setHue(int newHue);
{ int hue() const;
if (m_color.hsvHue() == newHue) void setAlpha(int newAlpha);
return; int alpha() const { return m_color.alpha(); }
void setStrColor(const QString &colorStr);
int oldAlpha = m_color.alpha(); void setColor(const QColor &color);
m_color.setHsv(newHue,m_color.hsvSaturation(),m_color.value()); QString strColor() const;
m_color.setAlpha(oldAlpha); QColor color() const { return m_color; }
update(); int saturation() const { return m_color.hsvSaturation(); }
emit hueChanged(); void setSaturation(int newsaturation);
emit colorChanged(); int value() const { return m_color.value(); }
} void setValue(int newvalue);
int hue() const
{
int retval = m_color.hsvHue();
if (retval<0) retval=0;
if (retval>359) retval=359;
return retval;
}
void setAlpha(int newAlpha)
{
if (m_color.alpha() == newAlpha)
return;
m_color.setAlpha(newAlpha);
update();
emit alphaChanged();
emit colorChanged();
}
int alpha() const
{
return m_color.alpha();
}
void setStrColor(const QString &colorStr)
{
if (properName(m_color) == colorStr)
return;
setColor(properColor(colorStr));
}
void setColor(const QColor &color)
{
if (m_color == color)
return;
int oldsaturation = m_color.hsvSaturation();
int oldvalue = m_color.value();
int oldhue = m_color.hsvHue();
int oldAlpha = m_color.alpha();
m_color=color;
update();
if (oldhue != m_color.hsvHue()) emit hueChanged();
if (oldsaturation != saturation()) emit saturationChanged();
if (oldvalue != value()) emit valueChanged();
if (oldAlpha != alpha()) emit alphaChanged();
emit colorChanged();
}
QString strColor() const
{
return properName(m_color);
}
QColor color() const
{
return m_color;
}
int saturation() const
{
return m_color.hsvSaturation();
}
void setSaturation(int newsaturation)
{
if (m_color.hsvSaturation()==newsaturation) return;
int oldAlpha = m_color.alpha();
m_color.setHsv(m_color.hsvHue(),newsaturation,m_color.value());
m_color.setAlpha(oldAlpha);
update();
emit saturationChanged();
emit colorChanged();
}
int value() const
{
return m_color.value();
}
void setValue(int newvalue)
{
if (m_color.value()==newvalue) return;
int oldAlpha = m_color.alpha();
m_color.setHsv(m_color.hsvHue(),m_color.hsvSaturation(),newvalue);
m_color.setAlpha(oldAlpha);
update();
emit valueChanged();
emit colorChanged();
}
signals: signals:
void colorChanged(); void colorChanged();
@@ -253,29 +113,10 @@ signals:
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *e) void mousePressEvent(QMouseEvent *);
{ void mouseReleaseEvent(QMouseEvent *);
// The current cell marker is set to the cell the mouse is pressed in void mouseMoveEvent(QMouseEvent *);
QPoint pos = e->pos(); void setCurrent(int x, int y);
m_mousePressed = true;
setCurrent(pos.x() - 5, pos.y() - 5);
}
void mouseReleaseEvent(QMouseEvent * /* event */)
{
m_mousePressed = false;
}
void mouseMoveEvent(QMouseEvent *e)
{
if (!m_mousePressed)
return;
QPoint pos = e->pos();
setCurrent(pos.x() - 5, pos.y() - 5);
}
void setCurrent(int x, int y);
private: private:
QColor m_color; QColor m_color;
@@ -293,55 +134,24 @@ Q_PROPERTY(qreal hue READ hue WRITE setHue NOTIFY hueChanged)
public: public:
HueControl(QWidget *parent = 0) : QWidget(parent), m_color(Qt::white), m_mousePressed(false) HueControl(QWidget *parent = 0) : QWidget(parent), m_color(Qt::white), m_mousePressed(false)
{ {
setFixedWidth(40); setFixedWidth(40);
setFixedHeight(130); setFixedHeight(130);
} }
void setHue(int newHue) void setHue(int newHue);
{ int hue() const { return m_color.hsvHue(); }
if (m_color.hsvHue() == newHue)
return;
m_color.setHsv(newHue, m_color.hsvSaturation(), m_color.value());
update();
emit hueChanged();
}
int hue() const
{
return m_color.hsvHue();
}
signals: signals:
void hueChanged(); void hueChanged();
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *e) void mouseReleaseEvent(QMouseEvent *);
{ void mouseMoveEvent(QMouseEvent *);
// The current cell marker is set to the cell the mouse is pressed in void setCurrent(int y);
QPoint pos = e->pos();
m_mousePressed = true;
setCurrent(pos.y() - 5);
}
void mouseReleaseEvent(QMouseEvent * /* event */)
{
m_mousePressed = false;
}
void mouseMoveEvent(QMouseEvent *e)
{
if (!m_mousePressed)
return;
QPoint pos = e->pos();
setCurrent(pos.y() - 5);
}
void setCurrent(int y);
private: private:
QColor m_color; QColor m_color;
@@ -358,50 +168,20 @@ class GradientLine : public QWidget {
Q_PROPERTY(bool active READ active WRITE setActive) Q_PROPERTY(bool active READ active WRITE setActive)
public: public:
GradientLine(QWidget *parent = 0) : QWidget(parent), m_activeColor(Qt::black), m_gradientName("gradient"), m_dragActive(false), m_yOffset(0), m_create(false), m_active(false) GradientLine(QWidget *parent = 0);
{
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
setFocusPolicy(Qt::StrongFocus);
setFixedHeight(50);
setMinimumWidth(160);
resize(160, 50);
m_colorList << m_activeColor << QColor(Qt::white);
m_stops << 0 << 1;
updateGradient();
setCurrentIndex(0);
}
QVariant itemNode() const { return QVariant::fromValue(m_itemNode.modelNode()); } QVariant itemNode() const { return QVariant::fromValue(m_itemNode.modelNode()); }
void setItemNode(const QVariant &itemNode); void setItemNode(const QVariant &itemNode);
QString gradientName() const { return m_gradientName; } QString gradientName() const { return m_gradientName; }
void setGradientName(const QString &newName) void setGradientName(const QString &newName);
{
if (newName == m_gradientName)
return;
m_gradientName = newName;
setup();
emit gradientNameChanged();
}
QColor activeColor() const { return m_activeColor; } QColor activeColor() const { return m_activeColor; }
void setActiveColor(const QColor &newColor) void setActiveColor(const QColor &newColor);
{
if (newColor.name() == m_activeColor.name() && newColor.alpha() == m_activeColor.alpha())
return;
m_activeColor = newColor;
m_colorList.removeAt(currentColorIndex());
m_colorList.insert(currentColorIndex(), m_activeColor);
updateGradient();
update();
}
bool active() const { return m_active; } bool active() const { return m_active; }
void setActive(bool a) { m_active = a; } void setActive(bool a) { m_active = a; }
public slots: public slots:
void setupGradient(); void setupGradient();
void deleteGradient();
signals: signals:
void activeColorChanged(); void activeColorChanged();
@@ -419,15 +199,7 @@ private:
void setup(); void setup();
void updateGradient(); void updateGradient();
int currentColorIndex() const { return m_colorIndex; } int currentColorIndex() const { return m_colorIndex; }
void setCurrentIndex(int i) void setCurrentIndex(int i);
{
if (i == m_colorIndex)
return;
m_colorIndex = i;
setActiveColor(m_colorList.at(i));
emit activeColorChanged();
update();
}
QColor m_activeColor; QColor m_activeColor;
QmlItemNode m_itemNode; QmlItemNode m_itemNode;