mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
Bring nicer widget header gradient to Master
This commit is contained in:
@@ -26,14 +26,14 @@
|
|||||||
QColor
|
QColor
|
||||||
StyleHelper::headerUpperColor()
|
StyleHelper::headerUpperColor()
|
||||||
{
|
{
|
||||||
return QColor( "#615858" );
|
return QColor( "#25292c" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QColor
|
QColor
|
||||||
StyleHelper::headerLowerColor()
|
StyleHelper::headerLowerColor()
|
||||||
{
|
{
|
||||||
return QColor( "#231F1F" );
|
return QColor( "#707070" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,32 +48,32 @@ void
|
|||||||
StyleHelper::horizontalHeader( QPainter* painter, const QRect& r )
|
StyleHelper::horizontalHeader( QPainter* painter, const QRect& r )
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
/* QRect upperHalf( 0, 0, r.width(), r.height() / 2 );
|
/* QRect upperHalf( 0, 0, r.width(), r.height() / 2 );
|
||||||
QRect lowerHalf( 0, upperHalf.height(), r.width(), r.height() );
|
QRect lowerHalf( 0, upperHalf.height(), r.width(), r.height() );
|
||||||
painter->fillRect( upperHalf, StyleHelper::headerUpperColor() );
|
painter->fillRect( upperHalf, StyleHelper::headerUpperColor() );
|
||||||
painter->fillRect( lowerHalf, StyleHelper::headerLowerColor() );*/
|
painter->fillRect( lowerHalf, StyleHelper::headerLowerColor() );*/
|
||||||
QLinearGradient gradient( QPoint( 0, 0 ), QPoint( 0, 1 ) );
|
QLinearGradient gradient( QPoint( 0, 0 ), QPoint( 0, 1 ) );
|
||||||
gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
|
gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
|
||||||
gradient.setColorAt( 0.0, StyleHelper::headerLowerColor() );
|
gradient.setColorAt( 0.0, StyleHelper::headerLowerColor() );
|
||||||
gradient.setColorAt( 1.0, StyleHelper::headerUpperColor() );
|
gradient.setColorAt( 1.0, StyleHelper::headerUpperColor() );
|
||||||
|
|
||||||
painter->setBrush( gradient );
|
painter->setBrush( gradient );
|
||||||
painter->fillRect( r, gradient );
|
painter->fillRect( r, gradient );
|
||||||
|
|
||||||
/* {
|
/* {
|
||||||
QColor lineColor( 100, 100, 100 );
|
QColor lineColor( 100, 100, 100 );
|
||||||
QLine line( 0, 0, r.width(), 0 );
|
QLine line( 0, 0, r.width(), 0 );
|
||||||
painter->setPen( lineColor );
|
painter->setPen( lineColor );
|
||||||
painter->drawLine( line );
|
painter->drawLine( line );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QColor lineColor( 30, 30, 30 );
|
QColor lineColor( 30, 30, 30 );
|
||||||
QLine line( 0, r.height() - 1, r.width(), r.height() - 1 );
|
QLine line( 0, r.height() - 1, r.width(), r.height() - 1 );
|
||||||
painter->setPen( lineColor );
|
painter->setPen( lineColor );
|
||||||
painter->drawLine( line );
|
painter->drawLine( line );
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ StyleHelper::horizontalHeader( QPainter* painter, const QRect& r )
|
|||||||
QColor
|
QColor
|
||||||
StyleHelper::headerTextColor()
|
StyleHelper::headerTextColor()
|
||||||
{
|
{
|
||||||
return Qt::white;
|
return QColor( "#eaeaea" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -96,62 +96,62 @@ void StyleHelper::drawArrow( QStyle::PrimitiveElement element, QPainter* p, cons
|
|||||||
{
|
{
|
||||||
if ( opt->rect.width() <= 1 || opt->rect.height() <= 1 )
|
if ( opt->rect.width() <= 1 || opt->rect.height() <= 1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QRect r = opt->rect;
|
QRect r = opt->rect;
|
||||||
int size = qMin( r.height(), r.width() );
|
int size = qMin( r.height(), r.width() );
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
QString pixmapName;
|
QString pixmapName;
|
||||||
|
|
||||||
pixmapName.sprintf( "arrow-%s-%d-%d-%d-%lld", "$qt_ia", uint(opt->state), element, size, opt->palette.cacheKey() );
|
pixmapName.sprintf( "arrow-%s-%d-%d-%d-%lld", "$qt_ia", uint(opt->state), element, size, opt->palette.cacheKey() );
|
||||||
if ( !QPixmapCache::find( pixmapName, pixmap ) )
|
if ( !QPixmapCache::find( pixmapName, pixmap ) )
|
||||||
{
|
{
|
||||||
int border = size / 5;
|
int border = size / 5;
|
||||||
int sqsize = 2 * ( size / 2 );
|
int sqsize = 2 * ( size / 2 );
|
||||||
|
|
||||||
QImage image( sqsize, sqsize, QImage::Format_ARGB32 );
|
QImage image( sqsize, sqsize, QImage::Format_ARGB32 );
|
||||||
image.fill( 0 );
|
image.fill( 0 );
|
||||||
QPainter imagePainter( &image );
|
QPainter imagePainter( &image );
|
||||||
imagePainter.setRenderHint( QPainter::Antialiasing, true );
|
imagePainter.setRenderHint( QPainter::Antialiasing, true );
|
||||||
QPolygon a;
|
QPolygon a;
|
||||||
|
|
||||||
switch ( element )
|
switch ( element )
|
||||||
{
|
{
|
||||||
case QStyle::PE_IndicatorArrowUp:
|
case QStyle::PE_IndicatorArrowUp:
|
||||||
a.setPoints( 3, border, sqsize / 2, sqsize / 2, border, sqsize - border, sqsize / 2 );
|
a.setPoints( 3, border, sqsize / 2, sqsize / 2, border, sqsize - border, sqsize / 2 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QStyle::PE_IndicatorArrowDown:
|
case QStyle::PE_IndicatorArrowDown:
|
||||||
a.setPoints( 3, border, sqsize / 2, sqsize / 2, sqsize - border, sqsize - border, sqsize / 2 );
|
a.setPoints( 3, border, sqsize / 2, sqsize / 2, sqsize - border, sqsize - border, sqsize / 2 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QStyle::PE_IndicatorArrowRight:
|
case QStyle::PE_IndicatorArrowRight:
|
||||||
a.setPoints( 3, sqsize - border, sqsize / 2, sqsize / 2, border, sqsize / 2, sqsize - border );
|
a.setPoints( 3, sqsize - border, sqsize / 2, sqsize / 2, border, sqsize / 2, sqsize - border );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QStyle::PE_IndicatorArrowLeft:
|
case QStyle::PE_IndicatorArrowLeft:
|
||||||
a.setPoints( 3, border, sqsize / 2, sqsize / 2, border, sqsize / 2, sqsize - border );
|
a.setPoints( 3, border, sqsize / 2, sqsize / 2, border, sqsize / 2, sqsize - border );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bsx = 0;
|
int bsx = 0;
|
||||||
int bsy = 0;
|
int bsy = 0;
|
||||||
|
|
||||||
if ( opt->state & QStyle::State_Sunken )
|
if ( opt->state & QStyle::State_Sunken )
|
||||||
{
|
{
|
||||||
bsx = qApp->style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal );
|
bsx = qApp->style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal );
|
||||||
bsy = qApp->style()->pixelMetric( QStyle::PM_ButtonShiftVertical );
|
bsy = qApp->style()->pixelMetric( QStyle::PM_ButtonShiftVertical );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect bounds = a.boundingRect();
|
QRect bounds = a.boundingRect();
|
||||||
int sx = sqsize / 2 - bounds.center().x() - 1;
|
int sx = sqsize / 2 - bounds.center().x() - 1;
|
||||||
int sy = sqsize / 2 - bounds.center().y() - 1;
|
int sy = sqsize / 2 - bounds.center().y() - 1;
|
||||||
imagePainter.translate( sx + bsx, sy + bsy );
|
imagePainter.translate( sx + bsx, sy + bsy );
|
||||||
imagePainter.setPen( opt->palette.buttonText().color() );
|
imagePainter.setPen( opt->palette.buttonText().color() );
|
||||||
imagePainter.setBrush( opt->palette.buttonText() );
|
imagePainter.setBrush( opt->palette.buttonText() );
|
||||||
|
|
||||||
if ( !( opt->state & QStyle::State_Enabled ) )
|
if ( !( opt->state & QStyle::State_Enabled ) )
|
||||||
{
|
{
|
||||||
QColor foreGround( 150, 150, 150, 150 );
|
QColor foreGround( 150, 150, 150, 150 );
|
||||||
@@ -170,15 +170,15 @@ void StyleHelper::drawArrow( QStyle::PrimitiveElement element, QPainter* p, cons
|
|||||||
imagePainter.setPen( foreGround );
|
imagePainter.setPen( foreGround );
|
||||||
imagePainter.setBrush( foreGround );
|
imagePainter.setBrush( foreGround );
|
||||||
}
|
}
|
||||||
|
|
||||||
imagePainter.drawPolygon( a );
|
imagePainter.drawPolygon( a );
|
||||||
imagePainter.end();
|
imagePainter.end();
|
||||||
|
|
||||||
pixmap = QPixmap::fromImage( image );
|
pixmap = QPixmap::fromImage( image );
|
||||||
QPixmapCache::insert( pixmapName, pixmap );
|
QPixmapCache::insert( pixmapName, pixmap );
|
||||||
}
|
}
|
||||||
|
|
||||||
int xOffset = r.x() + ( r.width() - size ) / 2;
|
int xOffset = r.x() + ( r.width() - size ) / 2;
|
||||||
int yOffset = r.y() + ( r.height() - size ) / 2;
|
int yOffset = r.y() + ( r.height() - size ) / 2;
|
||||||
p->drawPixmap( xOffset, yOffset, pixmap );
|
p->drawPixmap( xOffset, yOffset, pixmap );
|
||||||
}
|
}
|
Reference in New Issue
Block a user