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