File indexing completed on 2025-02-16 05:05:38
0001 /* 0002 SPDX-FileCopyrightText: 2009 Alan Alpert <alan.alpert@nokia.com> 0003 SPDX-FileCopyrightText: 2010 Ménard Alexis <menard@kde.org> 0004 SPDX-FileCopyrightText: 2010 Marco Martin <mart@kde.org> 0005 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #include "corebindingsplugin.h" 0011 0012 #include <QActionGroup> 0013 #include <QQmlContext> 0014 0015 #include <KLocalizedContext> 0016 0017 #include "action.h" 0018 #include "appletpopup.h" 0019 0020 #include "dialog.h" 0021 #include "quicktheme.h" 0022 0023 #include "tooltip.h" 0024 #include "windowthumbnail.h" 0025 0026 #include <QDebug> 0027 #include <QQmlPropertyMap> 0028 #include <QWindow> 0029 #include <qqml.h> 0030 0031 void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) 0032 { 0033 QQmlExtensionPlugin::initializeEngine(engine, uri); 0034 0035 QQmlContext *context = engine->rootContext(); 0036 0037 if (!context->contextObject()) { 0038 KLocalizedContext *localizedContextObject = new KLocalizedContext(engine); 0039 context->setContextObject(localizedContextObject); 0040 } 0041 // This ensures that importing plasmacore will make any KSvg use the current lasma theme 0042 new Plasma::Theme(engine); 0043 } 0044 0045 void CoreBindingsPlugin::registerTypes(const char *uri) 0046 { 0047 Q_ASSERT(uri == QByteArray("org.kde.plasma.core")); 0048 0049 qmlRegisterUncreatableType<Plasma::Types>(uri, 2, 0, "Types", {}); 0050 0051 // qmlRegisterType<ThemeProxy>(uri, 2, 0, "Theme"); 0052 qmlRegisterSingletonType<Plasma::QuickTheme>(uri, 2, 0, "Theme", [](QQmlEngine *engine, QJSEngine *) -> QObject * { 0053 return new Plasma::QuickTheme(engine); 0054 }); 0055 0056 qmlRegisterType<PlasmaQuick::AppletPopup>(uri, 2, 0, "AppletPopup"); 0057 qmlRegisterType<PlasmaQuick::PopupPlasmaWindow>(uri, 2, 0, "PopupPlasmaWindow"); 0058 qmlRegisterType<PlasmaQuick::Dialog>(uri, 2, 0, "Dialog"); 0059 // HACK make properties like "opacity" work that are in REVISION 1 of QWindow 0060 qmlRegisterRevision<QWindow, 1>(uri, 2, 0); 0061 qmlRegisterRevision<QQuickItem, 1>(uri, 2, 0); 0062 qmlRegisterType<ToolTip>(uri, 2, 0, "ToolTipArea"); 0063 0064 qmlRegisterAnonymousType<QQmlPropertyMap>(uri, 1); 0065 0066 qmlRegisterType<Plasma::WindowThumbnail>(uri, 2, 0, "WindowThumbnail"); 0067 0068 qmlRegisterAnonymousType<IconGroup>(uri, 2); 0069 qmlRegisterExtendedType<QAction, ActionExtension>(uri, 2, 0, "Action"); 0070 qmlRegisterType<ActionGroup>(uri, 2, 0, "ActionGroup"); 0071 } 0072 0073 #include "moc_corebindingsplugin.cpp"