diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:43:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:43:50 +0000 |
commit | ceea23677c61f20759ae986bd77b0d5c4d673edb (patch) | |
tree | 3fcec1702eaf9c14d1dd736e594f5df08dab4001 /kbfxlib/common/kbfxplasmapixmapprovider.cpp | |
download | kbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.tar.gz kbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.zip |
Added old KDE3 version of kbfx
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kbfx@1091549 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbfxlib/common/kbfxplasmapixmapprovider.cpp')
-rw-r--r-- | kbfxlib/common/kbfxplasmapixmapprovider.cpp | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/kbfxlib/common/kbfxplasmapixmapprovider.cpp b/kbfxlib/common/kbfxplasmapixmapprovider.cpp new file mode 100644 index 0000000..e505c62 --- /dev/null +++ b/kbfxlib/common/kbfxplasmapixmapprovider.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <[email protected]> + * PhobosK <[email protected]> + * see Also AUTHORS + * + * This program 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 program 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 General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kbfxplasmapixmapprovider.h" + +int +KbfxPlasmaPixmapProvider::addPixmap ( QString pixmapname ) +{ + QString lFileName = PixmapPath( pixmapname ); + QPixmap * lPixmapPtr = 0; + + if ( ( lPixmapPtr = QPixmapCache::find ( pixmapname ) ) == NULL ) + { + lPixmapPtr = new QPixmap ( lFileName ); + QPixmapCache::insert ( pixmapname,lPixmapPtr ); + return ( lPixmapPtr->height() *lPixmapPtr->width() *lPixmapPtr->depth() ) /8; + } + return 0; +} + +QString +KbfxPlasmaPixmapProvider::PixmapPath ( QString pixmapName ) +{ + QString lFileName = ConfigInit ().m_SpinxThemeBasePath + ConfigInit ().m_SpinxThemeName + "/" + pixmapName + ".png"; + + if ( QPixmap::QPixmap ( lFileName ).isNull() ) + lFileName = locate ( "data", "kbfx/skins/default/" + pixmapName + ".png" ); + + return lFileName; +} + +QString +KbfxPlasmaPixmapProvider::PixmapPath ( QString pixmapName, QString themePath, QString themeName ) +{ + QString lFileName = themePath + themeName + "/" + pixmapName + ".png"; + + if ( QPixmap::QPixmap ( lFileName ).isNull() ) + lFileName = locate ( "data", "kbfx/skins/default/" + pixmapName + ".png" ); + + return lFileName; +} + +bool +KbfxPlasmaPixmapProvider::PixmapPathCheck ( QString pixmapPath ) +{ + if ( QPixmap::QPixmap ( pixmapPath ).isNull() ) + return FALSE; + + return TRUE; +} + +void +KbfxPlasmaPixmapProvider::deletePixmap ( const QString & key ) +{ + QPixmapCache::remove ( key ); +} + +void +KbfxPlasmaPixmapProvider::rebuildCache() +{ + QPixmapCache::clear (); + buildCache(); +} + +void KbfxPlasmaPixmapProvider::buildCache() +{ +//m_skinElements.append("topbg"); + QPixmapCache::setCacheLimit ( 1024*5 ); + static QStringList m_skinElements; + m_skinElements + <<"appfind" + <<"bg" + <<"botbg" + <<"butterfly" + <<"dudebox" + <<"find" + <<"hover" + <<"indexseparator" + <<"listboxbg" + <<"lock" + <<"lockhover" + <<"logout" + <<"logouthover" + <<"mask" + <<"menu_top" + <<"menu_top_image_person" + <<"middleboxbg" + <<"normal" + <<"off" + <<"on" + <<"pressed" + <<"preview" + <<"rhshovertile" + <<"rhstile" + <<"scrollnormal" + <<"separator" + <<"tabbg" + <<"tilehover" + <<"tilenormal" + <<"topbg" + <<"appviewbg" + ; + + for ( QStringList::Iterator it = m_skinElements.begin(); it != m_skinElements.end(); ++it ) + { + QPixmapCache::setCacheLimit ( KbfxPlasmaPixmapProvider::addPixmap ( *it ) +QPixmapCache::cacheLimit() ); + } + + +} + +QPixmap * +KbfxPlasmaPixmapProvider::pixmap ( const QString & key ) +{ + QPixmap* pp; + QPixmap p; + if ( ( pp=QPixmapCache::find ( key ) ) ) + { + return pp; + } + else + { + addPixmap ( key ); + return pixmap ( key ); + } + +} + |