1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-06 07:19:51 +01:00

Add a background to the sidebar

This commit is contained in:
David Sansome 2010-10-02 12:09:06 +00:00
parent 8b3972f447
commit 5d54d517ab
5 changed files with 20 additions and 8 deletions

View File

@ -477,14 +477,10 @@ void FancyTabWidget::removeTab(int index)
m_tabBar->removeTab(index);
}
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
void FancyTabWidget::setBackgroundPixmap(const QPixmap& pixmap)
{
QPalette pal = m_tabBar->palette();
pal.setBrush(QPalette::Mid, brush);
m_tabBar->setPalette(pal);
pal = m_cornerWidgetContainer->palette();
pal.setBrush(QPalette::Mid, brush);
m_cornerWidgetContainer->setPalette(pal);
m_backgroundPixmap = pixmap;
update();
}
void FancyTabWidget::paintEvent(QPaintEvent *event)
@ -495,6 +491,19 @@ void FancyTabWidget::paintEvent(QPaintEvent *event)
QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0);
rect = style()->visualRect(layoutDirection(), geometry(), rect);
Utils::StyleHelper::verticalGradient(&painter, rect, rect);
if (!m_backgroundPixmap.isNull()) {
QRect pixmap_rect(m_backgroundPixmap.rect());
pixmap_rect.moveTo(rect.topLeft());
while (pixmap_rect.top() < rect.bottom()) {
QRect source_rect(pixmap_rect.intersected(rect));
source_rect.moveTo(0, 0);
painter.drawPixmap(pixmap_rect.topLeft(), m_backgroundPixmap, source_rect);
pixmap_rect.moveTop(pixmap_rect.bottom() - 10);
}
}
painter.setPen(Utils::StyleHelper::borderColor());
painter.drawLine(rect.topRight(), rect.bottomRight());

View File

@ -140,7 +140,7 @@ public:
void addTab(QWidget *tab, const QIcon &icon, const QString &label);
void addSpacer(int size = 40);
void removeTab(int index);
void setBackgroundBrush(const QBrush &brush);
void setBackgroundPixmap(const QPixmap& pixmap);
void addCornerWidget(QWidget *widget);
void insertCornerWidget(int pos, QWidget *widget);
int cornerWidgetCount() const;
@ -171,6 +171,7 @@ private:
QStackedLayout *m_modesStack;
QWidget *m_selectionWidget;
QStatusBar *m_statusBar;
QPixmap m_backgroundPixmap;
};
} // namespace Internal

View File

@ -264,5 +264,6 @@
<file>icons/32x32/wiimotedev.png</file>
<file>schema-17.sql</file>
<file>lyrics/ultimate_providers.xml</file>
<file>sidebar_background.png</file>
</qresource>
</RCC>

BIN
data/sidebar_background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -189,6 +189,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
AddFancyTab(new QWidget, IconLoader::Load("view-media-lyrics"), tr("Artist info"));
ui_->tabs->statusBar()->hide();
ui_->tabs->setBackgroundPixmap(QPixmap(":/sidebar_background.png"));
StyleHelper::setBaseColor(palette().color(QPalette::Highlight).darker());
track_position_timer_->setInterval(1000);