• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaCore

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • core
corebindingsplugin.cpp
Go to the documentation of this file.
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 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 "corebindingsplugin.h"
23 
24 #include <QtDeclarative/qdeclarative.h>
25 #include <QDeclarativeContext>
26 #include <QScriptEngine>
27 
28 #include <kdeclarative.h>
29 
30 #include <Plasma/FrameSvg>
31 #include <Plasma/Svg>
32 #include <Plasma/QueryMatch>
33 
34 #include "datasource.h"
35 #include "datamodel.h"
36 #include "framesvgitem.h"
37 #include "runnermodel.h"
38 #include "svgitem.h"
39 #include "theme.h"
40 #include "dialog.h"
41 #include "iconitem.h"
42 #include "tooltip.h"
43 #include "dataenginebindings_p.h"
44 
45 void CoreBindingsPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
46 {
47  QDeclarativeExtensionPlugin::initializeEngine(engine, uri);
48 
49  QDeclarativeContext *context = engine->rootContext();
50 
51  ThemeProxy *theme = new ThemeProxy(context);
52  context->setContextProperty("theme", theme);
53 
54  KDeclarative kdeclarative;
55  kdeclarative.setDeclarativeEngine(engine);
56  kdeclarative.initialize();
57  QScriptEngine *scriptEngine = kdeclarative.scriptEngine();
58 
59  //inject the hack only if wasn't injected already
60  if (!scriptEngine->globalObject().property("i18n").isValid()) {
61  //binds things like kconfig and icons
62  kdeclarative.setupBindings();
63  }
64 
65  registerDataEngineMetaTypes(scriptEngine);
66 }
67 
68 void CoreBindingsPlugin::registerTypes(const char *uri)
69 {
70  Q_ASSERT(uri == QLatin1String("org.kde.plasma.core"));
71 
72  qmlRegisterType<Plasma::Svg>(uri, 0, 1, "Svg");
73  qmlRegisterType<Plasma::FrameSvg>(uri, 0, 1, "FrameSvg");
74  qmlRegisterType<Plasma::SvgItem>(uri, 0, 1, "SvgItem");
75  qmlRegisterType<Plasma::FrameSvgItem>(uri, 0, 1, "FrameSvgItem");
76 
77  qmlRegisterType<ThemeProxy>(uri, 0, 1, "Theme");
78 
79  qmlRegisterType<Plasma::DataSource>(uri, 0, 1, "DataSource");
80  qmlRegisterType<Plasma::DataModel>(uri, 0, 1, "DataModel");
81  qmlRegisterType<Plasma::SortFilterModel>(uri, 0, 1, "SortFilterModel");
82 
83  qmlRegisterType<DialogProxy>(uri, 0, 1, "Dialog");
84  qmlRegisterType<ToolTipProxy>(uri, 0, 1, "ToolTip");
85 
86  qmlRegisterInterface<Plasma::Service>("Service");
87  qRegisterMetaType<Plasma::Service*>("Service");
88  qmlRegisterInterface<Plasma::ServiceJob>("ServiceJob");
89  qRegisterMetaType<Plasma::ServiceJob*>("ServiceJob");
90  qmlRegisterType<QAbstractItemModel>();
91 
92  qmlRegisterType<RunnerModel>(uri, 0, 1, "RunnerModel");
93  qmlRegisterInterface<Plasma::QueryMatch>("QueryMatch");
94  qRegisterMetaType<Plasma::QueryMatch *>("QueryMatch");
95 
96  qmlRegisterType<QDeclarativePropertyMap>();
97  qmlRegisterType<IconItem>(uri, 0, 1, "IconItem");
98 
99  /*qmlRegisterInterface<Plasma::DataSource>("DataSource");
100  qRegisterMetaType<Plasma::DataSource*>("DataSource");*/
101 }
102 
103 
104 #include "corebindingsplugin.moc"
105 
QDeclarativeContext::setContextProperty
void setContextProperty(const QString &name, QObject *value)
datasource.h
QDeclarativeEngine
runnermodel.h
iconitem.h
svgitem.h
theme.h
QDeclarativeEngine::rootContext
QDeclarativeContext * rootContext() const
tooltip.h
QScriptEngine
CoreBindingsPlugin::initializeEngine
void initializeEngine(QDeclarativeEngine *engine, const char *uri)
Definition: corebindingsplugin.cpp:45
QDeclarativeContext
dataenginebindings_p.h
QScriptValue::property
QScriptValue property(const QString &name, const ResolveFlags &mode) const
corebindingsplugin.h
ThemeProxy
QML wrapper for kdelibs Plasma::Theme.
Definition: theme.h:174
datamodel.h
framesvgitem.h
dialog.h
CoreBindingsPlugin::registerTypes
void registerTypes(const char *uri)
Definition: corebindingsplugin.cpp:68
QLatin1String
QScriptValue::isValid
bool isValid() const
QScriptEngine::globalObject
QScriptValue globalObject() const
QDeclarativeExtensionPlugin::initializeEngine
virtual void initializeEngine(QDeclarativeEngine *engine, const char *uri)
registerDataEngineMetaTypes
void registerDataEngineMetaTypes(QScriptEngine *engine)
Definition: dataenginebindings.cpp:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaCore

Skip menu "PlasmaCore"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



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