qt-material-widgets/components/slider_p.h

58 lines
1.1 KiB
C
Raw Normal View History

2016-05-01 19:56:39 +00:00
#ifndef SLIDER_P_H
#define SLIDER_P_H
#include "slider.h"
2016-05-01 21:10:31 +00:00
#include <QPainter>
2016-05-01 19:56:39 +00:00
class SliderPrivate
{
Q_DISABLE_COPY(SliderPrivate)
Q_DECLARE_PUBLIC(Slider)
public:
SliderPrivate(Slider *parent)
2016-05-01 21:10:31 +00:00
: q_ptr(parent),
orientation(Qt::Horizontal)
2016-05-01 19:56:39 +00:00
{
}
2016-05-01 21:10:31 +00:00
QRect trackGeometry() const
{
Q_Q(const Slider);
return Qt::Horizontal == orientation
? QRect(0, q->rect().height()/2 - 1, q->rect().width(), 2)
: QRect(q->rect().width()/2 - 1, 0, 2, q->rect().height());
}
void paintTrack(QPainter *painter)
{
Q_Q(Slider);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(QColor(0, 0, 0, 255));
painter->save();
painter->fillRect(trackGeometry(), brush);
painter->restore();
#ifdef DEBUG_LAYOUT
painter->drawRect(q->rect().adjusted(1, 1, -2, -2));
#endif
}
void paintThumb(QPainter *painter)
{
painter->save();
painter->restore();
}
2016-05-01 19:56:39 +00:00
Slider *const q_ptr;
2016-05-01 21:10:31 +00:00
Qt::Orientation orientation;
2016-05-01 19:56:39 +00:00
};
#endif // SLIDER_P_H