use the new Package::fileUrl to load from resources

Summary: QUrl::fromLocalFile can't be used when packages are qrc

Test Plan: plasashell loads correctly with packages from qrc

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9176
wilder-5.14
Marco Martin 8 years ago
parent da91a5224e
commit aa53860409
  1. 2
      krunner/view.cpp
  2. 2
      shell/containmentconfigview.cpp
  3. 4
      shell/desktopview.cpp
  4. 8
      shell/osd.cpp
  5. 3
      shell/osd.h
  6. 2
      shell/panelconfigview.cpp
  7. 2
      shell/panelview.cpp
  8. 8
      shell/shellcorona.cpp

@ -99,7 +99,7 @@ View::View(QWindow *)
package.setPath(packageName); package.setPath(packageName);
} }
m_qmlObj->setSource(QUrl::fromLocalFile(package.filePath("runcommandmainscript"))); m_qmlObj->setSource(package.fileUrl("runcommandmainscript"));
m_qmlObj->engine()->rootContext()->setContextProperty(QStringLiteral("runnerWindow"), this); m_qmlObj->engine()->rootContext()->setContextProperty(QStringLiteral("runnerWindow"), this);
m_qmlObj->completeInitialization(); m_qmlObj->completeInitialization();

@ -73,7 +73,7 @@ ContainmentConfigView::~ContainmentConfigView()
void ContainmentConfigView::init() void ContainmentConfigView::init()
{ {
setSource(QUrl::fromLocalFile(m_containment->corona()->kPackage().filePath("containmentconfigurationui"))); setSource(m_containment->corona()->kPackage().fileUrl("containmentconfigurationui"));
} }
PlasmaQuick::ConfigModel *ContainmentConfigView::containmentActionConfigModel() PlasmaQuick::ConfigModel *ContainmentConfigView::containmentActionConfigModel()

@ -50,7 +50,7 @@ DesktopView::DesktopView(Plasma::Corona *corona, QScreen *targetScreen)
setTitle(corona->kPackage().metadata().name()); setTitle(corona->kPackage().metadata().name());
setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName())); setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName()));
rootContext()->setContextProperty(QStringLiteral("desktop"), this); rootContext()->setContextProperty(QStringLiteral("desktop"), this);
setSource(QUrl::fromLocalFile(corona->kPackage().filePath("views", QStringLiteral("Desktop.qml")))); setSource(corona->kPackage().fileUrl("views", QStringLiteral("Desktop.qml")));
connect(this, &QWindow::screenChanged, this, &DesktopView::adaptToScreen); connect(this, &QWindow::screenChanged, this, &DesktopView::adaptToScreen);
@ -295,7 +295,7 @@ void DesktopView::screenGeometryChanged()
void DesktopView::coronaPackageChanged(const KPackage::Package &package) void DesktopView::coronaPackageChanged(const KPackage::Package &package)
{ {
setContainment(0); setContainment(0);
setSource(QUrl::fromLocalFile(package.filePath("views", QStringLiteral("Desktop.qml")))); setSource(package.fileUrl("views", QStringLiteral("Desktop.qml")));
} }
void DesktopView::setupWaylandIntegration() void DesktopView::setupWaylandIntegration()

@ -31,7 +31,7 @@
Osd::Osd(KSharedConfig::Ptr config, ShellCorona *corona) Osd::Osd(KSharedConfig::Ptr config, ShellCorona *corona)
: QObject(corona) : QObject(corona)
, m_osdPath(corona->lookAndFeelPackage().filePath("osdmainscript")) , m_osdUrl(corona->lookAndFeelPackage().fileUrl("osdmainscript"))
, m_config(config) , m_config(config)
{ {
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/osdService"), this, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals); QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/osdService"), this, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals);
@ -162,7 +162,7 @@ bool Osd::init()
return true; return true;
} }
if (m_osdPath.isEmpty()) { if (m_osdUrl.isEmpty()) {
return false; return false;
} }
@ -170,10 +170,10 @@ bool Osd::init()
m_osdObject = new KDeclarative::QmlObject(this); m_osdObject = new KDeclarative::QmlObject(this);
} }
m_osdObject->setSource(QUrl::fromLocalFile(m_osdPath)); m_osdObject->setSource(m_osdUrl);
if (m_osdObject->status() != QQmlComponent::Ready) { if (m_osdObject->status() != QQmlComponent::Ready) {
qWarning() << "Failed to load OSD QML file" << m_osdPath; qWarning() << "Failed to load OSD QML file" << m_osdUrl;
return false; return false;
} }

