mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdeui: remove unused private member
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7df1c4b6bb
commit
a2e4da709f
5 changed files with 361 additions and 348 deletions
|
@ -23,14 +23,17 @@
|
|||
|
||||
#include "kcolorchoosermode_p.h"
|
||||
|
||||
using namespace KDEPrivate;
|
||||
|
||||
class KColorValueSelector::Private
|
||||
{
|
||||
public:
|
||||
Private(KColorValueSelector *q): q(q), _hue(0), _sat(0), _colorValue(0), _mode(ChooserClassic) {}
|
||||
Private()
|
||||
: _hue(0),
|
||||
_sat(0),
|
||||
_colorValue(0),
|
||||
_mode(KColorChooserMode::ChooserClassic)
|
||||
{
|
||||
}
|
||||
|
||||
KColorValueSelector *q;
|
||||
int _hue;
|
||||
int _sat;
|
||||
int _colorValue;
|
||||
|
@ -39,13 +42,15 @@ public:
|
|||
};
|
||||
|
||||
KColorValueSelector::KColorValueSelector(QWidget *parent)
|
||||
: KSelector( Qt::Vertical, parent ), d( new Private( this ) )
|
||||
: KSelector(Qt::Vertical, parent),
|
||||
d( new Private())
|
||||
{
|
||||
setRange(0, 255);
|
||||
}
|
||||
|
||||
KColorValueSelector::KColorValueSelector(Qt::Orientation o, QWidget *parent)
|
||||
: KSelector( o, parent ), d( new Private( this ) )
|
||||
: KSelector(o, parent),
|
||||
d(new Private())
|
||||
{
|
||||
setRange(0, 255);
|
||||
}
|
||||
|
@ -85,15 +90,14 @@ void KColorValueSelector::setColorValue ( int colorValue )
|
|||
d->_colorValue = colorValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void KColorValueSelector::updateContents()
|
||||
{
|
||||
drawPalette(&d->pixmap);
|
||||
}
|
||||
|
||||
void KColorValueSelector::resizeEvent( QResizeEvent * )
|
||||
void KColorValueSelector::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
updateContents();
|
||||
}
|
||||
|
||||
|
@ -102,14 +106,14 @@ void KColorValueSelector::drawContents( QPainter *painter )
|
|||
painter->drawPixmap(contentsRect().x(), contentsRect().y(), d->pixmap);
|
||||
}
|
||||
|
||||
void KColorValueSelector::setChooserMode( KColorChooserMode c )
|
||||
void KColorValueSelector::setChooserMode(KColorChooserMode chooserMode)
|
||||
{
|
||||
if ( c == ChooserHue ) {
|
||||
if (chooserMode == KColorChooserMode::ChooserHue) {
|
||||
setRange(0, 360);
|
||||
} else {
|
||||
setRange(0, 255);
|
||||
}
|
||||
d->_mode = c;
|
||||
d->_mode = chooserMode;
|
||||
|
||||
// really needed?
|
||||
// emit modeChanged();
|
||||
|
@ -138,9 +142,9 @@ void KColorValueSelector::drawPalette( QPixmap *pixmap )
|
|||
gradient.setFinalStop(contentsRect().width(), 0);
|
||||
}
|
||||
|
||||
const int steps = componentValueSteps(chooserMode());
|
||||
const int steps = KDEPrivate::componentValueSteps(chooserMode());
|
||||
for (int v = 0; v <= steps; ++v) {
|
||||
setComponentValue(color, chooserMode(), v * (1.0 / steps));
|
||||
KDEPrivate::setComponentValue(color, chooserMode(), v * (1.0 / steps));
|
||||
gradient.setColorAt(v * (1.0 / steps), color);
|
||||
}
|
||||
|
||||
|
@ -149,5 +153,4 @@ void KColorValueSelector::drawPalette( QPixmap *pixmap )
|
|||
painter.fillRect(pixmap->rect(), gradient);
|
||||
}
|
||||
|
||||
|
||||
#include "moc_kcolorvalueselector.cpp"
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
#include "kselector.h"
|
||||
#include "kcolorchoosermode.h"
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
class KDEUI_EXPORT KColorValueSelector : public KSelector
|
||||
{
|
||||
|
@ -35,11 +36,11 @@ public:
|
|||
/**
|
||||
* Constructs a widget for color selection.
|
||||
*/
|
||||
explicit KColorValueSelector( QWidget *parent=0 );
|
||||
explicit KColorValueSelector(QWidget *parent = nullptr);
|
||||
/**
|
||||
* Constructs a widget for color selection with a given orientation
|
||||
*/
|
||||
explicit KColorValueSelector( Qt::Orientation o, QWidget *parent = 0 );
|
||||
explicit KColorValueSelector(Qt::Orientation o, QWidget *parent = nullptr);
|
||||
|
||||
~KColorValueSelector();
|
||||
|
||||
|
@ -114,7 +115,7 @@ protected:
|
|||
* which is used for buffering.
|
||||
*/
|
||||
virtual void drawPalette(QPixmap *pixmap);
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
|
||||
/**
|
||||
* Reimplemented from KSelector. The drawing is
|
||||
|
|
|
@ -19,12 +19,10 @@
|
|||
|
||||
#include "khuesaturationselect.h"
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include <QPainter>
|
||||
|
||||
#include "kcolorchoosermode_p.h"
|
||||
|
||||
using namespace KDEPrivate;
|
||||
|
||||
class KHueSaturationSelector::Private
|
||||
{
|
||||
public:
|
||||
|
@ -135,17 +133,17 @@ void KHueSaturationSelector::drawContents(QPainter *painter)
|
|||
|
||||
void KHueSaturationSelector::drawPalette(QPixmap *pixmap)
|
||||
{
|
||||
int xSteps = componentXSteps(chooserMode());
|
||||
int ySteps = componentYSteps(chooserMode());
|
||||
int xSteps = KDEPrivate::componentXSteps(chooserMode());
|
||||
int ySteps = KDEPrivate::componentYSteps(chooserMode());
|
||||
|
||||
QColor color;
|
||||
color.setHsv(hue(), saturation(), chooserMode() == ChooserClassic ? 192 : colorValue());
|
||||
color.setHsv(hue(), saturation(), chooserMode() == KColorChooserMode::ChooserClassic ? 192 : colorValue());
|
||||
|
||||
QImage image(QSize(xSteps + 1, ySteps + 1), QImage::Format_RGB32);
|
||||
for (int y = 0; y <= ySteps; ++y) {
|
||||
setComponentY(color, chooserMode(), y * (1.0 / ySteps));
|
||||
KDEPrivate::setComponentY(color, chooserMode(), y * (1.0 / ySteps));
|
||||
for (int x = 0; x <= xSteps; ++x) {
|
||||
setComponentX(color, chooserMode(), x * (1.0 / xSteps));
|
||||
KDEPrivate::setComponentX(color, chooserMode(), x * (1.0 / xSteps));
|
||||
image.setPixel(x, ySteps - y, color.rgb());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
*/
|
||||
|
||||
#include "kxyselector.h"
|
||||
#include "kdebug.h"
|
||||
|
||||
#include <QStyle>
|
||||
#include <QPainter>
|
||||
#include <QtGui/qpen.h>
|
||||
#include <QtGui/qstyleoption.h>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <kdebug.h>
|
||||
#include <QPen>
|
||||
#include <QStyleOptionFrame>
|
||||
#include <QWheelEvent>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
|
@ -34,8 +35,8 @@
|
|||
class KXYSelector::Private
|
||||
{
|
||||
public:
|
||||
Private(KXYSelector *q):
|
||||
q(q),
|
||||
Private(KXYSelector *q)
|
||||
: q(q),
|
||||
xPos(0),
|
||||
yPos(0),
|
||||
minX(0),
|
||||
|
@ -43,7 +44,8 @@ public:
|
|||
minY(0),
|
||||
maxY(100),
|
||||
m_markerColor(Qt::white)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void setValues(int _xPos, int _yPos);
|
||||
|
||||
|
@ -60,8 +62,8 @@ public:
|
|||
};
|
||||
|
||||
KXYSelector::KXYSelector(QWidget *parent)
|
||||
: QWidget( parent )
|
||||
, d(new Private(this))
|
||||
: QWidget(parent),
|
||||
d(new Private(this))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -92,7 +94,6 @@ void KXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY )
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
int w = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
d->px = w;
|
||||
d->py = w;
|
||||
|
@ -124,15 +125,17 @@ void KXYSelector::Private::setValues(int _xPos, int _yPos )
|
|||
xPos = _xPos;
|
||||
yPos = _yPos;
|
||||
|
||||
if ( xPos > maxX )
|
||||
if (xPos > maxX) {
|
||||
xPos = maxX;
|
||||
else if ( xPos < minX )
|
||||
} else if (xPos < minX) {
|
||||
xPos = minX;
|
||||
}
|
||||
|
||||
if ( yPos > maxY )
|
||||
if (yPos > maxY) {
|
||||
yPos = maxY;
|
||||
else if ( yPos < minY )
|
||||
} else if (yPos < minY) {
|
||||
yPos = minY;
|
||||
}
|
||||
|
||||
Q_ASSERT(maxX != minX);
|
||||
int xp = w + (q->width() - 2 * w) * xPos / (maxX - minX);
|
||||
|
@ -160,8 +163,10 @@ QSize KXYSelector::minimumSizeHint() const
|
|||
return QSize(2 * w, 2 * w);
|
||||
}
|
||||
|
||||
void KXYSelector::paintEvent( QPaintEvent * /* ev */ )
|
||||
void KXYSelector::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
|
||||
QStyleOptionFrame opt;
|
||||
opt.initFrom(this);
|
||||
|
||||
|
@ -183,7 +188,8 @@ void KXYSelector::mousePressEvent( QMouseEvent *e )
|
|||
|
||||
void KXYSelector::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
int xVal, yVal;
|
||||
int xVal = 0;
|
||||
int yVal = 0;
|
||||
int w = style()->pixelMetric(QStyle::PM_DefaultFrameWidth );
|
||||
valuesFromPosition(e->pos().x() - w, e->pos().y() - w, xVal, yVal);
|
||||
setValues(xVal, yVal);
|
||||
|
@ -193,10 +199,11 @@ void KXYSelector::mouseMoveEvent( QMouseEvent *e )
|
|||
|
||||
void KXYSelector::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
if ( e->orientation() == Qt::Horizontal )
|
||||
if (e->orientation() == Qt::Horizontal) {
|
||||
setValues(xValue() + e->delta() / 120, yValue());
|
||||
else
|
||||
} else {
|
||||
setValues(xValue(), yValue() + e->delta() / 120);
|
||||
}
|
||||
|
||||
emit valueChanged(d->xPos, d->yPos);
|
||||
}
|
||||
|
@ -206,32 +213,36 @@ void KXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const
|
|||
int w = style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
|
||||
|
||||
xVal = ((d->maxX - d->minX) * (x - w)) / (width() - 2 * w);
|
||||
yVal = d->maxY - ( ( ( d->maxY - d->minY ) * (y - w) ) / ( height() - 2 * w ) );
|
||||
yVal = (d->maxY - (((d->maxY - d->minY) * (y - w) ) / (height() - 2 * w)));
|
||||
|
||||
if ( xVal > d->maxX )
|
||||
if (xVal > d->maxX) {
|
||||
xVal = d->maxX;
|
||||
else if ( xVal < d->minX )
|
||||
} else if (xVal < d->minX) {
|
||||
xVal = d->minX;
|
||||
}
|
||||
|
||||
if ( yVal > d->maxY )
|
||||
if (yVal > d->maxY) {
|
||||
yVal = d->maxY;
|
||||
else if ( yVal < d->minY )
|
||||
} else if ( yVal < d->minY) {
|
||||
yVal = d->minY;
|
||||
}
|
||||
}
|
||||
|
||||
void KXYSelector::setPosition(int xp, int yp)
|
||||
{
|
||||
int w = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
||||
if ( xp < w )
|
||||
if (xp < w) {
|
||||
xp = w;
|
||||
else if ( xp > width() - w )
|
||||
} else if (xp > width() - w) {
|
||||
xp = width() - w;
|
||||
}
|
||||
|
||||
if ( yp < w )
|
||||
if (yp < w) {
|
||||
yp = w;
|
||||
else if ( yp > height() - w )
|
||||
} else if (yp > height() - w) {
|
||||
yp = height() - w;
|
||||
}
|
||||
|
||||
d->px = xp;
|
||||
d->py = yp;
|
||||
|
@ -239,9 +250,10 @@ void KXYSelector::setPosition( int xp, int yp )
|
|||
update();
|
||||
}
|
||||
|
||||
void KXYSelector::drawContents( QPainter * )
|
||||
{}
|
||||
|
||||
void KXYSelector::drawContents(QPainter *p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void KXYSelector::drawMarker(QPainter *p, int xp, int yp )
|
||||
{
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
#include <kdeui_export.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QWidget>
|
||||
#include <QPixmap>
|
||||
|
||||
/**
|
||||
* KXYSelector is the base class for other widgets which
|
||||
|
@ -39,13 +39,12 @@ class KDEUI_EXPORT KXYSelector : public QWidget
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(int xValue READ xValue WRITE setXValue)
|
||||
Q_PROPERTY(int yValue READ yValue WRITE setYValue)
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs a two-dimensional selector widget which
|
||||
* has a value range of [0..100] in both directions.
|
||||
*/
|
||||
explicit KXYSelector( QWidget *parent=0 );
|
||||
explicit KXYSelector(QWidget *parent = nullptr);
|
||||
/**
|
||||
* Destructs the widget.
|
||||
*/
|
||||
|
@ -115,7 +114,7 @@ protected:
|
|||
*
|
||||
* Draw within contentsRect() only.
|
||||
*/
|
||||
virtual void drawContents( QPainter * );
|
||||
virtual void drawContents(QPainter *p);
|
||||
|
||||
/**
|
||||
* Override this function to draw the marker which
|
||||
|
@ -123,10 +122,10 @@ protected:
|
|||
*/
|
||||
virtual void drawMarker(QPainter *p, int xp, int yp);
|
||||
|
||||
virtual void paintEvent( QPaintEvent *e );
|
||||
virtual void mousePressEvent( QMouseEvent *e );
|
||||
virtual void mouseMoveEvent( QMouseEvent *e );
|
||||
virtual void wheelEvent( QWheelEvent * );
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
virtual void wheelEvent(QWheelEvent *event);
|
||||
|
||||
/**
|
||||
* Converts a pixel position to its corresponding values.
|
||||
|
|
Loading…
Add table
Reference in a new issue