|
|
|
|
@ -23,6 +23,12 @@ |
|
|
|
|
* Boston, MA 02110-1301, USA. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include "breezetileset.h" |
|
|
|
|
|
|
|
|
|
#include <KSharedConfig> |
|
|
|
|
#include <KColorScheme> |
|
|
|
|
|
|
|
|
|
#include <QCache> |
|
|
|
|
#include <QScopedPointer> |
|
|
|
|
|
|
|
|
|
#if HAVE_X11 |
|
|
|
|
@ -32,35 +38,146 @@ |
|
|
|
|
namespace Breeze |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
template<typename T> class BaseCache: public QCache<quint64, T> |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
|
BaseCache( int maxCost ): |
|
|
|
|
QCache<quint64, T>( maxCost ), |
|
|
|
|
_enabled( true ) |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
|
explicit BaseCache( void ): |
|
|
|
|
_enabled( true ) |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
|
~BaseCache( void ) |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
//! enable
|
|
|
|
|
void setEnabled( bool value ) |
|
|
|
|
{ _enabled = value; } |
|
|
|
|
|
|
|
|
|
//! enable state
|
|
|
|
|
bool enabled( void ) const |
|
|
|
|
{ return _enabled; } |
|
|
|
|
|
|
|
|
|
//! access
|
|
|
|
|
T* object( const quint64& key ) |
|
|
|
|
{ return _enabled ? QCache<quint64, T>::object( key ) : 0; } |
|
|
|
|
|
|
|
|
|
//! max cost
|
|
|
|
|
void setMaxCost( int cost ) |
|
|
|
|
{ |
|
|
|
|
if( cost <= 0 ) { |
|
|
|
|
|
|
|
|
|
QCache<quint64, T>::clear(); |
|
|
|
|
QCache<quint64, T>::setMaxCost( 1 ); |
|
|
|
|
setEnabled( false ); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
setEnabled( true ); |
|
|
|
|
QCache<quint64, T>::setMaxCost( cost ); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
//! enable flag
|
|
|
|
|
bool _enabled; |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//! breeze style helper class.
|
|
|
|
|
/*! contains utility functions used at multiple places in both breeze style and breeze window decoration */ |
|
|
|
|
class Helper |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
//! scoped pointer convenience typedef
|
|
|
|
|
template <typename T> using ScopedPointer = QScopedPointer<T, QScopedPointerPodDeleter>; |
|
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
|
explicit Helper() |
|
|
|
|
{} |
|
|
|
|
explicit Helper( KSharedConfig::Ptr ); |
|
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
|
virtual ~Helper() |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
template <typename T> class ScopedPointer: public QScopedPointer<T, QScopedPointerPodDeleter> |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
//! load configuration
|
|
|
|
|
virtual void loadConfig(); |
|
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
|
ScopedPointer( T* t ): |
|
|
|
|
QScopedPointer<T, QScopedPointerPodDeleter>( t ) |
|
|
|
|
{} |
|
|
|
|
//! pointer to shared config
|
|
|
|
|
KSharedConfigPtr config() const; |
|
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
|
virtual ~ScopedPointer( void ) |
|
|
|
|
{} |
|
|
|
|
//! reset all caches
|
|
|
|
|
virtual void invalidateCaches(); |
|
|
|
|
|
|
|
|
|
//! update maximum cache size
|
|
|
|
|
virtual void setMaxCacheSize( int ); |
|
|
|
|
|
|
|
|
|
//! add alpha channel multiplier to color
|
|
|
|
|
static QColor alphaColor( QColor color, qreal alpha ); |
|
|
|
|
|
|
|
|
|
//!@name brushes
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
//! focus brush
|
|
|
|
|
const KStatefulBrush& viewFocusBrush( void ) const |
|
|
|
|
{ return _viewFocusBrush; } |
|
|
|
|
|
|
|
|
|
//! hover brush
|
|
|
|
|
const KStatefulBrush& viewHoverBrush( void ) const |
|
|
|
|
{ return _viewHoverBrush; } |
|
|
|
|
|
|
|
|
|
//! negative text brush ( used for close button hover )
|
|
|
|
|
const KStatefulBrush& viewNegativeTextBrush( void ) const |
|
|
|
|
{ return _viewNegativeTextBrush; } |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//!@name tilesets
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
//! scrollbar hole
|
|
|
|
|
TileSet *scrollBarHole( const QColor& ); |
|
|
|
|
|
|
|
|
|
//! scrollbar handle
|
|
|
|
|
TileSet *scrollBarHandle( const QColor&, const QColor& ); |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
|
|
//! return color key for a given color, properly accounting for invalid colors
|
|
|
|
|
quint64 colorKey( const QColor& color ) const |
|
|
|
|
{ return color.isValid() ? color.rgba():0; } |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
//! configuration
|
|
|
|
|
KSharedConfigPtr _config; |
|
|
|
|
|
|
|
|
|
//!@name brushes
|
|
|
|
|
//@{
|
|
|
|
|
KStatefulBrush _viewFocusBrush; |
|
|
|
|
KStatefulBrush _viewHoverBrush; |
|
|
|
|
KStatefulBrush _viewNegativeTextBrush; |
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//!@name tileset caches
|
|
|
|
|
//@{
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
typedef BaseCache<TileSet> TileSetCache; |
|
|
|
|
TileSetCache _scrollBarHandleCache; |
|
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|