22 #include "kirigamiplugin.h"
24 #include "desktopicon.h"
27 #include <QQmlContext>
30 QString KirigamiPlugin::componentPath(
const QString &fileName)
const
32 foreach (
const QString &style, m_stylesFallbackChain) {
33 const QString candidate = QStringLiteral(
"styles/") + style + QLatin1Char(
'/') + fileName;
34 if (QFile::exists(resolveFilePath(candidate))) {
35 return resolveFileUrl(candidate);
38 return resolveFileUrl(fileName);
42 void KirigamiPlugin::registerTypes(
const char *uri)
44 Q_ASSERT(uri == QLatin1String(
"org.kde.kirigami"));
45 const QString style = QString::fromLatin1(qgetenv(
"QT_QUICK_CONTROLS_STYLE"));
47 #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
48 if (style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral(
"/styles/Desktop")))) {
49 m_stylesFallbackChain.prepend(QStringLiteral(
"Desktop"));
53 if (!style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral(
"/styles/") + style))) {
54 m_stylesFallbackChain.prepend(style);
62 qmlRegisterUncreatableType<ApplicationHeaderStyle>(uri, 1, 0,
"ApplicationHeaderStyle",
"Cannot create objects of type ApplicationHeaderStyle");
64 qmlRegisterSingletonType(componentPath(QStringLiteral(
"Theme.qml")), uri, 1, 0,
"Theme");
65 qmlRegisterSingletonType(componentPath(QStringLiteral(
"Units.qml")), uri, 1, 0,
"Units");
67 qmlRegisterType(componentPath(QStringLiteral(
"Action.qml")), uri, 1, 0,
"Action");
68 qmlRegisterType(componentPath(QStringLiteral(
"AbstractApplicationHeader.qml")), uri, 1, 0,
"AbstractApplicationHeader");
69 qmlRegisterType(componentPath(QStringLiteral(
"AbstractApplicationWindow.qml")), uri, 1, 0,
"AbstractApplicationWindow");
70 qmlRegisterType(componentPath(QStringLiteral(
"AbstractListItem.qml")), uri, 1, 0,
"AbstractListItem");
71 qmlRegisterType(componentPath(QStringLiteral(
"ApplicationHeader.qml")), uri, 1, 0,
"ApplicationHeader");
72 qmlRegisterType(componentPath(QStringLiteral(
"ToolBarApplicationHeader.qml")), uri, 1, 0,
"ToolBarApplicationHeader");
73 qmlRegisterType(componentPath(QStringLiteral(
"ApplicationWindow.qml")), uri, 1, 0,
"ApplicationWindow");
74 qmlRegisterType(componentPath(QStringLiteral(
"BasicListItem.qml")), uri, 1, 0,
"BasicListItem");
75 qmlRegisterType(componentPath(QStringLiteral(
"OverlayDrawer.qml")), uri, 1, 0,
"OverlayDrawer");
76 qmlRegisterType(componentPath(QStringLiteral(
"ContextDrawer.qml")), uri, 1, 0,
"ContextDrawer");
77 qmlRegisterType(componentPath(QStringLiteral(
"GlobalDrawer.qml")), uri, 1, 0,
"GlobalDrawer");
78 qmlRegisterType(componentPath(QStringLiteral(
"Heading.qml")), uri, 1, 0,
"Heading");
79 qmlRegisterType(componentPath(QStringLiteral(
"Separator.qml")), uri, 1, 0,
"Separator");
82 #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
83 if (!m_stylesFallbackChain.isEmpty() && m_stylesFallbackChain.first() == QStringLiteral(
"Desktop")) {
84 qmlRegisterType<DesktopIcon>(uri, 1, 0,
"Icon");
86 qmlRegisterType(componentPath(QStringLiteral(
"Icon.qml")), uri, 1, 0,
"Icon");
89 qmlRegisterType(componentPath(QStringLiteral(
"Icon.qml")), uri, 1, 0,
"Icon");
92 qmlRegisterType(componentPath(QStringLiteral(
"Label.qml")), uri, 1, 0,
"Label");
93 qmlRegisterType(componentPath(QStringLiteral(
"OverlaySheet.qml")), uri, 1, 0,
"OverlaySheet");
94 qmlRegisterType(componentPath(QStringLiteral(
"Page.qml")), uri, 1, 0,
"Page");
95 qmlRegisterType(componentPath(QStringLiteral(
"ScrollablePage.qml")), uri, 1, 0,
"ScrollablePage");
96 qmlRegisterType(componentPath(QStringLiteral(
"SplitDrawer.qml")), uri, 1, 0,
"SplitDrawer");
97 qmlRegisterType(componentPath(QStringLiteral(
"SwipeListItem.qml")), uri, 1, 0,
"SwipeListItem");
98 qmlProtectModule(uri, 1);
101 #include "moc_kirigamiplugin.cpp"