Changeset View
Changeset View
Standalone View
Standalone View
cuttlefish/src/main.cpp
Show All 29 Lines | |||||
30 | // Frameworks | 30 | // Frameworks | ||
31 | #include <KConfigGroup> | 31 | #include <KConfigGroup> | ||
32 | #include <KDeclarative/KDeclarative> | 32 | #include <KDeclarative/KDeclarative> | ||
33 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
34 | #include <KPackage/PackageLoader> | 34 | #include <KPackage/PackageLoader> | ||
35 | #include <Plasma/Theme> | 35 | #include <Plasma/Theme> | ||
36 | 36 | | |||
37 | // Own | 37 | // Own | ||
38 | #include "colorschemes.h" | ||||
38 | #include "iconmodel.h" | 39 | #include "iconmodel.h" | ||
39 | 40 | | |||
40 | void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) | 41 | void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) | ||
41 | { | 42 | { | ||
42 | if ((msg.contains("qt.svg") && msg.contains("Could not resolve property: #linearGradient")) || msg.contains("Could not resolve property: #pattern")) { | 43 | if ((msg.contains("qt.svg") && msg.contains("Could not resolve property: #linearGradient")) || msg.contains("Could not resolve property: #pattern")) { | ||
43 | return; | 44 | return; | ||
44 | } | 45 | } | ||
45 | 46 | | |||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 70 | { | |||
115 | package.setPath("org.kde.plasma.cuttlefish"); | 116 | package.setPath("org.kde.plasma.cuttlefish"); | ||
116 | 117 | | |||
117 | if (!package.isValid() || !package.metadata().isValid()) { | 118 | if (!package.isValid() || !package.metadata().isValid()) { | ||
118 | qWarning() << "Could not load package org.kde.plasma.cuttlefish:" << package.path(); | 119 | qWarning() << "Could not load package org.kde.plasma.cuttlefish:" << package.path(); | ||
119 | return -1; | 120 | return -1; | ||
120 | } | 121 | } | ||
121 | 122 | | |||
122 | auto iconModel = new CuttleFish::IconModel(engine.rootContext()); | 123 | auto iconModel = new CuttleFish::IconModel(engine.rootContext()); | ||
124 | auto colorSchemes = new CuttleFish::ColorSchemes(engine.rootContext()); | ||||
123 | engine.rootContext()->setContextProperty("iconModel", iconModel); | 125 | engine.rootContext()->setContextProperty("iconModel", iconModel); | ||
124 | engine.rootContext()->setContextProperty("pickerMode", parser.isSet("picker")); | 126 | engine.rootContext()->setContextProperty("pickerMode", parser.isSet("picker")); | ||
127 | engine.rootContext()->setContextProperty("colorSchemes", colorSchemes); | ||||
125 | 128 | | |||
126 | engine.load(QUrl::fromLocalFile(package.filePath("mainscript"))); | 129 | engine.load(QUrl::fromLocalFile(package.filePath("mainscript"))); | ||
127 | if (engine.rootObjects().isEmpty()) { | 130 | if (engine.rootObjects().isEmpty()) { | ||
128 | return -1; | 131 | return -1; | ||
129 | } | 132 | } | ||
130 | 133 | | |||
131 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | 134 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | ||
132 | qmlRegisterType<CuttleFish::IconModel>(); | 135 | qmlRegisterType<CuttleFish::IconModel>(); | ||
136 | qmlRegisterType<CuttleFish::ColorSchemes>(); | ||||
133 | #else | 137 | #else | ||
134 | qmlRegisterAnonymousType<CuttleFish::IconModel>("org.kde.plasma.sdk", 1); | 138 | qmlRegisterAnonymousType<CuttleFish::IconModel>("org.kde.plasma.sdk", 1); | ||
139 | qmlRegisterAnonymousType<CuttleFish::ColorSchemes>("org.kde.plasma.sdk", 1); | ||||
ngraham: typo causes a build failure | |||||
135 | #endif | 140 | #endif | ||
136 | 141 | | |||
137 | return app.exec(); | 142 | return app.exec(); | ||
138 | } | 143 | } | ||
Moving the setting of the context properties before loading of the file fixes these being unavailable at the beginning. => Less errors on startup and we can select the the current color scheme on startup because the index isn't reset when the color scheme model becomes available. davidre: Moving the setting of the context properties before loading of the file fixes these being… |
typo causes a build failure