aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicknativestyle/util/qquickmacfocusframe.mm
blob: e1c97231aeb0ac39631ded0692577c1b868c077c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
// Qt-Security score:significant reason:default

#include "qquickmacfocusframe.h"

#include <AppKit/AppKit.h>

#include <QtGui/qguiapplication.h>
#include <QtGui/private/qcoregraphics_p.h>

#include <QtQml/qqmlcomponent.h>

QT_BEGIN_NAMESPACE

QQuickItem *QQuickMacFocusFrame::createFocusFrame(QQmlContext *context)
{
    QQmlComponent component(
            context->engine(),
            QUrl(QStringLiteral(
                    "qrc:/qt-project.org/imports/QtQuick/NativeStyle/util/MacFocusFrame.qml")));
    auto frame = qobject_cast<QQuickItem *>(component.create());
    if (!frame)
        return nullptr;

    auto indicatorColor = qt_mac_toQColor(NSColor.keyboardFocusIndicatorColor.CGColor);
    indicatorColor.setAlpha(255);
    frame->setProperty("systemFrameColor", indicatorColor);
    return frame;
}

QT_END_NAMESPACE