diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-19 11:13:03 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-19 12:39:51 +0100 |
commit | abb569c99602febfec6d5822b26d36eb1af4a83f (patch) | |
tree | 811fc73d727f628e7ff16521ffc3766af3b0de4d /applications | |
parent | 1fc4fd0a0c067cb9900c8ebda273d65e0d140fd3 (diff) | |
download | kube-abb569c99602febfec6d5822b26d36eb1af4a83f.tar.gz kube-abb569c99602febfec6d5822b26d36eb1af4a83f.zip |
Set the imageprovider as part of the framework plugin
Diffstat (limited to 'applications')
-rw-r--r-- | applications/kube/main.cpp | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index 345d35bf..a7a3354e 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp | |||
@@ -36,8 +36,6 @@ | |||
36 | #include <QJsonDocument> | 36 | #include <QJsonDocument> |
37 | #include <QFileInfo> | 37 | #include <QFileInfo> |
38 | 38 | ||
39 | #include <QStandardPaths> | ||
40 | #include <QQuickImageProvider> | ||
41 | #include <QIcon> | 39 | #include <QIcon> |
42 | #include <QtWebEngine> | 40 | #include <QtWebEngine> |
43 | 41 | ||
@@ -133,44 +131,6 @@ void terminateHandler() | |||
133 | std::abort(); | 131 | std::abort(); |
134 | } | 132 | } |
135 | 133 | ||
136 | class KubeImageProvider : public QQuickImageProvider | ||
137 | { | ||
138 | public: | ||
139 | KubeImageProvider() | ||
140 | : QQuickImageProvider(QQuickImageProvider::Pixmap) | ||
141 | { | ||
142 | } | ||
143 | |||
144 | QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) Q_DECL_OVERRIDE | ||
145 | { | ||
146 | //The platform theme plugin can overwrite our setting again once it gets loaded, | ||
147 | //so we check on every icon load request... | ||
148 | if (QIcon::themeName() != "kube") { | ||
149 | QIcon::setThemeName("kube"); | ||
150 | } | ||
151 | const auto icon = QIcon::fromTheme(id); | ||
152 | auto expectedSize = requestedSize; | ||
153 | //Get the largest size that is still smaller or equal than requested | ||
154 | //Except if we only have larger sizes, then just pick the closest one | ||
155 | bool first = true; | ||
156 | for (const auto s : icon.availableSizes()) { | ||
157 | if (first && s.width() > requestedSize.width()) { | ||
158 | expectedSize = s; | ||
159 | break; | ||
160 | } | ||
161 | first = false; | ||
162 | if (s.width() <= requestedSize.width()) { | ||
163 | expectedSize = s; | ||
164 | } | ||
165 | } | ||
166 | const auto pixmap = icon.pixmap(expectedSize); | ||
167 | if (size) { | ||
168 | *size = pixmap.size(); | ||
169 | } | ||
170 | return pixmap; | ||
171 | } | ||
172 | }; | ||
173 | |||
174 | int main(int argc, char *argv[]) | 134 | int main(int argc, char *argv[]) |
175 | { | 135 | { |
176 | std::signal(SIGSEGV, crashHandler); | 136 | std::signal(SIGSEGV, crashHandler); |
@@ -211,7 +171,6 @@ int main(int argc, char *argv[]) | |||
211 | QIcon::setThemeName("kube"); | 171 | QIcon::setThemeName("kube"); |
212 | 172 | ||
213 | QQmlApplicationEngine engine; | 173 | QQmlApplicationEngine engine; |
214 | engine.addImageProvider(QLatin1String("kube"), new KubeImageProvider); | ||
215 | const auto file = "/org/kube/components/kube/main.qml"; | 174 | const auto file = "/org/kube/components/kube/main.qml"; |
216 | const auto mainFile = [&] { | 175 | const auto mainFile = [&] { |
217 | for (const auto &path : engine.importPathList()) { | 176 | for (const auto &path : engine.importPathList()) { |