// Copyright (C) 2025 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

#include "qaccessiblequickcontrol_p.h"
#include "qquickcontrol_p.h"

QT_BEGIN_NAMESPACE

QAccessibleQuickControl::QAccessibleQuickControl(QQuickControl *control)
    : QAccessibleQuickItem(control)
{
}

void *QAccessibleQuickControl::interface_cast(QAccessible::InterfaceType t)
{
    if (t == QAccessible::AttributesInterface)
        return static_cast<QAccessibleAttributesInterface *>(this);

    return QAccessibleQuickItem::interface_cast(t);
}

QList<QAccessible::Attribute> QAccessibleQuickControl::attributeKeys() const
{
    return { QAccessible::Attribute::Locale };
}

QVariant QAccessibleQuickControl::attributeValue(QAccessible::Attribute key) const
{
    if (key == QAccessible::Attribute::Locale)
        return QVariant::fromValue(control()->locale());

    return QVariant();
}

QQuickControl *QAccessibleQuickControl::control() const
{
    return static_cast<QQuickControl *>(object());
}

QT_END_NAMESPACE
