Fix navigation in twoPagesSpread mode
[qcomicbook-oblomov] / src / icons.cpp
1 /*
2  * This file is a part of QComicBook.
3  *
4  * Copyright (C) 2005-2006 Pawel Stolowski <yogin@linux.bydg.org>
5  *
6  * QComicBook is free software; you can redestribute it and/or modify it
7  * under terms of GNU General Public License by Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY. See GPL for more details.
11  */
12
13 #include "icons.h"
14 #include <qdir.h>
15
16 using namespace QComicBook;
17
18 QString Icons::iconpath = QString::null;
19 QDict<QIconSet> Icons::set;
20
21 bool Icons::init(const QString& path)
22 {
23         QDir dir(iconpath = path);
24         set.setAutoDelete(true); //icons in the set will be deleted on set deletion
25         return dir.exists();
26 }
27
28 const QIconSet& Icons::get(const QString &name)
29 {
30         QIconSet *icon = set.find(name);
31         if (icon)
32                 return *icon;
33         QPixmap pixmap(iconpath + "/" + name);
34         set.insert(name, icon = new QIconSet(pixmap));
35         return *icon;
36 }
37