tycho: use multiple sizes of icons

master
an 2019-07-08 08:42:11 -04:00
parent 77467ab69b
commit 3ba5499bb9
17 changed files with 69 additions and 17 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@ Cargo.lock
perf.data*
*.bat
*.user
/tycho/resources/icons/*
/tycho/resources/icons.qrc

View File

@ -32,7 +32,7 @@ err() {
}
declare -A icon_names=(
[Tycho]="resources/icons/pfhor-hand.png"
[Tycho]="resources/icons/pfhor-hand_1024.png"
)
name=$1

View File

@ -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

View File

@ -2,12 +2,22 @@
QIcon getIcon(QString const &name)
{
auto res = ":/tycho/icons/" + name + ".png";
constexpr std::array<int, 9> 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;
}
}

44
tycho/gen_images.sh Normal file
View File

@ -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 "<RCC>" > resources/icons.qrc
echo "<qresource prefix=\"/tycho\">" >> 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 " <file>${out_s}</file>" >> resources/icons.qrc
echo " <file>${out_h}</file>" >> 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 "</qresource>" >> resources/icons.qrc
echo "</RCC>" >> resources/icons.qrc
## EOF

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/tycho">
<file>images/tycho1.png</file>
<file>images/tycho2.png</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 820 B

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 819 B

View File

Before

Width:  |  Height:  |  Size: 888 B

After

Width:  |  Height:  |  Size: 888 B

View File

@ -1,11 +0,0 @@
<RCC>
<qresource prefix="/tycho">
<file alias="icons/tycho-lines.png">icons/lines.png</file>
<file alias="icons/tycho-map.png">icons/map.png</file>
<file alias="icons/tycho-points.png">icons/points.png</file>
<file alias="icons/tycho-polygons.png">icons/polygons.png</file>
<file alias="icons/pfhor-hand.png">icons/pfhor-hand.png</file>
<file>images/tycho1.png</file>
<file>images/tycho2.png</file>
</qresource>
</RCC>