Different themes between desktop and dialogs

different themes between QtControl themes in applets
and in config dialogs: this allows QtQuickControls
to be freely usable in applets without worrying how they
will integrate

Change-Id: I696bdcbd78eb2e4df708367ac0d70d13c5d6cf12
This commit is contained in:
Marco Martin 2014-11-20 18:26:35 +01:00
parent 2c8dd8982d
commit 340a4680bf
2 changed files with 30 additions and 0 deletions

View File

@ -435,6 +435,21 @@ void AppletQuickItem::init()
engine->setUrlInterceptor(interceptor);
}
//Force QtQuickControls to use the "Plasma" style for this engine.
//this way is possible to mix QtQuickControls and plasma components in applets
//while still having the desktop style in configuration dialogs
QQmlComponent c(engine);
c.setData("import QtQuick 2.1\n\
import QtQuick.Controls 1.0\n\
import QtQuick.Controls.Private 1.0\n \
Item {\
Component.onCompleted: {\
Settings.styleName = \"Plasma\";\
}\
}", QUrl());
QObject *o = c.create();
o->deleteLater();
d->qmlObject->setSource(QUrl::fromLocalFile(d->applet->package().filePath("mainscript")));
if (!engine || !engine->rootContext() || !engine->rootContext()->isValid() || !d->qmlObject->mainComponent() || d->qmlObject->mainComponent()->isError()) {

View File

@ -196,6 +196,21 @@ View::View(Plasma::Corona *corona, QWindow *parent)
qWarning() << "Invalid home screen package";
}
//Force QtQuickControls to use the "Plasma" style for this engine.
//this way is possible to mix QtQuickControls and plasma components in applets
//while still having the desktop style in configuration dialogs
QQmlComponent c(engine());
c.setData("import QtQuick 2.1\n\
import QtQuick.Controls 1.0\n\
import QtQuick.Controls.Private 1.0\n \
Item {\
Component.onCompleted: {\
Settings.styleName = \"Plasma\";\
}\
}", QUrl());
QObject *o = c.create();
o->deleteLater();
setResizeMode(View::SizeRootObjectToView);
}