/src/libtomahawk/widgets/HeaderLabel.cpp
C++ | 65 lines | 35 code | 13 blank | 17 comment | 0 complexity | a63606f026ec043d77de94f1b59d4448 MD5 | raw file
1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === 2 * 3 * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> 4 * 5 * Tomahawk is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * Tomahawk is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19#include "HeaderLabel.h" 20 21#include <QPainter> 22 23#include "utils/Logger.h" 24#include "utils/TomahawkStyle.h" 25#include "utils/TomahawkUtilsGui.h" 26 27 28HeaderLabel::HeaderLabel( QWidget* parent ) 29 : ClickableLabel( parent ) 30 , m_parent( parent ) 31{ 32 QFont f( font() ); 33 f.setBold( true ); 34 f.setPointSize( TomahawkUtils::defaultFontSize() ); 35 setFont( f ); 36 37 setFixedHeight( TomahawkUtils::defaultFontHeight() * 1.4 ); 38 setMouseTracking( true ); 39} 40 41 42HeaderLabel::~HeaderLabel() 43{ 44} 45 46 47QSize 48HeaderLabel::sizeHint() const 49{ 50 return QLabel::sizeHint(); 51} 52 53 54void 55HeaderLabel::paintEvent( QPaintEvent* /* event */ ) 56{ 57 QPainter p( this ); 58 QRect r = contentsRect(); 59 TomahawkStyle::horizontalHeader( &p, r ); 60 61 QTextOption to( alignment() | Qt::AlignVCenter ); 62 r.adjust( 8, 0, -8, 0 ); 63 p.setPen( TomahawkStyle::HEADER_TEXT ); 64 p.drawText( r, text(), to ); 65}