From e6c2498fc693b946e55e22937522a59a231ccc8b Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 29 Apr 2013 18:27:54 +0200 Subject: [PATCH] * No need to have const values being returned from methods. --- src/libtomahawk/context/ContextPage.cpp | 4 +-- src/libtomahawk/infobar/InfoBar.cpp | 9 +++--- src/libtomahawk/playlist/GridItemDelegate.cpp | 4 +-- src/libtomahawk/utils/TomahawkStyle.cpp | 32 ++----------------- src/libtomahawk/utils/TomahawkStyle.h | 25 ++++----------- src/libtomahawk/widgets/ComboBox.cpp | 4 +-- src/libtomahawk/widgets/HeaderLabel.cpp | 2 +- src/libtomahawk/widgets/ToggleButton.cpp | 8 ++--- 8 files changed, 25 insertions(+), 63 deletions(-) diff --git a/src/libtomahawk/context/ContextPage.cpp b/src/libtomahawk/context/ContextPage.cpp index 393df5bca..59435edb6 100644 --- a/src/libtomahawk/context/ContextPage.cpp +++ b/src/libtomahawk/context/ContextPage.cpp @@ -33,8 +33,8 @@ ContextProxyPage::paint( QPainter* painter, const QStyleOptionGraphicsItem* opti painter->save(); painter->setRenderHint( QPainter::Antialiasing, true ); - painter->setPen( TomahawkStyle::headerHighlightColor() ); - painter->setBrush( TomahawkStyle::headerHighlightColor() ); + painter->setPen( TomahawkStyle::HEADER_HIGHLIGHT ); + painter->setBrush( TomahawkStyle::HEADER_HIGHLIGHT ); painter->drawRoundedRect( option->rect, 4.0, 4.0 ); QFont f( font() ); diff --git a/src/libtomahawk/infobar/InfoBar.cpp b/src/libtomahawk/infobar/InfoBar.cpp index 9486b9096..18c489c54 100644 --- a/src/libtomahawk/infobar/InfoBar.cpp +++ b/src/libtomahawk/infobar/InfoBar.cpp @@ -26,12 +26,13 @@ #include #include +#include "Source.h" #include "ViewManager.h" #include "thirdparty/Qocoa/qsearchfield.h" +#include "widgets/QueryLabel.h" +#include "utils/TomahawkStyle.h" #include "utils/TomahawkUtilsGui.h" #include "utils/Logger.h" -#include "widgets/QueryLabel.h" -#include "Source.h" #define ANIMATION_TIME 400 #define IMAGE_HEIGHT 64 @@ -292,8 +293,8 @@ InfoBar::paintEvent( QPaintEvent* event ) QLinearGradient gradient( QPoint( 0, 0 ), QPoint( 0, 1 ) ); gradient.setCoordinateMode( QGradient::ObjectBoundingMode ); - gradient.setColorAt( 0.0, QColor( "#707070" ) ); - gradient.setColorAt( 1.0, QColor( "#25292c" ) ); + gradient.setColorAt( 0.0, TomahawkStyle::HEADER_LOWER ); + gradient.setColorAt( 1.0, TomahawkStyle::HEADER_LOWER ); painter.setBrush( gradient ); painter.fillRect( rect(), gradient ); diff --git a/src/libtomahawk/playlist/GridItemDelegate.cpp b/src/libtomahawk/playlist/GridItemDelegate.cpp index 5b0854df1..c25c368b2 100644 --- a/src/libtomahawk/playlist/GridItemDelegate.cpp +++ b/src/libtomahawk/playlist/GridItemDelegate.cpp @@ -157,8 +157,8 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, { painter->save(); - painter->setPen( QColor( "dddddd" ) ); - painter->setBrush( QColor( "#dddddd" ) ); + painter->setPen( TomahawkStyle::HOVER_GLOW ); + painter->setBrush( TomahawkStyle::HOVER_GLOW ); painter->setOpacity( opacity ); painter->drawRect( r ); diff --git a/src/libtomahawk/utils/TomahawkStyle.cpp b/src/libtomahawk/utils/TomahawkStyle.cpp index e5270fa1d..3bb1914a9 100644 --- a/src/libtomahawk/utils/TomahawkStyle.cpp +++ b/src/libtomahawk/utils/TomahawkStyle.cpp @@ -25,27 +25,6 @@ #include > -QColor -TomahawkStyle::headerUpperColor() -{ - return QColor( "#25292c" ); -} - - -QColor -TomahawkStyle::headerLowerColor() -{ - return QColor( "#707070" ); -} - - -QColor -TomahawkStyle::headerHighlightColor() -{ - return QColor( "#333" ); -} - - void TomahawkStyle::horizontalHeader( QPainter* painter, const QRect& r ) { @@ -57,8 +36,8 @@ TomahawkStyle::horizontalHeader( QPainter* painter, const QRect& r ) painter->fillRect( lowerHalf, TomahawkStyle::headerLowerColor() );*/ QLinearGradient gradient( QPoint( 0, 0 ), QPoint( 0, 1 ) ); gradient.setCoordinateMode( QGradient::ObjectBoundingMode ); - gradient.setColorAt( 0.0, TomahawkStyle::headerLowerColor() ); - gradient.setColorAt( 1.0, TomahawkStyle::headerUpperColor() ); + gradient.setColorAt( 0.0, TomahawkStyle::HEADER_LOWER ); + gradient.setColorAt( 1.0, TomahawkStyle::HEADER_UPPER ); painter->setBrush( gradient ); painter->fillRect( r, gradient ); @@ -80,13 +59,6 @@ TomahawkStyle::horizontalHeader( QPainter* painter, const QRect& r ) } -QColor -TomahawkStyle::headerTextColor() -{ - return QColor( "#eaeaea" ); -} - - /* * This implementation is from QWindowsStyle (Qt 4.2) * diff --git a/src/libtomahawk/utils/TomahawkStyle.h b/src/libtomahawk/utils/TomahawkStyle.h index 02d275312..bdb95bc70 100644 --- a/src/libtomahawk/utils/TomahawkStyle.h +++ b/src/libtomahawk/utils/TomahawkStyle.h @@ -28,23 +28,6 @@ namespace TomahawkStyle { - /** - * Our header BG is a two color gradient. This is the upper color. - */ - DLLEXPORT QColor headerUpperColor(); - /** - * Our header BG is a two color gradient. This is the lower color. - */ - DLLEXPORT QColor headerLowerColor(); - /** - * The color of text on a Header. - */ - DLLEXPORT QColor headerTextColor(); - /** - * The widget highlight color for headers - */ - DLLEXPORT QColor headerHighlightColor(); - /** * Draws a header background on a painter with the specified rectangle */ @@ -61,11 +44,17 @@ namespace TomahawkStyle static const QColor BORDER_LINE = QColor( "#8c8c8c" ); static const QColor POPUP_BACKGROUND = QColor( "#ffffff" ); static const QColor GROUP_HEADER = QColor( "#637180" ); + static const QColor HOVER_GLOW = QColor( "#dddddd" ); + static const QColor NOW_PLAYING_ITEM = QColor( "#962c26" ); static const QColor NOW_PLAYING_ITEM_TEXT = QColor( "#ffffff" ); static const QColor SELECTION_BACKGROUND = QColor( "#962c26" ); static const QColor SELECTION_FOREGROUND = QColor( "#ffffff" ); - static const QColor HEADER = QColor( "#ffffff" ); + + static const QColor HEADER_UPPER = QColor( "#25292c" ); + static const QColor HEADER_LOWER = QColor( "#707070" ); + static const QColor HEADER_TEXT = QColor( "#eaeaea" ); + static const QColor HEADER_HIGHLIGHT = QColor( "#333" ); static const int POPUP_ROUNDING_RADIUS = 6; static const float POPUP_OPACITY = 0.96; diff --git a/src/libtomahawk/widgets/ComboBox.cpp b/src/libtomahawk/widgets/ComboBox.cpp index 81f6d8638..1bdf79ae7 100644 --- a/src/libtomahawk/widgets/ComboBox.cpp +++ b/src/libtomahawk/widgets/ComboBox.cpp @@ -68,7 +68,7 @@ ComboBox::paintEvent( QPaintEvent* ) highlightRect.setSize( hS ); highlightRect.translate( 0, 2 ); p.setRenderHint( QPainter::Antialiasing ); - p.setBrush( TomahawkStyle::headerHighlightColor() ); + p.setBrush( TomahawkStyle::HEADER_HIGHLIGHT ); p.drawRoundedRect( highlightRect, 10.0, 10.0 ); p.restore(); } @@ -77,7 +77,7 @@ ComboBox::paintEvent( QPaintEvent* ) QTextOption to( Qt::AlignVCenter ); r.adjust( 8, 0, -8, 0 ); p.setPen( Qt::white ); - p.setBrush( TomahawkStyle::headerTextColor() ); + p.setBrush( TomahawkStyle::HEADER_TEXT ); p.drawText( r, cb.currentText, to ); bool reverse = cb.direction == Qt::RightToLeft; diff --git a/src/libtomahawk/widgets/HeaderLabel.cpp b/src/libtomahawk/widgets/HeaderLabel.cpp index 7a0e871af..2e3a22561 100644 --- a/src/libtomahawk/widgets/HeaderLabel.cpp +++ b/src/libtomahawk/widgets/HeaderLabel.cpp @@ -107,6 +107,6 @@ HeaderLabel::paintEvent( QPaintEvent* /* event */ ) QTextOption to( alignment() | Qt::AlignVCenter ); r.adjust( 8, 0, -8, 0 ); - p.setPen( TomahawkStyle::headerTextColor() ); + p.setPen( TomahawkStyle::HEADER_TEXT ); p.drawText( r, text(), to ); } diff --git a/src/libtomahawk/widgets/ToggleButton.cpp b/src/libtomahawk/widgets/ToggleButton.cpp index 1f913c6d3..b75e7c6a1 100644 --- a/src/libtomahawk/widgets/ToggleButton.cpp +++ b/src/libtomahawk/widgets/ToggleButton.cpp @@ -89,15 +89,15 @@ ToggleButton::paintEvent( QPaintEvent* event ) if ( isChecked() ) { - p.setBrush( TomahawkStyle::headerHighlightColor() ); + p.setBrush( TomahawkStyle::HEADER_HIGHLIGHT ); } else if ( false ) { - p.setBrush( TomahawkStyle::headerLowerColor() ); + p.setBrush( TomahawkStyle::HEADER_LOWER ); } else { - p.setBrush( TomahawkStyle::headerUpperColor() ); + p.setBrush( TomahawkStyle::HEADER_UPPER ); } p.drawRoundedRect( highlightRect, 4.0, 4.0 ); @@ -105,7 +105,7 @@ ToggleButton::paintEvent( QPaintEvent* event ) QTextOption to( Qt::AlignCenter ); r.adjust( 8, 0, -8, 0 ); - p.setBrush( TomahawkStyle::headerTextColor() ); + p.setBrush( TomahawkStyle::HEADER_TEXT ); p.drawText( r, text(), to ); p.restore();