/src/libtomahawk/widgets/HeaderLabel.cpp

http://github.com/tomahawk-player/tomahawk · 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. #include "HeaderLabel.h"
  19. #include <QPainter>
  20. #include "utils/Logger.h"
  21. #include "utils/TomahawkStyle.h"
  22. #include "utils/TomahawkUtilsGui.h"
  23. HeaderLabel::HeaderLabel( QWidget* parent )
  24. : ClickableLabel( parent )
  25. , m_parent( parent )
  26. {
  27. QFont f( font() );
  28. f.setBold( true );
  29. f.setPointSize( TomahawkUtils::defaultFontSize() );
  30. setFont( f );
  31. setFixedHeight( TomahawkUtils::defaultFontHeight() * 1.4 );
  32. setMouseTracking( true );
  33. }
  34. HeaderLabel::~HeaderLabel()
  35. {
  36. }
  37. QSize
  38. HeaderLabel::sizeHint() const
  39. {
  40. return QLabel::sizeHint();
  41. }
  42. void
  43. HeaderLabel::paintEvent( QPaintEvent* /* event */ )
  44. {
  45. QPainter p( this );
  46. QRect r = contentsRect();
  47. TomahawkStyle::horizontalHeader( &p, r );
  48. QTextOption to( alignment() | Qt::AlignVCenter );
  49. r.adjust( 8, 0, -8, 0 );
  50. p.setPen( TomahawkStyle::HEADER_TEXT );
  51. p.drawText( r, text(), to );
  52. }