MCPcopy Create free account
hub / github.com/KDE/kdevelop / PropertyPreviewWidget

Method PropertyPreviewWidget

plugins/qmljs/navigation/propertypreviewwidget.cpp:134–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134PropertyPreviewWidget::PropertyPreviewWidget(KTextEditor::Document* doc,
135 const KTextEditor::Range& keyRange, const KTextEditor::Range& valueRange,
136 const SupportedProperty& property, const QString& value)
137 : QWidget()
138 , view(new QQuickWidget)
139 , document(doc)
140 , keyRange(keyRange)
141 , valueRange(valueRange)
142 , property(property)
143{
144 //setup kdeclarative library
145 KDeclarative::KDeclarative::setupEngine(view->engine());
146 KLocalizedContext *localizedContextObject = new KLocalizedContext(view->engine());
147 localizedContextObject->setTranslationDomain(QStringLiteral("kdevqmljs"));
148 view->engine()->rootContext()->setContextObject(localizedContextObject);
149
150 // Configure layout
151 auto l = new QHBoxLayout;
152
153 l->setContentsMargins(0, 0, 0, 0);
154 setLayout(l);
155
156 // see docstring for ILanguageSupport::specialLanguageObjectNavigationWidget
157 setProperty("DoNotCloseOnCursorMove", true);
158
159 view->setSource(property.qmlfile);
160
161 if (!view->rootObject()) {
162 // don't crash because of a syntax error or missing QML file
163 l->addWidget(new QLabel(i18n("Error loading QML file: %1", property.qmlfile.path())));
164 delete view;
165 return;
166 }
167
168 // set the initial value read from the document
169 view->rootObject()->setProperty("initialValue", value);
170
171 // connect to the slot which has to be emitted from QML when the value changes
172 QObject::connect(view->rootObject(), SIGNAL(valueChanged()),
173 this, SLOT(updateValue()));
174 l->addWidget(view);
175}
176
177#include "moc_propertypreviewwidget.cpp"

Callers

nothing calls this directly

Calls 5

setPropertyMethod · 0.80
engineMethod · 0.45
setSourceMethod · 0.45
addWidgetMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected