Plasma-framework

corebindingsplugin.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Alan Alpert <alan.alpert@nokia.com>
3 SPDX-FileCopyrightText: 2010 Ménard Alexis <menard@kde.org>
4 SPDX-FileCopyrightText: 2010 Marco Martin <mart@kde.org>
5 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#include "corebindingsplugin.h"
11
12#include <QActionGroup>
13#include <QQmlContext>
14
15#include <KLocalizedContext>
16
17#include "action.h"
18#include "appletpopup.h"
19
20#include "dialog.h"
21#include "quicktheme.h"
22
23#include "tooltip.h"
24#include "windowthumbnail.h"
25
26#include <QDebug>
27#include <QQmlPropertyMap>
28#include <QWindow>
29#include <qqml.h>
30
31void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
32{
34
35 QQmlContext *context = engine->rootContext();
36
37 if (!context->contextObject()) {
38 KLocalizedContext *localizedContextObject = new KLocalizedContext(engine);
39 context->setContextObject(localizedContextObject);
40 }
41 // This ensures that importing plasmacore will make any KSvg use the current lasma theme
42 new Plasma::Theme(engine);
43}
44
45void CoreBindingsPlugin::registerTypes(const char *uri)
46{
47 Q_ASSERT(uri == QByteArray("org.kde.plasma.core"));
48
49 qmlRegisterUncreatableType<Plasma::Types>(uri, 2, 0, "Types", {});
50
51 // qmlRegisterType<ThemeProxy>(uri, 2, 0, "Theme");
52 qmlRegisterSingletonType<Plasma::QuickTheme>(uri, 2, 0, "Theme", [](QQmlEngine *engine, QJSEngine *) -> QObject * {
53 return new Plasma::QuickTheme(engine);
54 });
55
56 qmlRegisterType<PlasmaQuick::PlasmaWindow>(uri, 2, 0, "Window");
57 qmlRegisterType<PlasmaQuick::AppletPopup>(uri, 2, 0, "AppletPopup");
58 qmlRegisterType<PlasmaQuick::PopupPlasmaWindow>(uri, 2, 0, "PopupPlasmaWindow");
59 qmlRegisterType<PlasmaQuick::Dialog>(uri, 2, 0, "Dialog");
60 // HACK make properties like "opacity" work that are in REVISION 1 of QWindow
61 qmlRegisterRevision<QWindow, 1>(uri, 2, 0);
62 qmlRegisterRevision<QQuickItem, 1>(uri, 2, 0);
63 qmlRegisterType<ToolTip>(uri, 2, 0, "ToolTipArea");
64
65 qmlRegisterAnonymousType<QQmlPropertyMap>(uri, 1);
66
67 qmlRegisterType<Plasma::WindowThumbnail>(uri, 2, 0, "WindowThumbnail");
68
69 qmlRegisterAnonymousType<IconGroup>(uri, 2);
70 qmlRegisterExtendedType<QAction, ActionExtension>(uri, 2, 0, "Action");
71 qmlRegisterType<ActionGroup>(uri, 2, 0, "ActionGroup");
72}
73
74#include "moc_corebindingsplugin.cpp"
Interface to the Plasma theme.
Definition quicktheme.h:34
Interface to the Plasma theme.
Definition theme.h:40
QObject * contextObject() const const
void setContextObject(QObject *object)
QQmlContext * rootContext() const const
virtual void initializeEngine(QQmlEngine *engine, const char *uri) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.