tycho: heavily optimize icons
parent
e3875b956f
commit
350bb402d2
|
@ -2,15 +2,22 @@
|
||||||
|
|
||||||
QIcon getIcon(QString const &name)
|
QIcon getIcon(QString const &name)
|
||||||
{
|
{
|
||||||
constexpr std::array<int, 9> sizes{16, 24, 32, 48, 64, 128, 256, 512, 1024};
|
constexpr auto sizes = std::array{std::make_pair(16, "_16.svgz"),
|
||||||
|
std::make_pair(24, "_24.svgz"),
|
||||||
|
std::make_pair(32, "_32.svgz"),
|
||||||
|
std::make_pair(64, "_64.svgz"),
|
||||||
|
std::make_pair(128, "_128.svgz"),
|
||||||
|
std::make_pair(256, "_256.svgz"),
|
||||||
|
std::make_pair(512, "_512.svgz"),
|
||||||
|
std::make_pair(1024, "_1024.svgz")};
|
||||||
|
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
|
||||||
for(auto const &sz : sizes) {
|
for(auto const &sz : sizes) {
|
||||||
auto res = ":/tycho/icons/" + name + "_" + QString::number(sz) + ".png";
|
auto res = ":/tycho/icons/" + name + sz.second;
|
||||||
|
|
||||||
if(QFile(res).exists()) {
|
if(QFile(res).exists()) {
|
||||||
icon.addFile(res, QSize(sz, sz));
|
icon.addFile(res, QSize(sz.first, sz.first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,34 +5,34 @@ set hidpi 32 48 64 96 128 256 512 1024 2048
|
||||||
set numsize 9
|
set numsize 9
|
||||||
|
|
||||||
mkdir -p resources/icons
|
mkdir -p resources/icons
|
||||||
rm resources/icons/*.png resources/icons.qrc
|
rm -f resources/icons/* resources/icons.qrc
|
||||||
|
|
||||||
echo "<RCC>" > resources/icons.qrc
|
echo "<RCC>" > resources/icons.qrc
|
||||||
echo '<qresource prefix="/tycho">' >> resources/icons.qrc
|
echo '<qresource prefix="/tycho">' >> resources/icons.qrc
|
||||||
|
|
||||||
function conv_icon -a out sz inf
|
function conv_icon -a out sz inf
|
||||||
inkscape -z -e "$out" -w "$sz" -h "$sz" "$inf" &
|
rsvg-convert -w "$sz" -h "$sz" -f svg -o "$out" "$inf" &
|
||||||
end
|
end
|
||||||
|
|
||||||
function run_optipng -a out
|
function compress -a out
|
||||||
optipng -quiet -o5 "$out" &
|
pigz --best -fm -S z "$out"
|
||||||
end
|
end
|
||||||
|
|
||||||
function comp_icon -a f i
|
function comp_icon -a f i
|
||||||
set sz $sizes[$i]
|
set sz $sizes[$i]
|
||||||
set hz $hidpi[$i]
|
set hz $hidpi[$i]
|
||||||
set out icons/(basename -s .svg "$f")_$sz
|
set out icons/(basename -s .svg "$f")_$sz
|
||||||
set out_s $out.png
|
set out_s $out.svg
|
||||||
set out_h $out@2x.png
|
set out_h $out@2x.svg
|
||||||
echo \t"<file>$out_s</file>" >> resources/icons.qrc
|
echo \t"<file>$out_s""z</file>" >> resources/icons.qrc
|
||||||
echo \t"<file>$out_h</file>" >> resources/icons.qrc
|
echo \t"<file>$out_h""z</file>" >> resources/icons.qrc
|
||||||
set out_s resources/$out_s
|
set out_s resources/$out_s
|
||||||
set out_h resources/$out_h
|
set out_h resources/$out_h
|
||||||
conv_icon "$out_s" "$sz" "$f"
|
conv_icon "$out_s" "$sz" "$f"
|
||||||
conv_icon "$out_h" "$hz" "$f"
|
conv_icon "$out_h" "$hz" "$f"
|
||||||
wait inkscape
|
wait rsvg-convert
|
||||||
run_optipng "$out_s"
|
compress "$out_s"
|
||||||
run_optipng "$out_h"
|
compress "$out_h"
|
||||||
end
|
end
|
||||||
|
|
||||||
for f in resources/mini/*.svg
|
for f in resources/mini/*.svg
|
||||||
|
@ -44,8 +44,6 @@ end
|
||||||
echo "</qresource>" >> resources/icons.qrc
|
echo "</qresource>" >> resources/icons.qrc
|
||||||
echo "</RCC>" >> resources/icons.qrc
|
echo "</RCC>" >> resources/icons.qrc
|
||||||
|
|
||||||
wait optipng
|
|
||||||
|
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
## EOF
|
## EOF
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
<property name="horizontalScrollBarPolicy">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="viewMode">
|
<property name="viewMode">
|
||||||
<enum>QListView::IconMode</enum>
|
<enum>QListView::IconMode</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue