From 340a4680bf5b16fb66d2e0c3784bb358f743331b Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 20 Nov 2014 18:26:35 +0100 Subject: [PATCH] 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 --- src/plasmaquick/appletquickitem.cpp | 15 +++++++++++++++ src/plasmaquick/view.cpp | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/plasmaquick/appletquickitem.cpp b/src/plasmaquick/appletquickitem.cpp index 6ec12b918..9426600f7 100644 --- a/src/plasmaquick/appletquickitem.cpp +++ b/src/plasmaquick/appletquickitem.cpp @@ -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()) { diff --git a/src/plasmaquick/view.cpp b/src/plasmaquick/view.cpp index 1d1b506a5..5b2dbc88c 100644 --- a/src/plasmaquick/view.cpp +++ b/src/plasmaquick/view.cpp @@ -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); }