@ -21,6 +21,7 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QUrl>
#include <KSharedConfig> #include <KSharedConfig>
@ -68,7 +69,7 @@ private:
void showProgress(const QString &icon, const int percent, const QString &additionalText = QString()); void showProgress(const QString &icon, const int percent, const QString &additionalText = QString());
void showOsd(); void showOsd();
QString m_osdPath; QUrl m_osdUrl;
KDeclarative::QmlObject *m_osdObject = nullptr; KDeclarative::QmlObject *m_osdObject = nullptr;
QTimer *m_osdTimer = nullptr; QTimer *m_osdTimer = nullptr;
int m_timeout = 0; int m_timeout = 0;

@ -83,7 +83,7 @@ PanelConfigView::~PanelConfigView()
void PanelConfigView::init() void PanelConfigView::init()
{ {
setSource(QUrl::fromLocalFile(m_containment->corona()->kPackage().filePath("panelconfigurationui"))); setSource(m_containment->corona()->kPackage().fileUrl("panelconfigurationui"));
syncGeometry(); syncGeometry();
syncLocation(); syncLocation();
} }

@ -105,7 +105,7 @@ PanelView::PanelView(ShellCorona *corona, QScreen *targetScreen, QWindow *parent
qmlRegisterType<QScreen>(); qmlRegisterType<QScreen>();
rootContext()->setContextProperty(QStringLiteral("panel"), this); rootContext()->setContextProperty(QStringLiteral("panel"), this);
setSource(QUrl::fromLocalFile(m_corona->kPackage().filePath("views", QStringLiteral("Panel.qml")))); setSource(m_corona->kPackage().fileUrl("views", QStringLiteral("Panel.qml")));
} }
PanelView::~PanelView() PanelView::~PanelView()

@ -810,14 +810,14 @@ void ShellCorona::screenInvariants() const
void ShellCorona::showAlternativesForApplet(Plasma::Applet *applet) void ShellCorona::showAlternativesForApplet(Plasma::Applet *applet)
{ {
const QString alternativesQML = package().filePath("appletalternativesui"); const QUrl alternativesQML = kPackage().fileUrl("appletalternativesui");
if (alternativesQML.isEmpty()) { if (alternativesQML.isEmpty()) {
return; return;
} }
KDeclarative::QmlObject *qmlObj = new KDeclarative::QmlObject(this); KDeclarative::QmlObject *qmlObj = new KDeclarative::QmlObject(this);
qmlObj->setInitializationDelayed(true); qmlObj->setInitializationDelayed(true);
qmlObj->setSource(QUrl::fromLocalFile(alternativesQML)); qmlObj->setSource(alternativesQML);
AlternativesHelper *helper = new AlternativesHelper(applet, qmlObj); AlternativesHelper *helper = new AlternativesHelper(applet, qmlObj);
qmlObj->rootContext()->setContextProperty(QStringLiteral("alternativesHelper"), helper); qmlObj->rootContext()->setContextProperty(QStringLiteral("alternativesHelper"), helper);
@ -1409,14 +1409,14 @@ void ShellCorona::loadInteractiveConsole()
} }
if (!m_interactiveConsole) { if (!m_interactiveConsole) {
const QString consoleQML = package().filePath("interactiveconsole"); const QUrl consoleQML = kPackage().fileUrl("interactiveconsole");
if (consoleQML.isEmpty()) { if (consoleQML.isEmpty()) {
return; return;
} }
m_interactiveConsole = new KDeclarative::QmlObject(this); m_interactiveConsole = new KDeclarative::QmlObject(this);
m_interactiveConsole->setInitializationDelayed(true); m_interactiveConsole->setInitializationDelayed(true);
m_interactiveConsole->setSource(QUrl::fromLocalFile(consoleQML)); m_interactiveConsole->setSource(consoleQML);
QObject *engine = new WorkspaceScripting::ScriptEngine(this, m_interactiveConsole); QObject *engine = new WorkspaceScripting::ScriptEngine(this, m_interactiveConsole);
m_interactiveConsole->rootContext()->setContextProperty(QStringLiteral("scriptEngine"), engine); m_interactiveConsole->rootContext()->setContextProperty(QStringLiteral("scriptEngine"), engine);

Loading…
Cancel
Save