mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 00:24:12 +02:00
* Make BasicHeader use our HeaderWidget. One widget to rule them all.
This commit is contained in:
@@ -51,7 +51,7 @@ FlexibleHeader::FlexibleHeader( FlexibleView* parent )
|
||||
f.close();
|
||||
|
||||
QHBoxLayout* outerModeLayout = new QHBoxLayout;
|
||||
m_mainLayout->addLayout( outerModeLayout );
|
||||
ui->horizontalLayout->addLayout( outerModeLayout );
|
||||
outerModeLayout->addSpacing( 156 );
|
||||
outerModeLayout->addStretch();
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === 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>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -35,77 +35,42 @@ using namespace Tomahawk;
|
||||
|
||||
BasicHeader::BasicHeader( QWidget* parent )
|
||||
: BackgroundWidget( parent )
|
||||
, ui( new Ui::HeaderWidget )
|
||||
{
|
||||
setAutoFillBackground( false );
|
||||
ui->setupUi( this );
|
||||
|
||||
QVBoxLayout* l = new QVBoxLayout;
|
||||
TomahawkUtils::unmarginLayout( l );
|
||||
setLayout( l );
|
||||
{
|
||||
QFont f = ui->captionLabel->font();
|
||||
f.setBold( true );
|
||||
f.setPointSize( TomahawkUtils::defaultFontSize() + 6 );
|
||||
|
||||
m_mainLayout = new QHBoxLayout;
|
||||
TomahawkUtils::unmarginLayout( m_mainLayout );
|
||||
m_mainLayout->setContentsMargins( 32, 0, 32, 0 );
|
||||
QPalette p = ui->captionLabel->palette();
|
||||
p.setColor( QPalette::Foreground, Qt::white );
|
||||
|
||||
m_imageLabel = new QLabel( this );
|
||||
m_imageLabel->setMargin( 0 );
|
||||
m_imageLabel->setFixedSize( TomahawkUtils::defaultIconSize().width() * 3,
|
||||
TomahawkUtils::defaultIconSize().height() * 3 );
|
||||
ui->captionLabel->setFont( f );
|
||||
ui->captionLabel->setPalette( p );
|
||||
|
||||
m_imageLabel->setVisible( false );
|
||||
m_mainLayout->addWidget( m_imageLabel );
|
||||
ui->anchor1Label->hide();
|
||||
ui->anchor2Label->hide();
|
||||
ui->anchor3Label->hide();
|
||||
}
|
||||
|
||||
m_captionLabel = new ElidedLabel( this );
|
||||
m_descriptionLabel = new ElidedLabel( this );
|
||||
m_descriptionLabel->setVisible( false );
|
||||
m_mainLayout->addWidget( m_captionLabel );
|
||||
// m_mainLayout->addWidget( m_descriptionLabel );
|
||||
{
|
||||
QFont f = ui->anchor1Label->font();
|
||||
f.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
|
||||
f.setBold( true );
|
||||
|
||||
// m_mainLayout->addSpacing( TomahawkUtils::defaultIconSize().width() / 4 );
|
||||
// m_mainLayout->setStretchFactor( m_verticalLayout, 2 );
|
||||
QPalette p = ui->captionLabel->palette();
|
||||
p.setColor( QPalette::Foreground, Qt::white );
|
||||
|
||||
QPalette pal = palette();
|
||||
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 = 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 ) );*/
|
||||
ui->anchor1Label->setFont( f );
|
||||
ui->anchor1Label->setPalette( p );
|
||||
ui->anchor2Label->setFont( f );
|
||||
ui->anchor2Label->setPalette( p );
|
||||
ui->anchor3Label->setFont( f );
|
||||
ui->anchor3Label->setPalette( p );
|
||||
}
|
||||
|
||||
setFixedHeight( 160 );
|
||||
}
|
||||
@@ -119,19 +84,19 @@ BasicHeader::~BasicHeader()
|
||||
void
|
||||
BasicHeader::setCaption( const QString& s )
|
||||
{
|
||||
m_captionLabel->setText( s.toUpper() );
|
||||
ui->captionLabel->setText( s.toUpper() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BasicHeader::setDescription( const QString& s )
|
||||
{
|
||||
m_descriptionLabel->setText( s );
|
||||
// m_descriptionLabel->setText( s );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
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 ) );
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === 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>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef BASICHEADER_H
|
||||
#define BASICHEADER_H
|
||||
|
||||
#include "ui_HeaderWidget.h"
|
||||
|
||||
#include "widgets/BackgroundWidget.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
@@ -35,18 +37,12 @@ public:
|
||||
explicit BasicHeader( QWidget* parent = 0 );
|
||||
virtual ~BasicHeader();
|
||||
|
||||
Ui::HeaderWidget* ui;
|
||||
|
||||
public slots:
|
||||
virtual void setCaption( const QString& s );
|
||||
virtual void setDescription( const QString& s );
|
||||
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
|
||||
|
@@ -31,21 +31,19 @@ ScriptCollectionHeader::ScriptCollectionHeader( QWidget* parent )
|
||||
m_refreshButton->setFlat( true );
|
||||
m_refreshButton->setStyleSheet( "QPushButton { border: 0px; background: transparent; }" );
|
||||
QHBoxLayout* descLayout = new QHBoxLayout;
|
||||
m_mainLayout->insertLayout( m_mainLayout->indexOf( m_descriptionLabel ),
|
||||
descLayout );
|
||||
descLayout->addWidget( m_descriptionLabel );
|
||||
ui->horizontalLayout->addLayout( descLayout );
|
||||
// descLayout->addWidget( m_descriptionLabel );
|
||||
TomahawkUtils::unmarginLayout( descLayout );
|
||||
descLayout->addSpacing( m_descriptionLabel->fontMetrics().height() / 2 );
|
||||
// descLayout->addSpacing( m_descriptionLabel->fontMetrics().height() / 2 );
|
||||
descLayout->addWidget( m_refreshButton );
|
||||
descLayout->addStretch();
|
||||
|
||||
m_refreshButton->setIcon( ImageRegistry::instance()->pixmap( RESPATH "images/refresh.svg", QSize( m_descriptionLabel->fontMetrics().height(),
|
||||
m_descriptionLabel->fontMetrics().height() ), TomahawkUtils::DropShadow ) );
|
||||
m_refreshButton->setFixedSize( m_descriptionLabel->fontMetrics().height() + m_descriptionLabel->margin() * 2,
|
||||
m_descriptionLabel->fontMetrics().height() + m_descriptionLabel->margin() * 2 );
|
||||
m_refreshButton->setIcon( ImageRegistry::instance()->pixmap( RESPATH "images/refresh.svg", QSize( ui->captionLabel->fontMetrics().height(),
|
||||
ui->captionLabel->fontMetrics().height() ), TomahawkUtils::DropShadow ) );
|
||||
m_refreshButton->setFixedSize( ui->captionLabel->fontMetrics().height() + ui->captionLabel->margin() * 2,
|
||||
ui->captionLabel->fontMetrics().height() + ui->captionLabel->margin() * 2 );
|
||||
|
||||
connect( m_refreshButton, SIGNAL( clicked() ),
|
||||
this, SIGNAL( refreshClicked() ) );
|
||||
connect( m_refreshButton, SIGNAL( clicked() ), SIGNAL( refreshClicked() ) );
|
||||
m_refreshButton->hide();
|
||||
m_refreshButton->setToolTip( tr( "Reload Collection" ) );
|
||||
}
|
||||
|
Reference in New Issue
Block a user