1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

* Make BasicHeader use our HeaderWidget. One widget to rule them all.

This commit is contained in:
Christian Muehlhaeuser
2014-08-27 18:41:05 +02:00
parent 7ba97c0065
commit 33e8718e97
4 changed files with 45 additions and 86 deletions

View File

@@ -51,7 +51,7 @@ FlexibleHeader::FlexibleHeader( FlexibleView* parent )
f.close(); f.close();
QHBoxLayout* outerModeLayout = new QHBoxLayout; QHBoxLayout* outerModeLayout = new QHBoxLayout;
m_mainLayout->addLayout( outerModeLayout ); ui->horizontalLayout->addLayout( outerModeLayout );
outerModeLayout->addSpacing( 156 ); outerModeLayout->addSpacing( 156 );
outerModeLayout->addStretch(); outerModeLayout->addStretch();

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012-2013, Teo Mrnjavac <teo@kde.org> * Copyright 2012-2013, Teo Mrnjavac <teo@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -35,77 +35,42 @@ using namespace Tomahawk;
BasicHeader::BasicHeader( QWidget* parent ) BasicHeader::BasicHeader( QWidget* parent )
: BackgroundWidget( parent ) : BackgroundWidget( parent )
, ui( new Ui::HeaderWidget )
{ {
setAutoFillBackground( false ); setAutoFillBackground( false );
ui->setupUi( this );
QVBoxLayout* l = new QVBoxLayout; {
TomahawkUtils::unmarginLayout( l ); QFont f = ui->captionLabel->font();
setLayout( l ); f.setBold( true );
f.setPointSize( TomahawkUtils::defaultFontSize() + 6 );
m_mainLayout = new QHBoxLayout; QPalette p = ui->captionLabel->palette();
TomahawkUtils::unmarginLayout( m_mainLayout ); p.setColor( QPalette::Foreground, Qt::white );
m_mainLayout->setContentsMargins( 32, 0, 32, 0 );
m_imageLabel = new QLabel( this ); ui->captionLabel->setFont( f );
m_imageLabel->setMargin( 0 ); ui->captionLabel->setPalette( p );
m_imageLabel->setFixedSize( TomahawkUtils::defaultIconSize().width() * 3,
TomahawkUtils::defaultIconSize().height() * 3 );
m_imageLabel->setVisible( false ); ui->anchor1Label->hide();
m_mainLayout->addWidget( m_imageLabel ); ui->anchor2Label->hide();
ui->anchor3Label->hide();
}
m_captionLabel = new ElidedLabel( this ); {
m_descriptionLabel = new ElidedLabel( this ); QFont f = ui->anchor1Label->font();
m_descriptionLabel->setVisible( false ); f.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
m_mainLayout->addWidget( m_captionLabel ); f.setBold( true );
// m_mainLayout->addWidget( m_descriptionLabel );
// m_mainLayout->addSpacing( TomahawkUtils::defaultIconSize().width() / 4 ); QPalette p = ui->captionLabel->palette();
// m_mainLayout->setStretchFactor( m_verticalLayout, 2 ); p.setColor( QPalette::Foreground, Qt::white );
QPalette pal = palette(); ui->anchor1Label->setFont( f );
pal.setColor( QPalette::Foreground, Qt::white ); ui->anchor1Label->setPalette( p );
// pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); ui->anchor2Label->setFont( f );
ui->anchor2Label->setPalette( p );
m_captionLabel->setPalette( pal ); ui->anchor3Label->setFont( f );
m_descriptionLabel->setPalette( pal ); ui->anchor3Label->setPalette( p );
}
QFont font = m_captionLabel->font();
int captionFontSize = 16;
font.setPointSize( captionFontSize );
font.setBold( true );
m_captionLabel->setFont( font );
m_captionLabel->setElideMode( Qt::ElideRight );
m_captionLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
m_captionLabel->setMargin( 2 );
m_captionLabel->setMinimumHeight( QFontMetrics( font ).height() + 2 * m_captionLabel->margin() );
int descriptionFontSize = TomahawkUtils::defaultFontSize() + 2;
font.setPointSize( descriptionFontSize );
font.setBold( false );
m_descriptionLabel->setFont( font );
m_descriptionLabel->setElideMode( Qt::ElideRight );
m_descriptionLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
m_descriptionLabel->setMargin( 2 );
m_descriptionLabel->setMinimumHeight( QFontMetrics( font ).height() + 2 * m_descriptionLabel->margin() );
m_descriptionLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
l->addSpacerItem( new QSpacerItem( 0, 80, QSizePolicy::Minimum, QSizePolicy::Fixed ) );
l->addItem( 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 );*/
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( 160 ); setFixedHeight( 160 );
} }
@@ -119,19 +84,19 @@ BasicHeader::~BasicHeader()
void void
BasicHeader::setCaption( const QString& s ) BasicHeader::setCaption( const QString& s )
{ {
m_captionLabel->setText( s.toUpper() ); ui->captionLabel->setText( s.toUpper() );
} }
void void
BasicHeader::setDescription( const QString& s ) BasicHeader::setDescription( const QString& s )
{ {
m_descriptionLabel->setText( s ); // m_descriptionLabel->setText( s );
} }
void void
BasicHeader::setPixmap( const QPixmap& p ) 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 ) );
} }

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012, Teo Mrnjavac <teo@kde.org> * Copyright 2012, Teo Mrnjavac <teo@kde.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -20,6 +20,8 @@
#ifndef BASICHEADER_H #ifndef BASICHEADER_H
#define BASICHEADER_H #define BASICHEADER_H
#include "ui_HeaderWidget.h"
#include "widgets/BackgroundWidget.h" #include "widgets/BackgroundWidget.h"
#include "DllMacro.h" #include "DllMacro.h"
@@ -35,18 +37,12 @@ public:
explicit BasicHeader( QWidget* parent = 0 ); explicit BasicHeader( QWidget* parent = 0 );
virtual ~BasicHeader(); virtual ~BasicHeader();
Ui::HeaderWidget* ui;
public slots: public slots:
virtual void setCaption( const QString& s ); virtual void setCaption( const QString& s );
virtual void setDescription( const QString& s ); virtual void setDescription( const QString& s );
virtual void setPixmap( const QPixmap& p ); virtual void setPixmap( const QPixmap& p );
protected:
QLabel* m_imageLabel;
ElidedLabel* m_captionLabel;
ElidedLabel* m_descriptionLabel;
QBoxLayout* m_mainLayout;
// QBoxLayout* m_verticalLayout;
}; };
#endif // BASICHEADER_H #endif // BASICHEADER_H

