// Copyright (C) 2021 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 "qtquicktemplates2global_p.h"

#include <QtGui/qtguiglobal.h>

#if QT_CONFIG(accessibility)
#include "qquickpage_p.h"
#include "qquickpopupitem_p_p.h"
#include "qquickscrollbar_p.h"
#include "qquickslider_p.h"
#include "accessible/qaccessiblequickapplicationwindow_p.h"
#include "accessible/qaccessiblequickcontrol_p.h"
#include "accessible/qaccessiblequickpage_p.h"
#include "accessible/qaccessiblequickpopupitem_p.h"
#include "accessible/qaccessiblequickscrollbar_p.h"
#include "accessible/qaccessiblequickslider_p.h"
#endif

QT_BEGIN_NAMESPACE

#if QT_CONFIG(accessibility)
static QAccessibleInterface *qQuickAccessibleFactory(const QString &classname, QObject *object)
{
    if (classname == u"QQuickPage")
        return new QAccessibleQuickPage(qobject_cast<QQuickPage *>(object));
    if (classname == u"QQuickScrollBar")
        return new QAccessibleQuickScrollBar(qobject_cast<QQuickScrollBar *>(object));
    if (classname == u"QQuickSlider")
        return new QAccessibleQuickSlider(qobject_cast<QQuickSlider *>(object));
    if (classname == u"QQuickControl")
        return new QAccessibleQuickControl(qobject_cast<QQuickControl *>(object));
    if (classname == u"QQuickPopupItem")
        return new QAccessibleQuickPopupItem(qobject_cast<QQuickPopupItem *>(object));
    if (classname == u"QQuickApplicationWindow")
        return new QAccessibleQuickApplicationWindow(qobject_cast<QQuickApplicationWindow *>(object));

    return nullptr;
}
#endif

void QQuickTemplates_initializeModule()
{
#if QT_CONFIG(accessibility)
    QAccessible::installFactory(&qQuickAccessibleFactory);
#endif
}

Q_CONSTRUCTOR_FUNCTION(QQuickTemplates_initializeModule)

QT_END_NAMESPACE
