diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-18 20:32:57 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-18 20:37:06 +0100 |
commit | 1f62cf29d038e1dfd9bd56505ecaae10ca14b60b (patch) | |
tree | 724b2d4f979c06b5033ca86e3271b3a345a1cc30 /framework/src/accounts/accountfactory.cpp | |
parent | 321488dfe88fc3d60b35f3b5b8075adbabf93d29 (diff) | |
download | kube-1f62cf29d038e1dfd9bd56505ecaae10ca14b60b.tar.gz kube-1f62cf29d038e1dfd9bd56505ecaae10ca14b60b.zip |
Accounts without kpackage
Diffstat (limited to 'framework/src/accounts/accountfactory.cpp')
-rw-r--r-- | framework/src/accounts/accountfactory.cpp | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/framework/src/accounts/accountfactory.cpp b/framework/src/accounts/accountfactory.cpp index 1af07ac6..2babeb5d 100644 --- a/framework/src/accounts/accountfactory.cpp +++ b/framework/src/accounts/accountfactory.cpp | |||
@@ -19,12 +19,9 @@ | |||
19 | #include "accountfactory.h" | 19 | #include "accountfactory.h" |
20 | 20 | ||
21 | #include <QDebug> | 21 | #include <QDebug> |
22 | #include <QtQml> | ||
23 | #include <QFileInfo> | ||
22 | 24 | ||
23 | #include <KPackage/PackageLoader> | ||
24 | #include <KPackage/Package> | ||
25 | #include <KPluginMetaData> | ||
26 | |||
27 | #include "settings/settings.h" | ||
28 | #include <sink/store.h> | 25 | #include <sink/store.h> |
29 | 26 | ||
30 | AccountFactory::AccountFactory(QObject *parent) | 27 | AccountFactory::AccountFactory(QObject *parent) |
@@ -32,14 +29,6 @@ AccountFactory::AccountFactory(QObject *parent) | |||
32 | { | 29 | { |
33 | } | 30 | } |
34 | 31 | ||
35 | QString AccountFactory::name() const | ||
36 | { | ||
37 | if (mName.isEmpty()) { | ||
38 | return tr("Account"); | ||
39 | } | ||
40 | return mName; | ||
41 | } | ||
42 | |||
43 | void AccountFactory::setAccountId(const QString &accountId) | 32 | void AccountFactory::setAccountId(const QString &accountId) |
44 | { | 33 | { |
45 | mAccountId = accountId; | 34 | mAccountId = accountId; |
@@ -60,22 +49,27 @@ void AccountFactory::setAccountType(const QString &type) | |||
60 | 49 | ||
61 | void AccountFactory::loadPackage() | 50 | void AccountFactory::loadPackage() |
62 | { | 51 | { |
63 | auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.accounts." + mAccountType); | 52 | auto engine = QtQml::qmlEngine(this); |
64 | if (!package.isValid()) { | 53 | Q_ASSERT(engine); |
54 | const QString pluginPath = [&] { | ||
55 | for (const auto &p : engine->importPathList()) { | ||
56 | const auto path = p + QString::fromLatin1("/org/kube/accounts/") + mAccountType; | ||
57 | if (QFileInfo::exists(path)) { | ||
58 | return path; | ||
59 | } | ||
60 | } | ||
61 | return QString{}; | ||
62 | }(); | ||
63 | if (pluginPath.isEmpty()) { | ||
65 | qWarning() << "Failed to load account package: " << "org.kube.accounts." + mAccountType; | 64 | qWarning() << "Failed to load account package: " << "org.kube.accounts." + mAccountType; |
66 | mUiPath.clear(); | 65 | mUiPath.clear(); |
67 | mLoginUi.clear(); | 66 | mLoginUi.clear(); |
68 | mName.clear(); | ||
69 | mIcon.clear(); | ||
70 | mRequiresKeyring = true; | 67 | mRequiresKeyring = true; |
71 | emit accountLoaded(); | 68 | } else { |
72 | return; | 69 | mUiPath = pluginPath + "/AccountSettings.qml"; |
70 | mLoginUi = pluginPath + "/Login.qml"; | ||
71 | //FIXME | ||
72 | mRequiresKeyring = true; | ||
73 | } | 73 | } |
74 | Q_ASSERT(package.isValid()); | ||
75 | mUiPath = package.filePath("mainscript"); | ||
76 | mLoginUi = package.filePath("ui", "Login.qml"); | ||
77 | mName = package.metadata().name(); | ||
78 | mIcon = package.metadata().iconName(); | ||
79 | mRequiresKeyring = package.metadata().value("X-KDE-Kube-RequiresKeyring", "True").toLower() == "true"; | ||
80 | emit accountLoaded(); | 74 | emit accountLoaded(); |
81 | } | 75 | } |