Commit 282db459 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port away from KPackage related KDeclarative::QmlObject methods

As discussed on the last KF6 weekly, the KPackage related methods should be phased out.

This also has the adventage that we are more flexible in case we no longer want to have
the generic KPackage structure.

Task: https://phabricator.kde.org/T12137
parent 53055b35
Pipeline #221098 passed with stage
in 1 minute and 4 seconds
......@@ -50,7 +50,10 @@ int main(int argc, char **argv)
obj.setInitializationDelayed(true);
obj.engine()->rootContext()->setContextProperty("commandlineTheme", parser.value(themeOption));
obj.engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments());
obj.loadPackage(packagePath);
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
package.setPath(packagePath);
obj.setSource(QUrl::fromLocalFile(package.filePath("mainscript")));
const KPluginMetaData data = package.metadata();
qmlRegisterAnonymousType<LnfLogic>("org.kde.plasma.sdk", 1);
qmlRegisterAnonymousType<LnfListModel>("org.kde.plasma.sdk", 1);
......@@ -60,11 +63,10 @@ int main(int argc, char **argv)
obj.completeInitialization();
if (!obj.package().metadata().isValid()) {
if (!data.isValid()) {
return -1;
}
KPluginMetaData data = obj.package().metadata();
// About data
KAboutData aboutData(data.pluginId(), data.name(), data.version(), data.description(), KAboutLicense::byKeyword(data.license()).key());
......@@ -76,8 +78,8 @@ int main(int argc, char **argv)
// have to use a normal QQuickWindow since the root item is already created
QWindow *window = qobject_cast<QWindow *>(obj.rootObject());
if (window) {
window->setTitle(obj.package().metadata().name());
window->setIcon(QIcon::fromTheme(obj.package().metadata().iconName()));
window->setTitle(data.name());
window->setIcon(QIcon::fromTheme(data.iconName()));
} else {
qWarning() << "Error loading the ApplicationWindow";
}
......
......@@ -51,14 +51,18 @@ int main(int argc, char **argv)
KDeclarative::QmlObject *obj = new KDeclarative::QmlObject();
obj->setTranslationDomain(packagePath);
obj->setInitializationDelayed(true);
obj->loadPackage(packagePath);
obj->engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments());
QObject::connect(obj->engine(), &QQmlEngine::quit, &app, &QApplication::quit);
qmlRegisterAnonymousType<ThemeListModel>("org.kde.plasma.sdk", 1);
qmlRegisterAnonymousType<ColorEditor>("org.kde.plasma.sdk", 1);
ThemeModel *themeModel = new ThemeModel(obj->package());
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
package.setPath(packagePath);
obj->setSource(QUrl::fromLocalFile(package.filePath("mainscript")));
const KPluginMetaData data = package.metadata();
ThemeModel *themeModel = new ThemeModel(package);
if (parser.isSet(themeOption)) {
themeModel->setTheme(parser.value(themeOption));
obj->engine()->rootContext()->setContextProperty("commandlineTheme", parser.value(themeOption));
......@@ -70,11 +74,10 @@ int main(int argc, char **argv)
obj->completeInitialization();
if (!obj->package().metadata().isValid()) {
if (!data.isValid()) {
return -1;
}
KPluginMetaData data = obj->package().metadata();
// About data
KAboutData aboutData(data.pluginId(), data.name(), data.version(), data.description(), KAboutLicense::byKeyword(data.license()).key());
......@@ -86,8 +89,8 @@ int main(int argc, char **argv)
// have to use a normal QQuickWindow since the root item is already created
QWindow *window = qobject_cast<QWindow *>(obj->rootObject());
if (window) {
window->setTitle(obj->package().metadata().name());
window->setIcon(QIcon::fromTheme(obj->package().metadata().iconName()));
window->setTitle(data.name());
window->setIcon(QIcon::fromTheme(data.iconName()));
} else {
qWarning() << "Error loading the ApplicationWindow";
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment