diff --git a/kstyle/CMakeLists.txt b/kstyle/CMakeLists.txt index bb6fb62f..85290190 100644 --- a/kstyle/CMakeLists.txt +++ b/kstyle/CMakeLists.txt @@ -64,7 +64,6 @@ set(breeze_PART_SRCS breezemnemonics.cpp breezepropertynames.cpp breezestyle.cpp - breezetileset.cpp breezewindowmanager.cpp ) diff --git a/kstyle/breeze.kcfg b/kstyle/breeze.kcfg index 801ceb6d..bd8fa8fc 100644 --- a/kstyle/breeze.kcfg +++ b/kstyle/breeze.kcfg @@ -7,14 +7,6 @@ - - - - true - - - 512 - diff --git a/kstyle/breezehelper.cpp b/kstyle/breezehelper.cpp index e9fe410b..bfe001f3 100644 --- a/kstyle/breezehelper.cpp +++ b/kstyle/breezehelper.cpp @@ -46,14 +46,6 @@ namespace Breeze _viewNegativeTextBrush = KStatefulBrush( KColorScheme::View, KColorScheme::NegativeText, _config ); } - //______________________________________________________________________________ - void Helper::invalidateCaches( void ) - {} - - //____________________________________________________________________ - void Helper::setMaxCacheSize( int ) - {} - //______________________________________________________________________________ QPalette Helper::mergePalettes( const QPalette& source, qreal ratio ) const { diff --git a/kstyle/breezehelper.h b/kstyle/breezehelper.h index 97f102cb..b3d48b24 100644 --- a/kstyle/breezehelper.h +++ b/kstyle/breezehelper.h @@ -23,78 +23,12 @@ * Boston, MA 02110-1301, USA. */ -#include "breezetileset.h" - #include #include -#include -#include -#include - -#if HAVE_X11 -#include -#endif - namespace Breeze { - template class BaseCache: public QCache - { - - public: - - //! constructor - BaseCache( int maxCost ): - QCache( 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::object( key ) : 0; } - - //! max cost - void setMaxCost( int cost ) - { - if( cost <= 0 ) { - - QCache::clear(); - QCache::setMaxCost( 1 ); - setEnabled( false ); - - } else { - - setEnabled( true ); - QCache::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 @@ -117,12 +51,6 @@ namespace Breeze //! pointer to shared config KSharedConfigPtr config() const; - //! 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 ); diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index d36689ae..a7405064 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -568,10 +568,6 @@ namespace Breeze // load helper configuration _helper->loadConfig(); - // update caches size - const int cacheSize( StyleConfigData::cacheEnabled() ? StyleConfigData::maxCacheSize():0 ); - _helper->setMaxCacheSize( cacheSize ); - // reinitialize engines _animations->setupEngines(); _windowManager->initialize(); diff --git a/kstyle/breezetileset.cpp b/kstyle/breezetileset.cpp deleted file mode 100644 index 8d0a2b07..00000000 --- a/kstyle/breezetileset.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright 2009-2010 Hugo Pereira Da Costa - * Copyright 2008 Long Huynh Huu - * Copyright 2007 Matthew Woehlke - * - * 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 "breezetileset.h" - -#include - -namespace Breeze -{ - - //______________________________________________________________ - int TileSet::_sideExtent = 32; - - //______________________________________________________________ - void TileSet::initPixmap( PixmapList& pixmaps, const QPixmap &pix, int w, int h, const QRect &rect) - { - QSize size( w, h ); - if( !( size.isValid() && rect.isValid() ) ) - { - pixmaps.push_back( QPixmap() ); - - } else if( size != rect.size() ) { - - const QPixmap tile( pix.copy(rect) ); - QPixmap pixmap( w, h ); - - pixmap.fill(Qt::transparent); - QPainter p(&pixmap); - p.drawTiledPixmap(0, 0, w, h, tile); - - pixmaps.push_back( pixmap ); - - } else pixmaps.push_back( pix.copy(rect) ); - - } - - //______________________________________________________________ - TileSet::TileSet( void ): - _stretch( false ), - _w1(0), - _h1(0), - _w3(0), - _h3(0) - { _pixmaps.reserve(9); } - - //______________________________________________________________ - TileSet::TileSet(const QPixmap &pix, int w1, int h1, int w2, int h2, bool stretch ): - _stretch( stretch ), - _w1(w1), - _h1(h1), - _w3(0), - _h3(0) - { - _pixmaps.reserve(9); - if (pix.isNull()) return; - - _w3 = pix.width() - (w1 + w2); - _h3 = pix.height() - (h1 + h2); - int w = w2; - int h = h2; - if( !_stretch ) - { - while (w < _sideExtent && w2 > 0) w += w2; - while (h < _sideExtent && h2 > 0) h += h2; - } - - // initialise pixmap array - initPixmap( _pixmaps, pix, _w1, _h1, QRect(0, 0, _w1, _h1) ); - initPixmap( _pixmaps, pix, w, _h1, QRect(_w1, 0, w2, _h1) ); - initPixmap( _pixmaps, pix, _w3, _h1, QRect(_w1+w2, 0, _w3, _h1) ); - initPixmap( _pixmaps, pix, _w1, h, QRect(0, _h1, _w1, h2) ); - initPixmap( _pixmaps, pix, w, h, QRect(_w1, _h1, w2, h2) ); - initPixmap( _pixmaps, pix, _w3, h, QRect(_w1+w2, _h1, _w3, h2) ); - initPixmap( _pixmaps, pix, _w1, _h3, QRect(0, _h1+h2, _w1, _h3) ); - initPixmap( _pixmaps, pix, w, _h3, QRect(_w1, _h1+h2, w2, _h3) ); - initPixmap( _pixmaps, pix, _w3, _h3, QRect(_w1+w2, _h1+h2, _w3, _h3) ); - } - - //______________________________________________________________ - TileSet::TileSet(const QPixmap &pix, int w1, int h1, int w3, int h3, int x1, int y1, int w2, int h2, bool stretch ): - _stretch( stretch ), - _w1(w1), - _h1(h1), - _w3(w3), - _h3(h3) - { - _pixmaps.reserve(9); - if (pix.isNull()) return; - - int x2 = pix.width() - _w3; - int y2 = pix.height() - _h3; - int w = w2; - int h = h2; - if( !_stretch ) - { - while (w < _sideExtent && w2 > 0) w += w2; - while (h < _sideExtent && h2 > 0) h += h2; - } - - // initialise pixmap array - initPixmap( _pixmaps, pix, _w1, _h1, QRect(0, 0, _w1, _h1) ); - initPixmap( _pixmaps, pix, w, _h1, QRect(x1, 0, w2, _h1) ); - initPixmap( _pixmaps, pix, _w3, _h1, QRect(x2, 0, _w3, _h1) ); - initPixmap( _pixmaps, pix, _w1, h, QRect(0, y1, _w1, h2) ); - initPixmap( _pixmaps, pix, w, h, QRect(x1, y1, w2, h2) ); - initPixmap( _pixmaps, pix, _w3, h, QRect(x2, y1, _w3, h2) ); - initPixmap( _pixmaps, pix, _w1, _h3, QRect(0, y2, _w1, _h3) ); - initPixmap( _pixmaps, pix, w, _h3, QRect(x1, y2, w2, _h3) ); - initPixmap( _pixmaps, pix, _w3, _h3, QRect(x2, y2, _w3, _h3) ); - - } - - //___________________________________________________________ - inline bool bits(TileSet::Tiles flags, TileSet::Tiles testFlags) - { return (flags & testFlags) == testFlags; } - - //___________________________________________________________ - void TileSet::render(const QRect &r, QPainter *p, Tiles t) const - { - - const bool oldHint( p->testRenderHint( QPainter::SmoothPixmapTransform ) ); - if( _stretch ) p->setRenderHint( QPainter::SmoothPixmapTransform, true ); - - // check initialization - if( _pixmaps.size() < 9 ) return; - - int x0, y0, w, h; - r.getRect(&x0, &y0, &w, &h); - - // calculate pixmaps widths - int wLeft(0); - int wRight(0); - if( _w1+_w3 > 0 ) - { - qreal wRatio( qreal( _w1 )/qreal( _w1 + _w3 ) ); - wLeft = (t&Right) ? qMin( _w1, int(w*wRatio) ):_w1; - wRight = (t&Left) ? qMin( _w3, int(w*(1.0-wRatio)) ):_w3; - } - - // calculate pixmap heights - int hTop(0); - int hBottom(0); - if( _h1+_h3 > 0 ) - { - qreal hRatio( qreal( _h1 )/qreal( _h1 + _h3 ) ); - hTop = (t&Bottom) ? qMin( _h1, int(h*hRatio) ):_h1; - hBottom = (t&Top) ? qMin( _h3, int(h*(1.0-hRatio)) ):_h3; - } - - // calculate corner locations - w -= wLeft + wRight; - h -= hTop + hBottom; - const int x1 = x0 + wLeft; - const int x2 = x1 + w; - const int y1 = y0 + hTop; - const int y2 = y1 + h; - - const int w2 = _pixmaps.at(7).width(); - const int h2 = _pixmaps.at(5).height(); - - // corner - if( bits(t, Top|Left) ) p->drawPixmap(x0, y0, _pixmaps.at(0), 0, 0, wLeft, hTop); - if( bits(t, Top|Right) ) p->drawPixmap(x2, y0, _pixmaps.at(2), _w3-wRight, 0, wRight, hTop); - if( bits(t, Bottom|Left) ) p->drawPixmap(x0, y2, _pixmaps.at(6), 0, _h3-hBottom, wLeft, hBottom); - if( bits(t, Bottom|Right) ) p->drawPixmap(x2, y2, _pixmaps.at(8), _w3-wRight, _h3-hBottom, wRight, hBottom ); - - // top and bottom - if( w > 0 ) - { - if (t & Top ) - { - if( _stretch ) p->drawPixmap(x1, y0, w, hTop, _pixmaps.at(1)); - else p->drawTiledPixmap(x1, y0, w, hTop, _pixmaps.at(1)); - } - - if (t & Bottom ) - { - if( _stretch ) p->drawPixmap(x1, y2, w, hBottom, _pixmaps.at(7), 0, _h3-hBottom, w2, hBottom ); - else p->drawTiledPixmap(x1, y2, w, hBottom, _pixmaps.at(7), 0, _h3-hBottom ); - } - - } - - // left and right - if( h > 0 ) - { - if (t & Left ) - { - if( _stretch ) p->drawPixmap(x0, y1, wLeft, h, _pixmaps.at(3)); - else p->drawTiledPixmap(x0, y1, wLeft, h, _pixmaps.at(3)); - } - - if (t & Right ) - { - if( _stretch ) p->drawPixmap(x2, y1, wRight, h, _pixmaps.at(5), _w3-wRight, 0, wRight, h2 ); - else p->drawTiledPixmap(x2, y1, wRight, h, _pixmaps.at(5), _w3-wRight, 0 ); - } - } - - // center - if ( (t & Center) && h > 0 && w > 0 ) - { - if( _stretch ) p->drawPixmap(x1, y1, w, h, _pixmaps.at(4)); - else p->drawTiledPixmap(x1, y1, w, h, _pixmaps.at(4)); - } - - if( _stretch ) p->setRenderHint( QPainter::SmoothPixmapTransform, oldHint ); - - } - -} diff --git a/kstyle/breezetileset.h b/kstyle/breezetileset.h deleted file mode 100644 index 1baff191..00000000 --- a/kstyle/breezetileset.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef breezetileset_h -#define breezetileset_h - -/* - * Copyright 2014 Hugo Pereira Da Costa - * Copyright 2008 Long Huynh Huu - * Copyright 2007 Matthew Woehlke - * - * 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 -#include -#include - -//! handles proper scaling of pixmap to match widget rect. -/*! -tilesets are collections of stretchable pixmaps corresponding to a given widget corners, sides, and center. -corner pixmaps are never stretched. center pixmaps are -*/ -namespace Breeze -{ - class TileSet - { - public: - /*! - Create a TileSet from a pixmap. The size of the bottom/right chunks is - whatever is left over from the other chunks, whose size is specified - in the required parameters. - - @param w1 width of the left chunks - @param h1 height of the top chunks - @param w2 width of the not-left-or-right chunks - @param h2 height of the not-top-or-bottom chunks - */ - TileSet(const QPixmap&, int w1, int h1, int w2, int h2, bool stretch = false ); - - /*! - Create a TileSet from a pixmap. The size of the top/left and bottom/right - chunks is specified, with the middle chunks created from the specified - portion of the pixmap. This allows the middle chunks to overlap the outer - chunks (or to not use all pixels). The top/left and bottom/right chunks - are carved out of the corners of the pixmap. - - @param w1 width of the left chunks - @param h1 height of the top chunks - @param w3 width of the right chunks - @param h3 height of bottom chunks - @param x2 x-coordinate of the top of the not-left-or-right chunks - @param y2 y-coordinate of the left of the not-top-or-bottom chunks - @param w2 width of the not-left-or-right chunks - @param h2 height of the not-top-or-bottom chunks - */ - TileSet(const QPixmap &pix, int w1, int h1, int w3, int h3, int x2, int y2, int w2, int h2, bool stretch = false ); - - //! empty constructor - TileSet(); - - //! destructor - virtual ~TileSet() - {} - - /*! - Flags specifying what sides to draw in ::render. Corners are drawn when - the sides forming that corner are drawn, e.g. Top|Left draws the - top-center, center-left, and top-left chunks. The center-center chunk is - only drawn when Center is requested. - */ - enum Tile { - Top = 0x1, - Left = 0x2, - Bottom = 0x4, - Right = 0x8, - Center = 0x10, - TopLeft = Top|Left, - TopRight = Top|Right, - BottomLeft = Bottom|Left, - BottomRight = Bottom|Right, - Ring = Top|Left|Bottom|Right, - Horizontal = Left|Right|Center, - Vertical = Top|Bottom|Center, - Full = Ring|Center - }; - Q_DECLARE_FLAGS(Tiles, Tile) - - /*! - Fills the specified rect with tiled chunks. Corners are never tiled, - edges are tiled in one direction, and the center chunk is tiled in both - directions. Partial tiles are used as needed so that the entire rect is - perfectly filled. Filling is performed as if all chunks are being drawn. - */ - void render(const QRect&, QPainter*, Tiles = Ring) const; - - //! return size associated to this tileset - QSize size( void ) const - { return QSize( _w1 + _w3, _h1 + _h3 ); } - - //! is valid - bool isValid( void ) const - { return _pixmaps.size() == 9; } - - //! side extend - /*! - it is used to (pre) tile the side pixmaps, in order to make further tiling faster when rendering, at the cost of - using more memory for the cache. Changes to this member only affects tilesets that are created afterwards. - */ - void setSideExtent( int value ) - { _sideExtent = value; } - - //! returns pixmap for given index - QPixmap pixmap( int index ) const - { return _pixmaps[index]; } - - protected: - - //! shortcut to pixmap list - typedef QVector PixmapList; - - //! initialize pixmap - void initPixmap( PixmapList&, const QPixmap&, int w, int h, const QRect& ); - - private: - - //! side extend - /*! - it is used to (pre) tile the side pixmaps, in order to make further tiling faster when rendering, at the cost of - using more memory for the cache. - */ - static int _sideExtent; - - //! pixmap arry - PixmapList _pixmaps; - - // stretch pixmaps - bool _stretch; - - // dimensions - int _w1; - int _h1; - int _w3; - int _h3; - - }; - -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(Breeze::TileSet::Tiles) - -#endif //TILESET_H