Commit ba646463 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.

A bit ugly is that we need to save the KPluginMetaData separately, but because we only have
two occurrences it should be fine.

Task: https://phabricator.kde.org/T12137
parent 897a4edd
Pipeline #219535 passed with stage
in 54 seconds
......@@ -9,6 +9,7 @@ target_link_libraries(nextcloud_plugin_kaccounts
KF5::KIOCore
KF5::I18n
KF5::Declarative
KF5::Package
KAccounts
)
......
......@@ -11,6 +11,7 @@
#include <KDeclarative/QmlObject>
#include <KLocalizedString>
#include <KPackage/PackageLoader>
#include <QIcon>
#include <QQmlContext>
......@@ -31,12 +32,14 @@ void NextcloudWizard::init(KAccountsUiPlugin::UiType type)
{
if (type == KAccountsUiPlugin::NewAccountDialog) {
const QString packagePath(QStringLiteral("org.kde.kaccounts.nextcloud"));
m_object = new KDeclarative::QmlObject();
m_object->setTranslationDomain(packagePath);
m_object->setInitializationDelayed(true);
m_object->loadPackage(packagePath);
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
package.setPath(packagePath);
m_object->setSource(QUrl::fromLocalFile(package.filePath("mainscript")));
m_data = package.metadata();
NextcloudController *helper = new NextcloudController(m_object);
connect(helper, &NextcloudController::wizardFinished, this, [this](const QString &username, const QString &password, const QVariantMap &data) {
......@@ -53,7 +56,7 @@ void NextcloudWizard::init(KAccountsUiPlugin::UiType type)
m_object->completeInitialization();
if (!m_object->package().metadata().isValid()) {
if (!m_data.isValid()) {
return;
}
......@@ -73,8 +76,8 @@ void NextcloudWizard::showNewAccountDialog()
window->setTransientParent(transientParent());
window->show();
window->requestActivate();
window->setTitle(m_object->package().metadata().name());
window->setIcon(QIcon::fromTheme(m_object->package().metadata().iconName()));
window->setTitle(m_data.name());
window->setIcon(QIcon::fromTheme(m_data.iconName()));
}
}
......
......@@ -9,6 +9,7 @@
#ifndef NEXTCLOUD_H
#define NEXTCLOUD_H
#include <KPluginMetaData>
#include <QHash>
#include <QUrl>
......@@ -38,6 +39,7 @@ public:
private:
QHash<QString, int> m_services;
KDeclarative::QmlObject *m_object;
KPluginMetaData m_data;
};
#endif // NEXTCLOUD_H
......@@ -8,6 +8,7 @@ target_link_libraries(owncloud_plugin_kaccounts
KF5::KIOCore
KF5::I18n
KF5::Declarative
KF5::Package
KAccounts
)
......
......@@ -10,6 +10,7 @@
#include <KDeclarative/QmlObject>
#include <KLocalizedString>
#include <KPackage/PackageLoader>
#include <QQmlContext>
#include <QQmlEngine>
......@@ -29,11 +30,14 @@ void OwnCloudWizard::init(KAccountsUiPlugin::UiType type)
{
if (type == KAccountsUiPlugin::NewAccountDialog) {
const QString packagePath(QStringLiteral("org.kde.kaccounts.owncloud"));
m_object = new KDeclarative::QmlObject();
m_object->setTranslationDomain(packagePath);
m_object->setInitializationDelayed(true);
m_object->loadPackage(packagePath);
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
package.setPath(packagePath);
m_object->setSource(QUrl::fromLocalFile(package.filePath("mainscript")));
m_data = package.metadata();
OwncloudController *helper = new OwncloudController(m_object);
......@@ -51,7 +55,7 @@ void OwnCloudWizard::init(KAccountsUiPlugin::UiType type)
m_object->completeInitialization();
if (!m_object->package().metadata().isValid()) {
if (!m_data.isValid()) {
return;
}
......@@ -71,8 +75,8 @@ void OwnCloudWizard::showNewAccountDialog()
window->setTransientParent(transientParent());
window->show();
window->requestActivate();
window->setTitle(m_object->package().metadata().name());
window->setIcon(QIcon::fromTheme(m_object->package().metadata().iconName()));
window->setTitle(m_data.name());
window->setIcon(QIcon::fromTheme(m_data.iconName()));
}
}
......
......@@ -8,6 +8,7 @@
#ifndef OWNCLOUD_H
#define OWNCLOUD_H
#include <KPluginMetaData>
#include <QHash>
#include <QUrl>
......@@ -37,6 +38,7 @@ public:
private:
QHash<QString, int> m_services;
KDeclarative::QmlObject *m_object;
KPluginMetaData m_data;
};
#endif // OWNCLOUD_H
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