]> git.sur5r.net Git - minitube/blob - src/iconutils.h
2fbe0b2340c891273343020563d34e6be8c59007
[minitube] / src / iconutils.h
1 /* $BEGIN_LICENSE
2
3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
5
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
18
19 $END_LICENSE */
20
21 #ifndef ICONUTILS_H
22 #define ICONUTILS_H
23
24 #include <QtGui>
25
26 class IconUtils {
27
28 public:
29     static QIcon fromTheme(const QString &name);
30     static QIcon fromResources(const QString &name);
31     static QIcon icon(const QString &name);
32     static QIcon icon(const QStringList &names);
33     static QIcon tintedIcon(const QString &name, const QColor &color,
34                             QList<QSize> sizes = QList<QSize>());
35     static QIcon tintedIcon(const QString &name, const QColor &color, const QSize &size);
36     static void setupAction(QAction *action);
37
38     // HiDPI stuff
39     static QPixmap pixmap(const QString &name);
40     static qreal maxSupportedPixelRatio() { return 2.0; }
41     static qreal pixelRatio();
42
43 private:
44     IconUtils() { }
45     static QImage grayscaled(const QImage &image);
46     static QImage tinted(const QImage &image, const QColor &color,
47                          QPainter::CompositionMode mode = QPainter::CompositionMode_Screen);
48 };
49
50 #endif // ICONUTILS_H