Remove hardcoded colors from color palette dialog -- use current style colors.

This commit is contained in:
Jim Evins
2015-08-19 11:45:03 -04:00
parent e4d2603cb4
commit f27cf4708b
3 changed files with 13 additions and 28 deletions
+5 -10
View File
@@ -32,12 +32,7 @@ namespace
{ {
const int border = 4; const int border = 4;
const int hBox = 25; const int hBox = 25;
const QColor hoverOutlineColor( 89, 130, 182 );
const QColor hoverGradientColor0( 164, 195, 232 );
const QColor hoverGradientColor1( 147, 181, 224 );
const int outlineWidthPixels = 1; const int outlineWidthPixels = 1;
const QColor textColor( 0, 0, 0 );
const QColor hoverTextColor( 255, 255, 255 );
} }
@@ -68,11 +63,11 @@ namespace glabels
if ( mHover ) if ( mHover )
{ {
QLinearGradient gradient( 0, 0, 0, height() ); QLinearGradient gradient( 0, 0, 0, height() );
gradient.setColorAt( 0, hoverGradientColor0 ); gradient.setColorAt( 0, palette().color( QPalette::Highlight ).lighter() );
gradient.setColorAt( 1, hoverGradientColor1 ); gradient.setColorAt( 1, palette().color( QPalette::Highlight ) );
painter.setBrush( QBrush( gradient ) ); painter.setBrush( QBrush( gradient ) );
QPen pen( hoverOutlineColor ); QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( outlineWidthPixels ); pen.setWidth( outlineWidthPixels );
painter.setPen( pen ); painter.setPen( pen );
@@ -86,11 +81,11 @@ namespace glabels
if ( mHover ) if ( mHover )
{ {
painter.setPen( QPen( hoverTextColor ) ); painter.setPen( QPen( palette().color( QPalette::HighlightedText ) ) );
} }
else else
{ {
painter.setPen( QPen( textColor ) ); painter.setPen( QPen( palette().color( QPalette::Text ) ) );
} }
QRect textRect( border, border, width()-2*border, hBox ); QRect textRect( border, border, width()-2*border, hBox );
+1 -3
View File
@@ -26,8 +26,6 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QGridLayout> #include <QGridLayout>
#include <QPushButton>
#include <QToolButton>
#include <QFrame> #include <QFrame>
@@ -90,7 +88,7 @@ namespace glabels
mDefaultColor = defaultColor; mDefaultColor = defaultColor;
mColorNode = ColorNode( color ); mColorNode = ColorNode( color );
setStyleSheet( "background: white; border: 1px solid black" ); setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" );
setWindowFlags( Qt::Popup | Qt::FramelessWindowHint ); setWindowFlags( Qt::Popup | Qt::FramelessWindowHint );
QVBoxLayout* vLayout = new QVBoxLayout(); QVBoxLayout* vLayout = new QVBoxLayout();
+6 -14
View File
@@ -34,14 +34,8 @@ namespace
const int wSwatch = 25; const int wSwatch = 25;
const int hSwatch = 25; const int hSwatch = 25;
const QColor hoverBgOutlineColor( 89, 130, 182 );
const QColor hoverBgGradientColor0( 164, 195, 232 );
const QColor hoverBgGradientColor1( 147, 181, 224 );
const int hoverBgOutlineWidthPixels = 1; const int hoverBgOutlineWidthPixels = 1;
const QColor outlineColor( 0, 0, 0 );
const QColor hoverOutlineColor( 255, 255, 255 );
const QColor emptyOutlineColor( 192, 192, 192 );
const int outlineWidthPixels = 1; const int outlineWidthPixels = 1;
} }
@@ -93,11 +87,11 @@ namespace glabels
if ( isEnabled() && mHover ) if ( isEnabled() && mHover )
{ {
QLinearGradient gradient( 0, 0, 0, height() ); QLinearGradient gradient( 0, 0, 0, height() );
gradient.setColorAt( 0, hoverBgGradientColor0 ); gradient.setColorAt( 0, palette().color( QPalette::Highlight ).lighter() );
gradient.setColorAt( 1, hoverBgGradientColor1 ); gradient.setColorAt( 1, palette().color( QPalette::Highlight ) );
painter.setBrush( QBrush( gradient ) ); painter.setBrush( QBrush( gradient ) );
QPen pen( hoverBgOutlineColor ); QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( hoverBgOutlineWidthPixels ); pen.setWidth( hoverBgOutlineWidthPixels );
painter.setPen( pen ); painter.setPen( pen );
@@ -107,19 +101,17 @@ namespace glabels
// //
// Draw swatch // Draw swatch
// //
painter.setBrush( QBrush( Qt::NoBrush ) );
if ( isEnabled() ) if ( isEnabled() )
{ {
if ( mHover ) if ( mHover )
{ {
QPen pen( hoverOutlineColor ); QPen pen( palette().color( QPalette::HighlightedText ) );
pen.setWidth( outlineWidthPixels ); pen.setWidth( outlineWidthPixels );
painter.setPen( pen ); painter.setPen( pen );
} }
else else
{ {
QPen pen( outlineColor ); QPen pen( palette().color( QPalette::Text ) );
pen.setWidth( outlineWidthPixels ); pen.setWidth( outlineWidthPixels );
painter.setPen( pen ); painter.setPen( pen );
} }
@@ -128,7 +120,7 @@ namespace glabels
} }
else else
{ {
QPen pen( emptyOutlineColor ); QPen pen( palette().color( QPalette::Disabled, QPalette::Text ) );
pen.setWidth( outlineWidthPixels ); pen.setWidth( outlineWidthPixels );
painter.setPen( pen ); painter.setPen( pen );
} }