Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qcocoaservices.h"
5
6#include <AppKit/NSWorkspace.h>
7#include <AppKit/NSColorSampler.h>
8#include <Foundation/NSURL.h>
9
10#include <QtCore/QUrl>
11#include <QtCore/qscopedvaluerollback.h>
12
13#include <QtGui/qdesktopservices.h>
14#include <QtGui/private/qcoregraphics_p.h>
15
17
19{
20 // avoid recursing back into self
21 if (url == m_handlingUrl)
22 return false;
23
24 return [[NSWorkspace sharedWorkspace] openURL:url.toNSURL()];
25}
26
28{
29 return openUrl(url);
30}
31
32/* Callback from macOS that the application should handle a URL */
34{
35 QScopedValueRollback<QUrl> rollback(m_handlingUrl, url);
36 // FIXME: Add platform services callback from QDesktopServices::setUrlHandler
37 // so that we can warn the user if calling setUrlHandler without also setting
38 // up the matching keys in the Info.plist file (CFBundleURLTypes and friends).
40}
41
43{
44public:
45 QCocoaColorPicker() : m_colorSampler([NSColorSampler new]) {}
46 ~QCocoaColorPicker() { [m_colorSampler release]; }
47
48 void pickColor() override
49 {
50 [m_colorSampler showSamplerWithSelectionHandler:^(NSColor *selectedColor) {
51 emit colorPicked(qt_mac_toQColor(selectedColor));
52 }];
53 }
54private:
55 NSColorSampler *m_colorSampler = nullptr;
56};
57
58
64
66{
67 switch (capability) {
68 case ColorPicking: return true;
69 default: return false;
70 }
71}
72
void pickColor() override
bool handleUrl(const QUrl &url)
bool hasCapability(Capability capability) const override
QPlatformServiceColorPicker * colorPicker(QWindow *parent) override
bool openUrl(const QUrl &url) override
bool openDocument(const QUrl &url) override
static bool openUrl(const QUrl &url)
Opens the given url in the appropriate Web browser for the user's desktop environment,...
void colorPicked(const QColor &color)
Capability
Capabilities are used to determine a specific platform service's availability.
\inmodule QtCore
Definition qurl.h:94
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
QColor qt_mac_toQColor(CGColorRef color)
#define emit
#define Q_UNUSED(x)
QUrl url("example.com")
[constructor-url-reference]
sem release()