| 1 |  | 
| 2 | // Copyright (C) 2024 The Qt Company Ltd. | 
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | 
| 4 | #include "qquickfluentwinui3focusstroke_p.h" | 
| 5 | #include <QtGui/qpainter.h> | 
| 6 | #include <QtGui/qpainterpath.h> | 
| 7 | #include <QtQuick/private/qquickitem_p.h> | 
| 8 | QT_BEGIN_NAMESPACE | 
| 9 | QQuickFluentWinUI3FocusStroke::QQuickFluentWinUI3FocusStroke(QQuickItem *parent) | 
| 10 |     : QQuickPaintedItem(parent) | 
| 11 | { | 
| 12 | } | 
| 13 | void QQuickFluentWinUI3FocusStroke::paint(QPainter *painter) | 
| 14 | { | 
| 15 |     painter->setRenderHint(hint: QPainter::Antialiasing); | 
| 16 |     QPainterPath path; | 
| 17 |     QRectF rect = boundingRect(); | 
| 18 |     path.moveTo(x: rect.left(), y: rect.top() + m_radius); | 
| 19 |     path.lineTo(x: rect.left(), y: rect.bottom() - m_radius); | 
| 20 |     path.arcTo(rect: QRectF(rect.left(), rect.bottom() - 2 * m_radius, 2 * m_radius, 2 * m_radius), startAngle: 180, arcLength: 90); | 
| 21 |     path.lineTo(x: rect.right() - m_radius, y: rect.bottom()); | 
| 22 |     path.arcTo(rect: QRectF(rect.right() - 2 * m_radius, rect.bottom() - 2 * m_radius, 2 * m_radius, 2 * m_radius), startAngle: 270, arcLength: 90); | 
| 23 |     path.lineTo(x: rect.right(), y: rect.top() + m_radius); | 
| 24 |     path.lineTo(x: rect.right(), y: rect.top() + m_radius); | 
| 25 |     path.lineTo(x: rect.right(), y: rect.top()); | 
| 26 |     path.lineTo(x: rect.left(), y: rect.top()); | 
| 27 |     painter->fillPath(path, brush: m_color); | 
| 28 | } | 
| 29 | QColor QQuickFluentWinUI3FocusStroke::color() const | 
| 30 | { | 
| 31 |     return m_color; | 
| 32 | } | 
| 33 | void QQuickFluentWinUI3FocusStroke::setColor(const QColor &color) | 
| 34 | { | 
| 35 |     if (color == m_color) | 
| 36 |         return; | 
| 37 |     m_color = color; | 
| 38 |     update(); | 
| 39 | } | 
| 40 | int QQuickFluentWinUI3FocusStroke::radius() const | 
| 41 | { | 
| 42 |     return m_radius; | 
| 43 | } | 
| 44 | void QQuickFluentWinUI3FocusStroke::setRadius(int radius) | 
| 45 | { | 
| 46 |     if (m_radius == radius) | 
| 47 |         return; | 
| 48 |     m_radius = radius; | 
| 49 |     update(); | 
| 50 | } | 
| 51 | QT_END_NAMESPACE | 
| 52 | #include "moc_qquickfluentwinui3focusstroke_p.cpp" | 
| 53 |  |