File indexing completed on 2024-06-23 05:13:36

0001 /*
0002     accessibility/accessiblewidgetfactory.cpp
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2021, 2022 g10 Code GmbH
0006     SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #include "accessiblewidgetfactory.h"
0012 
0013 #include "accessiblerichtextlabel_p.h"
0014 #include "accessiblevaluelabel_p.h"
0015 
0016 #include "utils/accessibility.h"
0017 #include "view/htmllabel.h"
0018 #include "view/urllabel.h"
0019 
0020 QAccessibleInterface *Kleo::accessibleWidgetFactory(const QString &classname, QObject *object)
0021 {
0022     QAccessibleInterface *iface = nullptr;
0023     if (!object || !object->isWidgetType())
0024         return iface;
0025 
0026     QWidget *widget = static_cast<QWidget *>(object);
0027 
0028     if (classname == QString::fromLatin1(Kleo::HtmlLabel::staticMetaObject.className())
0029         || classname == QString::fromLatin1(Kleo::UrlLabel::staticMetaObject.className())) {
0030         iface = new AccessibleRichTextLabel{widget};
0031     } else if (classname == QLatin1StringView("QLabel") && Kleo::representAsAccessibleValueWidget(widget)) {
0032         iface = new AccessibleValueLabel{widget};
0033     }
0034 
0035     return iface;
0036 }