void Dialog::updateGradient() { clearStops(); int nColors(m_colors.size()); QHBoxLayout* layout(m_dialog.buttonLayout); QSpacerItem* spacer; StopButton* button; for (int i = 0; i < nColors-1; ++i) { button = new StopButton(this, i, m_colors[i]); connect(button, SIGNAL(colorChanged(int const, QColor const&)), this, SLOT(colorChanged(int const, QColor const&))); layout->addWidget(button); spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); layout->addItem(spacer); } button = new StopButton(this, nColors-1, m_colors.last()); connect(button, SIGNAL(colorChanged(int const, QColor const&)), this, SLOT(colorChanged(int const, QColor const&))); layout->addWidget(button); QString grad("background-color: " + ToString(m_colors)); m_dialog.gradientView->setStyleSheet(grad); m_dialog.stopsSpin->setValue(m_colors.size()); }
VGradient::VGradient( const VGradient& gradient ) { m_origin = gradient.m_origin; m_focalPoint = gradient.m_focalPoint; m_vector = gradient.m_vector; m_type = gradient.m_type; m_repeatMethod = gradient.m_repeatMethod; clearStops(); QList<VColorStop*> cs = gradient.colorStops(); qStableSort(cs.begin(), cs.end(), compareStops); for( int i = 0; i < cs.count(); ++i) m_colorStops.append( new VColorStop( *cs[i] ) ); } // VGradient::VGradient
VGradientEx& VGradientEx::operator=( const VGradientEx& gradient ) { if ( this == &gradient ) return *this; m_origin = gradient.m_origin; m_focalPoint = gradient.m_focalPoint; m_vector = gradient.m_vector; m_type = gradient.m_type; m_repeatMethod = gradient.m_repeatMethod; clearStops(); QList<VColorStopEx*> cs = gradient.colorStops(); qStableSort( cs.begin(), cs.end(), compareStopsEx); for( int i = 0; i < cs.count(); ++i ) m_colorStops.append( new VColorStopEx( *cs[i] ) ); return *this; } // VGradientEx::operator=
VGradientEx::~VGradientEx() { clearStops(); }
VGradient::~VGradient() { clearStops(); }