View File

@@ -31,21 +31,19 @@ ScriptCollectionHeader::ScriptCollectionHeader( QWidget* parent )
m_refreshButton->setFlat( true ); m_refreshButton->setFlat( true );
m_refreshButton->setStyleSheet( "QPushButton { border: 0px; background: transparent; }" ); m_refreshButton->setStyleSheet( "QPushButton { border: 0px; background: transparent; }" );
QHBoxLayout* descLayout = new QHBoxLayout; QHBoxLayout* descLayout = new QHBoxLayout;
m_mainLayout->insertLayout( m_mainLayout->indexOf( m_descriptionLabel ), ui->horizontalLayout->addLayout( descLayout );
descLayout ); // descLayout->addWidget( m_descriptionLabel );
descLayout->addWidget( m_descriptionLabel );
TomahawkUtils::unmarginLayout( descLayout ); TomahawkUtils::unmarginLayout( descLayout );
descLayout->addSpacing( m_descriptionLabel->fontMetrics().height() / 2 ); // descLayout->addSpacing( m_descriptionLabel->fontMetrics().height() / 2 );
descLayout->addWidget( m_refreshButton ); descLayout->addWidget( m_refreshButton );
descLayout->addStretch(); descLayout->addStretch();
m_refreshButton->setIcon( ImageRegistry::instance()->pixmap( RESPATH "images/refresh.svg", QSize( m_descriptionLabel->fontMetrics().height(), m_refreshButton->setIcon( ImageRegistry::instance()->pixmap( RESPATH "images/refresh.svg", QSize( ui->captionLabel->fontMetrics().height(),
m_descriptionLabel->fontMetrics().height() ), TomahawkUtils::DropShadow ) ); ui->captionLabel->fontMetrics().height() ), TomahawkUtils::DropShadow ) );
m_refreshButton->setFixedSize( m_descriptionLabel->fontMetrics().height() + m_descriptionLabel->margin() * 2, m_refreshButton->setFixedSize( ui->captionLabel->fontMetrics().height() + ui->captionLabel->margin() * 2,
m_descriptionLabel->fontMetrics().height() + m_descriptionLabel->margin() * 2 ); ui->captionLabel->fontMetrics().height() + ui->captionLabel->margin() * 2 );
connect( m_refreshButton, SIGNAL( clicked() ), connect( m_refreshButton, SIGNAL( clicked() ), SIGNAL( refreshClicked() ) );
this, SIGNAL( refreshClicked() ) );
m_refreshButton->hide(); m_refreshButton->hide();
m_refreshButton->setToolTip( tr( "Reload Collection" ) ); m_refreshButton->setToolTip( tr( "Reload Collection" ) );
} }