void BlockAnalyzer::paletteChange( const QPalette& ) //virtual { DEBUG_BLOCK const QColor bg = palette().color( QPalette::Active, QPalette::Background ); const QColor fg = ensureContrast( bg, KGlobalSettings::activeTitleColor() ); m_topBarPixmap.fill( fg ); const double dr = 15*double(bg.red() - fg.red()) / (m_rows*16); const double dg = 15*double(bg.green() - fg.green()) / (m_rows*16); const double db = 15*double(bg.blue() - fg.blue()) / (m_rows*16); const int r = fg.red(), g = fg.green(), b = fg.blue(); bar()->fill( bg ); QPainter p( bar() ); for( int y = 0; (uint)y < m_rows; ++y ) //graduate the fg color p.fillRect( 0, y*(HEIGHT+1), WIDTH, HEIGHT, QColor( r+int(dr*y), g+int(dg*y), b+int(db*y) ) ); { const QColor bg = palette().color( QPalette::Active, QPalette::Background ).dark( 112 ); //make a complimentary fadebar colour //TODO dark is not always correct, dumbo! int h,s,v; palette().color( QPalette::Active, QPalette::Background ).dark( 150 ).getHsv( &h, &s, &v ); const QColor fg = QColor::fromHsv( h + 60, s, v ); const double dr = fg.red() - bg.red(); const double dg = fg.green() - bg.green(); const double db = fg.blue() - bg.blue(); const int r = bg.red(), g = bg.green(), b = bg.blue(); // Precalculate all fade-bar pixmaps for( uint y = 0; y < FADE_SIZE; ++y ) { m_fade_bars[y].fill( palette().color( QPalette::Active, QPalette::Background ) ); QPainter f( &m_fade_bars[y] ); for( int z = 0; (uint)z < m_rows; ++z ) { const double Y = 1.0 - (log10( static_cast<float>(FADE_SIZE) - y ) / log10( static_cast<float>(FADE_SIZE) )); f.fillRect( 0, z*(HEIGHT+1), WIDTH, HEIGHT, QColor( r+int(dr*Y), g+int(dg*Y), b+int(db*Y) ) ); } } } drawBackground(); }
void BlockAnalyzer::paletteChange(const QPalette&) { const QColor bg = palette().color(QPalette::Background); const QColor fg = ensureContrast(bg, palette().color(QPalette::Highlight)); m_topBarPixmap.fill(fg); const double dr = 15 * static_cast<double>(bg.red() - fg.red()) / (m_rows * 16); const double dg = 15 * static_cast<double>(bg.green() - fg.green()) / (m_rows * 16); const double db = 15 * static_cast<double>(bg.blue() - fg.blue()) / (m_rows * 16); const int r = fg.red(), g = fg.green(), b = fg.blue(); bar()->fill(bg); QPainter p(bar()); for (int y = 0; static_cast<uint>(y) < m_rows; ++y) // graduate the fg color p.fillRect(0, y * (HEIGHT + 1), WIDTH, HEIGHT, QColor(r + static_cast<int>(dr * y), g + static_cast<int>(dg * y), b + static_cast<int>(db * y))); { const QColor bg = palette().color(QPalette::Background).dark(112); // make a complimentary fadebar colour // TODO(John Maguire): dark is not always correct, dumbo! int h, s, v; palette().color(QPalette::Background).dark(150).getHsv(&h, &s, &v); const QColor fg(QColor::fromHsv(h + 120, s, v)); const double dr = fg.red() - bg.red(); const double dg = fg.green() - bg.green(); const double db = fg.blue() - bg.blue(); const int r = bg.red(), g = bg.green(), b = bg.blue(); // Precalculate all fade-bar pixmaps for (uint y = 0; y < FADE_SIZE; ++y) { m_fade_bars[y].fill(palette().color(QPalette::Background)); QPainter f(&m_fade_bars[y]); for (int z = 0; static_cast<uint>(z) < m_rows; ++z) { const double Y = 1.0 - (log10(FADE_SIZE - y) / log10(FADE_SIZE)); f.fillRect(0, z * (HEIGHT + 1), WIDTH, HEIGHT, QColor(r + static_cast<int>(dr * Y), g + static_cast<int>(dg * Y), b + static_cast<int>(db * Y))); } } } drawBackground(); }