• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. Kirigami
  • KDE Home
  • Contact Us

Quick Links

Skip menu "Kirigami"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Related Pages

Class Picker

About

QtQuick plugins to build user interfaces based on the KDE UX guidelines

Maintainer
Marco Martin
Supported platforms
Android, Linux
Community
IRC: #plasma on Freenode
Mailing list: plasma-devel
Use with CMake
find_package(KF5Kirigami)
target_link_libraries(yourapp KF5::Kirigami)
Clone
git clone git://anongit.kde.org/kirigami1.git
Browse source
Kirigami on cgit.kde.org

Kirigami

  • src
kirigamiplugin.cpp
1 /*
2  * Copyright 2009 by Alan Alpert <alan.alpert@nokia.com>
3  * Copyright 2010 by Ménard Alexis <menard@kde.org>
4  * Copyright 2010 by Marco Martin <mart@kde.org>
5 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Library General Public License as
8  * published by the Free Software Foundation; either version 2, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Library General Public License for more details
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #include "kirigamiplugin.h"
23 #include "enums.h"
24 #include "desktopicon.h"
25 
26 #include <QQmlEngine>
27 #include <QQmlContext>
28 #include <QQuickItem>
29 
30 QString KirigamiPlugin::componentPath(const QString &fileName) const
31 {
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);
36  }
37  }
38  return resolveFileUrl(fileName);
39 }
40 
41 
42 void KirigamiPlugin::registerTypes(const char *uri)
43 {
44  Q_ASSERT(uri == QLatin1String("org.kde.kirigami"));
45  const QString style = QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_STYLE"));
46 
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"));
50  }
51 #endif
52 
53  if (!style.isEmpty() && QFile::exists(resolveFilePath(QStringLiteral("/styles/") + style))) {
54  m_stylesFallbackChain.prepend(style);
55  }
56  //At this point the fallback chain will be selected->Desktop->Fallback
57 
58 
59  //TODO: in this plugin it will end up something similar to
60  //PlasmaCore's ColorScope?
61 
62  qmlRegisterUncreatableType<ApplicationHeaderStyle>(uri, 1, 0, "ApplicationHeaderStyle", "Cannot create objects of type ApplicationHeaderStyle");
63 
64  qmlRegisterSingletonType(componentPath(QStringLiteral("Theme.qml")), uri, 1, 0, "Theme");
65  qmlRegisterSingletonType(componentPath(QStringLiteral("Units.qml")), uri, 1, 0, "Units");
66 
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");
80 
81  //The icon is "special: we have to use a wrapper class to QIcon on desktops
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");
85  } else {
86  qmlRegisterType(componentPath(QStringLiteral("Icon.qml")), uri, 1, 0, "Icon");
87  }
88 #else
89  qmlRegisterType(componentPath(QStringLiteral("Icon.qml")), uri, 1, 0, "Icon");
90 #endif
91 
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);
99 }
100 
101 #include "moc_kirigamiplugin.cpp"
102 
This file is part of the KDE documentation.
Documentation copyright © 1996-2017 The KDE developers.
Generated on Fri Feb 17 2017 11:09:23 by doxygen 1.8.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal