1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-18 12:28:31 +01:00

Add a background to the pretty OSD

This commit is contained in:
David Sansome 2010-06-02 19:19:30 +00:00
parent 7e92fd3e57
commit e110febc86
4 changed files with 12 additions and 1 deletions

View File

@ -177,5 +177,6 @@
<file>icons/48x48/document-new.png</file>
<file>schema-10.sql</file>
<file>schema-11.sql</file>
<file>osd_background.png</file>
</qresource>
</RCC>

BIN
data/osd_background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -100,6 +100,7 @@ OSDPretty::OSDPretty(Mode mode, QWidget *parent)
shadow_edge_[i] = QPixmap::fromImage(shadow_edge.transformed(rotation));
shadow_corner_[i] = QPixmap::fromImage(shadow_corner.transformed(rotation));
}
background_ = QPixmap(":osd_background.png");
// Set the margins to allow for the drop shadow
QBoxLayout* l = static_cast<QBoxLayout*>(layout());
@ -178,12 +179,20 @@ void OSDPretty::paintEvent(QPaintEvent *) {
p.setOpacity(background_opacity_);
p.drawRoundedRect(box, kBorderRadius, kBorderRadius);
// Background pattern
QPainterPath background_path;
background_path.addRoundedRect(box, kBorderRadius, kBorderRadius);
p.setClipPath(background_path);
p.setOpacity(1.0);
p.drawPixmap(box.right() - background_.width(),
box.bottom() - background_.height(), background_);
p.setClipping(false);
// Gradient overlay
QLinearGradient gradient(0, 0, 0, height());
gradient.setColorAt(0, QColor(255, 255, 255, 130));
gradient.setColorAt(1, QColor(255, 255, 255, 50));
p.setBrush(gradient);
p.setOpacity(1.0);
p.drawRoundedRect(box, kBorderRadius, kBorderRadius);
// Box border

View File

@ -113,6 +113,7 @@ class OSDPretty : public QWidget {
// Cached pixmaps
QPixmap shadow_edge_[4];
QPixmap shadow_corner_[4];
QPixmap background_;
// For dragging the OSD
QPoint original_window_pos_;