[AppletQuickItem] Only set QtQuick Controls 1 style once per engine
The style is global per engine, there's no need to set it for every applet created as the engines are shared. Since this entire thing is just a hack, just setting a dynamic property to identify that we've set a style is valid imho. Also turn it into a plain QtObject since we don't need a fully-fledged Item. Differential Revision: https://phabricator.kde.org/D4362
This commit is contained in:
parent
78f83f5c77
commit
3ad4798ca6
@ -504,17 +504,20 @@ void AppletQuickItem::init()
|
|||||||
//Force QtQuickControls to use the "Plasma" style for this engine.
|
//Force QtQuickControls to use the "Plasma" style for this engine.
|
||||||
//this way is possible to mix QtQuickControls and plasma components in applets
|
//this way is possible to mix QtQuickControls and plasma components in applets
|
||||||
//while still having the desktop style in configuration dialogs
|
//while still having the desktop style in configuration dialogs
|
||||||
QQmlComponent c(engine);
|
if (!engine->property("_plasma_qqc_style_set").toBool()) {
|
||||||
c.setData(QByteArrayLiteral("import QtQuick 2.1\n\
|
QQmlComponent c(engine);
|
||||||
import QtQuick.Controls 1.0\n\
|
c.setData(QByteArrayLiteral("import QtQuick 2.1\n\
|
||||||
import QtQuick.Controls.Private 1.0\n \
|
import QtQuick.Controls 1.0\n\
|
||||||
Item {\
|
import QtQuick.Controls.Private 1.0\n \
|
||||||
Component.onCompleted: {\
|
QtObject {\
|
||||||
Settings.styleName = \"Plasma\";\
|
Component.onCompleted: {\
|
||||||
}\
|
Settings.styleName = \"Plasma\";\
|
||||||
}"), QUrl());
|
}\
|
||||||
QObject *o = c.create();
|
}"), QUrl());
|
||||||
o->deleteLater();
|
QObject *o = c.create();
|
||||||
|
o->deleteLater();
|
||||||
|
engine->setProperty(("_plasma_qqc_style_set"), true);
|
||||||
|
}
|
||||||
|
|
||||||
d->qmlObject->setSource(QUrl::fromLocalFile(d->applet->kPackage().filePath("mainscript")));
|
d->qmlObject->setSource(QUrl::fromLocalFile(d->applet->kPackage().filePath("mainscript")));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user