1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QABSTRACTFILEICONENGINE_P_H
5#define QABSTRACTFILEICONENGINE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qfileinfo.h>
19#include <private/qicon_p.h>
20#include <qpa/qplatformtheme.h>
21
22QT_BEGIN_NAMESPACE
23
24class Q_GUI_EXPORT QAbstractFileIconEngine : public QPixmapIconEngine
25{
26public:
27 explicit QAbstractFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts)
28 : QPixmapIconEngine(), m_fileInfo(info), m_options(opts) {}
29
30 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override;
31 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State, qreal scale) override;
32 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
33 bool isNull() override { return false; }
34
35 QFileInfo fileInfo() const { return m_fileInfo; }
36 QPlatformTheme::IconOptions options() const { return m_options; }
37
38 // Helper to convert a sequence of ints to a list of QSize
39 template <class It> static QList<QSize> toSizeList(It i1, It i2);
40
41protected:
42 virtual QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) = 0;
43 virtual QString cacheKey() const;
44
45private:
46 const QFileInfo m_fileInfo;
47 const QPlatformTheme::IconOptions m_options;
48};
49
50template <class It>
51inline QList<QSize> QAbstractFileIconEngine::toSizeList(It i1, It i2)
52{
53 QList<QSize> result;
54 result.reserve(size: int(i2 - i1));
55 for ( ; i1 != i2; ++i1)
56 result.append(t: QSize(*i1, *i1));
57 return result;
58}
59
60QT_END_NAMESPACE
61
62#endif // QABSTRACTFILEICONENGINE_P_H
63

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/gui/image/qabstractfileiconengine_p.h