Commit 13d3095b authored by Cyrille Berger's avatar Cyrille Berger

* get/set configuration from the widget

* cleanup kgradientslider

svn path=/trunk/koffice/; revision=849792
parent 2fad88bf
......@@ -41,7 +41,6 @@ KGradientSlider::KGradientSlider(QWidget *parent)
m_dragging = false;
setMouseTracking(true);
setPaletteBackgroundColor(Qt::NoBackground);
setMaximumSize(255, 28);
m_blackcursor = 0;
......@@ -65,11 +64,7 @@ void KGradientSlider::paintEvent(QPaintEvent *)
// A QPixmap is used for enable the double buffering.
/*if (!m_dragging) {*/
QPixmap pm(size());
QPainter p1;
p1.begin(&pm, this);
pm.fill();
QPainter p1(this);
// Draw first gradient
y = 0;
......@@ -123,8 +118,6 @@ void KGradientSlider::paintEvent(QPaintEvent *)
p1.setBrush(Qt::white);
p1.drawPolygon(a, 3);
p1.end();
bitBlt(this, 0, 0, &pm);
}
void KGradientSlider::mousePressEvent ( QMouseEvent * e )
......@@ -204,7 +197,7 @@ void KGradientSlider::mousePressEvent ( QMouseEvent * e )
m_gamma = 1.0 / pow (10, tmp);
break;
}
repaint(false);
update();
}
void KGradientSlider::mouseReleaseEvent ( QMouseEvent * e )
......@@ -213,7 +206,7 @@ void KGradientSlider::mouseReleaseEvent ( QMouseEvent * e )
return;
m_dragging = false;
repaint(false);
update();
switch (m_grab_cursor) {
case BlackCursor:
......@@ -284,7 +277,7 @@ void KGradientSlider::mouseMoveEvent ( QMouseEvent * e )
}
}
repaint(false);
update();
}
void KGradientSlider::leaveEvent( QEvent * )
......@@ -295,7 +288,7 @@ void KGradientSlider::leaveEvent( QEvent * )
void KGradientSlider::enableGamma(bool b)
{
m_gammaEnabled = b;
repaint(false);
update();
}
double KGradientSlider::getGamma(void)
......@@ -312,7 +305,7 @@ void KGradientSlider::modifyBlack(int v) {
double tmp = log10 (1.0 / m_gamma);
m_gammacursor = (unsigned int)qRound(mid + delta * tmp);
}
repaint(false);
update();
}
}
void KGradientSlider::modifyWhite(int v) {
......@@ -324,16 +317,20 @@ void KGradientSlider::modifyWhite(int v) {
double tmp = log10 (1.0 / m_gamma);
m_gammacursor = (unsigned int)qRound(mid + delta * tmp);
}
repaint(false);
update();
}
}
void KGradientSlider::modifyGamma(double v) {
if( m_gamma != v )
{
emit modifiedGamma( v );
}
m_gamma = v;
double delta = (double) (m_whitecursor - m_blackcursor) / 2.0;
double mid = (double)m_blackcursor + delta;
double tmp = log10 (1.0 / m_gamma);
m_gammacursor = (unsigned int)qRound(mid + delta * tmp);
repaint(false);
update();
}
#include "kgradientslider.moc"
......@@ -289,26 +289,39 @@ void KisLevelConfigWidget::drawHistogram(bool logarithmic)
KisFilterConfiguration * KisLevelConfigWidget::configuration() const
{
KisFilterConfiguration * cfg = new KisFilterConfiguration(KisLevelFilter::id().id(), 1);
KisFilterConfiguration * config = new KisFilterConfiguration(KisLevelFilter::id().id(), 1);
// cfg->blackvalue = m_page.blackspin->value();
// cfg->whitevalue = m_page.whitespin->value();
// cfg->gammavalue = m_page.ingradient->getGamma();
// cfg->outblackvalue = m_page.outblackspin->value() * 255;
// cfg->outwhitevalue = m_page.outwhitespin->value() * 255;
return cfg;
config->setProperty( "blackvalue", m_page.blackspin->value());
config->setProperty( "whitevalue", m_page.whitespin->value());
config->setProperty( "gammavalue", m_page.ingradient->getGamma());
config->setProperty( "outblackvalue", m_page.outblackspin->value());
config->setProperty( "outwhitevalue", m_page.outwhitespin->value());
return config;
}
void KisLevelConfigWidget::setConfiguration( KisFilterConfiguration * config )
{
// KisLevelFilterConfiguration * cfg = dynamic_cast<KisLevelFilterConfiguration *>(config);
// m_page.blackspin->setValue(cfg->blackvalue);
// m_page.whitespin->setValue(cfg->whitevalue);
// m_page.ingradient->modifyGamma(cfg->gammavalue);
// m_page.outblackspin->setValue(cfg->outblackvalue / 255);
// m_page.outwhitespin->setValue(cfg->outwhitevalue / 255);
QVariant value;
if (config->getProperty("blackvalue", value))
{
m_page.blackspin->setValue( value.toUInt() );
}
if (config->getProperty("whitevalue", value))
{
m_page.whitespin->setValue( value.toUInt() );
}
if (config->getProperty("gammavalue", value))
{
m_page.ingradient->modifyGamma(value.toDouble());
}
if (config->getProperty("outblackvalue", value))
{
m_page.outblackspin->setValue( value.toUInt() );
}
if (config->getProperty("outwhitevalue", value))
{
m_page.outwhitespin->setValue( value.toUInt() );
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment