tycho: heavily optimize icons
parent
e3875b956f
commit
350bb402d2
|
@ -2,15 +2,22 @@
|
|||
|
||||
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;
|
||||
|
||||
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()) {
|
||||
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
|
||||
|
||||
mkdir -p resources/icons
|
||||
rm resources/icons/*.png resources/icons.qrc
|
||||
rm -f resources/icons/* resources/icons.qrc
|
||||
|
||||
echo "<RCC>" > resources/icons.qrc
|
||||
echo '<qresource prefix="/tycho">' >> resources/icons.qrc
|
||||
|
||||
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
|
||||
|
||||
function run_optipng -a out
|
||||
optipng -quiet -o5 "$out" &
|
||||
function compress -a out
|
||||
pigz --best -fm -S z "$out"
|
||||
end
|
||||
|
||||
function comp_icon -a f i
|
||||
set sz $sizes[$i]
|
||||
set hz $hidpi[$i]
|
||||
set out icons/(basename -s .svg "$f")_$sz
|
||||
set out_s $out.png
|
||||
set out_h $out@2x.png
|
||||
echo \t"<file>$out_s</file>" >> resources/icons.qrc
|
||||
echo \t"<file>$out_h</file>" >> resources/icons.qrc
|
||||
set out_s $out.svg
|
||||
set out_h $out@2x.svg
|
||||
echo \t"<file>$out_s""z</file>" >> resources/icons.qrc
|
||||
echo \t"<file>$out_h""z</file>" >> resources/icons.qrc
|
||||
set out_s resources/$out_s
|
||||
set out_h resources/$out_h
|
||||
conv_icon "$out_s" "$sz" "$f"
|
||||
conv_icon "$out_h" "$hz" "$f"
|
||||
wait inkscape
|
||||
run_optipng "$out_s"
|
||||
run_optipng "$out_h"
|
||||
wait rsvg-convert
|
||||
compress "$out_s"
|
||||
compress "$out_h"
|
||||
end
|
||||
|
||||
for f in resources/mini/*.svg
|
||||
|
@ -44,8 +44,6 @@ end
|
|||
echo "</qresource>" >> resources/icons.qrc
|
||||
echo "</RCC>" >> resources/icons.qrc
|
||||
|
||||
wait optipng
|
||||
|
||||
echo "done"
|
||||
|
||||
## EOF
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue