You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.6 KiB
79 lines
3.6 KiB
/* |
|
* Copyright 2009-2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> |
|
* Copyright 2008 Long Huynh Huu <long.upcase@googlemail.com> |
|
* Copyright 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> |
|
* Copyright 2007 Casper Boemann <cbr@boemann.dk> |
|
* Copyright 2007 Fredrik H?glund <fredrik@kde.org> |
|
* |
|
* This library is free software; you can redistribute it and/or |
|
* modify it under the terms of the GNU Library General Public |
|
* License version 2 as published by the Free Software Foundation. |
|
* |
|
* This library is distributed in the hope that it will be useful, |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
* Library General Public License for more details. |
|
* |
|
* You should have received a copy of the GNU Library General Public License |
|
* along with this library; see the file COPYING.LIB. If not, write to |
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
* Boston, MA 02110-1301, USA. |
|
*/ |
|
|
|
#include "breezehelper.h" |
|
|
|
#include "breezemetrics.h" |
|
|
|
#include <KColorUtils> |
|
#include <QPainter> |
|
|
|
namespace Breeze |
|
{ |
|
//____________________________________________________________________ |
|
Helper::Helper( KSharedConfig::Ptr config ): |
|
_config( config ) |
|
{} |
|
|
|
//____________________________________________________________________ |
|
KSharedConfigPtr Helper::config() const |
|
{ return _config; } |
|
|
|
//____________________________________________________________________ |
|
void Helper::loadConfig() |
|
{ |
|
_viewFocusBrush = KStatefulBrush( KColorScheme::View, KColorScheme::FocusColor, _config ); |
|
_viewHoverBrush = KStatefulBrush( KColorScheme::View, KColorScheme::HoverColor, _config ); |
|
_viewNegativeTextBrush = KStatefulBrush( KColorScheme::View, KColorScheme::NegativeText, _config ); |
|
} |
|
|
|
//______________________________________________________________________________ |
|
void Helper::invalidateCaches( void ) |
|
{} |
|
|
|
//____________________________________________________________________ |
|
void Helper::setMaxCacheSize( int ) |
|
{} |
|
|
|
//______________________________________________________________________________ |
|
QPalette Helper::mergePalettes( const QPalette& source, qreal ratio ) const |
|
{ |
|
|
|
QPalette out( source ); |
|
out.setColor( QPalette::Background, KColorUtils::mix( source.color( QPalette::Active, QPalette::Background ), source.color( QPalette::Disabled, QPalette::Background ), 1.0-ratio ) ); |
|
out.setColor( QPalette::Highlight, KColorUtils::mix( source.color( QPalette::Active, QPalette::Highlight ), source.color( QPalette::Disabled, QPalette::Highlight ), 1.0-ratio ) ); |
|
out.setColor( QPalette::WindowText, KColorUtils::mix( source.color( QPalette::Active, QPalette::WindowText ), source.color( QPalette::Disabled, QPalette::WindowText ), 1.0-ratio ) ); |
|
out.setColor( QPalette::ButtonText, KColorUtils::mix( source.color( QPalette::Active, QPalette::ButtonText ), source.color( QPalette::Disabled, QPalette::ButtonText ), 1.0-ratio ) ); |
|
out.setColor( QPalette::Text, KColorUtils::mix( source.color( QPalette::Active, QPalette::Text ), source.color( QPalette::Disabled, QPalette::Text ), 1.0-ratio ) ); |
|
out.setColor( QPalette::Button, KColorUtils::mix( source.color( QPalette::Active, QPalette::Button ), source.color( QPalette::Disabled, QPalette::Button ), 1.0-ratio ) ); |
|
return out; |
|
} |
|
|
|
//____________________________________________________________________ |
|
QColor Helper::alphaColor( QColor color, qreal alpha ) |
|
{ |
|
if( alpha >= 0 && alpha < 1.0 ) |
|
{ color.setAlphaF( alpha*color.alphaF() ); } |
|
return color; |
|
} |
|
|
|
}
|
|
|