Change Sliders to new Slider-class

Use the new PixmapSlider class which is based on Qt's AbstractSlider
class for sliders. This should also fix some offset problems in
PositionSlider which appeared after the introduction of the new Button
class
This commit is contained in:
Thomas Frauendorfer 2008-05-08 04:19:34 +02:00
parent d3e140ad0e
commit 60c17af114
12 changed files with 142 additions and 161 deletions

View file

@ -25,7 +25,7 @@
PixmapSlider::PixmapSlider (QWidget *parent) : QAbstractSlider (parent)
{
setSliderDown (false);
m_slider_offset = 0;
m_slider_offset = QPoint ();
}
void
@ -144,11 +144,11 @@ PixmapSlider::paintEvent (QPaintEvent *event)
QPixmap *slider = isSliderDown () ? &m_pressed : &m_normal;
QRect rect (slider->rect ());
if (orientation () == Qt::Vertical) {
rect.moveTop (sliderPositionFromValue ());
rect.moveLeft (m_slider_offset);
rect.moveTop (sliderPositionFromValue () + m_slider_offset.y ());
rect.moveLeft (m_slider_offset.x ());
} else {
rect.moveLeft (sliderPositionFromValue ());
rect.moveTop (m_slider_offset);
rect.moveLeft (sliderPositionFromValue () + m_slider_offset.x ());
rect.moveTop (m_slider_offset.y ());
}
p.drawPixmap (rect , *slider, slider->rect ());
p.end ();

View file

@ -19,6 +19,7 @@
#include <QAbstractSlider>
#include <QList>
#include <QPoint>
class QWidget;
class QPixmap;
@ -44,6 +45,8 @@ class PixmapSlider : public QAbstractSlider
QPixmap normalSlider () const { return m_normal; }
QPixmap pressedSlider () const { return m_pressed; }
void setSliderOffset (QPoint offset) { m_slider_offset = offset; }
protected slots:
void paintEvent (QPaintEvent *event);
@ -58,17 +61,13 @@ class PixmapSlider : public QAbstractSlider
int sliderValueFromPosition (int pos);
int backgroundIndex ();
// horizontal offset in vertical sliders or
// vertical offset in horizontal sliders
void setSliderOffset (int offset) { m_slider_offset = offset; };
private:
QPixmapList m_backgrounds;
QPixmap m_normal;
QPixmap m_pressed;
QPoint m_slider_offset;
int m_background_index;
int m_slider_offset;
};
#endif