mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdeui: fix possible use of uninitialized variables in KHueSaturationSelector
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d47d67b645
commit
7df1c4b6bb
2 changed files with 37 additions and 31 deletions
|
@ -28,9 +28,14 @@ using namespace KDEPrivate;
|
||||||
class KHueSaturationSelector::Private
|
class KHueSaturationSelector::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(KHueSaturationSelector *q): q(q) {}
|
Private()
|
||||||
|
: _mode(KColorChooserMode::ChooserClassic),
|
||||||
|
_hue(0),
|
||||||
|
_sat(0),
|
||||||
|
_colorValue(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
KHueSaturationSelector *q;
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,11 +50,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
KHueSaturationSelector::KHueSaturationSelector(QWidget *parent)
|
||||||
KHueSaturationSelector::KHueSaturationSelector( QWidget *parent )
|
: KXYSelector(parent),
|
||||||
: KXYSelector( parent ), d( new Private( this ) )
|
d(new Private())
|
||||||
{
|
{
|
||||||
setChooserMode( ChooserClassic );
|
setChooserMode(KColorChooserMode::ChooserClassic);
|
||||||
}
|
}
|
||||||
|
|
||||||
KColorChooserMode KHueSaturationSelector::chooserMode() const
|
KColorChooserMode KHueSaturationSelector::chooserMode() const
|
||||||
|
@ -57,14 +62,14 @@ KColorChooserMode KHueSaturationSelector::chooserMode() const
|
||||||
return d->_mode;
|
return d->_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KHueSaturationSelector::setChooserMode( KColorChooserMode chooserMode )
|
void KHueSaturationSelector::setChooserMode(KColorChooserMode chooserMode)
|
||||||
{
|
{
|
||||||
int x;
|
int x = 0;
|
||||||
int y = 255;
|
int y = 255;
|
||||||
|
|
||||||
switch ( chooserMode ) {
|
switch (chooserMode) {
|
||||||
case ChooserSaturation:
|
case KColorChooserMode::ChooserSaturation:
|
||||||
case ChooserValue:
|
case KColorChooserMode::ChooserValue:
|
||||||
x = 359;
|
x = 359;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -72,27 +77,27 @@ void KHueSaturationSelector::setChooserMode( KColorChooserMode chooserMode )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setRange( 0, 0, x, y );
|
setRange(0, 0, x, y);
|
||||||
d->_mode = chooserMode;
|
d->_mode = chooserMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KHueSaturationSelector::hue () const
|
int KHueSaturationSelector::hue() const
|
||||||
{
|
{
|
||||||
return d->_hue;
|
return d->_hue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KHueSaturationSelector::setHue ( int hue )
|
void KHueSaturationSelector::setHue(int hue)
|
||||||
{
|
{
|
||||||
d->_hue = hue;
|
d->_hue = hue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KHueSaturationSelector::saturation () const
|
int KHueSaturationSelector::saturation() const
|
||||||
|
|
||||||
{
|
{
|
||||||
return d->_sat;
|
return d->_sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KHueSaturationSelector::setSaturation( int saturation )
|
void KHueSaturationSelector::setSaturation(int saturation)
|
||||||
{
|
{
|
||||||
d->_sat = saturation;
|
d->_sat = saturation;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +107,7 @@ int KHueSaturationSelector::colorValue() const
|
||||||
return d->_colorValue;
|
return d->_colorValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KHueSaturationSelector::setColorValue( int colorValue )
|
void KHueSaturationSelector::setColorValue(int colorValue)
|
||||||
{
|
{
|
||||||
d->_colorValue = colorValue;
|
d->_colorValue = colorValue;
|
||||||
}
|
}
|
||||||
|
@ -117,17 +122,18 @@ void KHueSaturationSelector::updateContents()
|
||||||
drawPalette( &d->pixmap );
|
drawPalette( &d->pixmap );
|
||||||
}
|
}
|
||||||
|
|
||||||
void KHueSaturationSelector::resizeEvent( QResizeEvent * )
|
void KHueSaturationSelector::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
updateContents();
|
updateContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KHueSaturationSelector::drawContents( QPainter *painter )
|
void KHueSaturationSelector::drawContents(QPainter *painter)
|
||||||
{
|
{
|
||||||
painter->drawPixmap( contentsRect().x(), contentsRect().y(), d->pixmap );
|
painter->drawPixmap(contentsRect().x(), contentsRect().y(), d->pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KHueSaturationSelector::drawPalette( QPixmap *pixmap )
|
void KHueSaturationSelector::drawPalette(QPixmap *pixmap)
|
||||||
{
|
{
|
||||||
int xSteps = componentXSteps(chooserMode());
|
int xSteps = componentXSteps(chooserMode());
|
||||||
int ySteps = componentYSteps(chooserMode());
|
int ySteps = componentYSteps(chooserMode());
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Constructs a hue/saturation selection widget.
|
* Constructs a hue/saturation selection widget.
|
||||||
*/
|
*/
|
||||||
explicit KHueSaturationSelector( QWidget *parent = 0 );
|
explicit KHueSaturationSelector(QWidget *parent = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
|
@ -45,14 +45,14 @@ public:
|
||||||
*
|
*
|
||||||
* @param The chooser mode as defined in KColorChooserMode
|
* @param The chooser mode as defined in KColorChooserMode
|
||||||
*/
|
*/
|
||||||
void setChooserMode ( KColorChooserMode chooserMode );
|
void setChooserMode(KColorChooserMode chooserMode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the chooser mode.
|
* Returns the chooser mode.
|
||||||
*
|
*
|
||||||
* @return The chooser mode (defined in KColorChooserMode)
|
* @return The chooser mode (defined in KColorChooserMode)
|
||||||
*/
|
*/
|
||||||
KColorChooserMode chooserMode () const;
|
KColorChooserMode chooserMode() const;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param hue The hue value (0-360)
|
* @param hue The hue value (0-360)
|
||||||
*/
|
*/
|
||||||
void setHue( int hue );
|
void setHue(int hue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the saturation (0-255)
|
* Returns the saturation (0-255)
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param saturation The saturation (0-255)
|
* @param saturation The saturation (0-255)
|
||||||
*/
|
*/
|
||||||
void setSaturation( int saturation );
|
void setSaturation(int saturation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the color value (also known as lumniousity, 0-255)
|
* Returns the color value (also known as lumniousity, 0-255)
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param colorValue The color value (0-255)
|
* @param colorValue The color value (0-255)
|
||||||
*/
|
*/
|
||||||
void setColorValue( int colorValue );
|
void setColorValue(int colorValue);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,15 +108,15 @@ protected:
|
||||||
* Draws the contents of the widget on a pixmap,
|
* Draws the contents of the widget on a pixmap,
|
||||||
* which is used for buffering.
|
* which is used for buffering.
|
||||||
*/
|
*/
|
||||||
virtual void drawPalette( QPixmap *pixmap );
|
virtual void drawPalette(QPixmap *pixmap);
|
||||||
virtual void resizeEvent( QResizeEvent * );
|
virtual void resizeEvent(QResizeEvent *event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplemented from KXYSelector. This drawing is
|
* Reimplemented from KXYSelector. This drawing is
|
||||||
* buffered in a pixmap here. As real drawing
|
* buffered in a pixmap here. As real drawing
|
||||||
* routine, drawPalette() is used.
|
* routine, drawPalette() is used.
|
||||||
*/
|
*/
|
||||||
virtual void drawContents( QPainter *painter );
|
virtual void drawContents(QPainter *painter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ private:
|
||||||
friend class Private;
|
friend class Private;
|
||||||
Private * const d;
|
Private * const d;
|
||||||
|
|
||||||
Q_DISABLE_COPY( KHueSaturationSelector )
|
Q_DISABLE_COPY(KHueSaturationSelector)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*KHUESATURATIONSELECT_H_*/
|
#endif /*KHUESATURATIONSELECT_H_*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue