mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 14:46:33 +02:00
* New design for BasicHeader, soon to be obsolete.
This commit is contained in:
@@ -29,53 +29,52 @@
|
|||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QGraphicsDropShadowEffect>
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
BasicHeader::BasicHeader( QWidget* parent )
|
BasicHeader::BasicHeader( QWidget* parent )
|
||||||
: QWidget( parent )
|
: BackgroundWidget( parent )
|
||||||
{
|
{
|
||||||
QLayout* l = new QVBoxLayout;
|
setAutoFillBackground( false );
|
||||||
|
|
||||||
|
QVBoxLayout* l = new QVBoxLayout;
|
||||||
TomahawkUtils::unmarginLayout( l );
|
TomahawkUtils::unmarginLayout( l );
|
||||||
setLayout( l );
|
setLayout( l );
|
||||||
|
|
||||||
m_mainLayout = new QHBoxLayout;
|
m_mainLayout = new QHBoxLayout;
|
||||||
|
TomahawkUtils::unmarginLayout( m_mainLayout );
|
||||||
|
m_mainLayout->setContentsMargins( 32, 0, 32, 0 );
|
||||||
|
|
||||||
m_imageLabel = new QLabel( this );
|
m_imageLabel = new QLabel( this );
|
||||||
m_imageLabel->setMargin( 0 );
|
m_imageLabel->setMargin( 0 );
|
||||||
m_imageLabel->setFixedSize( TomahawkUtils::defaultIconSize().width() * 3,
|
m_imageLabel->setFixedSize( TomahawkUtils::defaultIconSize().width() * 3,
|
||||||
TomahawkUtils::defaultIconSize().height() * 3 );
|
TomahawkUtils::defaultIconSize().height() * 3 );
|
||||||
|
|
||||||
|
m_imageLabel->setVisible( false );
|
||||||
m_mainLayout->addWidget( m_imageLabel );
|
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_captionLabel = new ElidedLabel( this );
|
||||||
m_descriptionLabel = new ElidedLabel( this );
|
m_descriptionLabel = new ElidedLabel( this );
|
||||||
m_verticalLayout->addWidget( m_captionLabel );
|
m_descriptionLabel->setVisible( false );
|
||||||
m_verticalLayout->addWidget( m_descriptionLabel );
|
m_mainLayout->addWidget( m_captionLabel );
|
||||||
m_verticalLayout->addStretch();
|
// m_mainLayout->addWidget( m_descriptionLabel );
|
||||||
|
|
||||||
m_mainLayout->addSpacing( TomahawkUtils::defaultIconSize().width() / 4 );
|
// m_mainLayout->addSpacing( TomahawkUtils::defaultIconSize().width() / 4 );
|
||||||
m_mainLayout->setStretchFactor( m_verticalLayout, 2 );
|
// m_mainLayout->setStretchFactor( m_verticalLayout, 2 );
|
||||||
|
|
||||||
QPalette pal = palette();
|
QPalette pal = palette();
|
||||||
pal.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT );
|
pal.setColor( QPalette::Foreground, Qt::white );
|
||||||
pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND );
|
// pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND );
|
||||||
|
|
||||||
m_captionLabel->setPalette( pal );
|
m_captionLabel->setPalette( pal );
|
||||||
m_descriptionLabel->setPalette( pal );
|
m_descriptionLabel->setPalette( pal );
|
||||||
|
|
||||||
QFont font = m_captionLabel->font();
|
QFont font = m_captionLabel->font();
|
||||||
|
|
||||||
int captionFontSize = TomahawkUtils::defaultFontSize() + 6;
|
int captionFontSize = 16;
|
||||||
font.setPointSize( captionFontSize );
|
font.setPointSize( captionFontSize );
|
||||||
font.setBold( true );
|
font.setBold( true );
|
||||||
font.setFamily( "Titillium Web" );
|
|
||||||
|
|
||||||
m_captionLabel->setFont( font );
|
m_captionLabel->setFont( font );
|
||||||
m_captionLabel->setElideMode( Qt::ElideRight );
|
m_captionLabel->setElideMode( Qt::ElideRight );
|
||||||
@@ -93,43 +92,22 @@ BasicHeader::BasicHeader( QWidget* parent )
|
|||||||
m_descriptionLabel->setMinimumHeight( QFontMetrics( font ).height() + 2 * m_descriptionLabel->margin() );
|
m_descriptionLabel->setMinimumHeight( QFontMetrics( font ).height() + 2 * m_descriptionLabel->margin() );
|
||||||
m_descriptionLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
m_descriptionLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||||
|
|
||||||
/* QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
|
l->addSpacerItem( new QSpacerItem( 0, 80, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
|
||||||
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->addItem( m_mainLayout );
|
l->addItem( m_mainLayout );
|
||||||
l->addWidget( lineAbove );
|
l->addStretch();
|
||||||
l->addWidget( lineBelow );
|
|
||||||
|
|
||||||
TomahawkUtils::unmarginLayout( m_mainLayout );
|
|
||||||
|
|
||||||
// on 72dpi, 1px = 1pt
|
// on 72dpi, 1px = 1pt
|
||||||
// margins that should be around 8 4 8 4 on ~100dpi
|
// margins that should be around 8 4 8 4 on ~100dpi
|
||||||
int leftRightMargin = TomahawkUtils::defaultFontHeight() / 3;
|
int leftRightMargin = TomahawkUtils::defaultFontHeight() / 3;
|
||||||
int topBottomMargin = TomahawkUtils::defaultFontHeight() / 6;
|
int topBottomMargin = TomahawkUtils::defaultFontHeight() / 6;
|
||||||
|
|
||||||
m_mainLayout->setContentsMargins( leftRightMargin, topBottomMargin,
|
/* m_mainLayout->setContentsMargins( leftRightMargin, topBottomMargin, leftRightMargin, topBottomMargin );*/
|
||||||
leftRightMargin, topBottomMargin );
|
|
||||||
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
|
||||||
// top-margin + header + layout spacing + description + bottom-margin
|
// top-margin + header + layout spacing + description + bottom-margin
|
||||||
setFixedHeight( qMax( topBottomMargin + m_captionLabel->height() + TomahawkUtils::defaultIconSize().height() / 4 + m_descriptionLabel->height() + topBottomMargin,
|
/* setFixedHeight( qMax( topBottomMargin + m_captionLabel->height() + TomahawkUtils::defaultIconSize().height() / 4 + m_descriptionLabel->height() + topBottomMargin,
|
||||||
topBottomMargin + m_imageLabel->height() + topBottomMargin ) );
|
topBottomMargin + m_imageLabel->height() + topBottomMargin ) );*/
|
||||||
|
|
||||||
setAutoFillBackground( true );
|
setFixedHeight( 160 );
|
||||||
setPalette( pal );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -141,7 +119,7 @@ BasicHeader::~BasicHeader()
|
|||||||
void
|
void
|
||||||
BasicHeader::setCaption( const QString& s )
|
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 ) );
|
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 );*/
|
|
||||||
}
|
|
||||||
|
@@ -20,8 +20,7 @@
|
|||||||
#ifndef BASICHEADER_H
|
#ifndef BASICHEADER_H
|
||||||
#define BASICHEADER_H
|
#define BASICHEADER_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include "widgets/BackgroundWidget.h"
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
@@ -29,7 +28,7 @@ class ElidedLabel;
|
|||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
class QBoxLayout;
|
class QBoxLayout;
|
||||||
|
|
||||||
class DLLEXPORT BasicHeader : public QWidget
|
class DLLEXPORT BasicHeader : public BackgroundWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -42,14 +41,12 @@ public slots:
|
|||||||
virtual void setPixmap( const QPixmap& p );
|
virtual void setPixmap( const QPixmap& p );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent( QPaintEvent* event );
|
|
||||||
|
|
||||||
QLabel* m_imageLabel;
|
QLabel* m_imageLabel;
|
||||||
ElidedLabel* m_captionLabel;
|
ElidedLabel* m_captionLabel;
|
||||||
ElidedLabel* m_descriptionLabel;
|
ElidedLabel* m_descriptionLabel;
|
||||||
|
|
||||||
QBoxLayout* m_mainLayout;
|
QBoxLayout* m_mainLayout;
|
||||||
QBoxLayout* m_verticalLayout;
|
// QBoxLayout* m_verticalLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASICHEADER_H
|
#endif // BASICHEADER_H
|
||||||
|
Reference in New Issue
Block a user