1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #include "iconloader_p.h" |
30 | |
31 | #include <QtCore/qfile.h> |
32 | #include <QtGui/qicon.h> |
33 | #include <QtGui/qpixmap.h> |
34 | |
35 | QT_BEGIN_NAMESPACE |
36 | |
37 | namespace qdesigner_internal { |
38 | |
39 | QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) |
40 | { |
41 | const QStringList candidates = QStringList() |
42 | << (QString::fromUtf8(str: ":/qt-project.org/formeditor/images/" ) + name) |
43 | #ifdef Q_OS_MACOS |
44 | << (QString::fromUtf8(":/qt-project.org/formeditor/images/mac/" ) + name) |
45 | #else |
46 | << (QString::fromUtf8(str: ":/qt-project.org/formeditor/images/win/" ) + name) |
47 | #endif |
48 | << (QString::fromUtf8(str: ":/qt-project.org/formeditor/images/designer_" ) + name); |
49 | |
50 | for (const QString &f : candidates) { |
51 | if (QFile::exists(fileName: f)) |
52 | return QIcon(f); |
53 | } |
54 | |
55 | return QIcon(); |
56 | } |
57 | |
58 | QDESIGNER_SHARED_EXPORT QIcon emptyIcon() |
59 | { |
60 | return QIcon(QStringLiteral(":/qt-project.org/formeditor/images/emptyicon.png" )); |
61 | } |
62 | |
63 | static QIcon buildIcon(const QString &prefix, const int *sizes, size_t sizeCount) |
64 | { |
65 | QIcon result; |
66 | for (size_t i = 0; i < sizeCount; ++i) { |
67 | const QString size = QString::number(sizes[i]); |
68 | const QPixmap pixmap(prefix + size + QLatin1Char('x') + size + QStringLiteral(".png" )); |
69 | Q_ASSERT(!pixmap.size().isEmpty()); |
70 | result.addPixmap(pixmap); |
71 | } |
72 | return result; |
73 | } |
74 | |
75 | QDESIGNER_SHARED_EXPORT QIcon qtLogoIcon() |
76 | { |
77 | static const int sizes[] = {16, 24, 32, 64}; |
78 | static const QIcon result = |
79 | buildIcon(QStringLiteral(":/qt-project.org/formeditor/images/qtlogo" ), |
80 | sizes, sizeCount: sizeof(sizes) / sizeof(sizes[0])); |
81 | return result; |
82 | } |
83 | |
84 | } // namespace qdesigner_internal |
85 | |
86 | QT_END_NAMESPACE |
87 | |
88 | |