1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2011, Casey Link <unnamedrambler@gmail.com>
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.
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.
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/>.
21
#include "utils/StyleHelper.h"
22
#include "utils/TomahawkUtilsGui.h"
23
#include "utils/Logger.h"
26
#include <QTextOption>
27
#include <QStylePainter>
28
#include <QStyleOptionComboBox>
31
ComboBox::ComboBox( QWidget* parent )
43
ComboBox::sizeHint() const
45
return QComboBox::sizeHint() + QSize( 8, 0 );
50
ComboBox::paintEvent( QPaintEvent* )
52
QStylePainter p( this );
53
p.setPen( palette().color( QPalette::Text ) );
54
QStyleOptionComboBox cb;
55
initStyleOption( &cb );
57
r.setHeight( TomahawkUtils::defaultFontHeight() + 8 );
59
StyleHelper::horizontalHeader( &p, r );
61
if ( cb.state & QStyle::State_MouseOver )
64
QRect highlightRect( r );
66
QSize hS( highlightRect.size() );
68
highlightRect.setSize( hS );
69
highlightRect.translate( 0, 2 );
70
p.setRenderHint( QPainter::Antialiasing );
71
p.setBrush( StyleHelper::headerHighlightColor() );
72
p.drawRoundedRect( highlightRect, 10.0, 10.0 );
77
QTextOption to( Qt::AlignVCenter );
78
r.adjust( 8, 0, -8, 0 );
79
p.setPen( Qt::white );
80
p.setBrush( StyleHelper::headerTextColor() );
81
p.drawText( r, cb.currentText, to );
83
bool reverse = cb.direction == Qt::RightToLeft;
84
int menuButtonWidth = 12;
85
int left = !reverse ? r.right() - menuButtonWidth : r.left();
86
int right = !reverse ? r.right() : r.left() + menuButtonWidth;
87
QRect arrowRect( ( left + right ) / 2 + ( reverse ? 6 : -6 ), r.center().y() - 3, 9, 9 ); //FIXME: no consts please
89
QStyleOption arrowOpt = cb;
90
arrowOpt.rect = arrowRect;
91
StyleHelper::drawArrow( QStyle::PE_IndicatorArrowDown, &p, &arrowOpt );