Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcocoaservices.mm
Go to the documentation of this file.
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
// Qt-Security score:significant reason:default
4
5
#
include
"qcocoaservices.h"
6
7
#
include
<
AppKit
/
NSWorkspace
.
h
>
8
#
include
<
AppKit
/
NSColorSampler
.
h
>
9
#
include
<
Foundation
/
NSURL
.
h
>
10
11
#
include
<
QtCore
/
QUrl
>
12
#
include
<
QtCore
/
qscopedvaluerollback
.
h
>
13
14
#
include
<
QtGui
/
qdesktopservices
.
h
>
15
#
include
<
QtGui
/
private
/
qcoregraphics_p
.
h
>
16
17
QT_BEGIN_NAMESPACE
18
19
bool
QCocoaServices
::
openUrl
(
const
QUrl &url)
20
{
21
// avoid recursing back into self
22
if
(url == m_handlingUrl)
23
return
false
;
24
25
return
[[NSWorkspace sharedWorkspace] openURL:url.toNSURL()];
26
}
27
28
bool
QCocoaServices
::
openDocument
(
const
QUrl &url)
29
{
30
return
openUrl(url);
31
}
32
33
/* Callback from macOS that the application should handle a URL */
34
bool
QCocoaServices
::
handleUrl
(
const
QUrl &url)
35
{
36
QScopedValueRollback<QUrl> rollback(m_handlingUrl, url);
37
// FIXME: Add platform services callback from QDesktopServices::setUrlHandler
38
// so that we can warn the user if calling setUrlHandler without also setting
39
// up the matching keys in the Info.plist file (CFBundleURLTypes and friends).
40
return
QDesktopServices::openUrl(url);
41
}
42
43
class
QCocoaColorPicker
:
public
QPlatformServiceColorPicker
44
{
45
public
:
46
QCocoaColorPicker
() :
m_colorSampler
([
NSColorSampler
new
]) {}
47
~
QCocoaColorPicker
() { [m_colorSampler release]; }
48
49
void
pickColor
()
override
50
{
51
[m_colorSampler showSamplerWithSelectionHandler:^(NSColor *selectedColor) {
52
emit colorPicked(qt_mac_toQColor(selectedColor));
53
}];
54
}
55
private
:
56
NSColorSampler *m_colorSampler =
nullptr
;
57
};
58
59
60
QPlatformServiceColorPicker
*
QCocoaServices
::
colorPicker
(QWindow *parent)
61
{
62
Q_UNUSED(parent);
63
return
new
QCocoaColorPicker
;
64
}
65
66
bool
QCocoaServices
::
hasCapability
(Capability capability)
const
67
{
68
switch
(capability) {
69
case
ColorPicking:
return
true
;
70
default
:
return
false
;
71
}
72
}
73
74
QT_END_NAMESPACE
QCocoaColorPicker
Definition
qcocoaservices.mm:44
QCocoaColorPicker::pickColor
void pickColor() override
Definition
qcocoaservices.mm:49
QCocoaColorPicker::~QCocoaColorPicker
~QCocoaColorPicker()
Definition
qcocoaservices.mm:47
QCocoaColorPicker::QCocoaColorPicker
QCocoaColorPicker()
Definition
qcocoaservices.mm:46
QCocoaServices
Definition
qcocoaservices.h:15
QCocoaServices::handleUrl
bool handleUrl(const QUrl &url)
Definition
qcocoaservices.mm:34
QCocoaServices::hasCapability
bool hasCapability(Capability capability) const override
Definition
qcocoaservices.mm:66
QCocoaServices::colorPicker
QPlatformServiceColorPicker * colorPicker(QWindow *parent) override
Definition
qcocoaservices.mm:60
QCocoaServices::openUrl
bool openUrl(const QUrl &url) override
Definition
qcocoaservices.mm:19
QCocoaServices::openDocument
bool openDocument(const QUrl &url) override
Definition
qcocoaservices.mm:28
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtbase
src
plugins
platforms
cocoa
qcocoaservices.mm
Generated on
for Qt by
1.14.0