PCManFM-Qt
icontheme.h
1 /*
2  <one line to give the library's name and an idea of what it does.>
3  Copyright (C) 2012 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 
21 #ifndef FM_ICONTHEME_H
22 #define FM_ICONTHEME_H
23 
24 #include "libfmqtglobals.h"
25 #include <QIcon>
26 #include <QString>
27 #include "libfm/fm.h"
28 
29 namespace Fm {
30 
31 // NOTE:
32 // Qt seems to has its own QIcon pixmap caching mechanism internally.
33 // Besides, it also caches QIcon objects created by QIcon::fromTheme().
34 // So maybe we should not duplicate the work.
35 // See http://qt.gitorious.org/qt/qt/blobs/4.8/src/gui/image/qicon.cpp
36 // QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state).
37 // In addition, QPixmap is actually stored in X11 server, not client side.
38 // Hence maybe we should not cache too many pixmaps, I guess?
39 // Let's have Qt do its work and only translate GIcon to QIcon here.
40 
41 // Nice article about QPixmap from KDE: http://techbase.kde.org/Development/Tutorials/Graphics/Performance
42 
43 class LIBFM_QT_API IconTheme: public QObject {
44  Q_OBJECT
45 public:
46  IconTheme();
47  ~IconTheme();
48 
49  static IconTheme* instance();
50  static QIcon icon(FmIcon* fmicon);
51  static QIcon icon(GIcon* gicon);
52 
53  static void checkChanged(); // check if current icon theme name is changed
54 Q_SIGNALS:
55  void changed(); // emitted when the name of current icon theme is changed
56 
57 protected:
58  bool eventFilter(QObject *obj, QEvent *event);
59  static QIcon convertFromGIcon(GIcon* gicon);
60  static QIcon iconFromNames(const char * const * names);
61 
62 protected:
63  QIcon fallbackIcon_;
64  QString currentThemeName_;
65 };
66 
67 }
68 
69 #endif // FM_ICONTHEME_H
Definition: appchoosercombobox.cpp:26
Definition: icontheme.h:43