tycho: use multiple sizes of icons
|
@ -5,3 +5,5 @@ Cargo.lock
|
||||||
perf.data*
|
perf.data*
|
||||||
*.bat
|
*.bat
|
||||||
*.user
|
*.user
|
||||||
|
/tycho/resources/icons/*
|
||||||
|
/tycho/resources/icons.qrc
|
||||||
|
|
|
@ -32,7 +32,7 @@ err() {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare -A icon_names=(
|
declare -A icon_names=(
|
||||||
[Tycho]="resources/icons/pfhor-hand.png"
|
[Tycho]="resources/icons/pfhor-hand_1024.png"
|
||||||
)
|
)
|
||||||
|
|
||||||
name=$1
|
name=$1
|
||||||
|
|
|
@ -36,7 +36,8 @@ add_library(
|
||||||
cc/project.cc
|
cc/project.cc
|
||||||
cc/tycho.h
|
cc/tycho.h
|
||||||
cc/utility.cc
|
cc/utility.cc
|
||||||
resources/resources.qrc
|
resources/icons.qrc
|
||||||
|
resources/images.qrc
|
||||||
ui/about.ui
|
ui/about.ui
|
||||||
ui/license.ui
|
ui/license.ui
|
||||||
ui/mapprops.ui
|
ui/mapprops.ui
|
||||||
|
|
|
@ -2,12 +2,22 @@
|
||||||
|
|
||||||
QIcon getIcon(QString const &name)
|
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()) {
|
QIcon icon;
|
||||||
return QIcon(res);
|
|
||||||
} else {
|
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);
|
return QIcon::fromTheme(name);
|
||||||
|
} else {
|
||||||
|
return icon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 158 KiB |
Before Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 44 KiB |
|
@ -0,0 +1,6 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/tycho">
|
||||||
|
<file>images/tycho1.png</file>
|
||||||
|
<file>images/tycho2.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 820 B After Width: | Height: | Size: 820 B |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 819 B After Width: | Height: | Size: 819 B |
Before Width: | Height: | Size: 888 B After Width: | Height: | Size: 888 B |
|
@ -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>
|
|