2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
14 #include "loader/theme.h"
15 #include "pixmaploader.h"
16 #include "themeinfo.h"
18 class PixmapLoader::ThemeLoader
: public Loader::Theme
{
22 ThemeLoader(const ThemeInfo
& t
)
28 PixmapLoader::PixmapLoader()
34 PixmapLoader::~PixmapLoader() {
38 PixmapLoader::ThemeLoadersCache
& PixmapLoader::loaders() {
39 static ThemeLoadersCache cache
;
43 void PixmapLoader::flush() {
47 m_loader
->unrefSize(m_size
);
48 m_loader
->unrefSize(0);
50 /* unref the loader, and possibly destroy it */
51 if(!--m_loader
->m_ref_count
) {
53 loaders().remove(m_theme
);
59 void PixmapLoader::setTheme(const ThemeInfo
& theme
) {
67 void PixmapLoader::setSize(int s
) {
75 m_loader
->unrefSize(m_size
);
80 void PixmapLoader::initialize() {
84 /* try to get a loader */
85 m_loader
= loaders().value(m_theme
, 0);
89 m_loader
= new ThemeLoader(m_theme
);
90 loaders().insert(m_theme
, m_loader
);
95 m_loader
->m_ref_count
++;
97 m_loader
->refSize(m_size
);
102 QPixmap
PixmapLoader::operator()(const QString
& id
) {
103 return getValue
<QPixmap
>(id
);
107 T
PixmapLoader::getValue(const QString
& id
, const ::LuaApi::LuaValueMap
* args
) {
108 if (!m_size
|| !m_theme
)
114 return m_loader
->getValue
<T
>(id
, m_size
, args
);
117 template QPixmap
PixmapLoader::getValue
<QPixmap
>(const QString
&, const ::LuaApi::LuaValueMap
*);
118 template Loader::PixmapOrMap
PixmapLoader::getValue
<Loader::PixmapOrMap
>(const QString
&, const ::LuaApi::LuaValueMap
*);
119 template Loader::Glyph
PixmapLoader::getValue
<Loader::Glyph
>(const QString
&, const ::LuaApi::LuaValueMap
*);
120 template double PixmapLoader::getValue
<double>(const QString
&, const ::LuaApi::LuaValueMap
*);
121 template QPointF
PixmapLoader::getValue
<QPointF
>(const QString
&, const ::LuaApi::LuaValueMap
*);
122 template QRectF
PixmapLoader::getValue
<QRectF
>(const QString
&, const ::LuaApi::LuaValueMap
*);
123 template QBrush
PixmapLoader::getValue
<QBrush
>(const QString
&, const ::LuaApi::LuaValueMap
*);
124 template QColor
PixmapLoader::getValue
<QColor
>(const QString
&, const ::LuaApi::LuaValueMap
*);
125 template QFont
PixmapLoader::getValue
<QFont
>(const QString
&, const ::LuaApi::LuaValueMap
*);
126 template ::LuaApi::LuaValueMap
PixmapLoader::getValue
< ::LuaApi::LuaValueMap
>(const QString
&, const ::LuaApi::LuaValueMap
*);
130 T
PixmapLoader::getStaticValue(const QString
& id
, const ::LuaApi::LuaValueMap
* args
) {
137 return m_loader
->getValue
<T
>(id
, 0, args
);
140 template QPixmap
PixmapLoader::getStaticValue
<QPixmap
>(const QString
&, const ::LuaApi::LuaValueMap
*);
141 template Loader::PixmapOrMap
PixmapLoader::getStaticValue
<Loader::PixmapOrMap
>(const QString
&, const ::LuaApi::LuaValueMap
*);
142 template Loader::Glyph
PixmapLoader::getStaticValue
<Loader::Glyph
>(const QString
&, const ::LuaApi::LuaValueMap
*);
143 template double PixmapLoader::getStaticValue
<double>(const QString
&, const ::LuaApi::LuaValueMap
*);
144 template QPointF
PixmapLoader::getStaticValue
<QPointF
>(const QString
&, const ::LuaApi::LuaValueMap
*);
145 template QRectF
PixmapLoader::getStaticValue
<QRectF
>(const QString
&, const ::LuaApi::LuaValueMap
*);
146 template QBrush
PixmapLoader::getStaticValue
<QBrush
>(const QString
&, const ::LuaApi::LuaValueMap
*);
147 template QColor
PixmapLoader::getStaticValue
<QColor
>(const QString
&, const ::LuaApi::LuaValueMap
*);
148 template QFont
PixmapLoader::getStaticValue
<QFont
>(const QString
&, const ::LuaApi::LuaValueMap
*);
149 template ::LuaApi::LuaValueMap
PixmapLoader::getStaticValue
< ::LuaApi::LuaValueMap
>(const QString
&, const ::LuaApi::LuaValueMap
*);