2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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::getPixmap(const QString
& id
) {
103 return getValue
<QPixmap
>(id
);
106 QPixmap
PixmapLoader::piecePixmap(const QString
& id
, bool flipped
) {
107 ::LuaApi::LuaValueMap args
;
109 args
["flipped"] = 0.0;
111 return getValue
<QPixmap
>(id
, &args
);
112 // return getValue<QPixmap>(id);
116 T
PixmapLoader::getValue(const QString
& id
, const ::LuaApi::LuaValueMap
* args
, bool allow_nil
) {
117 if (!m_size
|| !m_theme
)
123 return m_loader
->getValue
<T
>(id
, m_size
, args
, allow_nil
);
126 template QPixmap
PixmapLoader::getValue
<QPixmap
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
127 template Loader::PixmapOrMap
PixmapLoader::getValue
<Loader::PixmapOrMap
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
128 template Loader::Glyph
PixmapLoader::getValue
<Loader::Glyph
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
129 template double PixmapLoader::getValue
<double>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
130 template QPointF
PixmapLoader::getValue
<QPointF
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
131 template QRectF
PixmapLoader::getValue
<QRectF
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
132 template QBrush
PixmapLoader::getValue
<QBrush
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
133 template QColor
PixmapLoader::getValue
<QColor
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
134 template QFont
PixmapLoader::getValue
<QFont
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
135 template ::LuaApi::LuaValueMap
PixmapLoader::getValue
< ::LuaApi::LuaValueMap
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
139 T
PixmapLoader::getStaticValue(const QString
& id
, const ::LuaApi::LuaValueMap
* args
, bool allow_nil
) {
146 return m_loader
->getValue
<T
>(id
, 0, args
, allow_nil
);
149 template QPixmap
PixmapLoader::getStaticValue
<QPixmap
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
150 template Loader::PixmapOrMap
PixmapLoader::getStaticValue
<Loader::PixmapOrMap
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
151 template Loader::Glyph
PixmapLoader::getStaticValue
<Loader::Glyph
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
152 template double PixmapLoader::getStaticValue
<double>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
153 template QPointF
PixmapLoader::getStaticValue
<QPointF
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
154 template QRectF
PixmapLoader::getStaticValue
<QRectF
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
155 template QBrush
PixmapLoader::getStaticValue
<QBrush
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
156 template QColor
PixmapLoader::getStaticValue
<QColor
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
157 template QFont
PixmapLoader::getStaticValue
<QFont
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);
158 template ::LuaApi::LuaValueMap
PixmapLoader::getStaticValue
< ::LuaApi::LuaValueMap
>(const QString
&, const ::LuaApi::LuaValueMap
*, bool allow_nil
);