1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-24 09:49:42 +01:00

Moved some colors and constants for popup widgets to TomahawkUtilsGui.

There are probably better ways to do this. Suggestions are welcome.
This aims to make it easier to keep the popup dialogs consistent even
though the code gets a little more verbose.
This commit is contained in:
Teo Mrnjavac 2012-10-20 23:28:13 +02:00
parent 83e872e00f
commit 5533019a65
9 changed files with 40 additions and 26 deletions

View File

@ -29,8 +29,6 @@
#include "utils/Logger.h"
#include "Source.h"
#define CORNER_ROUNDNESS 6.0
#define OPACITY 0.96
#define ARROW_HEIGHT 6
@ -68,7 +66,7 @@ SocialWidget::SocialWidget( QWidget* parent )
ui->buttonBox->button( QDialogButtonBox::Ok )->setIcon( QIcon( RESPATH "images/ok.png" ) );
ui->buttonBox->button( QDialogButtonBox::Cancel )->setIcon( QIcon( RESPATH "images/cancel.png" ) );
ui->textEdit->setStyleSheet( "border: 1px solid #8c8c8c;" );
ui->textEdit->setStyleSheet( "border: 1px solid " + TomahawkUtils::Colors::BORDER_LINE.name() );
m_parent->installEventFilter( this );
@ -142,7 +140,7 @@ SocialWidget::paintEvent( QPaintEvent* event )
QPainterPath outline;
QRect r = contentsRect();
outline.addRoundedRect( r, CORNER_ROUNDNESS, CORNER_ROUNDNESS );
outline.addRoundedRect( r, TomahawkUtils::POPUP_ROUNDING_RADIUS, TomahawkUtils::POPUP_ROUNDING_RADIUS );
outline.moveTo( r.right() - ARROW_HEIGHT * 2, r.bottom()+1 );
outline.lineTo( r.right() - ARROW_HEIGHT * 3, r.bottom()+1 + ARROW_HEIGHT );
outline.lineTo( r.right() - ARROW_HEIGHT * 4, r.bottom()+1 );
@ -151,13 +149,13 @@ SocialWidget::paintEvent( QPaintEvent* event )
p.setRenderHint( QPainter::Antialiasing );
p.setBackgroundMode( Qt::TransparentMode );
QPen pen( QColor( 0x8c, 0x8c, 0x8c ) );
QPen pen( TomahawkUtils::Colors::BORDER_LINE );
pen.setWidth( 2 );
p.setPen( pen );
p.drawPath( outline );
p.setOpacity( OPACITY );
p.fillPath( outline, QColor( "#FFFFFF" ) );
p.setOpacity( TomahawkUtils::POPUP_OPACITY );
p.fillPath( outline, TomahawkUtils::Colors::POPUP_BACKGROUND );
QWidget::paintEvent( event );
return;

View File

