diff --git a/.gitignore b/.gitignore index 861fb08..857ca63 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ Cargo.lock perf.data* *.bat *.user +/tycho/resources/icons/* +/tycho/resources/icons.qrc diff --git a/bundle.sh b/bundle.sh index 591a903..c5190d0 100755 --- a/bundle.sh +++ b/bundle.sh @@ -32,7 +32,7 @@ err() { } declare -A icon_names=( - [Tycho]="resources/icons/pfhor-hand.png" + [Tycho]="resources/icons/pfhor-hand_1024.png" ) name=$1 diff --git a/tycho/CMakeLists.txt b/tycho/CMakeLists.txt index efe29d5..6801c0c 100644 --- a/tycho/CMakeLists.txt +++ b/tycho/CMakeLists.txt @@ -36,7 +36,8 @@ add_library( cc/project.cc cc/tycho.h cc/utility.cc - resources/resources.qrc + resources/icons.qrc + resources/images.qrc ui/about.ui ui/license.ui ui/mapprops.ui diff --git a/tycho/cc/utility.cc b/tycho/cc/utility.cc index f7b3d46..7dc5e65 100644 --- a/tycho/cc/utility.cc +++ b/tycho/cc/utility.cc @@ -2,12 +2,22 @@ QIcon getIcon(QString const &name) { - auto res = ":/tycho/icons/" + name + ".png"; + constexpr std::array sizes{16, 24, 32, 48, 64, 128, 256, 512, 1024}; - if(QFile(res).exists()) { - return QIcon(res); - } else { + QIcon icon; + + for(auto const &sz : sizes) { + auto res = ":/tycho/icons/" + name + "_" + QString::number(sz) + ".png"; + + if(QFile(res).exists()) { + icon.addFile(res, QSize(sz, sz)); + } + } + + if(icon.isNull()) { return QIcon::fromTheme(name); + } else { + return icon; } } diff --git a/tycho/gen_images.sh b/tycho/gen_images.sh new file mode 100644 index 0000000..1978a35 --- /dev/null +++ b/tycho/gen_images.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +sizes=(16 24 32 48 64 128 256 512 1024) +hidpi=(32 48 64 96 128 256 512 1024 2048) +numsize=8 + +mkdir -p resources/icons +rm resources/icons/*.png resources/icons.qrc + +echo "" > resources/icons.qrc +echo "" >> resources/icons.qrc + +comp_icon() { + f=$1 + i=$2 + sz=${sizes[${i}]} + hz=${hidpi[${i}]} + out=icons/$(basename -s .svg "${f}")_${sz} + out_s=${out}.png + out_h=${out}@2x.png + echo " ${out_s}" >> resources/icons.qrc + echo " ${out_h}" >> resources/icons.qrc + out_s=resources/${out_s} + out_h=resources/${out_h} + echo "${out_s}" + convert -background none "${f}" -resize "${sz}x${sz}" "${out_s}" & + convert -background none "${f}" -resize "${hz}x${hz}" "${out_h}" & + wait + optipng -quiet -o5 "${out_s}" & + optipng -quiet -o5 "${out_h}" & +} + +for f in resources/mini/*.svg +do + for i in $(seq 0 "${numsize}") + do + comp_icon "${f}" "${i}" + done +done + +echo "" >> resources/icons.qrc +echo "" >> resources/icons.qrc + +## EOF diff --git a/tycho/resources/icons/lines.png b/tycho/resources/icons/lines.png deleted file mode 100644 index 903c047..0000000 Binary files a/tycho/resources/icons/lines.png and /dev/null differ diff --git a/tycho/resources/icons/map.png b/tycho/resources/icons/map.png deleted file mode 100644 index a6cb47d..0000000 Binary files a/tycho/resources/icons/map.png and /dev/null differ diff --git a/tycho/resources/icons/pfhor-hand.png b/tycho/resources/icons/pfhor-hand.png deleted file mode 100644 index dad128a..0000000 Binary files a/tycho/resources/icons/pfhor-hand.png and /dev/null differ diff --git a/tycho/resources/icons/points.png b/tycho/resources/icons/points.png deleted file mode 100644 index 2cdf86f..0000000 Binary files a/tycho/resources/icons/points.png and /dev/null differ diff --git a/tycho/resources/icons/polygons.png b/tycho/resources/icons/polygons.png deleted file mode 100644 index 780d299..0000000 Binary files a/tycho/resources/icons/polygons.png and /dev/null differ diff --git a/tycho/resources/images.qrc b/tycho/resources/images.qrc new file mode 100644 index 0000000..07174d0 --- /dev/null +++ b/tycho/resources/images.qrc @@ -0,0 +1,6 @@ + + + images/tycho1.png + images/tycho2.png + + diff --git a/tycho/resources/icons/pfhor-hand.svg b/tycho/resources/mini/pfhor-hand.svg similarity index 100% rename from tycho/resources/icons/pfhor-hand.svg rename to tycho/resources/mini/pfhor-hand.svg diff --git a/tycho/resources/icons/lines.svg b/tycho/resources/mini/tycho-lines.svg similarity index 100% rename from tycho/resources/icons/lines.svg rename to tycho/resources/mini/tycho-lines.svg diff --git a/tycho/resources/icons/map.svg b/tycho/resources/mini/tycho-map.svg similarity index 100% rename from tycho/resources/icons/map.svg rename to tycho/resources/mini/tycho-map.svg diff --git a/tycho/resources/icons/points.svg b/tycho/resources/mini/tycho-points.svg similarity index 100% rename from tycho/resources/icons/points.svg rename to tycho/resources/mini/tycho-points.svg diff --git a/tycho/resources/icons/polygons.svg b/tycho/resources/mini/tycho-polygons.svg similarity index 100% rename from tycho/resources/icons/polygons.svg rename to tycho/resources/mini/tycho-polygons.svg diff --git a/tycho/resources/resources.qrc b/tycho/resources/resources.qrc deleted file mode 100644 index d8e109d..0000000 --- a/tycho/resources/resources.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - icons/lines.png - icons/map.png - icons/points.png - icons/polygons.png - icons/pfhor-hand.png - images/tycho1.png - images/tycho2.png - -