diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-12 15:16:19 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-12 15:16:19 +0200 |
commit | 7d3eac6e33085ffa66ff72294fc079ffd5f25b02 (patch) | |
tree | 6ab1a425f12cf19a1ee0dc3c2d06c5d3d739c168 | |
parent | 3bc1cebfb3d67e08dc934c5090ad659e3166a79c (diff) | |
download | kube-7d3eac6e33085ffa66ff72294fc079ffd5f25b02.tar.gz kube-7d3eac6e33085ffa66ff72294fc079ffd5f25b02.zip |
Try to pick a useful size if we don't have an exact match.
The smallest is not always the best.
-rw-r--r-- | applications/kube/main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/applications/kube/main.cpp b/applications/kube/main.cpp index 03a128c4..ad7bac88 100644 --- a/applications/kube/main.cpp +++ b/applications/kube/main.cpp | |||
@@ -27,8 +27,18 @@ public: | |||
27 | } | 27 | } |
28 | const auto icon = QIcon::fromTheme(id); | 28 | const auto icon = QIcon::fromTheme(id); |
29 | auto expectedSize = requestedSize; | 29 | auto expectedSize = requestedSize; |
30 | if (!icon.availableSizes().contains(requestedSize) && !icon.availableSizes().isEmpty()) { | 30 | //Get the largest size that is still smaller or equal than requested |
31 | expectedSize = icon.availableSizes().first(); | 31 | //Except if we only have larger sizes, then just pick the closest one |
32 | bool first = true; | ||
33 | for (const auto s : icon.availableSizes()) { | ||
34 | if (first && s.width() > requestedSize.width()) { | ||
35 | expectedSize = s; | ||
36 | break; | ||
37 | } | ||
38 | first = false; | ||
39 | if (s.width() <= requestedSize.width()) { | ||
40 | expectedSize = s; | ||
41 | } | ||
32 | } | 42 | } |
33 | const auto pixmap = icon.pixmap(expectedSize); | 43 | const auto pixmap = icon.pixmap(expectedSize); |
34 | if (size) { | 44 | if (size) { |