Пример #1
0
QColor OxygenClient::titlebarTextColor(const QPalette &palette)
{
    if (isActive())
        return palette.color(QPalette::Active, QPalette::WindowText);
    else {
        if(colorCacheInvalid_) {
            QColor ab = palette.color(QPalette::Active, QPalette::Window);
            QColor af = palette.color(QPalette::Active, QPalette::WindowText);
            QColor nb = palette.color(QPalette::Inactive, QPalette::Window);
            QColor nf = palette.color(QPalette::Inactive, QPalette::WindowText);

            colorCacheInvalid_ = false;
            cachedTitlebarTextColor_ = reduceContrast(nb, nf, qMax(qreal(2.5), KColorUtils::contrastRatio(ab, KColorUtils::mix(ab, af, 0.4))));
        }
        return cachedTitlebarTextColor_;
    }
}
Пример #2
0
    //______________________________________________________________________________
    const QColor& DecoHelper::inactiveButtonTextColor( const QPalette& palette )
    {

        const quint32 key( colorKey( palette.color(QPalette::Active, QPalette::Window) ) );
        QColor* out( _buttonTextColorCache.object( key ) );
        if( !out )
        {

            // todo: reimplement cache
            const QColor ab = palette.color(QPalette::Active, QPalette::Button);
            const QColor af = palette.color(QPalette::Active, QPalette::ButtonText);
            const QColor nb = palette.color(QPalette::Inactive, QPalette::Button);
            const QColor nf = palette.color(QPalette::Inactive, QPalette::ButtonText);
            out = new QColor( reduceContrast(nb, nf, qMax(qreal(2.5), KColorUtils::contrastRatio(ab, KColorUtils::mix(ab, af, 0.4)))) );
            _buttonTextColorCache.insert( key, out );
        }

        return *out;
    }