KQuickCharts

ChartsControlsPlugin.cpp
1/*
2 * This file is part of KQuickCharts
3 * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8#include "ChartsControlsPlugin.h"
9
10#include <QDebug>
11#include <QFile>
12#include <QQmlEngine>
13#include <QQuickStyle>
14#include <QUrl>
15
16ChartsControlsPlugin::ChartsControlsPlugin(QObject *parent)
17 : QQmlExtensionPlugin(parent)
18{
19}
20
21void ChartsControlsPlugin::registerTypes(const char *uri)
22{
23 Q_ASSERT(QString::fromLatin1(uri) == QLatin1String("org.kde.quickcharts.controls"));
24
25 m_styleName = QQuickStyle::name();
26
27 qmlRegisterSingletonType(componentUrl(QStringLiteral("Theme.qml")), uri, 1, 0, "Theme");
28 qmlRegisterType(componentUrl(QStringLiteral("Legend.qml")), uri, 1, 0, "Legend");
29 qmlRegisterType(componentUrl(QStringLiteral("LegendDelegate.qml")), uri, 1, 0, "LegendDelegate");
30 qmlRegisterType(componentUrl(QStringLiteral("LineChartControl.qml")), uri, 1, 0, "LineChartControl");
31 qmlRegisterType(componentUrl(QStringLiteral("PieChartControl.qml")), uri, 1, 0, "PieChartControl");
32
33 qmlRegisterSingletonType(componentUrl(QStringLiteral("Logging.qml")), uri, 1, 0, "Logging");
34}
35
36QUrl ChartsControlsPlugin::componentUrl(const QString &fileName)
37{
38 auto url = baseUrl();
39 url.setPath(url.path() % QLatin1Char('/'));
40
41 auto styled = url.resolved(QUrl{QStringLiteral("styles/") % m_styleName % QLatin1Char('/') % fileName});
42 if (QFile::exists(styled.toLocalFile())) {
43 return styled;
44 }
45
46 return url.resolved(QUrl{fileName});
47}
48
49#include "moc_ChartsControlsPlugin.cpp"
bool exists() const const
QString name()
QString fromLatin1(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:57 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.