Port away from deprecated KDeclarative::setupContext()
NO_CHANGELOG
This commit is contained in:
parent
d6a5b10b3b
commit
d1617d6d2d
@ -32,6 +32,7 @@ target_link_libraries(corebindingsplugin
|
|||||||
Qt5::Qml
|
Qt5::Qml
|
||||||
KF5::Declarative
|
KF5::Declarative
|
||||||
KF5::IconThemes
|
KF5::IconThemes
|
||||||
|
KF5::I18n
|
||||||
KF5::Service #for kplugininfo.h
|
KF5::Service #for kplugininfo.h
|
||||||
KF5::WindowSystem
|
KF5::WindowSystem
|
||||||
KF5::Plasma
|
KF5::Plasma
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
|
||||||
|
#include <KLocalizedContext>
|
||||||
|
|
||||||
#include <kdeclarative/kdeclarative.h>
|
#include <kdeclarative/kdeclarative.h>
|
||||||
|
|
||||||
#include <plasma/framesvg.h>
|
#include <plasma/framesvg.h>
|
||||||
@ -48,10 +50,10 @@ void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
|
|||||||
|
|
||||||
context->setContextProperty(QStringLiteral("units"), &Units::instance());
|
context->setContextProperty(QStringLiteral("units"), &Units::instance());
|
||||||
|
|
||||||
if (!engine->rootContext()->contextObject()) {
|
if (!context->contextObject()) {
|
||||||
KDeclarative::KDeclarative kdeclarative;
|
KLocalizedContext *localizedContextObject = new KLocalizedContext(engine);
|
||||||
kdeclarative.setDeclarativeEngine(engine);
|
context->setContextObject(localizedContextObject);
|
||||||
kdeclarative.setupContext();
|
|
||||||
KDeclarative::KDeclarative::setupEngine(engine);
|
KDeclarative::KDeclarative::setupEngine(engine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <KAuthorized>
|
#include <KAuthorized>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <KLocalizedContext>
|
||||||
#include <kdeclarative/kdeclarative.h>
|
#include <kdeclarative/kdeclarative.h>
|
||||||
#include <packageurlinterceptor.h>
|
#include <packageurlinterceptor.h>
|
||||||
#include <KQuickAddons/ConfigModule>
|
#include <KQuickAddons/ConfigModule>
|
||||||
@ -80,15 +81,15 @@ void ConfigViewPrivate::init()
|
|||||||
|
|
||||||
applet.data()->setUserConfiguring(true);
|
applet.data()->setUserConfiguring(true);
|
||||||
|
|
||||||
KDeclarative::KDeclarative kdeclarative;
|
KLocalizedContext *localizedContextObject = new KLocalizedContext(q->engine());
|
||||||
kdeclarative.setDeclarativeEngine(q->engine());
|
|
||||||
const QString rootPath = applet.data()->pluginMetaData().value(QStringLiteral("X-Plasma-RootPath"));
|
const QString rootPath = applet.data()->pluginMetaData().value(QStringLiteral("X-Plasma-RootPath"));
|
||||||
if (!rootPath.isEmpty()) {
|
if (!rootPath.isEmpty()) {
|
||||||
kdeclarative.setTranslationDomain(QStringLiteral("plasma_applet_") + rootPath);
|
localizedContextObject->setTranslationDomain(QStringLiteral("plasma_applet_") + rootPath);
|
||||||
} else {
|
} else {
|
||||||
kdeclarative.setTranslationDomain(QStringLiteral("plasma_applet_") + applet.data()->pluginMetaData().pluginId());
|
localizedContextObject->setTranslationDomain(QStringLiteral("plasma_applet_") + applet.data()->pluginMetaData().pluginId());
|
||||||
}
|
}
|
||||||
kdeclarative.setupContext();
|
q->engine()->rootContext()->setContextObject(localizedContextObject);
|
||||||
|
|
||||||
KDeclarative::KDeclarative::setupEngine(q->engine()); // ### how to make sure to do this only once per engine?
|
KDeclarative::KDeclarative::setupEngine(q->engine()); // ### how to make sure to do this only once per engine?
|
||||||
|
|
||||||
//FIXME: problem on nvidia, all windows should be transparent or won't show
|
//FIXME: problem on nvidia, all windows should be transparent or won't show
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
|
||||||
|
#include <KLocalizedContext>
|
||||||
|
|
||||||
#include "plasma/pluginloader.h"
|
#include "plasma/pluginloader.h"
|
||||||
#include <packageurlinterceptor.h>
|
#include <packageurlinterceptor.h>
|
||||||
#include <kdeclarative/kdeclarative.h>
|
#include <kdeclarative/kdeclarative.h>
|
||||||
@ -182,11 +184,11 @@ View::View(Plasma::Corona *corona, QWindow *parent)
|
|||||||
interceptor->setForcePlasmaStyle(true);
|
interceptor->setForcePlasmaStyle(true);
|
||||||
engine()->setUrlInterceptor(interceptor);
|
engine()->setUrlInterceptor(interceptor);
|
||||||
|
|
||||||
KDeclarative::KDeclarative kdeclarative;
|
KLocalizedContext *localizedContextObject = new KLocalizedContext(engine());
|
||||||
kdeclarative.setDeclarativeEngine(engine());
|
localizedContextObject->setTranslationDomain(QStringLiteral("plasma_shell_") + pkg.metadata().pluginId());
|
||||||
|
engine()->rootContext()->setContextObject(localizedContextObject);
|
||||||
|
|
||||||
//binds things like kconfig and icons
|
//binds things like kconfig and icons
|
||||||
kdeclarative.setTranslationDomain(QStringLiteral("plasma_shell_") + pkg.metadata().pluginId());
|
|
||||||
kdeclarative.setupContext();
|
|
||||||
KDeclarative::KDeclarative::setupEngine(engine()); // ### how to make sure to do this only once per engine?
|
KDeclarative::KDeclarative::setupEngine(engine()); // ### how to make sure to do this only once per engine?
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Invalid home screen package";
|
qWarning() << "Invalid home screen package";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user