Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qapplefileiconengine.mm
Go to the documentation of this file.
1
// Copyright (C) 2025 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
// Qt-Security score:significant reason:default
4
5
#
include
"qapplefileiconengine_p.h"
6
#
include
"qappleiconengine_p.h"
7
8
#
if
defined
(
Q_OS_MACOS
)
9
#
include
<
AppKit
/
AppKit
.
h
>
10
#
elif
defined
(
QT_PLATFORM_UIKIT
)
11
#
include
<
UIKit
/
UIKit
.
h
>
12
#
endif
13
14
#
include
<
QtCore
/
qurl
.
h
>
15
#
include
<
QtGui
/
private
/
qcoregraphics_p
.
h
>
16
17
QT_BEGIN_NAMESPACE
18
19
using
namespace
Qt::StringLiterals;
20
21
QAppleFileIconEngine::QAppleFileIconEngine(
const
QFileInfo &info, QPlatformTheme::IconOptions opts)
22
: QAbstractFileIconEngine(info, opts)
23
{
24
#
if
defined
(
Q_OS_MACOS
)
25
m_image = [[NSWorkspace sharedWorkspace] iconForFile:fileInfo().canonicalFilePath().toNSString()];
26
#
elif
defined
(
QT_PLATFORM_UIKIT
)
27
const
QUrl url = QUrl::fromLocalFile(fileInfo().canonicalFilePath());
28
const
auto
controller = [UIDocumentInteractionController interactionControllerWithURL:url.toNSURL()];
29
const
auto
allIcons = controller.icons;
30
m_image = allIcons.count > 0 ? [allIcons firstObject] : nil;
31
#
endif
32
if
(m_image)
33
[m_image retain];
34
}
35
36
QAppleFileIconEngine::~QAppleFileIconEngine()
37
{
38
if
(m_image)
39
[m_image release];
40
}
41
42
QList<QSize> QAppleFileIconEngine::availableSizes(QIcon::Mode, QIcon::State)
43
{
44
return
QAppleIconEngine::availableIconSizes();
45
}
46
47
bool
QAppleFileIconEngine::isNull()
48
{
49
return
m_image == nil;
50
}
51
52
QPixmap QAppleFileIconEngine::filePixmap(
const
QSize &size, QIcon::Mode, QIcon::State)
53
{
54
if
(!m_image)
55
return
QPixmap();
56
57
const
QSize preferredSize = QSize(m_image.size.width,
58
m_image.size.height).scaled(size, Qt::KeepAspectRatio);
59
60
if
(m_pixmap.size() == preferredSize)
61
return
m_pixmap;
62
63
#
if
defined
(
Q_OS_MACOS
)
64
m_pixmap = qt_mac_toQPixmap(m_image, preferredSize);
65
#
elif
defined
(
QT_PLATFORM_UIKIT
)
66
m_pixmap = QPixmap::fromImage(qt_mac_toQImage(m_image, preferredSize));
67
#
endif
68
return
m_pixmap;
69
}
70
71
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
gui
platform
darwin
qapplefileiconengine.mm
Generated on
for Qt by
1.18.0