1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-22 07:26:47 +01:00

Volume Pixmap render

volume pixmap
This commit is contained in:
narunlifescience 2015-09-11 08:16:54 -05:00
parent 9d3e3eb33a
commit aaec092454
5 changed files with 25 additions and 2 deletions

View File

@ -408,7 +408,6 @@
<file>volumeslider-gradient.png</file>
<file>volumeslider-handle_glow.png</file>
<file>volumeslider-handle.png</file>
<file>volumeslider-inset.png</file>
<file>vk/add.png</file>
<file>vk/bookmarks.png</file>
<file>vk/delete.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

View File

@ -195,7 +195,7 @@ Amarok::VolumeSlider::VolumeSlider(QWidget* parent, uint max)
: Amarok::Slider(Qt::Horizontal, parent, max),
m_animCount(0),
m_animTimer(new QTimer(this)),
m_pixmapInset(QPixmap(":volumeslider-inset.png")) {
m_pixmapInset(QPixmap(volumePixmapDraw ())) {
setFocusPolicy(Qt::NoFocus);
// BEGIN Calculate handle animation pixmaps for mouse-over effect
@ -301,6 +301,8 @@ void Amarok::VolumeSlider::paintEvent(QPaintEvent*) {
const int padding = 7;
const int offset = int(double((width() - 2 * padding) * value()) / maximum());
m_pixmapInset = volumePixmapDraw();
p.drawPixmap(0, 0, m_pixmapGradient, 0, 0, offset + padding, 0);
p.drawPixmap(0, 0, m_pixmapInset);
p.drawPixmap(offset - m_handlePixmaps[0].width() / 2 + padding, 0,
@ -335,3 +337,24 @@ void Amarok::VolumeSlider::leaveEvent(QEvent*) {
void Amarok::VolumeSlider::paletteChange(const QPalette&) {
generateGradient();
}
QPixmap Amarok::VolumeSlider::volumePixmapDraw () {
QPixmap pixmap (112, 36);
pixmap.fill(Qt::transparent);
QPainter painter( &pixmap );
QPen pen(palette().color(QPalette::WindowText), 0.3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter.setPen(pen);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
// Draw volume control pixmap
QPolygon poly;
poly << QPoint(6, 21) << QPoint(104, 21)
<< QPoint(104, 7) << QPoint(6, 16)
<< QPoint(6, 21);
QPainterPath path;
path.addPolygon(poly);
painter.drawPolygon(poly);
painter.drawLine(6, 29, 104, 29);
// Return QPixmap
return pixmap;
}

View File

@ -98,6 +98,7 @@ class VolumeSlider : public Slider {
public:
VolumeSlider(QWidget* parent, uint max = 0);
QPixmap volumePixmapDraw();
protected:
virtual void paintEvent(QPaintEvent*);