@ -25,6 +25,7 @@
#include <QWidget>
#include "utils/Logger.h"
#include "utils/TomahawkUtilsGui.h"
#define ARROW_WIDTH 7
#define ARROW_HEIGHT 7
@ -88,7 +89,7 @@ ProxyStyle::drawControl( ControlElement ce, const QStyleOption* opt, QPainter* p
const QSplitter* splitter = qobject_cast< const QSplitter* >( w );
if ( !splitter->sizes().contains( 0 ) )
{
p->setPen( QColor( 0x8c, 0x8c, 0x8c ) );
p->setPen( TomahawkUtils::Colors::BORDER_LINE );
// We must special-case this because of the AnimatedSplitterHandle which has a
// SizeHint of 0,0.
if( splitter->orientation() == Qt::Vertical )

View File

@ -73,6 +73,16 @@ namespace TomahawkUtils
DLLEXPORT QPixmap createTiledPixmap( int width, int height, const QImage& src );
DLLEXPORT QPixmap addDropShadow( const QPixmap& sourceImage, const QSize& targetSize );
namespace Colors
{
static const QColor BORDER_LINE = QColor( "#8c8c8c" );
static const QColor POPUP_BACKGROUND = QColor( "#ffffff" );
static const QColor GROUP_HEADER = QColor( "#637180" );
}
static const int POPUP_ROUNDING_RADIUS = 6;
static const float POPUP_OPACITY = 0.96;
}
#endif // TOMAHAWKUTILSGUI_H

View File

@ -56,7 +56,7 @@ SourceTreePopupDialog::SourceTreePopupDialog()
m_title = new QLabel( this );
QFont titleFont = m_title->font();
titleFont.setBold( true );
m_title->setStyleSheet( "color: rgb( 99, 113, 128 );" );
m_title->setStyleSheet( "color: " + TomahawkUtils::Colors::GROUP_HEADER.name() );
titleFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
m_title->setFont( titleFont );
m_title->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
@ -81,7 +81,8 @@ SourceTreePopupDialog::SourceTreePopupDialog()
m_separatorLine = new QWidget( this );
m_separatorLine->setFixedHeight( 1 );
m_separatorLine->setContentsMargins( 0, 0, 0, 0 );
m_separatorLine->setStyleSheet( "QWidget { border-top: 1px solid black; }" );
m_separatorLine->setStyleSheet( "QWidget { border-top: 1px solid " +
TomahawkUtils::Colors::BORDER_LINE.name() + "; }" );
m_layout->addWidget( m_separatorLine );
m_layout->addWidget( m_label );
m_layout->addWidget( m_buttons );
@ -174,7 +175,7 @@ SourceTreePopupDialog::paintEvent( QPaintEvent* event )
{
// Constants for painting
const int leftTriangleWidth = 12;
const int cornerRounding = 6;
const int cornerRounding = TomahawkUtils::POPUP_ROUNDING_RADIUS;
const int leftEdgeOffset = 2 /*margin*/ + leftTriangleWidth / 2;
const QRect brect = rect().adjusted( 2, 3, -2, -3 );
@ -195,7 +196,7 @@ SourceTreePopupDialog::paintEvent( QPaintEvent* event )
p.setRenderHint( QPainter::Antialiasing );
QPen pen( QColor( 0x8c, 0x8c, 0x8c ) );
QPen pen( TomahawkUtils::Colors::BORDER_LINE );
pen.setWidth( 2 );
p.setPen( pen );
p.drawPath( outline );
@ -204,8 +205,8 @@ SourceTreePopupDialog::paintEvent( QPaintEvent* event )
p.setOpacity( 0.93 );
p.fillPath( outline, QColor( "#D6E3F1" ) );
#else
p.setOpacity( 0.96 );
p.fillPath( outline, QColor( "#FFFFFF" ) );
p.setOpacity( TomahawkUtils::POPUP_OPACITY );
p.fillPath( outline, TomahawkUtils::Colors::POPUP_BACKGROUND );
#endif
#ifdef QT_MAC_USE_COCOA

View File

@ -294,7 +294,7 @@ SourceDelegate::paintCategory( QPainter* painter, const QStyleOptionViewItem& op
painter->setPen( Qt::white );
painter->drawText( option.rect.translated( 4, 1 ), index.data().toString().toUpper(), to );
painter->setPen( QColor( 99, 113, 128 ) );
painter->setPen( TomahawkUtils::Colors::GROUP_HEADER );
painter->drawText( option.rect.translated( 4, 0 ), index.data().toString().toUpper(), to );
if ( option.state & QStyle::State_MouseOver )
@ -311,7 +311,7 @@ SourceDelegate::paintCategory( QPainter* painter, const QStyleOptionViewItem& op
// draw close icon
painter->setPen( Qt::white );
painter->drawText( option.rect.translated( -4, 1 ), text, to );
painter->setPen( QColor( 99, 113, 128 ) );
painter->setPen( TomahawkUtils::Colors::GROUP_HEADER );
painter->drawText( option.rect.translated( -4, 0 ), text, to );
}
@ -338,7 +338,7 @@ SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& optio
painter->setPen( Qt::white );
painter->drawText( option.rect.translated( 4, 1 ), index.data().toString().toUpper(), to );
painter->setPen( QColor( 99, 113, 128 ) );
painter->setPen( TomahawkUtils::Colors::GROUP_HEADER );
painter->drawText( option.rect.translated( 4, 0 ), index.data().toString().toUpper(), to );
if ( option.state & QStyle::State_MouseOver )
@ -353,7 +353,7 @@ SourceDelegate::paintGroup( QPainter* painter, const QStyleOptionViewItem& optio
// draw close icon
painter->setPen( Qt::white );
painter->drawText( option.rect.translated( -4, 1 ), text, to );
painter->setPen( QColor( 99, 113, 128 ) );
painter->setPen( TomahawkUtils::Colors::GROUP_HEADER );
painter->drawText( option.rect.translated( -4, 0 ), text, to );
}

View File

@ -52,14 +52,15 @@ AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget*
QWidget* separatorLine = new QWidget( this );
separatorLine->setFixedHeight( 1 );
separatorLine->setContentsMargins( 0, 0, 0, 0 );
separatorLine->setStyleSheet( "QWidget { border-top: 1px solid rgb( 140, 140, 140 ); }" ); //from ProxyStyle
separatorLine->setStyleSheet( "QWidget { border-top: 1px solid " +
TomahawkUtils::Colors::BORDER_LINE.name() + "; }" ); //from ProxyStyle
mainLayout->insertWidget( 0, separatorLine );
mainLayout->addSpacing( 6 );
QLabel *connectionsLabel = new QLabel( tr( "Connections" ).toUpper(), this );
QFont clFont = connectionsLabel->font();
clFont.setBold( true );
connectionsLabel->setStyleSheet( "color: rgb( 99, 113, 128 );" );
connectionsLabel->setStyleSheet( "color: " + TomahawkUtils::Colors::GROUP_HEADER.name() );
clFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 );
connectionsLabel->setFont( clFont );
connectionsLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );

View File

@ -97,7 +97,7 @@ AccountWidget::AccountWidget( QWidget* parent )
m_inviteContainer = new UnstyledFrame( this );
vLayout->addWidget( m_inviteContainer, 1, 0 );
m_inviteContainer->setFrameColor( QColor( 0x8c, 0x8c, 0x8c ) ); //from ProxyStyle
m_inviteContainer->setFrameColor( TomahawkUtils::Colors::BORDER_LINE );
m_inviteContainer->setMinimumWidth( m_inviteContainer->logicalDpiX() * 2 );
m_inviteContainer->setContentsMargins( 1, 1, 1, 2 );
m_inviteContainer->setAttribute( Qt::WA_TranslucentBackground, false );

View File

@ -19,6 +19,8 @@
#include "AccountsPopupWidget.h"
#include "utils/TomahawkUtilsGui.h"
#include <QDebug>
#include <QPainter>
#include <QPaintEvent>
@ -88,7 +90,7 @@ AccountsPopupWidget::setArrowOffset( int arrowOffset )
void AccountsPopupWidget::paintEvent( QPaintEvent* )
{
// Constants for painting
const int cornerRadius = 6; //the rounding radius of the widget
const int cornerRadius = TomahawkUtils::POPUP_ROUNDING_RADIUS; //the rounding radius of the widget
const int arrowHeight = 6;
//m_arrowOffset is the distance between the far right boundary and the x value of the arrow head.
@ -110,13 +112,13 @@ void AccountsPopupWidget::paintEvent( QPaintEvent* )
p.setRenderHint( QPainter::Antialiasing );
p.setBackgroundMode( Qt::TransparentMode );
QPen pen( QColor( 0x8c, 0x8c, 0x8c ) );
QPen pen( TomahawkUtils::Colors::BORDER_LINE );
pen.setWidth( 2 );
p.setPen( pen );
p.drawPath( outline );
p.setOpacity( 0.96 );
p.fillPath( outline, QColor( "#FFFFFF" ) );
p.setOpacity( TomahawkUtils::POPUP_OPACITY );
p.fillPath( outline, TomahawkUtils::Colors::POPUP_BACKGROUND );
#ifdef QT_MAC_USE_COCOA
// Work around bug in Qt/Mac Cocoa where opening subsequent popups

View File

@ -77,7 +77,8 @@ AccountsToolButton::AccountsToolButton( QWidget* parent )
QWidget *separatorLine = new QWidget( w );
separatorLine->setFixedHeight( 1 );
separatorLine->setContentsMargins( 0, 0, 0, 0 );
separatorLine->setStyleSheet( "QWidget { border-top: 1px solid rgb( 140, 140, 140 ); }" ); //from ProxyStyle
separatorLine->setStyleSheet( "QWidget { border-top: 1px solid " +
TomahawkUtils::Colors::BORDER_LINE.name() + "; }" ); //from ProxyStyle
wMainLayout->addWidget( separatorLine );
wMainLayout->addSpacing( 6 );