Merge pull request #5035 from narunlifescience/master
Volume pixmap render on the fly using system theme
This commit is contained in:
commit
8757cb36c6
|
@ -408,7 +408,6 @@
|
||||||
<file>volumeslider-gradient.png</file>
|
<file>volumeslider-gradient.png</file>
|
||||||
<file>volumeslider-handle_glow.png</file>
|
<file>volumeslider-handle_glow.png</file>
|
||||||
<file>volumeslider-handle.png</file>
|
<file>volumeslider-handle.png</file>
|
||||||
<file>volumeslider-inset.png</file>
|
|
||||||
<file>vk/add.png</file>
|
<file>vk/add.png</file>
|
||||||
<file>vk/bookmarks.png</file>
|
<file>vk/bookmarks.png</file>
|
||||||
<file>vk/delete.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 |
|
@ -195,9 +195,12 @@ Amarok::VolumeSlider::VolumeSlider(QWidget* parent, uint max)
|
||||||
: Amarok::Slider(Qt::Horizontal, parent, max),
|
: Amarok::Slider(Qt::Horizontal, parent, max),
|
||||||
m_animCount(0),
|
m_animCount(0),
|
||||||
m_animTimer(new QTimer(this)),
|
m_animTimer(new QTimer(this)),
|
||||||
m_pixmapInset(QPixmap(":volumeslider-inset.png")) {
|
m_pixmapInset(QPixmap(volumePixmapDraw ())) {
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
|
// Store window text color to check theme change at paintEvent
|
||||||
|
m_previous_theme_text_color = palette().color(QPalette::WindowText);
|
||||||
|
|
||||||
// BEGIN Calculate handle animation pixmaps for mouse-over effect
|
// BEGIN Calculate handle animation pixmaps for mouse-over effect
|
||||||
QImage pixmapHandle(":volumeslider-handle.png");
|
QImage pixmapHandle(":volumeslider-handle.png");
|
||||||
QImage pixmapHandleGlow(":volumeslider-handle_glow.png");
|
QImage pixmapHandleGlow(":volumeslider-handle_glow.png");
|
||||||
|
@ -301,6 +304,12 @@ void Amarok::VolumeSlider::paintEvent(QPaintEvent*) {
|
||||||
const int padding = 7;
|
const int padding = 7;
|
||||||
const int offset = int(double((width() - 2 * padding) * value()) / maximum());
|
const int offset = int(double((width() - 2 * padding) * value()) / maximum());
|
||||||
|
|
||||||
|
// If theme changed since last paintEvent, redraw the volume pixmap with new theme colors
|
||||||
|
if (m_previous_theme_text_color != palette().color(QPalette::WindowText)) {
|
||||||
|
m_pixmapInset = volumePixmapDraw();
|
||||||
|
m_previous_theme_text_color = palette().color(QPalette::WindowText);
|
||||||
|
}
|
||||||
|
|
||||||
p.drawPixmap(0, 0, m_pixmapGradient, 0, 0, offset + padding, 0);
|
p.drawPixmap(0, 0, m_pixmapGradient, 0, 0, offset + padding, 0);
|
||||||
p.drawPixmap(0, 0, m_pixmapInset);
|
p.drawPixmap(0, 0, m_pixmapInset);
|
||||||
p.drawPixmap(offset - m_handlePixmaps[0].width() / 2 + padding, 0,
|
p.drawPixmap(offset - m_handlePixmaps[0].width() / 2 + padding, 0,
|
||||||
|
@ -335,3 +344,25 @@ void Amarok::VolumeSlider::leaveEvent(QEvent*) {
|
||||||
void Amarok::VolumeSlider::paletteChange(const QPalette&) {
|
void Amarok::VolumeSlider::paletteChange(const QPalette&) {
|
||||||
generateGradient();
|
generateGradient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap Amarok::VolumeSlider::volumePixmapDraw () const {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ class VolumeSlider : public Slider {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VolumeSlider(QWidget* parent, uint max = 0);
|
VolumeSlider(QWidget* parent, uint max = 0);
|
||||||
|
QPixmap volumePixmapDraw() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent*);
|
virtual void paintEvent(QPaintEvent*);
|
||||||
|
@ -129,6 +130,8 @@ class VolumeSlider : public Slider {
|
||||||
QPixmap m_pixmapInset;
|
QPixmap m_pixmapInset;
|
||||||
QPixmap m_pixmapGradient;
|
QPixmap m_pixmapGradient;
|
||||||
|
|
||||||
|
QColor m_previous_theme_text_color;
|
||||||
|
|
||||||
QList<QPixmap> m_handlePixmaps;
|
QList<QPixmap> m_handlePixmaps;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue