mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Try out a background pixmap for the infobar. What do people think?
This commit is contained in:
BIN
data/images/playlist-header-tiled.png
Normal file
BIN
data/images/playlist-header-tiled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
@@ -135,6 +135,7 @@
|
|||||||
<file>data/images/rdio.png</file>
|
<file>data/images/rdio.png</file>
|
||||||
<file>data/images/grooveshark.png</file>
|
<file>data/images/grooveshark.png</file>
|
||||||
<file>data/images/lastfm-icon.png</file>
|
<file>data/images/lastfm-icon.png</file>
|
||||||
|
<file>data/images/playlist-header-tiled.png</file>
|
||||||
<file>data/sql/dbmigrate-27_to_28.sql</file>
|
<file>data/sql/dbmigrate-27_to_28.sql</file>
|
||||||
<file>data/images/process-stop.png</file>
|
<file>data/images/process-stop.png</file>
|
||||||
<file>data/icons/tomahawk-icon-128x128-grayscale.png</file>
|
<file>data/icons/tomahawk-icon-128x128-grayscale.png</file>
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
#include "utils/tomahawkutils.h"
|
#include "utils/tomahawkutils.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QPainter>
|
||||||
#include <widgets/querylabel.h>
|
#include <widgets/querylabel.h>
|
||||||
|
|
||||||
#define ANIMATION_TIME 400
|
#define ANIMATION_TIME 400
|
||||||
@@ -96,17 +98,13 @@ InfoBar::InfoBar( QWidget* parent )
|
|||||||
|
|
||||||
ui->horizontalLayout->addWidget( m_searchWidget );
|
ui->horizontalLayout->addWidget( m_searchWidget );
|
||||||
|
|
||||||
QLinearGradient gradient = QLinearGradient( QPoint( 0, 0 ), QPoint( 500, 200 ) ); //HACK
|
|
||||||
gradient.setColorAt( 0.0, QColor( 100, 100, 100 ) );
|
|
||||||
gradient.setColorAt( 0.8, QColor( 63, 63, 63 ) );
|
|
||||||
|
|
||||||
QPalette p = palette();
|
|
||||||
p.setBrush( QPalette::Window, QBrush( gradient ) );
|
|
||||||
setPalette( p );
|
|
||||||
setAutoFillBackground( true );
|
setAutoFillBackground( true );
|
||||||
|
|
||||||
setMinimumHeight( geometry().height() );
|
setMinimumHeight( geometry().height() );
|
||||||
setMaximumHeight( geometry().height() );
|
setMaximumHeight( geometry().height() );
|
||||||
|
|
||||||
|
createTile();
|
||||||
|
|
||||||
connect( ViewManager::instance(), SIGNAL( filterAvailable( bool ) ), SLOT( setFilterAvailable( bool ) ) );
|
connect( ViewManager::instance(), SIGNAL( filterAvailable( bool ) ), SLOT( setFilterAvailable( bool ) ) );
|
||||||
connect( ViewManager::instance(), SIGNAL( autoUpdateAvailable( bool ) ), SLOT( setAutoUpdateAvailable( bool ) ) );
|
connect( ViewManager::instance(), SIGNAL( autoUpdateAvailable( bool ) ), SLOT( setAutoUpdateAvailable( bool ) ) );
|
||||||
}
|
}
|
||||||
@@ -225,6 +223,63 @@ InfoBar::onFilterEdited()
|
|||||||
emit filterTextChanged( m_searchWidget->text() );
|
emit filterTextChanged( m_searchWidget->text() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoBar::createTile( int w )
|
||||||
|
{
|
||||||
|
QImage tile = QImage( RESPATH "images/playlist-header-tiled.png" );
|
||||||
|
|
||||||
|
if ( tile.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( tile.height() < height() )
|
||||||
|
{
|
||||||
|
// image must be at least as tall as we are
|
||||||
|
QImage taller( tile.width(), height(), QImage::Format_ARGB32_Premultiplied );
|
||||||
|
QPainter p( &taller );
|
||||||
|
int curY = 0;
|
||||||
|
while ( curY < taller.height() )
|
||||||
|
{
|
||||||
|
const int thisHeight = (curY + tile.height() > height()) ? height() - curY : tile.height();
|
||||||
|
p.drawImage( QRect( 0, curY, tile.width(), thisHeight ), tile, QRect( 0, 0, tile.width(), thisHeight ) );
|
||||||
|
curY += tile.height();
|
||||||
|
}
|
||||||
|
tile = taller;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bgTile = QPixmap( w, height() );
|
||||||
|
m_bgTile.fill( Qt::transparent );
|
||||||
|
|
||||||
|
int curWidth = 0;
|
||||||
|
QPainter p( &m_bgTile );
|
||||||
|
while ( curWidth < w )
|
||||||
|
{
|
||||||
|
const int thisWidth = (curWidth + tile.width() > w) ? w - curWidth : tile.width();
|
||||||
|
|
||||||
|
const QRect source( 0, 0, thisWidth, m_bgTile.height() );
|
||||||
|
const QRect dest( curWidth, 0, thisWidth, m_bgTile.height() );
|
||||||
|
p.drawImage( dest, tile, source );
|
||||||
|
curWidth += thisWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InfoBar::paintEvent( QPaintEvent* e )
|
||||||
|
{
|
||||||
|
if ( m_bgTile.isNull() || width() > m_bgTile.width() )
|
||||||
|
createTile( width() );
|
||||||
|
|
||||||
|
if ( m_bgTile.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
QPainter p( this );
|
||||||
|
|
||||||
|
// Truncate bg pixmap and paint into bg
|
||||||
|
p.drawPixmap( rect(), m_bgTile, rect() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoBar::changeEvent( QEvent* e )
|
InfoBar::changeEvent( QEvent* e )
|
||||||
{
|
{
|
||||||
|
@@ -64,14 +64,19 @@ signals:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent( QEvent* e );
|
void changeEvent( QEvent* e );
|
||||||
|
void paintEvent( QPaintEvent* e );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onFilterEdited();
|
void onFilterEdited();
|
||||||
void artistClicked();
|
void artistClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void createTile( int width = 2000 );
|
||||||
|
|
||||||
Ui::InfoBar* ui;
|
Ui::InfoBar* ui;
|
||||||
|
|
||||||
|
QPixmap m_bgTile;
|
||||||
|
|
||||||
QSearchField* m_searchWidget;
|
QSearchField* m_searchWidget;
|
||||||
QCheckBox* m_autoUpdate;
|
QCheckBox* m_autoUpdate;
|
||||||
QueryLabel* m_queryLabel;
|
QueryLabel* m_queryLabel;
|
||||||
|
Reference in New Issue
Block a user