~ubuntu-branches/ubuntu/vivid/sni-qt/vivid

« back to all changes in this revision

Viewing changes to .pc/do-not-eat-cpu-with-animated-icons.diff/src/iconcache.h

  • Committer: Package Import Robot
  • Author(s): Aurélien Gâteau
  • Date: 2011-10-25 15:52:35 UTC
  • Revision ID: package-import@ubuntu.com-20111025155235-iqg8hr22nhat246u
Tags: 0.2.5-0ubuntu3
Backport r88.1.4 from upstream trunk: avoid causing unity-panel-service to
eat all CPU when an application uses an animated icon (LP: #865601)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the sni-qt project
 
2
   Copyright 2011 Canonical
 
3
   Author: Aurelien Gateau <aurelien.gateau@canonical.com>
 
4
 
 
5
   sni-qt is free software; you can redistribute it and/or modify it under the
 
6
   terms of the GNU Lesser General Public License (LGPL) as published by the
 
7
   Free Software Foundation; version 3 of the License.
 
8
 
 
9
   sni-qt is distributed in the hope that it will be useful, but WITHOUT ANY
 
10
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
   FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 
12
   more details.
 
13
 
 
14
   You should have received a copy of the GNU Lesser General Public License
 
15
   along with sni-qt.  If not, see <http://www.gnu.org/licenses/>.
 
16
*/
 
17
#ifndef ICONCACHE_H
 
18
#define ICONCACHE_H
 
19
 
 
20
// Qt
 
21
#include <QObject>
 
22
#include <QStringList>
 
23
 
 
24
class QIcon;
 
25
 
 
26
/**
 
27
 * This class will save pixmaps from icons in a temporary dir on the disk,
 
28
 * making it possible to pass filenames for icons without names.
 
29
 */
 
30
class IconCache : public QObject
 
31
{
 
32
    Q_OBJECT
 
33
public:
 
34
    IconCache(const QString& baseDir, QObject* parent=0);
 
35
 
 
36
    static const int MaxIconCount;
 
37
 
 
38
    QString themePath() const;
 
39
 
 
40
    QString nameForIcon(const QIcon& icon) const;
 
41
 
 
42
    // Internal, testing only
 
43
    QStringList cacheKeys() const { return m_cacheKeys; }
 
44
 
 
45
private:
 
46
    QString m_themePath;
 
47
    mutable QStringList m_cacheKeys;
 
48
 
 
49
    void cacheIcon(const QIcon&) const;
 
50
    void trimCache() const;
 
51
};
 
52
 
 
53
#endif /* ICONCACHE_H */