diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-18 16:37:29 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-18 16:37:29 +0100 |
commit | 321488dfe88fc3d60b35f3b5b8075adbabf93d29 (patch) | |
tree | c50fed8e360d19b094b1276edd9daabf8d8dfec4 | |
parent | 8f0b7c2aa54b9d93e35871efd1cf4e8a23faf557 (diff) | |
download | kube-321488dfe88fc3d60b35f3b5b8075adbabf93d29.tar.gz kube-321488dfe88fc3d60b35f3b5b8075adbabf93d29.zip |
Less kpackage usage
-rw-r--r-- | applications/kube/main.cpp | 24 | ||||
-rw-r--r-- | components/CMakeLists.txt | 12 |
2 files changed, 23 insertions, 13 deletions
diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index 0c2e5eb7..345d35bf 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp | |||
@@ -34,9 +34,9 @@ | |||
34 | #include <QQmlApplicationEngine> | 34 | #include <QQmlApplicationEngine> |
35 | #include <QCommandLineParser> | 35 | #include <QCommandLineParser> |
36 | #include <QJsonDocument> | 36 | #include <QJsonDocument> |
37 | #include <QFileInfo> | ||
37 | 38 | ||
38 | #include <QStandardPaths> | 39 | #include <QStandardPaths> |
39 | #include <KPackage/PackageLoader> | ||
40 | #include <QQuickImageProvider> | 40 | #include <QQuickImageProvider> |
41 | #include <QIcon> | 41 | #include <QIcon> |
42 | #include <QtWebEngine> | 42 | #include <QtWebEngine> |
@@ -187,8 +187,7 @@ int main(int argc, char *argv[]) | |||
187 | parser.addHelpOption(); | 187 | parser.addHelpOption(); |
188 | parser.addVersionOption(); | 188 | parser.addVersionOption(); |
189 | parser.addOption({{"k", "keyring"}, | 189 | parser.addOption({{"k", "keyring"}, |
190 | QCoreApplication::translate("main", "To automatically unlock the keyring pass in a keyring in the form of {\"accountId\": {\"resourceId\": \"secret\", *}}"), | 190 | QCoreApplication::translate("main", "To automatically unlock the keyring pass in a keyring in the form of {\"accountId\": {\"resourceId\": \"secret\", *}}"), "keyring dictionary"} |
191 | "keyring dictionary"} | ||
192 | ); | 191 | ); |
193 | parser.process(app); | 192 | parser.process(app); |
194 | 193 | ||
@@ -211,11 +210,24 @@ int main(int argc, char *argv[]) | |||
211 | QtWebEngine::initialize(); | 210 | QtWebEngine::initialize(); |
212 | QIcon::setThemeName("kube"); | 211 | QIcon::setThemeName("kube"); |
213 | 212 | ||
214 | auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.components.kube"); | ||
215 | Q_ASSERT(package.isValid()); | ||
216 | QQmlApplicationEngine engine; | 213 | QQmlApplicationEngine engine; |
217 | engine.addImageProvider(QLatin1String("kube"), new KubeImageProvider); | 214 | engine.addImageProvider(QLatin1String("kube"), new KubeImageProvider); |
218 | engine.load(QUrl::fromLocalFile(package.filePath("mainscript"))); | 215 | const auto file = "/org/kube/components/kube/main.qml"; |
216 | const auto mainFile = [&] { | ||
217 | for (const auto &path : engine.importPathList()) { | ||
218 | QString f = path + file; | ||
219 | if (QFileInfo::exists(f)) { | ||
220 | return f; | ||
221 | } | ||
222 | } | ||
223 | return QString{}; | ||
224 | }(); | ||
225 | if (mainFile.isEmpty()) { | ||
226 | qWarning() << "Failed to find " << file; | ||
227 | qWarning() << "Searched: " << engine.importPathList(); | ||
228 | return -1; | ||
229 | } | ||
230 | engine.load(QUrl::fromLocalFile(mainFile)); | ||
219 | return app.exec(); | 231 | return app.exec(); |
220 | } | 232 | } |
221 | 233 | ||
diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 7b06929f..ff001324 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt | |||
@@ -1,14 +1,12 @@ | |||
1 | project(kube-components) | 1 | project(kube-components) |
2 | 2 | ||
3 | find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Widgets) | 3 | find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Widgets) |
4 | find_package(KF5 REQUIRED COMPONENTS Package) | ||
5 | 4 | ||
6 | macro(install_component name) | 5 | macro(install_qml_component name) |
7 | install(DIRECTORY ${name}/contents/ui/ DESTINATION ${QML_INSTALL_DIR}/org/kube/components/${name}) | 6 | install(DIRECTORY ${name}/contents/ui/ DESTINATION ${QML_INSTALL_DIR}/org/kube/components/${name}) |
8 | install(FILES ${name}/qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/components/${name}) | 7 | install(FILES ${name}/qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/components/${name}) |
9 | kpackage_install_package(${name} org.kube.components.${name} "genericqml") | 8 | endmacro(install_qml_component) |
10 | endmacro(install_component) | ||
11 | 9 | ||
12 | install_component(kube) | 10 | install_qml_component(kube) |
13 | install_component(accounts) | 11 | install_qml_component(accounts) |
14 | install_component(mailviewer) | 12 | install_qml_component(mailviewer) |