diff --git a/src/libtomahawk/widgets/BasicHeader.cpp b/src/libtomahawk/widgets/BasicHeader.cpp index 547a2369c..00bfa4cac 100644 --- a/src/libtomahawk/widgets/BasicHeader.cpp +++ b/src/libtomahawk/widgets/BasicHeader.cpp @@ -29,54 +29,53 @@ #include #include #include -#include using namespace Tomahawk; BasicHeader::BasicHeader( QWidget* parent ) - : QWidget( parent ) + : BackgroundWidget( parent ) { - QLayout* l = new QVBoxLayout; + setAutoFillBackground( false ); + + QVBoxLayout* l = new QVBoxLayout; TomahawkUtils::unmarginLayout( l ); setLayout( l ); m_mainLayout = new QHBoxLayout; + TomahawkUtils::unmarginLayout( m_mainLayout ); + m_mainLayout->setContentsMargins( 32, 0, 32, 0 ); m_imageLabel = new QLabel( this ); m_imageLabel->setMargin( 0 ); m_imageLabel->setFixedSize( TomahawkUtils::defaultIconSize().width() * 3, TomahawkUtils::defaultIconSize().height() * 3 ); + m_imageLabel->setVisible( false ); m_mainLayout->addWidget( m_imageLabel ); - m_mainLayout->addSpacing( TomahawkUtils::defaultIconSize().width() / 4 ); - - m_verticalLayout = new QVBoxLayout; - m_mainLayout->addLayout( m_verticalLayout ); m_captionLabel = new ElidedLabel( this ); m_descriptionLabel = new ElidedLabel( this ); - m_verticalLayout->addWidget( m_captionLabel ); - m_verticalLayout->addWidget( m_descriptionLabel ); - m_verticalLayout->addStretch(); + m_descriptionLabel->setVisible( false ); + m_mainLayout->addWidget( m_captionLabel ); +// m_mainLayout->addWidget( m_descriptionLabel ); - m_mainLayout->addSpacing( TomahawkUtils::defaultIconSize().width() / 4 ); - m_mainLayout->setStretchFactor( m_verticalLayout, 2 ); +// m_mainLayout->addSpacing( TomahawkUtils::defaultIconSize().width() / 4 ); +// m_mainLayout->setStretchFactor( m_verticalLayout, 2 ); QPalette pal = palette(); - pal.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT ); - pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); + pal.setColor( QPalette::Foreground, Qt::white ); +// pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); m_captionLabel->setPalette( pal ); m_descriptionLabel->setPalette( pal ); QFont font = m_captionLabel->font(); - - int captionFontSize = TomahawkUtils::defaultFontSize() + 6; + + int captionFontSize = 16; font.setPointSize( captionFontSize ); font.setBold( true ); - font.setFamily( "Titillium Web" ); - + m_captionLabel->setFont( font ); m_captionLabel->setElideMode( Qt::ElideRight ); m_captionLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft ); @@ -93,43 +92,22 @@ BasicHeader::BasicHeader( QWidget* parent ) m_descriptionLabel->setMinimumHeight( QFontMetrics( font ).height() + 2 * m_descriptionLabel->margin() ); m_descriptionLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); -/* QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); - effect->setBlurRadius( 4 ); - effect->setXOffset( 0 ); - effect->setYOffset( 0 ); - effect->setColor( Qt::white ); - m_captionLabel->setGraphicsEffect( effect );*/ -// m_descriptionLabel->setGraphicsEffect( effect ); - - QFrame* lineAbove = new QFrame( this ); - lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) ); - lineAbove->setFrameShape( QFrame::HLine ); - lineAbove->setMaximumHeight( 1 ); - QFrame* lineBelow = new QFrame( this ); - lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) ); - lineBelow->setFrameShape( QFrame::HLine ); - lineBelow->setMaximumHeight( 1 ); - + l->addSpacerItem( new QSpacerItem( 0, 80, QSizePolicy::Minimum, QSizePolicy::Fixed ) ); l->addItem( m_mainLayout ); - l->addWidget( lineAbove ); - l->addWidget( lineBelow ); - - TomahawkUtils::unmarginLayout( m_mainLayout ); + l->addStretch(); // on 72dpi, 1px = 1pt // margins that should be around 8 4 8 4 on ~100dpi int leftRightMargin = TomahawkUtils::defaultFontHeight() / 3; int topBottomMargin = TomahawkUtils::defaultFontHeight() / 6; - m_mainLayout->setContentsMargins( leftRightMargin, topBottomMargin, - leftRightMargin, topBottomMargin ); +/* m_mainLayout->setContentsMargins( leftRightMargin, topBottomMargin, leftRightMargin, topBottomMargin );*/ setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); // top-margin + header + layout spacing + description + bottom-margin - setFixedHeight( qMax( topBottomMargin + m_captionLabel->height() + TomahawkUtils::defaultIconSize().height() / 4 + m_descriptionLabel->height() + topBottomMargin, - topBottomMargin + m_imageLabel->height() + topBottomMargin ) ); +/* setFixedHeight( qMax( topBottomMargin + m_captionLabel->height() + TomahawkUtils::defaultIconSize().height() / 4 + m_descriptionLabel->height() + topBottomMargin, + topBottomMargin + m_imageLabel->height() + topBottomMargin ) );*/ - setAutoFillBackground( true ); - setPalette( pal ); + setFixedHeight( 160 ); } @@ -141,7 +119,7 @@ BasicHeader::~BasicHeader() void BasicHeader::setCaption( const QString& s ) { - m_captionLabel->setText( s ); + m_captionLabel->setText( s.toUpper() ); } @@ -157,21 +135,3 @@ BasicHeader::setPixmap( const QPixmap& p ) { m_imageLabel->setPixmap( p.scaledToHeight( m_imageLabel->height(), Qt::SmoothTransformation ) ); } - - -void -BasicHeader::paintEvent( QPaintEvent* event ) -{ - QWidget::paintEvent( event ); - -/* QPainter painter( this ); - painter.setRenderHint( QPainter::Antialiasing ); - - QLinearGradient gradient( QPoint( 0, 0 ), QPoint( 0, 1 ) ); - gradient.setCoordinateMode( QGradient::ObjectBoundingMode ); - gradient.setColorAt( 0.0, TomahawkStyle::HEADER_LOWER ); - gradient.setColorAt( 1.0, TomahawkStyle::HEADER_UPPER ); - - painter.setBrush( gradient ); - painter.fillRect( rect(), gradient );*/ -} diff --git a/src/libtomahawk/widgets/BasicHeader.h b/src/libtomahawk/widgets/BasicHeader.h index 7fc990bd6..42ebb723f 100644 --- a/src/libtomahawk/widgets/BasicHeader.h +++ b/src/libtomahawk/widgets/BasicHeader.h @@ -20,8 +20,7 @@ #ifndef BASICHEADER_H #define BASICHEADER_H -#include - +#include "widgets/BackgroundWidget.h" #include "DllMacro.h" class QLabel; @@ -29,7 +28,7 @@ class ElidedLabel; class QPaintEvent; class QBoxLayout; -class DLLEXPORT BasicHeader : public QWidget +class DLLEXPORT BasicHeader : public BackgroundWidget { Q_OBJECT public: @@ -42,14 +41,12 @@ public slots: virtual void setPixmap( const QPixmap& p ); protected: - virtual void paintEvent( QPaintEvent* event ); - QLabel* m_imageLabel; ElidedLabel* m_captionLabel; ElidedLabel* m_descriptionLabel; QBoxLayout* m_mainLayout; - QBoxLayout* m_verticalLayout; +// QBoxLayout* m_verticalLayout; }; #endif // BASICHEADER_H