Source Code (Use browser search to find items of interest.)
Class Index
amor'AmorThemeManager (./kdetoys/amor/amoranim.h:73)
class AmorThemeManager
{
public:
AmorThemeManager();
virtual ~AmorThemeManager();
bool setTheme(const char *file);
bool readGroup(const char *seq);
AmorAnim *random(const char *group);
QSize maximumSize() const { return mMaximumSize; }
protected:
QString mPath;
KSimpleConfig *mConfig;
QSize mMaximumSize; // The largest pixmap used
QDict<AmorAnimationGroup> mAnimations; // list of animation groups
};
amor'AmorThemeManager::AmorThemeManager() (./kdetoys/amor/amoranim.cpp:126)
AmorThemeManager::AmorThemeManager()
: mMaximumSize(0, 0)
{
mConfig = 0;
mAnimations.setAutoDelete(true);
}
//---------------------------------------------------------------------------
//
amor'AmorThemeManager::~AmorThemeManager() (./kdetoys/amor/amoranim.cpp:135)
AmorThemeManager::~AmorThemeManager()
{
if (mConfig)
{
delete mConfig;
}
}
//---------------------------------------------------------------------------
//
amor'AmorThemeManager::setTheme() (./kdetoys/amor/amoranim.cpp:145)
bool AmorThemeManager::setTheme(const char *file)
{
#if QT_VERSION >= 199
mPath = locate("appdata", file);
#else
mPath = KApplication::localkdedir().copy();
mPath += "/share/apps/amor/";
mPath += file;
if (access(mPath, R_OK))
{
mPath = KApplication::kde_datadir().copy();
mPath += "/amor/";
mPath += file;
}
#endif
if (mConfig)
{
delete mConfig;
}
mConfig = new KSimpleConfig(mPath, true);
mConfig->setGroup("Config");
// Get the directory where the pixmaps are stored and tell the
// pixmap manager.
QString pixmapPath = mConfig->readEntry("PixmapPath");
if (pixmapPath.isEmpty())
{
return false;
}
if (pixmapPath[0] == '/')
{
// absolute path to pixmaps
mPath = pixmapPath;
}
else
{
// relative to config file.
mPath.truncate(mPath.findRev('/')+1);
mPath += pixmapPath;
}
mMaximumSize.setWidth(0);
mMaximumSize.setHeight(0);
mAnimations.clear();
return true;
}
//---------------------------------------------------------------------------
//
// Select an animimation randomly from a group
//
amor'AmorThemeManager::random() (./kdetoys/amor/amoranim.cpp:201)
AmorAnim *AmorThemeManager::random(const char *group)
{
AmorAnimationGroup *animGroup = mAnimations.find(group);
if (animGroup)
{
return animGroup->at(kapp->random()%animGroup->count());
}
return 0;
}
//---------------------------------------------------------------------------
//
// Read an animation group.
//
amor'AmorThemeManager::readGroup() (./kdetoys/amor/amoranim.cpp:217)
bool AmorThemeManager::readGroup(const char *seq)
{
AmorPixmapManager::manager()->setPixmapDir(mPath);
AmorAnimationGroup *animList = new AmorAnimationGroup;
animList->setAutoDelete(true);
// Read the list of available animations.
mConfig->setGroup("Config");
QStrList list;
int entries = mConfig->readListEntry(seq, list);
// Read each individual animation
for (int i = 0; i < entries; i++)
{
mConfig->setGroup(list.at(i));
AmorAnim *anim = new AmorAnim(*mConfig);
animList->append(anim);
mMaximumSize = mMaximumSize.expandedTo(anim->maximumSize());
}
// If no animations were available for this group, just add the base anim
if (entries == 0)
{
mConfig->setGroup("Base");
AmorAnim *anim = new AmorAnim(*mConfig);
if (anim)
{
animList->append(anim);
mMaximumSize = mMaximumSize.expandedTo(anim->maximumSize());
entries++;
}
}
// Couldn't read any entries at all
if (entries == 0)
{
return false;
}
mAnimations.insert(seq, animList);
return true;
}